tophu.bandpass_equiripple_filter
- tophu.bandpass_equiripple_filter(bandwidth, shape, ripple, attenuation, centerfreq=0.0, samplerate=1.0, *, force_odd_length=False, maxiter=25, grid_density=16)
Design a bandpass FIR digital filter using the Parks-McClellan algorithm.
Form a linear-phase finite impulse response (FIR) discrete-time digital filter wth desired passband, stopband, and attenuation characteristics using the Parks-McClellan algorithm1. The algorithm produces a filter that is optimal in the sense that it minimizes the maximum weighted deviation from the ideal frequency response in the passband and stopband.
The resulting filter has equiripple frequency response in both the passband and stopband.
- Parameters
- bandwidthfloat
Width of the passband, in the same units as samplerate.
- shapefloat
Shape factor – the ratio of the width of the combined passband and transition band to the passband width.
- ripplefloat
Passband ripple – the maximum allowed ripple amplitude below unity gain in the passband, in decibels.
- attenuationfloat
Stopband attenuation – the difference in amplitude, in decibels, between the ideal gain in the passband and the highest gain in the stopband.
- centerfreqfloat, optional
Center frequency of the passband, in the same units as samplerate. Defaults to 0.
- sampleratefloat, optional
Sampling frequency of the signal. Defaults to 1.
- force_odd_lengthbool, optional
Whether to force the filter length to be odd-valued. Defaults to False.
- maxiterint, optional
Maximum number of iterations of the algorithm. Defaults to 25.
- grid_densityint, optional
Density of Lagrange interpolation points used in the algorithm. Defaults to 16.
- Returns
- coeffsnumpy.ndarray
Filter coefficients.
References
- 1
J. McClellan and T. Parks. A unified approach to the design of optimum FIR linear-phase digital filters. IEEE Transactions on Circuit Theory, 20(6):697–701, November 1973. URL: https://doi.org/10.1109/tct.1973.1083764, doi:10.1109/tct.1973.1083764.