Bandpass butterworth filter frequencies in scipy
- Don't use
b, a = butter
for high-order filters, whether in Matlab or SciPy or Octave. Transfer function format has numerical stability problems, because some of the coefficients are very large while others are very small. This is why we changed the filter design functions to use zpk format internally. To see the benefits of this, you need to use z, p, k = butter(output='zpk')
and then work with poles and zeros instead of numerator and denominator.
- Don't do high-order digital filters in a single stage. This is a bad idea no matter what software or hardware you're implementing them on. Typically it's best to break them up into second-order sections. In Matlab, you can use zp2sos to generate these automatically. In SciPy, you can use
sos = butter(output='sos')
and then filter using sosfilt()
or sosfiltfilt()
. This is the recommended way to filter for most applications.