- 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_i\).
\[y[n] = \sum_{i=0}^{N} h_i x[n-i] .\]The transfer function of the filter is
\[H(z) = \sum\limits_{i=0}^{N} h_i z^{-i} .\]Examples¶
See the FIR filters example.
Constructors¶
-
FIR(h: ArrayLike, streaming: bool =
False
) Creates a FIR filter with feedforward coefficients \(h_i\).
Special methods¶
String representation¶
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. The impulse response \(h[n]\) is the filter output when the input is an impulse \(\delta[n]\).
-
step_response(N: int | None =
None
) NDArray Returns the step response \(s[n]\) of the FIR filter. The step response \(s[n]\) is the filter output when the input is a unit step \(u[n]\).
- frequency_response(...) tuple[NDArray, NDArray]
Returns the frequency response \(H(\omega)\) of the FIR filter.
- frequency_response_log(...) tuple[NDArray, NDArray]
Returns the frequency response \(H(\omega)\) of the FIR filter on a logarithmic frequency axis.
Properties¶
- property taps : NDArray
The feedforward taps \(h_i\) for \(i = 0,...,N\).
- property delay : int
The delay of the FIR filter \(d = \lfloor \frac{N + 1}{2} \rfloor\) in samples.
-
FIR(h: ArrayLike, streaming: bool =