Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

plot calculated IR-spectrum

351 views
Skip to first unread message

Philipp Eiden

unread,
Jul 3, 2008, 7:15:37 AM7/3/08
to
Hi everybody,

I would like to plot an IR-spectrum. The problem is,
that I have only the datapoints of the intensity and
wavenumber at the maximum, e.g.

# spectrum.dat
# v I
0.00 0.00
108.97 0.00
169.61 6.21
325.48 0.00
486.67 183.07

so I would need to fit a Lorentzian function to each
datapoint-pair

f(x) = alpha*I_(1strow)/(pi*alpha*(x-v_(1strow))**2+1)
g(x) = alpha*I_(2ndrow)/(pi*alpha*(x-v_(2ndrow))**2+1)
.
.
.
z(x) = alpha*I_(last-row)/(pi*alpha*(x-v_(last-row))**2+1)

and then sum all functions to obtain the spectrum. Is
this possible with gnuplot? How?

Thanks

Philipp Eiden

goo...@catking.net

unread,
Jul 4, 2008, 6:18:15 AM7/4/08
to

I don't have time to think this through completely but one way would
be call an awk script that parsed each line into gnuplot set
commands , eg:

v_2 =169.61; l_2 =6.21

or more directly, your function definitions. Call the script from
gnuplot (help system) then read the output into gnuplot with load
command and plot f(x)+g(x)....+z(x)

$0 is the line counter for gnuplot data but I can't think of a clean
way to use that to be part of a varable name.

You will obviously need to make sure your data are valid : (0,0) ?!!

Ben

unread,
Jul 5, 2008, 4:11:18 AM7/5/08
to

What is an IR-Spectrum?
Infra-Red?

How does it look?

Rahul

unread,
Jul 5, 2008, 10:53:27 PM7/5/08
to
Philipp Eiden <pei...@web.de> wrote in news:486cbd65$0$27451$9b4e6d93
@newsspool4.arcor-online.net:

> so I would need to fit a Lorentzian function to each
> datapoint-pair
>
> f(x) = alpha*I_(1strow)/(pi*alpha*(x-v_(1strow))**2+1)
> g(x) = alpha*I_(2ndrow)/(pi*alpha*(x-v_(2ndrow))**2+1)
>

What is alpha? Is the first column v_(nth_row). Or the other way around?

--
Rahul

Hans-Bernhard Bröker

unread,
Jul 6, 2008, 3:21:50 PM7/6/08
to
Philipp Eiden wrote:

> # spectrum.dat
> # v I
> 0.00 0.00
> 108.97 0.00
> 169.61 6.21
> 325.48 0.00
> 486.67 183.07
>
> so I would need to fit a Lorentzian function to each datapoint-pair

Erm, no. That:

> f(x) = alpha*I_(1strow)/(pi*alpha*(x-v_(1strow))**2+1)

is not a fit. That's just the function with the given parameters.

> and then sum all functions to obtain the spectrum. Is this possible with
> gnuplot?

It might be possible with the current development version, but at the
bottom of it, gnuplot is not the right tool for this job. For number
crunching, use a number crunching tool. Octave should work just fine.

goo...@catking.net

unread,
Jul 6, 2008, 5:37:32 PM7/6/08
to

reading in two parameters and plotting a standard function can hardly
be called number crunching even if it is repeated for several pairs of
parameters. Gnuplot is a plotting program and plotting such functions
would seem to be very much what it is intended to do.

it's not a question of number cruching just a case of reading in a
small number of parameter constants and plotting the function.

can you see a way to name a variable from $0 ?

goo...@catking.net

unread,
Jul 6, 2008, 5:58:26 PM7/6/08
to
create a file lorenz.sh:

#! /usr/bin/awk -f

BEGIN {line=0}

($0 !~ /^#/)&&($0 != "") {

print "f"line"(x)=alpha*"$1"/(pi(x-"$2")**2+1)\n"


}

in gnuplot :

load << system(lorenz.sh)


Debug the syntax yourself , I ain't going to do the whole job for you,
but that should do what you want in an efficient manner.

Philipp Eiden

unread,
Jul 7, 2008, 2:55:28 PM7/7/08
to
Hmmm, this doesn't work here... but
awk '{print "f"NR"(x)=alpha*"$2"/(pi(x-"$1")**2+1)"'
did the job.

Thanks for your effort.

goo...@catking.net

unread,
Jul 8, 2008, 3:55:22 PM7/8/08
to
On Jul 7, 8:55 pm, Philipp Eiden <pei...@web.de> wrote:

oops , I forgot to increment "line" . I warned you it would need
debuggin , I was in a rush but at least it wasn't far off. Glad it
gave you what you wanted.

It always amazes me what you can do with gnuplot ( and maybe a little
help from awk).

best

0 new messages