X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 14 Aug 2011 01:33 PM by  anon
difficulty using "linterp" command - need help making loop to exclude a value yet average others
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
14 Aug 2011 01:33 PM
    I am writing a program for my 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 I 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 I am trying to interpolate: linterp, w1a, f1a, wgrid, fint1a linterp, w1b, f2b, wgrid, fint1b linterp, w2a, f2a, wgrid, fint2a ..... etc through 8 But I got 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 I 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 ???

    Deleted User



    New Member


    Posts:
    New Member


    --
    15 Aug 2011 02:54 PM
    Hi Emily, The error seems to point to the 3rd parameter input to the LINTERP routine: linterp, w1a, f1a, wgrid, fint1a i.e. wgrid. It seems, from the error message, that wgrid needs to be a scalar. You will need to check the documentation for the routine LINTERP which doesn't seem to be an IDL routine. I mean, that routine is not part of the original IDL package. In IDL the linear interpolation can be done using INTERPOLATE. cheers, fernando

    Deleted User



    New Member


    Posts:
    New Member


    --
    16 Aug 2011 01:31 PM
    Now, I am very new to IDL. So are you saying that linterp is not a command IDL uses/recognizes? I have done some reading about the differnces between linterp and interpolate and it seems to me that interpolate may not do the exact thing linterp does... Also, I had a thought. It seems that findgen creates an array not a vector/scalar which is what linterp wants. Is there a way to make the array a vector/scalar? Thank you so much for you time and ideas! Emily We actually found out that it was a spelling error. Needless to say, I felt a bit silly. I do have another question though. We are trying to remove some values of our spectra that are equal to 0, but by using the remove command it literally removes the values where the flux is equal to 0 which is what it is supposed to do, but the problem with that is that when those values are remove the whole graph then moves which will mess up our final result. Is there a command that will take out the values equal to zero, but leave the graph where it is?
    You are not authorized to post a reply.