【发布时间】:2019-11-16 01:02:40
【问题描述】:
我刚刚开始使用 scipy 的信号函数。
在附图中,我试图找到曲线与任意阈值(检测到的峰值的左侧和右侧)相交的坐标 A[n] 的位置。使用peak_widths 给出点 B[n],其中 B 位于某个相对峰值位置。我正在寻找 A[n] 处于固定阈值的位置。
我该如何解决这个问题?我还不能添加内联图片,因为我是 Stack exchange 的新手。附图片。 提前致谢。
Annotated Plot from Code below
x = np.linspace(0, 6 * np.pi, 1000)
x = np.sin(x) #+ 0.6 * np.sin(2.6 * x)
peaks, _ = find_peaks(x,height=0.5)
threshold = 0.3
results_half = peak_widths(x, peaks, rel_height=0.5)
results_half[0] # widths
plt.plot(x)
plt.plot(peaks, x[peaks], "x",color='r')
plt.hlines(*results_half[1:], color="C2")
plt.axhline(threshold,color='green')
【问题讨论】: