array subscripts [message #12867] |
Thu, 17 September 1998 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Hi all,
now, here is something I have been wondering about several times, so
I'd like to ask you for ideas *why* this is so:
It's easy to extract "rectangular domains" from an array like
A = FINDGEN(72,46,20)
B=A[10:20,30:32,1:10]
However, the following does produce an error message
I1 = INDGEN(11)+10
I2 = INDGEN(3)+30
I3 = INDGEN(10)+1
B=A[I1,I2,I3]
% All array subscripts must be same size. Var = A
% Execution halted at: $MAIN$
Since all array subscripts are orthogonal to each other, I can't
think of a logical reason why one should not be able to extract
subarrays the second way. And, although I am not a programming expert,
merely an "Experienced User with Medium Level Programming skills"
(EUMLP), I cannot think of any real issues why it would not be possible
to program the subarray extraction to allow index array arguments. One
has to extract one dimension after the other anyway, so it would not be
more penalty than one further index level. Am I missing something here?
Would other people also like to see this feature?
Martin.
PS: For those who now think "Hey, IDL can't do that?": one can of course
always extract the dimensions one after the other
B = A[I1,*,*]
B = B[*,I2,*]
B = B[*,*,I3]
PPS: And while we are at it... One of the most useful tips I got from
David's book (so far) was the A[n:*] syntax to extract ranges from n to
end. I am really grateful for this!
--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA
phone: (617)-496-8318
fax : (617)-495-4551
e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
|
|
|