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

Home » Public Forums » archive » Re: chunk indexing like
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: chunk indexing like [message #69437 is a reply to message #69433] Fri, 08 January 2010 06:12 Go to previous message
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Fri, 08 Jan 2010 14:08:45 +0100, Wox <spam@nomail.com> wrote:

> Hi IDLers,
>
> I know how to get
> from [2,3,1,0,5] to [0,0,1,1,1,2,4,4,4,4,4] (i.e. chunk indexing)
> but how do I get
> from [2,3,1,0,5] to [0,1,0,1,2,0,0,1,2,3,4]
> without loops that is.
>
> I have been juggling with histogram and total(.../cumulative) but I
> can figure this one out.
>
> Any ideas?

Ok, I got something working:

n=[2,3,1,0,5]
h=histogram(total(n>0,/CUMULATIVE,/int)-1,/BINSIZE,MIN=0,REVERSE_INDICES=ri)
nh=n_elements(h)
chinkind=ri[0:nh-1]-ri[0]
ind2=where([1,chinkind[1:*]-chinkind[0:nh-2]] ne 0)
print,lindgen(nh)-ind2[chinkind]

IDL> 0 1 0 1 2 0 0 1 2 3 4
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Greek Symbols in Plot Annotations
Next Topic: isurface with custom palette

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

Current Time: Fri Oct 10 11:54:32 PDT 2025

Total time taken to generate the page: 1.33280 seconds