Re: WHERE - problem [message #33771] |
Wed, 29 January 2003 09:31 |
Pavel A. Romashkin
Messages: 531 Registered: November 2000
|
Senior Member |
|
|
Thomas Jordi wrote:
>
> thanks, it worked. however am I right, that the WHERE procedure is not
> able to handle the case, wehre you search values in a 3d array in one
> plane, and then want to acces with array[where] ?
>
> array(500,500,10)
> find=where(array(*,*,4) eq x)
>
> then the find-array with the subscripts indizes does not return the
> right values. it does it only at one or two dimensional arrays
> i thought, there must be a way like (array(find)) eg array(*,*,4(find))
> or whatever.
> So you cannot us the where for parts of the array only?
The deal here is, WHERE takes the explicitly specified dimension by
value, and analyzes the 2D array. If you look at the result of
WHERE(array[*, *, 4]) then you will see that the smallest index you can
get is 0, although you can't possibly want to use that zero and refer to
the entire Array. However, the following works:
find=where(array[*,*,4] eq x)
print, mean((array[*,*,4])[find])
or
s = size(array)
print, mean(array[find + 4*(s[1]*s[2])])
In the latter example, you do use Find to index Array, but you add the
size of the 3 ignored layers to Find, so the result is correct.
Hope this helps.
Cheers,
Pavel
|
|
|
Re: WHERE - problem [message #33772 is a reply to message #33771] |
Tue, 28 January 2003 22:10  |
Thomas Jordi
Messages: 5 Registered: August 2002
|
Junior Member |
|
|
> Good luck,
thanks, it worked. however am I right, that the WHERE procedure is not
able to handle the case, wehre you search values in a 3d array in one
plane, and then want to acces with array[where] ?
array(500,500,10)
find=where(array(*,*,4) eq x)
then the find-array with the subscripts indizes does not return the
right values. it does it only at one or two dimensional arrays
i thought, there must be a way like (array(find)) eg array(*,*,4(find))
or whatever.
So you cannot us the where for parts of the array only?
however, your onditional way is really better looking. thank you
tschordi
>
> JD
--
�`����,��,�`ï¿½ï ¿½ï¿½ï¿½,�
Thomas Jordi
Geographisches Institut
Universitaet Bern
Hallerstrasse 12
3012 Bern
tschordi@giub.unibe.ch
�`����,��,�`ï¿½ï ¿½ï¿½ï¿½
|
|
|
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
|
|
|