comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » array juggling
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
array juggling [message #51169] Wed, 08 November 2006 09:38
MA is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Finding distributor for new ergonomic product for CTS and RSI
Next Topic: Re: Concatenate arrays of different dimensions

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:10:12 PDT 2025

Total time taken to generate the page: 0.00582 seconds