-
sdr.lowpass_fir(order: int, cutoff_freq: float, window: str | float | tuple | None =
'hamming'
) NDArray[float64] Designs a lowpass FIR filter impulse response \(h[n]\) using the window method.
- Parameters:¶
- order: int¶
The filter order \(N\). Must be even.
- cutoff_freq: float¶
The cutoff frequency \(f_c\), normalized to the Nyquist frequency \(f_s / 2\).
- window: str | float | tuple | None =
'hamming'
¶ The SciPy window definition. See
scipy.signal.windows.get_window()
for details. IfNone
, no window is applied.
- Returns:¶
The filter impulse response \(h[n]\) with length \(N + 1\). The center of the passband has 0 dB gain.
References
Examples
Design a length-101 lowpass FIR filter with cutoff frequency \(f_c = 0.2 \cdot f_s / 2\), using a Hamming window.
In [1]: h_hamming = sdr.lowpass_fir(100, 0.2, window="hamming") In [2]: plt.figure(); \ ...: sdr.plot.impulse_response(h_hamming); ...: In [3]: plt.figure(); \ ...: sdr.plot.magnitude_response(h_hamming); ...:
Compare filter designs using different windows.
In [4]: h_hann = sdr.lowpass_fir(100, 0.2, window="hann"); \ ...: h_blackman = sdr.lowpass_fir(100, 0.2, window="blackman"); \ ...: h_blackman_harris = sdr.lowpass_fir(100, 0.2, window="blackmanharris"); \ ...: h_chebyshev = sdr.lowpass_fir(100, 0.2, window=("chebwin", 60)); \ ...: h_kaiser = sdr.lowpass_fir(100, 0.2, window=("kaiser", 0.5)) ...: In [5]: plt.figure(); \ ...: sdr.plot.magnitude_response(h_hamming, label="Hamming"); \ ...: sdr.plot.magnitude_response(h_hann, label="Hann"); \ ...: sdr.plot.magnitude_response(h_blackman, label="Blackman"); \ ...: sdr.plot.magnitude_response(h_blackman_harris, label="Blackman-Harris"); \ ...: sdr.plot.magnitude_response(h_chebyshev, label="Chebyshev"); \ ...: sdr.plot.magnitude_response(h_kaiser, label="Kaiser"); \ ...: plt.ylim(-100, 10); ...: