Bessel/Thomson digital and analog filter design.
Design an Nth order digital or analog Bessel 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
|
Notes
Also known as a Thomson filter, the analog Bessel filter has maximally flat group delay and maximally linear phase response, with very little ringing in the step response.
As order increases, the Bessel filter approaches a Gaussian filter.
The digital Bessel filter is generated using the bilinear transform, which does not preserve the phase response of the analog filter. As such, it is only approximately correct at frequencies below about fs/4. To get maximally flat group delay at higher frequencies, the analog Bessel filter must be transformed using phase-preserving techniques.
For a given Wn, the lowpass and highpass filter have the same phase vs frequency curves; they are “phase-matched”.
Examples
Plot the filter’s frequency response, showing the flat group delay and the relationship to the Butterworth’s cutoff frequency:
>>> 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(np.abs(h)), color='silver', ls='dashed')
>>> b, a = signal.bessel(4, 100, 'low', analog=True)
>>> w, h = signal.freqs(b, a)
>>> plt.plot(w, 20 * np.log10(np.abs(h)))
>>> plt.xscale('log')
>>> plt.title('Bessel filter frequency response (with Butterworth)')
>>> 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()
>>> plt.figure()
>>> plt.plot(w[1:], -np.diff(np.unwrap(np.angle(h)))/np.diff(w))
>>> plt.xscale('log')
>>> plt.title('Bessel filter group delay')
>>> plt.xlabel('Frequency [radians / second]')
>>> plt.ylabel('Group delay [seconds]')
>>> plt.margins(0, 0.1)
>>> plt.grid(which='both', axis='both')
>>> plt.show()