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 #56678 is a reply to message #56583] Wed, 07 November 2007 03:15 Go to previous messageGo to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
Spon wrote:
> I can get rid of it, but I'm not sure why you're getting a square (as
> opposed to just junk):
>
Ok, now *I'm* confused:

*** Code

pro threedtest
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]

print, 'Fixed version.'
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)
print, ''
print, 'Original version.'
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)
print, ''
print, 'Concatenated version.'
subscripts = [0, xidx, yidx]
test2d = bytarr(10,10)
test3d = bytarr(10,10,10)
test2d[xidx,yidx] = 1
test3d[subscripts] = 1
print,test2d,total(test2d)
print,reform(test3d[0,*,*]),total(test3d)

return
end

*** End of Code

...
IDL> Concatenated version.
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 1 1 1 0 0 0
0 0 0 1 1 1 1 1 0 0
0 0 0 0 1 1 1 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
13.0000
1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
6.00000

***End of Output

Why does OP get a nice square whereas I just get a solitary 1 in the
corner? :-(
What is concatenating before defining the subscripting causing IDL to
do differently?

Just curious,
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: Tue Dec 02 12:21:38 PST 2025

Total time taken to generate the page: 0.16368 seconds