【问题标题】:Determining the event location on an oscillatory signal确定振荡信号上的事件位置
【发布时间】:2016-06-13 18:20:18
【问题描述】:

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

例如,衰减正弦信号:

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

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

注意:如果我只是通过limit = 0.05 的第一个交叉点,它会出现在t =~ 0.05,这显然不是我想要的。

【问题讨论】:

  • 你的意思是你需要检测本地峰值何时不超过阈值。您可以反向分析,也可以区分并仅在梯度为零的点与阈值进行比较。

标签: python events math integration signal-processing


【解决方案1】:

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

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

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

附:评估信封可能有更简单的方法,请参阅信封的 wiki 链接。

【讨论】:

    【解决方案2】:

    您可以使用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))
    

    【讨论】:

      猜你喜欢
      • 2019-01-24
      • 1970-01-01
      • 2010-10-06
      • 2015-11-30
      • 2017-04-29
      • 1970-01-01
      • 1970-01-01
      • 2018-08-09
      • 1970-01-01
      相关资源
      最近更新 更多