sdr.design_bandstop_fir(order: int, center_freq: float, bandwidth: float, window: None | 'hamming' | 'hann' | 'blackman' | 'blackman-harris' | 'chebyshev' | 'kaiser' | ArrayLike = 'hamming', atten: float = 60) NDArray[float_]

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: None | 'hamming' | 'hann' | 'blackman' | 'blackman-harris' | 'chebyshev' | 'kaiser' | ArrayLike = 'hamming'

The time-domain window to use.

atten: float = 60

The sidelobe attenuation in dB. Only used if window is "chebyshev" or "kaiser".

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.design_bandstop_fir(100, 0.4, 0.75, window="hamming")

In [2]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.impulse_response(h_hamming);
   ...: 

In [3]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.magnitude_response(h_hamming, x_axis="one-sided");
   ...: 
../../_images/sdr_design_bandstop_fir_1.png ../../_images/sdr_design_bandstop_fir_2.png

Compare filter designs using different windows.

In [4]: h_hann = sdr.design_bandstop_fir(100, 0.4, 0.75, window="hann"); \
   ...: h_blackman = sdr.design_bandstop_fir(100, 0.4, 0.75, window="blackman"); \
   ...: h_blackman_harris = sdr.design_bandstop_fir(100, 0.4, 0.75, window="blackman-harris"); \
   ...: h_chebyshev = sdr.design_bandstop_fir(100, 0.4, 0.75, window="chebyshev"); \
   ...: h_kaiser = sdr.design_bandstop_fir(100, 0.4, 0.75, window="kaiser")
   ...: 

In [5]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.magnitude_response(h_hamming, x_axis="one-sided", label="Hamming"); \
   ...: sdr.plot.magnitude_response(h_hann, x_axis="one-sided", label="Hann"); \
   ...: sdr.plot.magnitude_response(h_blackman, x_axis="one-sided", label="Blackman"); \
   ...: sdr.plot.magnitude_response(h_blackman_harris, x_axis="one-sided", label="Blackman-Harris"); \
   ...: sdr.plot.magnitude_response(h_chebyshev, x_axis="one-sided", label="Chebyshev"); \
   ...: sdr.plot.magnitude_response(h_kaiser, x_axis="one-sided", label="Kaiser"); \
   ...: plt.legend(); \
   ...: plt.ylim(-100, 10);
   ...: 
../../_images/sdr_design_bandstop_fir_3.png