I have two large lists t
and y
and I want to determine in a performant way at which times and how long the data in y
exceeds a predefined limit
, i.e. >=limit
.
The problem may be illustrated with the following sample data:
t = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
y = [8,6,4,2,0,2,4,6,8,6,4,2,0,2,4,6,8]
limit = 4
In this example, the code should return the following lists:
t_exceedance_start = [0,6,14]
t_how_long_above_limit = [2,4,2]
I would expect that this can be implemented quite elegant in Numpy
but did not find out how .
Any suggestions are highly appreciated.