next up previous contents
Next: Using where on a Up: Section 2: Introduction to Previous: A first IDL procedure:   Contents

Using where

We only want to plot the data where its inside a sensible range and not equal to 9999999.

We could ``loop'' over all the data to find the ones that are not equal to 9999999, which is what you would do with fortran. But instead try,

window,0,retain=2
; note data(3,*) are temperatures and data(2,*) are heights 
wtempandheight=where(data(3,*) gt -200 and data(3,*) lt 500 and data(2,*) gt 0 and data(2,*) lt 30000.)

plot,(data(3,*))(wtempandheight),(data(2,*))(wtempandheight)
which actually gives a useful plot (and is much quicker to write and run than a loop).

``Where'' is incredibly useful, you will use it for many different things.

Look at ``temp'', ``height'' and ``wtempandheight'' using help. Now look at what where outputs, ``print, wtempandheight''. Print the data as well. You will see that where lists the positions of the elements where both the heights and tempetatures have fulfilled the conditions prescribed.

Look up where in the IDL help.



John Marsham 2009-12-07