I have the following time serie data and I need to detect the following pattern: - a 1st spike above a given value - a 2nd spike close to the given value

What defines "a spike" is that its value is x% above the surrounding spikes.

Time serie data

I would like to use python (numpy and pandas modules) to detect these.

As a background, the goal is to trigger an action when the second spike is detected (outlined in red in the attached image).


scipy.signal's finds_peaks should have most of what you need.

With the height argument you can set a minimum threshold to get the first peak.

With the prominence argument you should be able to approximate the second peak. This requires peak_prominences.

The prominence of a peak measures how much a peak stands out from the surrounding baseline of the signal and is defined as the vertical distance between the peak and its lowest contour line.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.