2016-03-01 74 views
1

我正在进行事件驱动集成,其中一个事件应检测到信号幅度低于某个值/限制的时间。确定振荡信号上的事件位置

在实例中,衰减正弦信号:

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

Decaying sine signal

从图中可以看出的是,condtition应在t =~ 90得到满足。尽管我可以看到它,但我想在集成过程中以数字方式获取位置。我怎样才能做到这一点?我如何定义条件?

注意:如果我只是第一次穿过limit = 0.05它发生在t =~ 0.05,这显然不是我想要的。

+1

你的意思是你需要检测当一个本地峰值d没有超过阈值。您可以在反向时间进行分析,或者可以区分并仅在梯度为零的点处与阈值进行比较。 – barny

回答

1

可以使用计算信封要么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)) 
1

您可以计算出envelope的信号,如果需要(噪声),用低通滤波器对其进行滤波并找到信封在哪里超过极限水平。

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

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

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