-
sdr.IIR.frequency_response(freqs: int =
1024
, sample_rate: float =1.0
, whole: bool =True
, decades: int | None =None
) tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[complex128]]] -
sdr.IIR.frequency_response(freqs: float | ndarray[Any, dtype[float64]], sample_rate: float =
1.0
) complex -
sdr.IIR.frequency_response(freqs: ndarray[Any, dtype[float64]], sample_rate: float =
1.0
) ndarray[Any, dtype[complex128]] Returns the frequency response \(H(\omega)\) of the IIR filter.
- Parameters:¶
- freqs: int =
1024
¶ - freqs: float | ndarray[Any, dtype[float64]]
- freqs: ndarray[Any, dtype[float64]]
The frequency specification.
int
: The number of frequency points. The endpoint is not included.float
: A single frequency.npt.NDArray[float]
: Multiple frequencies.
- sample_rate: float =
1.0
¶ The sample rate \(f_s\) of the filter in samples/s.
- whole: bool =
True
¶ Only used if
freqs
is an integer.True
: The maximum frequency ismax_f = sample_rate
.False
: The maximum frequency ismax_f = sample_rate / 2
.
- decades: int | None =
None
¶ Only used if
freqs
is an integer.None
:f = np.linspace(0, max_f, freqs, endpoint=False)
.int
:f = np.logspace(np.log10(max_f) - decades), np.log10(max_f), freqs, endpoint=False)
.
- freqs: int =
- Returns:¶
The frequency vector \(f\), only if
freqs
is an integer.The frequency response of the IIR filter \(H(\omega)\).
Examples
In [1]: zero = 0.6; \ ...: pole = 0.8 * np.exp(1j * np.pi / 8); \ ...: iir = sdr.IIR.ZerosPoles([zero], [pole, pole.conj()]) ...:
Compute the frequency response at 1024 evenly spaced frequencies.
In [2]: iir.frequency_response() Out[2]: (array([0.00000000e+00, 9.76562500e-04, 1.95312500e-03, ..., 9.97070312e-01, 9.98046875e-01, 9.99023438e-01]), array([2.4722987 +0.j , 2.47271105+0.0041658j , 2.47394825+0.00830241j, ..., 2.47601067-0.01238051j, 2.47394825-0.00830241j, 2.47271105-0.0041658j ]))
Compute the frequency response at 0.0 rad/s.
In [3]: iir.frequency_response(0.0) Out[3]: np.complex128(2.472298696877605+0j)
Compute the frequency response at several frequencies in Hz.
In [4]: iir.frequency_response([100, 200, 300, 400], sample_rate=1000) Out[4]: array([1.36961426-1.9678537j , 0.57338213-0.77694738j, 0.52496713-0.3885743j , 0.51520024-0.1706839j ])