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\).

Methods

filter(x: ArrayLike, ...) ndarray

Filters the input signal \(x[n]\) with the FIR filter.

frequency_response(...) tuple[numpy.ndarray, numpy.ndarray]

Returns the frequency response \(H(f)\) of the FIR filter.

frequency_response_log(...) tuple[numpy.ndarray, numpy.ndarray]

Returns the frequency response \(H(f)\) of the FIR filter on a logarithmic frequency axis.

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]\).

reset()

Streaming-mode only: Resets the filter state.

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]\).

Properties

property delay : int

The delay of the FIR filter in samples.

property order : int

The order of the FIR filter, \(N\).

property streaming : bool

Indicates whether the filter is in streaming mode.

property taps : ndarray

The feedforward taps \(h_i\).