-
sdr.highpass_fir(order: int, cutoff_freq: float, window: str | float | tuple | None =
'hamming'
) NDArray[float64] 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: 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 highpass FIR filter with cutoff frequency \(f_c = 0.7 \cdot f_s / 2\), using a Hamming window.
In [1]: h_hamming = sdr.highpass_fir(100, 0.7, 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.highpass_fir(100, 0.7, window="hann"); \ ...: h_blackman = sdr.highpass_fir(100, 0.7, window="blackman"); \ ...: h_blackman_harris = sdr.highpass_fir(100, 0.7, window="blackmanharris"); \ ...: h_chebyshev = sdr.highpass_fir(100, 0.7, window=("chebwin", 60)); \ ...: h_kaiser = sdr.highpass_fir(100, 0.7, 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); ...: