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 
Return to the default flat view Create a new topic Submit Reply
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
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Previous Topic: Sparse Matrix Routines
Next Topic: Keyboard Shortcuts

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

Current Time: Sat Oct 11 03:53:21 PDT 2025

Total time taken to generate the page: 7.51773 seconds