def _getFiltDesign(sf, f, npts, filtname, cycle, order, axis):
"""Get the designed filter
sf : sample frequency
f : frequency vector/list [ex : f = [2,4]]
npts : number of points
- 'fir1'
- 'butter'
- 'bessel'
"""
if type(f) != np.ndarray:
f = np.array(f)
# fir1 filter :
if filtname == 'fir1':
fOrder = fir_order(sf, npts, f[0], cycle=cycle)
b, a = fir1(fOrder, f/(sf / 2))
# butterworth filter :
elif filtname == 'butter':
b, a = butter(order, [(2*f[0])/sf, (2*f[1])/sf], btype='bandpass')
fOrder = None
# bessel filter :
elif filtname == 'bessel':
b, a = bessel(order, [(2*f[0])/sf, (2*f[1])/sf], btype='bandpass')
fOrder = None
def filtSignal(x):
return filtfilt(b, a, x, padlen=fOrder, axis=axis)
return filtSignal
评论列表
文章目录