How come? Weird subarray problem... [message #85208] |
Fri, 12 July 2013 13:07  |
stefan.meingast
Messages: 30 Registered: June 2012
|
Member |
|
|
Hey
I have been wondering why a specific part of my code does not work and I discovered this:
a = findgen(10,10,10)
help, a
FLOAT = Array[10, 10, 10]
help, a[*,*,0]
FLOAT = Array[10, 10]
help, a[*,0,*]
FLOAT = Array[10, 1, 10]
help, a[0,*,*]
FLOAT = Array[1, 10, 10]
IDL only recognises a subarray correctly if the given index is at the last position...is this normal or maybe is there a way around this?
cheers
:)
|
|
|
Re: How come? Weird subarray problem... [message #85209 is a reply to message #85208] |
Fri, 12 July 2013 13:13   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Stefan writes:
> I have been wondering why a specific part of my code does not work and I discovered this:
>
> a = findgen(10,10,10)
> help, a
> FLOAT = Array[10, 10, 10]
> help, a[*,*,0]
> FLOAT = Array[10, 10]
> help, a[*,0,*]
> FLOAT = Array[10, 1, 10]
> help, a[0,*,*]
> FLOAT = Array[1, 10, 10]
>
>
> IDL only recognises a subarray correctly if the given index is at the last position...is this normal or maybe is there a way around this?
A better way to state this is that IDL only *incorrectly* recognizes a
subarray when the given index is at the last position, when it
inexplicably drops the final dimension. (Well, inexplicably for a lot of
people. Some people--you maybe--like this way of doing things.) In any
case, a simple REFORM may set you right, for whatever it is you are
doing.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: How come? Weird subarray problem... [message #85210 is a reply to message #85209] |
Fri, 12 July 2013 13:23  |
stefan.meingast
Messages: 30 Registered: June 2012
|
Member |
|
|
Am Freitag, 12. Juli 2013 22:13:18 UTC+2 schrieb David Fanning:
> Stefan writes:
>
>
>
>> I have been wondering why a specific part of my code does not work and I discovered this:
>
>>
>
>> a = findgen(10,10,10)
>
>> help, a
>
>> FLOAT = Array[10, 10, 10]
>
>> help, a[*,*,0]
>
>> FLOAT = Array[10, 10]
>
>> help, a[*,0,*]
>
>> FLOAT = Array[10, 1, 10]
>
>> help, a[0,*,*]
>
>> FLOAT = Array[1, 10, 10]
>
>>
>
>>
>
>> IDL only recognises a subarray correctly if the given index is at the last position...is this normal or maybe is there a way around this?
>
>
>
> A better way to state this is that IDL only *incorrectly* recognizes a
>
> subarray when the given index is at the last position, when it
>
> inexplicably drops the final dimension. (Well, inexplicably for a lot of
>
> people. Some people--you maybe--like this way of doing things.) In any
>
> case, a simple REFORM may set you right, for whatever it is you are
>
> doing.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
True, I just never checked how this worked since I always got the results I wanted so far...I guess I need to check some of my code, hehe.
The tip with the REFORM works flawlessly, thanks a lot again!! :)
|
|
|