comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How come? Weird subarray problem...
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
How come? Weird subarray problem... [message #85208] Fri, 12 July 2013 13:07 Go to next message
stefan.meingast is currently offline  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 Go to previous messageGo to next message
David Fanning is currently offline  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 Go to previous message
stefan.meingast is currently offline  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!! :)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: localising IDL programs
Next Topic: Barplot

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:36:17 PDT 2025

Total time taken to generate the page: 0.00614 seconds