I am trying to extract the indices of all values of a 1D array of numbers that exceed some threshold. The array is on the order of 1e9
long.
My approach is the following in NumPy
:
idxs = where(data>threshold)
This takes something upwards of 20 mins, which is unacceptable. How can I speed this function up? Or, are there faster alternatives?
(To be specific, it takes that long on a Mac OS X running 10.6.7, 1.86 GHz Intel, 4GB RAM doing nothing else.)
data
is reallydata['timeseries']
and threshold is reallydata[threshold][spikes]
. I am sure the second variable is a scalar. – Curhanarray(array([[ 99.48158966]]), dtype=object)
. It now takes about 2 mins. – Curhan