在线图上的峰值检测

2024-10-04 05:23:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下程序来检测线图上的所有峰值。它成功地检测到了峰值,但我只想让它检测到那些明显的峰值(大到可以看到)。有什么建议吗?
Line Graph

import numpy as np

b = (X[1:]-X[:-1])[:-1]
c = (X[:-1]-X[1:])[1:]
minima = np.where(np.bitwise_and(b<0, c<0))[0]+1
maxima = np.where(np.bitwise_and(b>0, c>0))[0]+1
all_peaks = np.where((b*c)>0)[0]+1
del b,c

print(minima)
print(maxima)
print(all_peaks)

Tags: andimport程序numpynpallwhere建议