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

Home » Public Forums » archive » interpolation of two different model
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
interpolation of two different model [message #82599] Mon, 07 January 2013 12:49 Go to next message
abc is currently offline  abc
Messages: 46
Registered: March 2011
Member
I have the following 2 data file (2900-4.0-0.5.txt, 2900-4.0-0.0.txt) for example which contain wavelength and flux. The number of data in the both the files are not same.

(Where 2900 is Temperature, 4.0 is gravity and -0.5 and -0.0 is the metallicity)
2900-4.0-0.5 2900-4.0-0.0
wave flux wave flux
1 0.3 1.0 0.5
2 0.4 1.4 0.1
3 0.1 3.1 0.4
4 0.5 4.0 0.3
5 0.4 5.1 0.2
6 0.6

I need to interpolate these two data file i.e between -0.5 and -0.0 at a step of 0.1. I don't know how i can interpolate these two different files in IDL. Any help will be appreciated.

thanks in advance
Re: interpolation of two different model [message #82695 is a reply to message #82599] Mon, 07 January 2013 14:50 Go to previous message
abc is currently offline  abc
Messages: 46
Registered: March 2011
Member
On Monday, January 7, 2013 10:49:38 PM UTC+1, wlandsman wrote:
> First, I assume that you giving fake data, and that your fluxes are really more precise than only 1 significant digit.
>
>
>
> The data sets have the same temperature and gravity, so you only need to interpolate in metallicity. But first you should interpolate the two spectra onto a common wavelength scale. Here's is how I would linearly interpolate in wavelength and metallicity using procedures from the IDL Astronomy library. http://idlastro.gsfc.nasa.gov/homepage.html
>
>
>
> IDL> readcol,'2900-4.0-0.5.txt',w1,f1 ;read into wavelength & flux vectors
>
> IDL> readcol,'2900-4.0-0.0.txt',w2,f2
>
> IDL> linterp,w1,f1,w2,f1_w2 ;Use w2 as a common wavelength scale
>
> IDL> frac = (0.5+m)/0.5 ;Fractional distance between 0.0 and -0.5
>
> IDL> finterp = f1_w2*frac + f2*(1-frac) ;interpolated function
>
>
>
> where m is the metallicity between 0 and -0.5
>
>
>
> --Wayne
>
>
>
> On Monday, January 7, 2013 3:49:32 PM UTC-5, idlhelp wrote:
>
>> I have the following 2 data file (2900-4.0-0.5.txt, 2900-4.0-0.0.txt) for example which contain wavelength and flux. The number of data in the both the files are not same.
>
>>
>
>>
>
>>
>
>> (Where 2900 is Temperature, 4.0 is gravity and -0.5 and -0.0 is the metallicity)
>
>>
>
>> 2900-4.0-0.5 2900-4.0-0.0
>
>>
>
>> wave flux wave flux
>
>>
>
>> 1 0.3 1.0 0.5
>
>>
>
>> 2 0.4 1.4 0.1
>
>>
>
>> 3 0.1 3.1 0.4
>
>>
>
>> 4 0.5 4.0 0.3
>
>>
>
>> 5 0.4 5.1 0.2
>
>>
>
>> 6 0.6
>
>>
>
>>
>
>>
>
>> I need to interpolate these two data file i.e between -0.5 and -0.0 at a step of 0.1. I don't know how i can interpolate these two different files in IDL. Any help will be appreciated.
>
>>
>
>>
>
>>
>
>> thanks in advance

Thanks Wayne,
Yes, the data is fake as the files are so big that I can't upload them. Your method work fine. But just a small confusion. What if I have grid of model then how can I proceed for example

2900-4.0-0.5.txt
2900-4.0-0.0.txt
3000-4.0-0.0.txt
3000-4.0-0.0.txt
3100-4.0-0.0.txt
3100-4.0-0.0.txt
................
................
................
................
Re: interpolation of two different model [message #82698 is a reply to message #82599] Mon, 07 January 2013 13:49 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
First, I assume that you giving fake data, and that your fluxes are really more precise than only 1 significant digit.

The data sets have the same temperature and gravity, so you only need to interpolate in metallicity. But first you should interpolate the two spectra onto a common wavelength scale. Here's is how I would linearly interpolate in wavelength and metallicity using procedures from the IDL Astronomy library. http://idlastro.gsfc.nasa.gov/homepage.html

IDL> readcol,'2900-4.0-0.5.txt',w1,f1 ;read into wavelength & flux vectors
IDL> readcol,'2900-4.0-0.0.txt',w2,f2
IDL> linterp,w1,f1,w2,f1_w2 ;Use w2 as a common wavelength scale
IDL> frac = (0.5+m)/0.5 ;Fractional distance between 0.0 and -0.5
IDL> finterp = f1_w2*frac + f2*(1-frac) ;interpolated function

where m is the metallicity between 0 and -0.5

--Wayne

On Monday, January 7, 2013 3:49:32 PM UTC-5, idlhelp wrote:
> I have the following 2 data file (2900-4.0-0.5.txt, 2900-4.0-0.0.txt) for example which contain wavelength and flux. The number of data in the both the files are not same.
>
>
>
> (Where 2900 is Temperature, 4.0 is gravity and -0.5 and -0.0 is the metallicity)
>
> 2900-4.0-0.5 2900-4.0-0.0
>
> wave flux wave flux
>
> 1 0.3 1.0 0.5
>
> 2 0.4 1.4 0.1
>
> 3 0.1 3.1 0.4
>
> 4 0.5 4.0 0.3
>
> 5 0.4 5.1 0.2
>
> 6 0.6
>
>
>
> I need to interpolate these two data file i.e between -0.5 and -0.0 at a step of 0.1. I don't know how i can interpolate these two different files in IDL. Any help will be appreciated.
>
>
>
> thanks in advance
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: compare 2-d array with vector
Next Topic: compare 2-d array with vector

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

Current Time: Wed Oct 08 18:40:06 PDT 2025

Total time taken to generate the page: 0.00609 seconds