from scipy import signal
import numpy as np
y_coordinates = np.array(y_coordinates) # convert your 1-D array to a numpy array if it's not, otherwise omit this line
peak_widths = np.arange(1, max_peak_width)
peak_indices = signal.find_peaks_cwt(y_coordinates, peak_widths)
peak_count = len(peak_indices) # the number of peaks in the array
详见此处:https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks_cwt.html
很简单,把数据放入一个一维数组中,并将每个值与相邻的值进行比较,n-1和n+1的数据小于n。
像Robert Valencia建议的那样读取数据。
max_local=0
for u in range (1,len(data)-1):
if ((data[u]>data[u-1])&(data[u]>data[u+1])):
max_local=max_local+1
scipy.signal.find_peaks_cwt
。 - DYZscipy.signal.find_peaks
可能效果更好,除非您确实需要使用小波卷积。 - onewhaleid