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

Home » Public Forums » archive » Re: Where Function with 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: Where Function with Arrays [message #40131] Tue, 20 July 2004 16:11
rats is currently offline  rats
Messages: 11
Registered: June 2004
Junior Member
> The way you can do this is to append the two arrays together, sort and
> uniq them. But really I've already done this in a routine called
> CMSET_OP(), which will return the indices of an array intersection
> like this:
>
> wh = cmset_op(ArrayX, 'AND', ArrayY, /INDEX)
>
> which will give you indices into the ArrayX array. You can then
> reverse the order of X/Y and get the indices into the ArrayY array.
> Of course, you should check for the case of no intersection
> whatsoever.
>
> Good luck,
> Craig
>
> http://cow.physics.wisc.edu/~craigm/idl/idl.html (under "Array/Set" utilities)


Thanks Craig for your reply ... now it is working :)

Rafael
Re: Where Function with Arrays [message #40139 is a reply to message #40131] Tue, 20 July 2004 06:48 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
rats@mail.geog.uvic.ca (Rafael Loos) writes:

> Hi,
> I have two arrays. Both of them have 3 columns (First array:(INDEX, X,
> Altitude) and the other array:(INDEX, Y, Altitude). The first column
> is the INDEX that I have created to make some intersection with both
> arrays.
> After the intersection a new array was created to contain all the
> intersection points.
> Now that I have these values I want to find the respective rows for
> each array.
> I was trying to do something like that:
>
> int = setIntersection(ArrayX, ArrayY)
> newArray = where(XArray[0,*] EQ int[*])
>
> But it is not possible.

Unfortunately setIntersection only gives you the values, not the
indices, so you are stuck trying to get the intersection a second time
when you really just wanted the indices the first time.

The way you can do this is to append the two arrays together, sort and
uniq them. But really I've already done this in a routine called
CMSET_OP(), which will return the indices of an array intersection
like this:

wh = cmset_op(ArrayX, 'AND', ArrayY, /INDEX)

which will give you indices into the ArrayX array. You can then
reverse the order of X/Y and get the indices into the ArrayY array.
Of course, you should check for the case of no intersection
whatsoever.

Good luck,
Craig

http://cow.physics.wisc.edu/~craigm/idl/idl.html (under "Array/Set" utilities)

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Sparse Matrix Routines
Next Topic: Keyboard Shortcuts

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

Current Time: Wed Oct 08 18:38:48 PDT 2025

Total time taken to generate the page: 0.00482 seconds