# Required input defintions are as follows;
# time: Time between samples
# band: The bandwidth around the centerline freqency that you wish to filter
# freq: The centerline frequency to be filtered
# ripple: The maximum passband ripple that is allowed in db
# order: The filter order. For FIR notch filters this is best set to 2 or 3,
# IIR filters are best suited for high values of order. This algorithm
# is hard coded to FIR filters
# filter_type: 'butter', 'bessel', 'cheby1', 'cheby2', 'ellip'
# data: the data to be filtered
def Implement_Notch_Filter(time, band, freq, ripple, order, filter_type, data):
from scipy.signal import iirfilter
fs = 1/time
nyq = fs/2.0
low = freq - band/2.0
high = freq + band/2.0
low = low/nyq
high = high/nyq
b, a = iirfilter(order, [low, high], rp=ripple, btype='bandstop',
analog=False, ftype=filter_type)
filtered_data = lfilter(b, a, data)
return filtered_data
在
scipy.signal
网站上有一些解决方案,但是它们引入了很多振铃,这些振铃将转换为卷积信号中的伪影。在尝试了许多事情之后,我发现以下函数对于实现FIR陷波滤波器最有效。相关问题 更多 >
编程相关推荐