[SciPy-user] Finding Gaps in an Array
Mon Jul 6 07:01:14 CDT 2009
will give you the times between entries,
numpy.where(numpy.diff(your_array) > 20)
will give the indices where the gap was longer than 20
----- Original Message ----
From: Lorenzo Isella <email@example.com>
Sent: Monday, 6 July, 2009 8:18:07 PM
Subject: [SciPy-user] Finding Gaps in an Array
Suppose you have an integer array whose entries are like the one below
(no entry is ever repeated and the array is sorted in increasing order)
Let us assume that the entries represent contact times (in seconds)
between 2 objects (one does not need to know anything else for this
post). The value of the initial time does not matter (i.e. you could
subtract it to all the elements in the array to have a list starting
from zero). Now, you define the contact duration as the time spanned by
consecutive entries evenly spaced by 20 seconds.
E.g. in the array above, the first 5 elements define a contact of
duration 1240070100-1240070020=80. Then there is an 80-sec gap
(1240070180-1240070100) followed by a contact of duration 20
How can you automatically calculate these intervals?
Any suggestion is welcome.
SciPy-user mailing list
More information about the SciPy-user