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

Home » Public Forums » archive » Re: Removing equal elements from an array
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: Removing equal elements from an array [message #49743 is a reply to message #49742] Wed, 16 August 2006 09:54 Go to previous messageGo to previous message
Julio[1] is currently offline  Julio[1]
Messages: 52
Registered: May 2005
Member
Ok... :-) Now it really worked.


Jean H. escreveu:

> Hi,
>
> just sort your array based on the 2 fields...
> you can do something like:
> maxCol2 = max(a[1,*])
> sortedIndices = sort([a[0,*]*maxCol2 + a[1,*]])
> now do as you did before, but using a[0,sortedIndices] and
> a[1,sortedIndices]
>
> Jean
>
> Julio wrote:
>> Dear Maarten,
>>
>> I used your code to remove equal elements from an array. It worked fine
>> for a small array. But I tested using a greater amount of points and
>> some equal elements (pairs of coords) remains. There are 434 pairs...
>> an example of them:
>>
>> 234.000 208.000
>> 228.000 208.000
>> 234.000 208.000
>> 234.000 208.000
>> 178.000 209.000
>> ....
>> 153.000 314.000
>> 146.000 318.000
>> 181.000 318.000
>>
>> The pair (234.000, 208.000) repeats 3 times, so 2 pairs should be
>> removed. In the output array for these 434 input pairs I have:
>>
>> 234.000 208.000
>> 228.000 208.000
>> 234.000 208.000
>> 178.000 209.000
>> ... and so on
>>
>> We see the pair (234.000, 208.000) repeats 2 times! Do you have any
>> idea about what is going on??
>>
>> Julio
>>
>> Maarten escreveu:
>>
>>
>>> Mike wrote:
>>>
>>>> Julio wrote:
>>>>
>>>> >I have an array 'A' with two columns, latitudes and longitudes, and
>>>> >several lines. A need to make another array with the elements of A that
>>>> >don't repeat.
>>>>
>>>> Take a look at the uniq function. Here's an example:
>>>
>>> [snip]
>>>
>>> Which still doesn't take into account the following situation:
>>>
>>> A = [[20.4, 40.3, 50.2, 50.2], $
>>> [30.2, 60.2, 32.4, 32.5]]
>>>
>>> in which case no items should be removed. Just thinking out aloud here.
>>> With:
>>> lat = A[*,0] & lon = A[*,1]
>>>
>>> we have
>>> idx_lat = uniq(lat) & idx_lon = uniq(lon)
>>>
>>> At the very least both index arrays should be the same, if you want to
>>> apply this automagically.
>>>
>>> If the precision of the coordinates is limited, you can try to combine
>>> the lat and lon in a single number. If the coordinates are floats, the
>>> following ought to work:
>>>
>>> I = lat + (2.0D0^23)*lon
>>> idx = uniq(I)
>>> lat = lat[idx] & lon = lon[idx]
>>>
>>> Maarten
>>
>>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: File_COPY
Next Topic: SETENV

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

Current Time: Fri Oct 10 14:59:05 PDT 2025

Total time taken to generate the page: 1.52081 seconds