0

graph

This is the sample of my data. As you see there is 3 spikes and after the spikes data lasts above normal for different periods and levels.

I tried solve this with a basic for loop but could not manage it. I don't have to find every spike of the graph,I just have to figure out for example when is the spike starting at point 100 and when it drops like just before point 120 automatically.

Vitalizzare
  • 4,496
  • 7
  • 13
  • 32

1 Answers1

0

Your question opens up into a whole branch data analytics. A good starting point maybe the scipy.signal family. It provides find_peaks [1] and peak_widths [2] to help with that. A starting point for these functions might look like this:

from scipy import signal
ts = np.array([...])  # Your data
threshold = (np.max(ts) - np.min(ts))/2 + np.min(ts)

peaks = signal.find_peaks(ts, threshold=threshold)[0]
width = signal.peak_widths(ts, peaks)[0]

Since you have these smaller peaks on and next to the 3 big peaks, you want to set a threshold. Additionally, I assume you would need to tune the parameters of the peak_widths function, since it might detect the widths of the smaller peaks.

jan_w
  • 113
  • 1
  • 6