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

Home » Public Forums » archive » Re: How to extract a datarange from a multidimensional array?
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: How to extract a datarange from a multidimensional array? [message #42350] Fri, 28 January 2005 08:22
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Fri, 28 Jan 2005 11:33:05 +0100, David Lopez Pons wrote:

> aeon@gmx.de wrote:
>
>> Hi,
>>
>> i have following example data:
>> x = [0,5,2,6,5,3,9]
>> y = [1,5,7,4,3,4,8]
>>
>> to get the (x,y)-pairs in a special range i used the following:
>> points = WHERE((x LE (5))AND(x GE (2))AND(y LE (7))AND(y GE (3)),count)
>>
>> Because i accept now the fact, that IDL works faster with array
>> operations instead of for-loops ;)
>> i want to do the following:
>> xy=[[0,5,2,6,5,3,9],[1,5,7,4,3,4,8]]
>>
>> points=???
>>
>> i tried
>> points= WHERE ((xy LE[5,7])AND(xy GE[2,3]),count)
>> but this dont works for me.
>>
>> I know the solution is for sure simple one, but i cant find it.
>> THX for every idea.
>>
>>
>>
> May be this is enough for you:
>
> IDL> xy=[[0,5,2,6,5,3,9],[1,5,7,4,3,4,8]]
> IDL> points2 = WHERE((xy[*,0] LE (5))AND(xy[*,0] GE (2))AND(xy[*,1] LE
> (7))AND(xy[*,1] GE (3)),count)
> IDL> print,points2
> 1 2 4 5

This will actually be slower than the original method proposed,
keeping X & Y separate, since essentially you're doing the same amount
of comparison work, but must also generate subscripting indices to
divide the xy array back into x and y 4 times. Check out
http://www.dfanning.com/misc_tips/submemory.html for more info on why
higher-order subscripting can get you into trouble.

JD
Re: How to extract a datarange from a multidimensional array? [message #42358 is a reply to message #42350] Fri, 28 January 2005 02:43 Go to previous message
Bismarck is currently offline  Bismarck
Messages: 3
Registered: January 2005
Junior Member
Ok, i am officially a nerd. I cant see trees in a forest. But as i
thought, it was really simple.

THX made
Re: How to extract a datarange from a multidimensional array? [message #42359 is a reply to message #42358] Fri, 28 January 2005 02:33 Go to previous message
David Lopez Pons is currently offline  David Lopez Pons
Messages: 8
Registered: July 2003
Junior Member
aeon@gmx.de wrote:

> Hi,
>
> i have following example data:
> x = [0,5,2,6,5,3,9]
> y = [1,5,7,4,3,4,8]
>
> to get the (x,y)-pairs in a special range i used the following:
> points = WHERE((x LE (5))AND(x GE (2))AND(y LE (7))AND(y GE (3)),count)
>
> Because i accept now the fact, that IDL works faster with array
> operations instead of for-loops ;)
> i want to do the following:
> xy=[[0,5,2,6,5,3,9],[1,5,7,4,3,4,8]]
>
> points=???
>
> i tried
> points= WHERE ((xy LE[5,7])AND(xy GE[2,3]),count)
> but this dont works for me.
>
> I know the solution is for sure simple one, but i cant find it.
> THX for every idea.
>
>
>
May be this is enough for you:

IDL> xy=[[0,5,2,6,5,3,9],[1,5,7,4,3,4,8]]
IDL> points2 = WHERE((xy[*,0] LE (5))AND(xy[*,0] GE (2))AND(xy[*,1] LE
(7))AND(xy[*,1] GE (3)),count)
IDL> print,points2
1 2 4 5

I supose that you want yhe same results for points and points2 :)...

Bye.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: How to add each member of a pointarray to each member of another pointarray with arrayoperations?
Next Topic: Re: IDL 6.1.1 : how to activate opengl in hardware ?

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

Current Time: Fri Oct 10 07:26:42 PDT 2025

Total time taken to generate the page: 0.72198 seconds