为什么我的Python Butterworth滤波器可以平滑信号频谱(在频率空间中)?

时间:2018-07-25 14:45:12

标签: filter scipy filtering signal-processing butterworth

对于波动的时间序列,我使用低通巴特沃思滤波器来排除高频噪声。它使用scipy.signal butter和filtfilt函数实现。

def butter_lp(data, N, cutoff, df):
    b, a = butter(N, cutoff/(df*len(data)), btype='lowpass', output='ba')
    y = filtfilt(b, a, data)

    return y

def plot_response(N, cutoff, data, df):
    b, a = butter(N, cutoff/(df*len(data)), btype='lowpass', output='ba')
    w, h = freqz(b, a)
    plt.plot(w * (1/(2*dt)), 20 * log10(abs(h)), label='{0}, {1}'.format(forder,cutoff))
    plt.xscale('log')
    plt.xlabel('Frequency [radians / second]')
    plt.ylabel('Amplitude [dB]')
    plt.legend(loc='best')
    plt.margins(0, 0.1)
    plt.grid(which='both', axis='both')
    plt.axvline(100, color='green')  # cutoff frequency
    #plt.show()

为完整起见,输入的“数据”代码类似于

filtered["channel{0:02d}".format(ch)] = butter_lp(noiseelim(transpose(xbt[0][6])[ch-1][opint:clint]), forder, lpfreq, df)

采用5阶(请记住,它被应用了两次)并且截止频率为200kHz,我看到了在该截止频率之上的信号的预期衰减,但是信号的波动(现在在频谱的本底噪声区域)是平滑。为什么?我可以避免吗?

shared y plot showing on the left the original spectrum including noise floor and adjacent (right) the filtered spectrum showing a smoothed, attenuating tail in place of the noise floor

0 个答案:

没有答案