Re: Array slices [message #47247] |
Thu, 02 February 2006 08:58  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Richard Edgar writes:
> I'm having trouble with slices of 3D arrays in IDL, and I suspect that
> it's something I don't understand about the way IDL interprets things.
> My problem can be summed up as follows:
>
> IDL> arr=DINDGEN(3,3,3)
> IDL> help,arr
> ARR DOUBLE = Array[3, 3, 3]
> IDL> help,arr[*,*,1]
> <Expression> DOUBLE = Array[3, 3]
> IDL> help,arr[*,1,*]
> <Expression> DOUBLE = Array[3, 1, 3]
> IDL> help,arr[1,*,*]
> <Expression> DOUBLE = Array[1, 3, 3]
>
> My questions are:
> a) Why don't all three slices return a [3,3] array?
> b) How do I eliminate the 'useless' dimension?
>
> I typically have routines which want a 2D array, which I only get from
> the first of these. They (naturally) choke when given a 3D array, one of
> whose dimensions is unity.
One man's "useless" dimension is another man's "essential"
dimension, as you will learn if you follow this newsgroup
for any length of time. The lamentations over the "missing"
dimension are legendary.
But, if it is really useless to you, then REFORM it away:
IDL> Help, Reform(array[3,1,3], 3, 3)
<Expression> DOUBLE = Array[3, 3]
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|