[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A[X,Y,Z] -> A[Z,X,Y]



Dave Greenwood wrote:
> 
> I'm trying to analyze data from a new experiment using an IDL code from
> a different experiment.  The new experiment has data stored in an array
> of the form [X,Y,Z] while the code expects [Z,Y,X].  I can do something
> like (untested):
> 
>   FOR i = 0, z-1 DO BEGIN
>     FOR j = 0, y-1 DO BEGIN
>       newarray[i, y, *] = oldarray[*, y, i]
>     ENDFOR
>   ENDFOR
> 
> But I thought perhaps someone (probably several people) here could
> suggest a better (faster, more elegant, etc.) way?
> 
> Fyi, to give some size to the problem, X=1024, Y=39 and Z=3.

a = findgen(1024, 39, 3)
b = transpose(a, [2, 0, 1])
help, b
B               FLOAT     = Array[3, 1024, 39]

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley