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 
Switch to threaded view of this topic Create a new topic Submit Reply
difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77160] Fri, 12 August 2011 13:26 Go to next message
Emily Anne Moravec is currently offline  Emily Anne Moravec
Messages: 7
Registered: June 2011
Junior Member
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 ???
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77240 is a reply to message #77160] Mon, 15 August 2011 01:17 Go to previous messageGo to next message
Nikola is currently offline  Nikola
Messages: 53
Registered: November 2009
Member
On Aug 14, 3:47 pm, Emily Anne Moravec <mora...@stolaf.edu> wrote:
> On Aug 14, 3:49 am, Nikola <nikola.vi...@gmail.com> wrote:
>
>
>
>> It seems like you haven't defined wgrid in the procedure
>> interpolatedsixteen.pro.
>
>> linterp is not a standard idl function. Why not use interpol instead
>> (for the difference see the header of linterp.pro)?
>
>>> 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?
>
>> If you need to find mean of an array excluding elements equal to some
>> variable x (in your case x = 0) you don't need a loop. Just do
>
>> mask = array NE x
>> y = TOTAL(array*mask)/TOTAL(mask)
>
> So the mask = array NE x will exclude the x value?
> What do I put in place of array? One value or all of the values 16
> values I am averaging? Is NE the command for excluding something?
> Thank you for you time!!!

NE means Not Equal

So,
mask = array NE x
makes a new array of the same size as array, but with 1 where array is
not equal x and with zero in the opposite case. In place of array you
put the array you wish to average.

If you're going to use IDL extensively, I strongly recommend you to
read the part of the manual on arrays.
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77241 is a reply to message #77160] Sun, 14 August 2011 17:09 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Sunday, August 14, 2011 4:21:09 PM UTC-4, wlandsman wrote:

>
> It would make wgrid defined, but not wgird. ;-) Wayne

I was about to write that a clue to identifying the typo would have been to look at the line number of the error message, which would have told you that the first calls to LINTERP were successful, so that there was something different about the LINTERP call that was giving an error.

But then I realized that LINTERP uses a very old (1980s) error checking routine "zparcheck" which overrides the normal IDL traceback, so you weren't seeing the line number. I've added an HELP,/TRACEBACK to zparcheck. Someday, I will update the error checking methods in the astrolib, but I haven't found any error checking schemes yet that I am happy with. --Wayne
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77242 is a reply to message #77160] Sun, 14 August 2011 14:16 Go to previous messageGo to next message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On 8/14/11 4:21 PM, wlandsman wrote:
> On Sunday, August 14, 2011 3:42:25 PM UTC-4, Emily Anne Moravec wrote:
>> On Aug 12, 7:26 pm, Jeremy Bailin<astro...@gmail.com> wrote:
>
>> linterp, w6a, f6a, wgird, fint6a
>> linterp, w6b, f6b, wgird, fint6b
>> linterp, w7a, f7a, wgird, fint7a
>>
>>
>> I thought findgen would make wgrid defined because the findgen makes a
>> number.
>> Thanks for your time!!!
>
> It would make wgrid defined, but not wgird. ;-) Wayne

I think we have a winner. :-)=

-Jeremy.
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77244 is a reply to message #77160] Sun, 14 August 2011 13:26 Go to previous messageGo to next message
Emily Anne Moravec is currently offline  Emily Anne Moravec
Messages: 7
Registered: June 2011
Junior Member
On Aug 14, 2:47 pm, Emily Anne Moravec <mora...@stolaf.edu> wrote:
> On Aug 14, 3:49 am, Nikola <nikola.vi...@gmail.com> wrote:
>
>
>
>
>
>> It seems like you haven't defined wgrid in the procedure
>> interpolatedsixteen.pro.
>
>> linterp is not a standard idl function. Why not use interpol instead
>> (for the difference see the header of linterp.pro)?
>
>>> 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?
>
>> If you need to find mean of an array excluding elements equal to some
>> variable x (in your case x = 0) you don't need a loop. Just do
>
>> mask = array NE x
>> y = TOTAL(array*mask)/TOTAL(mask)
>
> So the mask = array NE x will exclude the x value?
> What do I put in place of array? One value or all of the values 16
> values I am averaging? Is NE the command for excluding something?
> Thank you for you time!!!

Also, I just looked at linterp and interpol and it seems linterp is
exactly what we want to do. I really also don't see the difference
between them.
To linearly interpolate from a spectrum wavelength-flux pair
; WAVE, FLUX to another wavelength grid defined as:
; WGRID = [1540., 1541., 1542., 1543., 1544, 1545.]
;
; IDL> LINTERP, WAVE, FLUX, WGRID, FGRID
;
; FGRID will be a 6 element vector containing the values of
FLUX
; linearly interpolated onto the WGRID wavelength scale
This is exactly what we want to do…...
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77245 is a reply to message #77160] Sun, 14 August 2011 13:21 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Sunday, August 14, 2011 3:42:25 PM UTC-4, Emily Anne Moravec wrote:
> On Aug 12, 7:26 pm, Jeremy Bailin <astro...@gmail.com> wrote:

> linterp, w6a, f6a, wgird, fint6a
> linterp, w6b, f6b, wgird, fint6b
> linterp, w7a, f7a, wgird, fint7a
>
>
> I thought findgen would make wgrid defined because the findgen makes a
> number.
> Thanks for your time!!!

