array juggling [message #51169] |
Wed, 08 November 2006 09:38 |
MA
Messages: 15 Registered: August 2005
|
Junior Member |
|
|
Hello,
I have the following problem:
I want to get a subset of data out of a 3D array. This is how I do it
now, but I want to eliminate the loop:
;----------------------------------------------------------- ------------------------------------------------------------ ----------------------
num_lon=360 ; longitude dimension
num_lat=181 ; latitude dimension
num_mod_levs=60 ; number of model levels
temp3D = FltArr(num_lon,num_lat,num_mod_levs)
OpenR,1, case_data.ecmwf_path+case_data.prefix+time+'_T.dump'
ReadU,1,temp3D
Close,1
num_records=6500
T=FltArr(num_mod_levs,num_records)
; latindex and lonindex are of dimension num_records
; and contain latitude and longitude
; indices. I.e. temp3D[lonindex[0],latindex[0],*] picks
; out one column in my global map and
; gives me the temperature for that colum. I want to get
; those temperature columns for
; 6500 latindex/lonindex combinations, and save
; them in the array T.
FOR i=0,num_records-1 DO BEGIN
T[*,i]=Reform(temp3D[lonindex[i],latindex[i],*],60)
ENDFOR
;----------------------------------------------------------- ------------------------
It seems to me I should be able to do something like this instead, and
avoid the loop:
T=temp3D[lonindex,latindex,*]
with a rotate or something thrown in. But this doesn't seem to work.
Would it work if num_mod_levs were the leading dimension?
Any ideas?
Thanks, Maike
|
|
|