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

Home » Public Forums » archive » Re: Create new arrays from series of subsequent integers in an existing 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: Create new arrays from series of subsequent integers in an existing array [message #48825 is a reply to message #48824] Mon, 22 May 2006 17:27 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
Jonathan Wolfe wrote:
> Hello,
>
> I have been trying to average components of a time series when they
> meet certain criteria.
> For example,
>
> I have values in which I use a where statement to specify the critera
>
> criteria=where(time lt 1000)
>
> and I get an array returned which looks like this
>
> data=[0,1,2,3,4,6,8,9,10]
>
> Now, given this array, I would like to specify individual arrays for
> any "block" of subsequent numbers with size greater than three.
>
> for this array it would look like this
>
> a=[0,1,2,3,4]
> b=[8,9,10]
>
> I tried using the complement keyword in the where statement to put the
> null values into an array and try to subscript my way through the
> answer
>
> where(-------,complement=q)
>
> result=data[0:Q(0)-1]
> result1=[Q(0):Q(1)]
>
> that turned out to be quite messy especially since I am using multiple
> files which all have a different "patterns of three or more"
>
> I've messed around with for loops and if statements, but again I have
> to change those for each individual file. It would be nice to know a
> technique which could accomplish what I am trying to do:
>
> find series of subsequent integers in an array to make multiple new
> arrays.
>
>
> This seems like a simple problem, but I haven't been able to figure it
> out. Maybe I'm overlooking something... Any help would be appreciated!
>
> Thank you in advance!
> Jon
>

I think something like this might work for you:

; I'm just setting up a fake data set like you have
n = 11
time = fltarr(n)
time[[5, 7]] = 1000

; morphological logical operators to eliminate groups smaller than three
k = [1, 1, 1]
r = dilate(erode(time lt 1000, k), k)

; label individual groups
regions = label_region([0, r, 0])
regions = regions[1:n]

; go through each group and print (or do whatever)
h = histogram(regions, reverse_indices=ri)
for i = 1L, n_elements(h) - 1L do print, ri[ri[i]:ri[i+1]-1

Mike
--
www.michaelgalloy.com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: SAVE files with /ROUTINES for Previous Versions
Next Topic: PLOTHIST and tick marks

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

Current Time: Fri Oct 10 11:30:35 PDT 2025

Total time taken to generate the page: 0.64143 seconds