我有一个信号,想对它进行带通滤波:
def butter_bandpass_prep(lowcut, highcut, fs, order=5):
"""Butterworth bandpass auxilliary function."""
nyq = 0.5 * fs # Minimal frequency (nyquist criterion)
low = lowcut / nyq
high = highcut / nyq
b, a = butter(order, [low, high], btype='band')
return b, a
def butter_bandpass(src, lowcut, highcut, fs, order=5):
"""Butterworth bandpass filter."""
b, a = butter_bandpass_prep(lowcut, highcut, fs, order=order)
dst = lfilter(b, a, src)
return dst然而,我的信号不是从零开始的,这似乎会导致问题,因为滤波后的信号在x方向上移位。我如何补偿这一点呢?

或者巴特沃斯过滤器不是首选的过滤器?!
发布于 2017-07-14 16:44:36
您可以使用filtfilt,它将过滤信号两次,一次向前,一次向后。这将消除所有相移,但会使阻带衰减加倍:
dst = filtfilt(b, a, src)https://stackoverflow.com/questions/45098384
复制相似问题