comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: interpolation between different files
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: interpolation between different files [message #82805] Wed, 16 January 2013 05:51 Go to previous message
abc is currently offline  abc
Messages: 46
Registered: March 2011
Member
On Wednesday, January 16, 2013 2:28:46 PM UTC+1, Helder wrote:
> On Wednesday, January 16, 2013 1:47:05 PM UTC+1, idlhelp wrote:
>
>> 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
>
>
>
> I didn't go through the whole code, but it seems that you are trying to make an array with the command
>
> frac = findgen(5*0.01)+0.5
>
> I don't see why you don't get an error before the one you mentioned... because that will give you an error.
>
> I think that what you should have wrote is:
>
> frac = findgen(5)*0.01+0.5
>
> Is this what you want:
>
> IDL> PRINT, findgen(5)*0.01+0.5
>
> 0.500000 0.510000 0.520000 0.530000 0.540000
>
> or do you want this:
>
> IDL> PRINT, -findgen(5)*0.1
>
> -0.000000 -0.100000 -0.200000 -0.300000 -0.400000
>
> or what should frac be?
>
>
>
> [for sure indexing a number that is not a number won't get you anywhere...]
>
>
>
> Cheers,
>
> Helder

Hi Helder,
sorry it was typing mistake.I have corrected it. But I don't know yet how I can I proceed with different files. :-(
[Message index]
 
Read Message
Read Message
Previous Topic: interpolation between different files
Next Topic: Waiting for Godot

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 04:34:52 PDT 2025

Total time taken to generate the page: 0.07995 seconds