It would make wgrid defined, but not wgird. ;-) Wayne
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77249 is a reply to message #77160] Sun, 14 August 2011 12:47 Go to previous messageGo to next message
Emily Anne Moravec is currently offline  Emily Anne Moravec
Messages: 7
Registered: June 2011
Junior Member
On Aug 14, 3:49 am, Nikola <nikola.vi...@gmail.com> wrote:
> It seems like you haven't defined wgrid in the procedure
> interpolatedsixteen.pro.
>
> linterp is not a standard idl function. Why not use interpol instead
> (for the difference see the header of linterp.pro)?
>
>> 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?
>
> If you need to find mean of an array excluding elements equal to some
> variable x (in your case x = 0) you don't need a loop. Just do
>
> mask = array NE x
> y = TOTAL(array*mask)/TOTAL(mask)

So the mask = array NE x will exclude the x value?
What do I put in place of array? One value or all of the values 16
values I am averaging? Is NE the command for excluding something?
Thank you for you time!!!
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 next 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!!!
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77253 is a reply to message #77160] Sun, 14 August 2011 01:49 Go to previous messageGo to next message
Nikola is currently offline  Nikola
Messages: 53
Registered: November 2009
Member
It seems like you haven't defined wgrid in the procedure
interpolatedsixteen.pro.

linterp is not a standard idl function. Why not use interpol instead
(for the difference see the header of linterp.pro)?


> 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?

If you need to find mean of an array excluding elements equal to some
variable x (in your case x = 0) you don't need a loop. Just do

mask = array NE x
y = TOTAL(array*mask)/TOTAL(mask)
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77256 is a reply to message #77160] Fri, 12 August 2011 17:26 Go to previous messageGo to next message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
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.
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77300 is a reply to message #77160] Wed, 17 August 2011 09:57 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I am just guessing what you mean by "leave the graph where it is" but note that you need to remove the zero values from both the wavelength and flux vectors. So, applying the idlastro procedure remove.pro to your wavelength, w, and flux, f, vectors:

g = where(f eq 0,Ng) ;Find locations of zero values in flux vector
if Ng gt 0 then remove,g,w,f ;Remove these locations from both wavelength & flux vectors

On Wednesday, August 17, 2011 12:10:39 PM UTC-4, Emily Anne Moravec wrote:

> 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?
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77301 is a reply to message #77160] Wed, 17 August 2011 09:35 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 8/17/11 10:17 AM, David Fanning wrote:
> Emily Anne Moravec writes:
>
>> 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?
>
> Are you looking for something like this, where there
> are gaps in the plot where the data goes to zero:
>
> IDL> data = randomu(-3L, 100)*10
> IDL> zeros = Long(randomu(-2L, 5)*100)
> IDL> data[zeros] = 0
> IDL> plot, data, min_value=0.1

Setting invalid values to !values.f_nan also works nicely for regular
line plots (though it can make related computations a bit more
complicated, with extra NAN keywords and the FINITE routine coming in
handy).

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77303 is a reply to message #77160] Wed, 17 August 2011 09:17 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Emily Anne Moravec writes:

> 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?

Are you looking for something like this, where there
are gaps in the plot where the data goes to zero:

IDL> data = randomu(-3L, 100)*10
IDL> zeros = Long(randomu(-2L, 5)*100)
IDL> data[zeros] = 0
IDL> plot, data, min_value=0.1

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77304 is a reply to message #77241] Wed, 17 August 2011 09:10 Go to previous message
Emily Anne Moravec is currently offline  Emily Anne Moravec
Messages: 7
Registered: June 2011
Junior Member
On Aug 14, 7:09 pm, wlandsman <wlands...@gmail.com> wrote:
> On Sunday, August 14, 2011 4:21:09 PM UTC-4, wlandsman wrote:
>
>> It would make wgrid defined, but not wgird.   ;-)   Wayne
>
> I was about to write that a clue to identifying the typo would have been to look at the line number of the error message, which would have told you that the first calls to LINTERP were successful, so that there was something different about the LINTERP call that was giving an error.
>
> But then I realized that LINTERP uses a very old (1980s) error checking routine "zparcheck" which overrides the normal IDL traceback, so you weren't seeing the line number.     I've added an HELP,/TRACEBACK to zparcheck.    Someday, I will update the error checking methods in the astrolib, but I haven't found any error checking schemes yet that I am happy with.   --Wayne

First of all, I feel rather silly.
But I have another question and it isn't just for apparent proof
reading.
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?
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77305 is a reply to message #77160] Wed, 17 August 2011 08:43 Go to previous message
Brian Wolven is currently offline  Brian Wolven
Messages: 94
Registered: May 2011
Member
On Wednesday, August 17, 2011 11:33:36 AM UTC-4, Emily Anne Moravec wrote:

> oh man… thanks. why does this always happen?

Computers insist on doing what you say, rather than what you mean. =P
Re: difficulty using "linterp" command - need help making loop to exclude a value yet average others [message #77306 is a reply to message #77242] Wed, 17 August 2011 08:33 Go to previous message
Emily Anne Moravec is currently offline  Emily Anne Moravec
Messages: 7
Registered: June 2011
Junior Member
On Aug 14, 4:16 pm, Jeremy Bailin <astroco...@gmail.com> wrote:
> On 8/14/11 4:21 PM, wlandsman wrote:
>
>> On Sunday, August 14, 2011 3:42:25 PM UTC-4, Emily Anne Moravec wrote:
>>> On Aug 12, 7:26 pm, Jeremy Bailin<astro...@gmail.com>  wrote:
>
>>>    linterp, w6a, f6a, wgird, fint6a
>>>    linterp, w6b, f6b, wgird, fint6b
>>>    linterp, w7a, f7a, wgird, fint7a
>
>>> I thought findgen would make wgrid defined because the findgen makes a
>>> number.
>>> Thanks for your time!!!
>
>> It would make wgrid defined, but not wgird.   ;-)   Wayne
>
> I think we have a winner. :-)=
>
> -Jeremy.

oh man… thanks. why does this always happen?
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Wed Oct 08 15:11:09 PDT 2025

Total time taken to generate the page: 0.00538 seconds