- class sdr.FIR
Implements a finite impulse response (FIR) filter.
This class is a wrapper for the
scipy.signal.convolve()
function. It supports one-time filtering and streamed filtering.Notes
A FIR filter is defined by its feedforward coefficients \(h[n]\).
\[y[n] = \sum_{i=0}^{N} h[i] \cdot x[n-i] .\]The transfer function of the filter is
\[H(z) = \sum\limits_{i=0}^{N} h[i] \cdot z^{-i} .\]+------+ +------+ +------+ +------+ x[n] --+->| z^-1 |-+->| z^-1 |-+--...--+->| z^-1 |-+->| z^-1 |-+ | +------+ | +------+ | | +------+ | +------+ | | | | | | | h[0] | h[1] | h[2] | | h[N-1] | h[N] | | | | | | | +---------->@---------->@--...->@---------->@---------->@---> y[n]
Examples
See the FIR filters example.
Constructors¶
Special methods¶
Streaming mode only¶
- reset()
Resets the filter state. Only useful when using streaming mode.
- flush() NDArray
Flushes the filter state by passing zeros through the filter. Only useful when using streaming mode.
- property state : NDArray
The filter state consisting of the previous \(N\) inputs.
Methods¶
-
impulse_response(N: int | None =
None
) NDArray Returns the impulse response \(h[n]\) of the FIR filter.
-
step_response(N: int | None =
None
) NDArray Returns the step response \(s[n]\) of the FIR filter.
- frequency_response(...) tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[complex128]]]
- frequency_response(freqs: float, ...) complex
- frequency_response(freqs, ...) ndarray[Any, dtype[complex128]]
Returns the frequency response \(H(\omega)\) of the FIR filter.
- group_delay(...) tuple[NDArray, NDArray]
Returns the group delay \(\tau_g(\omega)\) of the FIR filter.
- phase_delay(...) tuple[NDArray, NDArray]
Returns the phase delay \(\tau_{\phi}(\omega)\) of the FIR filter.
-
noise_bandwidth(sample_rate: float =
1.0
) float Returns the noise bandwidth \(B_n\) of the FIR filter.
Properties¶
- property taps : NDArray
The feedforward taps \(h[n]\) with length \(N + 1\).
- property delay : int
The delay of the FIR filter \(d = \lfloor \frac{N + 1}{2} \rfloor\) in samples.