Butterworth digital and analog filter design.
Design an Nth order digital or analog Butterworth filter and return the filter coefficients in (B,A) or (Z,P,K) form.
Parameters: | N : int
Wn : array_like
btype : {‘lowpass’, ‘highpass’, ‘bandpass’, ‘bandstop’}, optional
analog : bool, optional
output : {‘ba’, ‘zpk’}, optional
|
---|---|
Returns: | b, a : ndarray, ndarray
z, p, k : ndarray, ndarray, float
|
See also
Notes
The Butterworth filter has maximally flat frequency response in the passband.
Examples
Plot the filter’s frequency response, showing the critical points:
>>> from scipy import signal
>>> import matplotlib.pyplot as plt
>>> b, a = signal.butter(4, 100, 'low', analog=True)
>>> w, h = signal.freqs(b, a)
>>> plt.plot(w, 20 * np.log10(abs(h)))
>>> plt.xscale('log')
>>> plt.title('Butterworth filter frequency response')
>>> plt.xlabel('Frequency [radians / second]')
>>> plt.ylabel('Amplitude [dB]')
>>> plt.margins(0, 0.1)
>>> plt.grid(which='both', axis='both')
>>> plt.axvline(100, color='green') # cutoff frequency
>>> plt.show()