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

Home » Public Forums » archive » Addressing 3D arrays different from 2D arrays?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Addressing 3D arrays different from 2D arrays? [message #56681 is a reply to message #56583] Tue, 06 November 2007 09:30 Go to previous messageGo to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Nov 6, 5:13 pm, Jaron Kurk <jaron.k...@googlemail.com> wrote:
> Dear readers,
>
> Apologies if this question has long been answered, but I could not
> find anything on it.
>
> Is there some fundamental difference in addressing 3D arrays and 2D
> arrays? In IDL 6.3 (and GDL), the following code fills a 2D array with
> a circle of 1's but a slice of a 3D array with a square of 1's, while
> I would expect just the same area filled with 1's as for the 2D case.
> Note that the use of reform() does not cause the difference, I have
> checked that.
>
> xidx=[5,4,5,6,3,4,5,6,7,4,5,6,5]
> yidx=[3,4,4,4,5,5,5,5,5,6,6,6,7]
> test2d = bytarr(10,10)
> test3d = bytarr(10,10,10)
> test2d[xidx,yidx] = 1
> test3d[0,xidx,yidx] = 1
> print,test2d,total(test2d)
> print,reform(test3d[0,*,*]),total(test3d)
>
> If anybody could enlighten me, I would appreciate it!
>
> Jaron Kurk.

I can get rid of it, but I'm not sure why you're getting a square (as
opposed to just junk):

xidx = [5,4,5,6,3,4,5,6,7,4,5,6,5]
yidx = [3,4,4,4,5,5,5,5,5,6,6,6,7]
zidx = REPLICATE (0, N_ELEMENTS (xidx))
test2d = bytarr(10,10)
test3d = bytarr(10,10,10)
test2d[xidx,yidx] = 1
test3d[zidx,xidx,yidx] = 1
print,test2d,total(test2d)
print,reform(test3d[0,*,*]),total(test3d)

Your test3d array wasn't shifting your first two arrays by a whole
dimension, just one element.

Chris
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL sorting
Next Topic: !path problem

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

Current Time: Sat Oct 11 15:00:55 PDT 2025

Total time taken to generate the page: 1.59787 seconds