Re: WHERE - problem [message #33780 is a reply to message #33772] |
Tue, 28 January 2003 09:48  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Tue, 28 Jan 2003 03:22:04 -0700, Thomas Jordi wrote:
> hi there
> i'm not an IDL-guru, but i'm using it for some time. the WHERE function
> is extremely handy and often of great use for me. however, one problem i
> failed to solve. lets state an array(500,500,10)
> array=INDGEN(500,500,10)
>
> so then, the find=WHERE(array[*,*,1] GT 252000) returns me all the
> needed values.
> but HOW do interact with these.
>
> a=mean(array[find]) doesnt do it right
>
> So I helped myself with
> idiotway=array[*,*,1]
> find=where(idiotway gt 252000)
> so then the example a=mean(idiotway(find)) does it right.
>
> However, somehow there must be a better way...
>
>
> some help would be appreciated
A few possibilities:
IDL> m=mean(array[wh+product((size(array,/DIMENSIONS))[0:1])]) ; v5.6
or
IDL> s=size(array, /DIMENSIONS)
IDL> m=mean(array[wh+s[0]*s[1]]) ; < v5.6
Nearly equivalent to your idiot way, but much easier on the eye:
IDL> m=mean((array[*,*,1])[wh])
The last is probably the best choice, unless you are indexing extremely
large arrays and don't want the overhead of creating the plane (in
parentheses) separately.
Good luck,
JD
|
|
|