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

Home » Public Forums » archive » indexing 2-d vs. 3-d arrays...ARGH!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
indexing 2-d vs. 3-d arrays...ARGH! [message #43642] Tue, 19 April 2005 14:39
Henry is currently offline  Henry
Messages: 8
Registered: April 2005
Junior Member
Hey folks,

This one tripped me up today. Wonder how many other places in code
I've been messed up by it. I (vaguely) understand the logic behind it.

Let's say you want to grab some points out of a 2-d image or a 3-d
stack of images:

To set the stage, some pretend images and indexes of the points to
grab:
arr2 = dindgen(10,10)
arr3 = dindgen(10,10,5)
index1 = [2,6]
index2 = [3,7]

Now,
help, arr2[index1,index2]
gives
<Expression> DOUBLE = Array[2]
which is what I would expect.

BUT,
help,arr3[index1, index2, 2]
gives
<Expression> DOUBLE = Array[2, 2]
which is what screwed me up.

IDL demands:
help,arr3[index1, index2, replicate(2,2)]
to get:
<Expression> DOUBLE = Array[2]


Get it? Got it? Good.

Actually, I take back the comment about vaguely understanding the logic
of the middle case.

-Henry

p.s. Best of luck David. Balance is key...I wish I could figure out
better how to reach it. In 30 years will I appreciate more the hours
spent in my kayak on the lake listening to loons, or the hours beating
my head against the aluminum paneling of my computer? (dang side panel
is too thick to put a satisfying dent in)
[Message index]
 
Read Message
Previous Topic: Re: how to draw vector fileld and potential field?
Next Topic: how to set the contour to a fixed point?

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

Current Time: Sat Oct 11 00:38:21 PDT 2025

Total time taken to generate the page: 0.32166 seconds