Array slices [message #47250] |
Thu, 02 February 2006 08:44  |
Richard Edgar
Messages: 8 Registered: February 2006
|
Junior Member |
|
|
Greetings,
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.
Thanks in advance,
Richard
|
|
|
Re: Array slices [message #47338 is a reply to message #47250] |
Thu, 02 February 2006 10:11   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> Richard Edgar writes:
>
>> For me, the most annoying thing is the inconsistency. If all gave a
>> {3,3,1} array (permute as necessary), then there'd be less of a problem.
>
> Oh, please, don't get us started on this again!
Craig,
Why don't you write the definitive article on this topic,
giving all points of view, and I'll publish it and we will
be done with it for all time. :-)
Cheers,
David
P.S. There are some topics I rather enjoy recycling. (I miss
DEVICE, DECOMPOSED=0 very, very much.) But there are others
that just seem too tedious to go into. This one *definitely*
falls into that category for me. Although I do see the need for
an explanation. I just can't write it myself without barfing. :-(
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Array slices [message #47339 is a reply to message #47250] |
Thu, 02 February 2006 10:01   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Richard Edgar writes:
> For me, the most annoying thing is the inconsistency. If all gave a
> {3,3,1} array (permute as necessary), then there'd be less of a problem.
Oh, please, don't get us started on this again!
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Array slices [message #47394 is a reply to message #47338] |
Sun, 05 February 2006 10:44  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
David Fanning <davidf@dfanning.com> writes:
> David Fanning writes:
>
>> Richard Edgar writes:
>>
>>> For me, the most annoying thing is the inconsistency. If all gave a
>>> {3,3,1} array (permute as necessary), then there'd be less of a problem.
>>
>> Oh, please, don't get us started on this again!
>
> Craig,
>
> Why don't you write the definitive article on this topic,
> giving all points of view, and I'll publish it and we will
> be done with it for all time. :-)
...
> ... I just can't write it myself without barfing. :-(
Neither can I :-)
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|