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

Home » Public Forums » archive » Re: Array index for arrays
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
Re: Array index for arrays [message #28335] Tue, 04 December 2001 06:35 Go to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
the_cacc@hotmail.com (trouble) writes:

> z=indgen(4,4)
> ix=[0,1]
> help,z[ix,ix]
>
> <Expression> INT = Array[2]
...
> Not what I expected !?!

Yes, this has burned me a couple of times. The short answer is that
when you combine two or more "index lists", then they are treated as
one-for-one coordinate lists. What you want can be achieved in two
separate indexing steps:

help, (z[ix,*])[*,iy]

Ie, first do the X index then the Y index.

Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Array index for arrays [message #28417 is a reply to message #28335] Tue, 04 December 2001 18:40 Go to previous message
air_jlin is currently offline  air_jlin
Messages: 22
Registered: July 2001
Junior Member
Craig Markwardt <craigmnet@cow.physics.wisc.edu> wrote in message
news:<onr8qb6ok2.fsf@cow.physics.wisc.edu>...
> [...]
>
> Yes, this has burned me a couple of times. The short answer is that
> when you combine two or more "index lists", then they are treated as
> one-for-one coordinate lists. What you want can be achieved in two
> separate indexing steps:
>
but how come adding a third "*" dimension gives something you would
expect?

---------------------------------
IDL> z=indgen(3,2,4)
IDL> ix=[0,1]
IDL> print,z
0 1 2
3 4 5

6 7 8
9 10 11

12 13 14
15 16 17

18 19 20
21 22 23
IDL> print,z[ix,ix,*]
0 1
3 4

6 7
9 10

12 13
15 16

18 19
21 22
---------------------------------

thanks!

best,
-Johnny


-------------------------------------------
Johnny Lin
CIRES, University of Colorado
Work Phone: (303) 735-1636
Web: http://cires.colorado.edu/~johnny/
-------------------------------------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: ION Script Windowing Issues
Next Topic: Re: set_plot,'PS'

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

Current Time: Wed Oct 08 08:51:06 PDT 2025

Total time taken to generate the page: 0.00767 seconds