-
sdr.bandstop_fir(order: int, center_freq: float, bandwidth: float, window: str | float | tuple | None =
'hamming'
) NDArray[float64] Designs a bandstop FIR filter impulse response \(h[n]\) using the window method.
- Parameters:¶
- order: int¶
The filter order \(N\). Must be even.
- center_freq: float¶
The center frequency \(f_{center}\), normalized to the Nyquist frequency \(f_s / 2\).
- bandwidth: float¶
The two-sided bandwidth about \(f_{center}\), 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 larger passband has 0 dB gain.
References
Examples
Design a length-101 bandstop FIR filter with center frequency \(f_{center} = 0.4 \cdot f_s / 2\) and bandwidth \(0.75 \cdot f_s / 2\), using a Hamming window.
In [1]: h_hamming = sdr.bandstop_fir(100, 0.4, 0.75, 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.bandstop_fir(100, 0.4, 0.75, window="hann"); \ ...: h_blackman = sdr.bandstop_fir(100, 0.4, 0.75, window="blackman"); \ ...: h_blackman_harris = sdr.bandstop_fir(100, 0.4, 0.75, window="blackmanharris"); \ ...: h_chebyshev = sdr.bandstop_fir(100, 0.4, 0.75, window=("chebwin", 60)); \ ...: h_kaiser = sdr.bandstop_fir(100, 0.4, 0.75, 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); ...: