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

Home » Public Forums » archive » difficulty using "linterp" command - need help making loop to exclude a value yet average others
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: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77250 is a reply to message #77160] Sun, 14 August 2011 12:42 Go to previous messageGo to previous message
Emily Anne Moravec is currently offline  Emily Anne Moravec
Messages: 7
Registered: June 2011
Junior Member
On Aug 12, 7:26 pm, Jeremy Bailin <astroco...@gmail.com> wrote:
> On 8/12/11 4:26 PM, Emily Anne Moravec wrote:
>
>
>
>
>
>> We are writing a program for our supervisor to take 8 spectra which
>> are each a matrix of 16384 by 2. The part of the program we have
>> already splits the matrices into single matrices. Which is the code
>> below:
>
>> fitfilename1 = '/Users/quasargroup/NGC3783/NGC3783 new data/X1dsum
>> files/lbgu19010_x1dsum.fits'
>>    data1 = mrdfits(fitfilename1,1,hdr)
>>    w1 = data1.wavelength
>>    w1a=w1(*, 0)
>>    w1b=w1(*, 1)
>>    f1= data1.flux
>>    f1a=f1(*, 0)
>>    f1b=f1(*, 1)
>> .... etc. through 8
>
>> Then we must get a new graph with a span of wavelengths and
>> interpolated flux values.
>> Here is the wavelength grid for the eventual interpolation:
>
>> wgrid=findgen(58400)*.01+1227  ; from 1227.00 to 1811.00
>>    help, /str, wgrid
>
>> Here is where we are trying to interpolate:
>
>>    linterp, w1a, f1a, wgrid, fint1a
>>    linterp, w1b, f2b, wgrid, fint1b
>>    linterp, w2a, f2a, wgrid, fint2a
>
>> ..... etc through 8
>> But we get this error.
>
>> % Compiled module: INTERPOLATEDSIXTEEN.
>> MRDFITS: Binary table.  12 columns by  2 rows.
>> MRDFITS: Binary table.  12 columns by  2 rows.
>> MRDFITS: Binary table.  12 columns by  2 rows.
>> MRDFITS: Binary table.  12 columns by  2 rows.
>> MRDFITS: Binary table.  12 columns by  2 rows.
>> MRDFITS: Binary table.  12 columns by  2 rows.
>> MRDFITS: Binary table.  12 columns by  2 rows.
>> MRDFITS: Binary table.  12 columns by  2 rows.
>>  Parameter 3 (New X Vector or Scalar)  of routine LINTERP  is
>> undefined.
>> Valid dimensions are: scalar  1
>> Valid types are:  byte int*2 int*4 real*4 real*8 Unsigned(i*2)
>> Unsigned(i*4) int*8 Unsigned(i*8)
>
>> Do we need to do something to our wgrid or to the interpolate command
>> to get it to work?
>
>> Also, in each of our 8 data sets, there is an increment of wavelength
>> values where the value of the flux is 0, which will make the average
>> of all 8 messed up.  Do you have any ideas how to write a loop that
>> goes through all of the wgrid values and averages the values of the
>> interpolated flux values, but skips the flux values that are 0 and
>> continues to the next? Is there a skip command? Would a where command
>> work the best?
>
>> Here is what I started with :
>> for i=1227.00, (1227.00+58400*.01), 0.01 do ???
>
> It seems to be complaining that wgrid is undefined. Can you show us the
> code a little more specifically? From what you've said, I wouldn't
> expect it to be undefined, so I suspect that there's something more
> subtle happening within your code.
>
> -Jeremy.

Here is my entire code.

pro interpolatedsixteen
; this takes the date from each column of the data, making it so that
they are 1-column arrays and can be easily graphed, then it will
interpolate the data
; onto a comprehensive graph
fitfilename1 = '/Users/quasargroup/NGC3783/NGC3783 new data/X1dsum
files/lbgu19010_x1dsum.fits'
data1 = mrdfits(fitfilename1,1,hdr)
w1 = data1.wavelength
w1a=w1(*, 0)
w1b=w1(*, 1)
f1= data1.flux
f1a=f1(*, 0)
f1b=f1(*, 1)

fitfilename2 = '/Users/quasargroup/NGC3783/NGC3783 new data/X1dsum
files/lbgu19020_x1dsum.fits'
data2= mrdfits(fitfilename2,1,hdr)
w2 = data2.wavelength
w2a=w2(*, 0)
w2b=w2(*, 1)
f2= data2.flux
f2a=f2(*, 0)
f2b=f2(*, 1)

fitfilename3 = '/Users/quasargroup/NGC3783/NGC3783 new data/X1dsum
files/lbgu19030_x1dsum.fits'
data3= mrdfits(fitfilename3,1,hdr)
w3 = data3.wavelength
w3a=w3(*, 0)
w3b=w3(*, 1)
f3= data3.flux
f3a=f3(*, 0)
f3b=f3(*, 1)

fitfilename4 = '/Users/quasargroup/NGC3783/NGC3783 new data/X1dsum
files/lbgu19040_x1dsum.fits'
data4= mrdfits(fitfilename4,1,hdr)
w4 = data4.wavelength
w4a=w4(*, 0)
w4b=w4(*, 1)
f4= data4.flux
f4a=f4(*, 0)
f4b=f4(*, 1)

fitfilename5 = '/Users/quasargroup/NGC3783/NGC3783 new data/X1dsum
files/lbgu19050_x1dsum.fits'
data5= mrdfits(fitfilename5,1,hdr)
w5 = data5.wavelength
w5a=w5(*, 0)
w5b=w5(*, 1)
f5= data5.flux
f5a=f5(*, 0)
f5b=f5(*, 1)

fitfilename6 = '/Users/quasargroup/NGC3783/NGC3783 new data/X1dsum
files/lbgu19060_x1dsum.fits'
data6 = mrdfits(fitfilename6,1,hdr)
w6 = data6.wavelength
w6a=w6(*, 0)
w6b=w6(*, 1)
f6= data6.flux
f6a=f6(*, 0)
f6b=f6(*, 1)

fitfilename7 = '/Users/quasargroup/NGC3783/NGC3783 new data/X1dsum
files/lbgu19070_x1dsum.fits'
data7= mrdfits(fitfilename7,1,hdr)
w7 = data7.wavelength
w7a=w7(*, 0)
w7b=w7(*, 1)
f7= data7.flux
f7a=f7(*, 0)
f7b=f7(*, 1)

fitfilename8 = '/Users/quasargroup/NGC3783/NGC3783 new data/X1dsum
files/lbgu19080_x1dsum.fits'
data8= mrdfits(fitfilename8,1,hdr)
w8 = data8.wavelength
w8a=w8(*, 0)
w8b=w8(*, 1)
f8= data8.flux
f8a=f8(*, 0)
f8b=f8(*, 1)

wgrid=findgen(58400)*.01+1227 ; from 1227.00 to 1811.00
help, /str, wgrid

linterp, w1a, f1a, wgrid, fint1a
linterp, w1b, f2b, wgrid, fint1b
linterp, w2a, f2a, wgrid, fint2a
linterp, w2b, f2b, wgrid, fint2b
linterp, w3a, f3a, wgrid, fint3a
linterp, w3b, f3b, wgrid, fint3b
linterp, w4a, f4a, wgrid, fint4a
linterp, w4b, f4b, wgrid, fint4b
linterp, w5a, f5a, wgrid, fint5a
linterp, w5b, f5b, wgrid, fint5b
linterp, w6a, f6a, wgird, fint6a
linterp, w6b, f6b, wgird, fint6b
linterp, w7a, f7a, wgird, fint7a
linterp, w7b, f7b, wgrid, fint7b
linterp, w8a, f8a, wgrid, fint8a
linterp, w8b, f8b, wgrid, fint8b

;for i=1227.00, (1227.00+58400*.01), 0.01 do
; if fint

I thought findgen would make wgrid defined because the findgen makes a
number.
Thanks for your time!!!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: creating a 2D mask for image filtering
Next Topic: Book Business Realities

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

Current Time: Sat Oct 11 06:06:04 PDT 2025

Total time taken to generate the page: 1.03961 seconds