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

Home » Public Forums » archive » using the WHERE function on a portion of an array
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: using the WHERE function on a portion of an array [message #59187 is a reply to message #59116] Fri, 07 March 2008 09:05 Go to previous message
becky_s is currently offline  becky_s
Messages: 4
Registered: February 2008
Junior Member
Jean,

Thanks for the tip about n_elements, I will do that! As for the other
stuff, I think we have the same idea but are talking at cross-
purposes. In your above example,
> ex: n_elements(A[*,0,0]) = 100 (10*10 array)
> index = 99 (last element of the 2D array)
> 99 * 100 = 9 900 ==> you are in the 99th plane, even if you haven't
> specified the plane!!!

My "indices" variable is actually from the 2D array A[0,*,*], but my
computation of the 1D index uses n_elements(A[*,0,0]). So, for
example, let A be a 4x2x2 array:
2830 0 0 0
2830 0 0 0

0 0 0 0
2830 0 0 0

and B another 4x2x2 array:
20 0 0 0
60 0 0 0

0 0 0 0
9 0 0 0

indices = WHERE(A[0,*,*] ge 2830 AND A[0,*,*] lt 2831, count)
;indices evaluates to 0, 1, 3

;Now, convert to 1D:
indices1D_B = indices * n_elements(A[*,0,0]) + 0
;yields 0, 4, 12

When I plug 0, 4, and 12 into B, I get the correct values I was
looking for,
B[0] = 20; B[4] = 60; B[12] = 9.

Hope that helps.
Becky
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: end-of-line termination
Next Topic: Re: end-of-line termination

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

Current Time: Sun Oct 12 03:41:25 PDT 2025

Total time taken to generate the page: 1.27854 seconds