interpolation between different files [message #82807] |
Wed, 16 January 2013 04:47 |
abc
Messages: 46 Registered: March 2011
|
Member |
|
|
Hello All,
I was trying to interpolate different model spectra w.r.t metallicity at a step of 0.1. In each model atmosphere I am having wave and flux w.r.t metallicity that ranges from -0.5 to +0.5 at a step of 0.5. The name of the files I am having is like that
2000K-0.5.txt
2000K-0.0.txt
2000K+0.5.txt
2100K-0.0.txt
2100K+0.5.txt
.............
.............
4000K-0.0.txt
First I want to interpolate for 2000K files between -0.5 to +0.5 at a step of 0.1 and in order to do so I am interpolations first between 1st and 2nd file and then 2nd and 3rd file and so on. In order to do that I have wrote a code. It works fine when I just read the first two files separately but as I have 100's of such file I am reading all the file at once and then performing the following calculations. But I am not sure that the code always keep 2000K constant and doing the interpolation and then for 2100K .....and so on.
Here is the code
readcol,'list.txt',fna,format='A' ; reading list of files
nl = n_elements(fna)
nm = 268522 ; number of elements in one file
all_w = fltarr(nm,nl)
all_f = fltarr(nm,nl)
for i=0,nl-1 do begin
fname = fna(i)
readcol,fname,temp1,temp2
all_w(*,i) = temp1
all_f(*,i) = temp2
endfor
alpha = (nl)-1
alpha = long(alpha)
for k = 0L, alpha do begin
w1 = all_w(*,k)
w2 = all_w(*,k+1)
f1 = all_f(*,k)
f2 = all_f(*,k+1)
linterp,w1,f1,w2,f1_2
frac = findgen(5*0.01)+0.5 ;Fractional distance between 0.0 and -0.5
for l = 0,4 do begin
finterp = f1_2*frac(l)+f2*(1-frac(l));interpolated function
endfor
endfor
end
I am also getting an error "Attempt to subscript FRAC with L is out of range".
Is there any how can I do that
thanks in advance
|
|
|