确定振荡信号上的事件位置

Determining the event location on an oscillatory signal

我正在做一个事件驱动的集成,其中一个事件应该检测到信号的幅度何时低于某些 value/limit。

例如,衰减的正弦信号:

signal = sin(t)*exp(-t/50)
limit = 0.05

从图中可以看出,在t =~ 90处应该满足条件。虽然我可以看到它,但我想在积分期间以数字方式获取位置。我怎样才能做到这一点?如何定义条件?

注意:如果我只走 limit = 0.05 的第一个十字路口,它出现在 t =~ 0.05,这显然不是我想要的。

您可以计算 envelope 信号,如果需要(噪声)用低通滤波器对其进行过滤,并找到包络线超过极限水平的位置。

要找到包络,您可以尝试计算信号 F(t) 的希尔伯特变换 H(t) 以生成正交信号 (How to find HT using Fourier transform)。包络是源信号与正交信号平方和的平方根。

E(t) = Sqrt(F^2(t) + H^2(t))

P.S。可能有更简单的方法来评估信封,请参阅信封的 wiki 链接。

您可以使用 scipy.signal.hilbert:

来计算包络
import numpy as np
from scipy import signal

# Add some padding to limit the periodic extension effect
padlen = int(np.floor(0.1*len(x)))
y = np.pad(x, (0,padlen), mode='edge');
# Compute the envelope
envelope = np.abs(signal.hilbert(y));
# Truncate to the original signal length
envelope = envelope[:-padlen]

或使用简单的 diode detector 实现:

def diode_detector(x,alpha):
    xmax = abs(x[0])
    y = np.array(x)
    for i in np.arange(len(x)):
        if (xmax < abs(x[i])):
            xmax = abs(x[i])
        else:
            xmax = alpha*xmax
        y[i] = xmax
    return y

# you may need to tweak the alpha parameter depending on your signal bandwidth
envelope = diode_detector(x,0.9997) 

那么就是计算触发位置的问题了:

T = t[1]-t[0]
print T*np.min(np.where(envelope < limit))