I\'m designing a bandpass filter in scipy following the cookbook. However, if I decrecrease the filtering frequencies too much I end up with garbage at high order filters. What
What happens is that the orders of the bandpass (BP) filters created in the script are in fact the double of those shown in the plot. Recall that the order of the filter is the order of the polynomial in the denominator of the transfer function. Canonic bandpass filters are always of even order.
Those numbers shown are the orders of the low-pass (LP) prototype (usually normalized to a cutoff frequency of 1 rad/s) which is used to apply the LP-to-BP transformation which doubles the order of the filter. So, for instance, if we start with an LP of order 1, we end up with a second order bandpass:
1/(S+1) => LP-2-BP transf. => k.s/(s^2+a.s+b)
Where k, a and b are constants. The numerator of a standard bandpass filter is k.s^ (N/2) and so the order N of the filter has to be even.
This order issue for bandpass (which also happens to notches or band-reject filters) is not mentioned in SciPy documentation. In fact, if you print the length of denominator a (by using print(len(a))
) before plt.show()
, you will see it has 19 coefficients, what corresponds to a polynomial of 18th order.