Subsetting an array with user defined values [message #40144] |
Mon, 19 July 2004 09:10 |
dfinnegan
Messages: 2 Registered: October 2001
|
Junior Member |
|
|
Hi all,
Not sure if this is a repetitive question or not.
I have a series of ascii XYX files that I am reading into IDL and
creating an array with (array[3,millions]). Importing is no problem as
well as working with the array. What I would like to do is subet the
array by a given min and max longitude and latitude so that I get back
only the values within that range, say a user defined box.
I am doing this with the following code (the data has been sorted and
nulls removed prior to this):
latmin=3763965.28
latmax=3763985.74
lonmin=534302.28
lonmax=534335.50
IF latmin GE min(data[0,*]) then begin
print, 'inside latmin'
vgood= where(data[0,*] GT latmin)
data = temporary(data[*,vgood])
ENDIF
IF latmax LT max(data[0,*]) then begin
print, 'inside latmax'
vgood= where(data[0,*] LE latmax)
data = temporary(data[*,vgood])
ENDIF
IF lonmin GE min(data[1,*]) then begin
vgood= where(data[1,*] GE lonmin)
data = temporary(data[*,vgood])
ENDIF
IF lonmax LE max(data[1,*]) then begin
vgood= where(data[1,*] LE lonmax)
data = temporary(data[*,vgood])
ENDIF
Is there a more efficient way of extracting the data from these
arrays? An example would be great!
Thanks in advance,
Dave
|
|
|