Re: Where Function with Arrays [message #40131] |
Tue, 20 July 2004 16:11 |
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  |
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
------------------------------------------------------------ --------------
|
|
|