- class sdr.Differentiator(sdr.FIR)
Implements a differentiator FIR filter.
Notes¶
A discrete-time differentiator is a FIR filter with the transfer function
\[H(z) = 1 - z^{-1} .\]x[n] --+---------------@--> y[n] | ^ | +------+ | -1 +-->| z^-1 |----+ +------+
Examples¶
Create a differentiator FIR filter.
In [1]: fir = sdr.Differentiator()
Differentiate a Gaussian pulse.
In [2]: x = sdr.gaussian(0.3, 5, 10); \ ...: y = fir(x) ...: In [3]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.time_domain(x, label="Input"); \ ...: sdr.plot.time_domain(y, offset=-fir.delay, label="Derivative"); \ ...: plt.title("Discrete-time differentiation of a Gaussian pulse"); \ ...: plt.tight_layout(); ...:
Differentiate a raised cosine pulse.
In [4]: x = sdr.root_raised_cosine(0.1, 8, 10); \ ...: y = fir(x) ...: In [5]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.time_domain(x, label="Input"); \ ...: sdr.plot.time_domain(y, offset=-fir.delay, label="Derivative"); \ ...: plt.title("Discrete-time differentiation of a raised cosine pulse"); \ ...: plt.tight_layout(); ...:
Plot the frequency response.
In [6]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.magnitude_response(fir); ...:
Constructors¶
-
Differentiator(streaming: bool =
False
) Creates a differentiator FIR filter.
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\).
-
Differentiator(streaming: bool =