-
sdr.design_highpass_fir(order: int, cutoff_freq: float, window: None | 'hamming' | 'hann' | 'blackman' | 'blackman-harris' | 'chebyshev' | 'kaiser' | ArrayLike =
'hamming'
, atten: float =60
) NDArray[float_] Designs a highpass 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: None | 'hamming' | 'hann' | 'blackman' | 'blackman-harris' | 'chebyshev' | 'kaiser' | ArrayLike =
'hamming'
¶ The time-domain window to use.
None
: No windowing. Equivalently, a length-\(N + 1\) vector of ones."hamming"
: Hamming window, seescipy.signal.windows.hamming()
."hann"
: Hann window, seescipy.signal.windows.hann()
."blackman"
: Blackman window, seescipy.signal.windows.blackman()
."blackman-harris"
: Blackman-Harris window, seescipy.signal.windows.blackmanharris()
."chebyshev"
: Chebyshev window, seescipy.signal.windows.chebwin()
."kaiser"
: Kaiser window, seescipy.signal.windows.kaiser()
.npt.ArrayLike
: A custom window. Must be a length-\(N + 1\) vector.
- 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 passband has 0 dB gain.
References¶
Examples¶
Design a length-101 highpass FIR filter with cutoff frequency \(f_c = 0.7 \cdot f_s / 2\), using a Hamming window.
In [1]: h_hamming = sdr.design_highpass_fir(100, 0.7, 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"); ...:
Compare filter designs using different windows.
In [4]: h_hann = sdr.design_highpass_fir(100, 0.7, window="hann"); \ ...: h_blackman = sdr.design_highpass_fir(100, 0.7, window="blackman"); \ ...: h_blackman_harris = sdr.design_highpass_fir(100, 0.7, window="blackman-harris"); \ ...: h_chebyshev = sdr.design_highpass_fir(100, 0.7, window="chebyshev"); \ ...: h_kaiser = sdr.design_highpass_fir(100, 0.7, 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); ...: