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

Home » Public Forums » archive » Remove the repeated lines in my 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: Remove the repeated lines in my array... [message #94021 is a reply to message #93986] Thu, 22 December 2016 05:30 Go to previous messageGo to previous message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 12/13/2016 06:22 PM, Markus Schmassmann wrote:
> Am 13.12.2016 um 16:37 schrieb dave poreh:
>> I have an array (24*300,000) and it is lon-lat with some
>> specification (24 characteristics). Some of these lines are repeated
>> numbers. I mean same lon-lat and same specifications. I just want to
>> know how could i remove the repeated lines in my array,
> the following functions are untested
>
> function ord, array
> ;+
> ; Calculates the ordinal of each value of an array in terms of the
> ; sorted values.
> ; inspired by jbiu's ord & uniqify, written by Markus Schmassmann
> ; IDL> result=ord(array)
> ;-
> compile_opt defint32, strictarr
> return, reform( value_locate(array[uniq(array,sort(array))],array), $
> size(array,/dimensions),/overwrite )
> end
>
> function uniq_multi, array
> ords=ulonarr(24,300000)
> for i=0,23 do ords[i,*]=ord(array[i,0])
> maxO=max(ords,dim=2)
> idx=ulon64arr(300000)
> for i=0,23 do idx=idx*maxO[i]+ords[*,i]
> return, array[*,uniq(idx,sort(idx))]
> end
>
>
> if you run into an overflow for idx, then you could print each of the
> lines into an element of an array of strings and then use
>
> array[*,uniq(idx,sort(stringarray))]
>
> I hope one of these approaches works or can be made to work,
here the corrected code should anyone else care.
Seasonal greetings to everyone, Markus


function uniq_multi, array
;+
; same as uniq, but considers multiple columns of an array
;-

compile_opt defint32, strictarr

sz=size(array,/dim)
ncol =sz[0]
nlines=sz[1]

ords=ulonarr(ncol,nlines)
for i=0,ncol-1 do ords[i,*]=ord(array[i,*])
maxO=max(ords,dim=2)
idx=ulon64arr(1,nlines)
for i=0,ncol-1 do idx=idx*maxO[i]+ords[i,*]

return, array[*,uniq(idx,sort(idx))]

end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: FYI: What's New in IDL 8.6
Next Topic: subscript and superscript in postscript file

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

Current Time: Wed Oct 08 16:13:52 PDT 2025

Total time taken to generate the page: 0.00400 seconds