Search code examples
pythonscipysignal-processing

How to group peak points corresponding to the same hill in signal plot


I have a list of points where I need to find peak points and group them. I am using find_peak() function from scipy.signal to find the peak points, Now I need to group the peak points which correspond to the same hill (as mentioned below). How can we do this, any suggestion would be of great help.

Sample images enter image description here enter image description here

Code

from matplotlib import pyplot as plt
from scipy.signal import find_peaks

# lst has list of points
A = np.array(lst)
peaks, _ = find_peaks(A)

plt.figure()
plt.plot(lst)
plt.plot(peaks, A[peaks], "ro")
plt.grid()
plt.show()

Solution

  • A typical way to group peaks is to low-pass filter the waveform. Lower the frequency cut-off of the low-pass filter until the peaks you think belong together for your "hills" merge. Then try the find peaks function.