cbadc.digital_estimator.FIRFilter

class cbadc.digital_estimator.FIRFilter(analog_system: cbadc.analog_system.AnalogSystem, digital_control: cbadc.digital_control.DigitalControl, eta2: float, K1: int, K2: int, stop_after_number_of_iterations: int = 9223372036854775808, Ts: Optional[float] = None, mid_point: bool = False, downsample: int = 1, offset: Optional[numpy.ndarray] = None)

Bases: Iterator[numpy.ndarray]

FIR filter implementation of the digital estimator.

Specifically, the FIR filter estimator estimates a filtered version \(\hat{\mathbf{u}}(t)\) (shaped by signal_transfer_function()) of the input signal \(\mathbf{u}(t)\) from a sequence of control signals \(\mathbf{s}[k]\).

Specifically, the estimate is of the form

\(\hat{\mathbf{u}}(k T) = \hat{\mathbf{u}}_0 + \sum_{\ell=-K_1}^{K_2} \mathbf{h}[\ell] \mathbf{s}[k + \ell]\)

where

\(\mathbf{h}[\ell]=\begin{cases}\mathbf{W}^{\mathsf{T}} \mathbf{A}_b^\ell \mathbf{B}_b & \mathrm{if} \, \ell \geq 0 \\ -\mathbf{W}^{\mathsf{T}} \mathbf{A}_f^{-\ell + 1} \mathbf{B}_f & \mathrm{else} \end{cases}\)

and \(\mathbf{W}^{\mathsf{T}}\), \(\mathbf{A}_b\), \(\mathbf{B}_b\), \(\mathbf{A}_f\), and \(\mathbf{B}_f\) are computed based on the analog system, the sample period \(T_s\), and the digital control’s DAC waveform as described in # page=67/>`_. `control-bounded converters <https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/469192/control-bounded_converters_a_dissertation_by_hampus_malmberg.pdf?sequence=1&isAllowed=y

Parameters
  • analog_system (cbadc.analog_system.AnalogSystem) – an analog system (necessary to compute the estimators filter coefficients).

  • digital_control (cbadc.digital_control.DigitalControl) – a digital control (necessary to determine the corresponding DAC waveform).

  • eta2 (float) – the \(\eta^2\) parameter determines the bandwidth of the estimator.

  • K1 (int) – The lookback size

  • K2 (int, optional) – lookahead size, defaults to 0.

  • stop_after_number_of_iterations (int) – determine a max number of iterations by the iterator, defaults to \(2^{63}\).

  • Ts (float, optional) – the sampling time, defaults to the time period of the digital control.

  • mid_point (bool, optional) – set samples in between control updates, i.e., \(\hat{u}(kT + T/2)\), defaults to False.

  • downsample (int, optional) – specify down sampling rate in relation to the control period \(T\), defaults to 1, i.e., no down sampling.

  • offset (array_like, shape=(L)) – the estimate offset \(\hat{\mathbf{u}}_0\), defaults to a zero vector.

analog_system

analog system as in cbadc.analog_system.AnalogSystem or from derived class.

Type

cbadc.analog_system.AnalogSystem

eta2

eta2, or equivalently \(\eta^2\), sets the bandwidth of the estimator.

Type

float

control_signal

a iterator suppling control signals as cbadc.digital_control.DigitalControl.

Type

cbadc.digital_control.DigitalControl

number_of_iterations

number of iterations until iterator raises StopIteration.

Type

int

K1

number of samples, prior to estimate, used in estimate

Type

int

K2

number of lookahead samples per computed batch.

Type

int

Ts

spacing between samples in seconds.

Type

float

mid_point

estimated samples shifted in between control updates, i.e., \(\hat{u}(kT + T/2)\).

Type

bool

downsample

down sampling rate in relation to the control period \(T\).

Type

int, optional

Af

The Af matrix

Type

array_like, shape=(N, N)

Ab

The Ab matrix

Type

array_like, shape=(N, N)

Bf

The Bf matrix

Type

array_like, shape=(N, M)

Bb

The Bb matrix

Type

array_like, shape=(N, M)

WT

The W matrix transposed

Type

array_like, shape=(L, N)

h

filter impulse response

Type

array_like, shape=(L, K1 + K2, M)

offset

the estimate offset \(\hat{\mathbf{u}}_0\).

Type

array_like, shape=(L)

Yields

array_like, shape=(L,) – an input estimate sample \(\hat{\mathbf{u}}(t)\)

Methods

__init__(analog_system, digital_control, ...)

Initializes filter coefficients

control_signal_transfer_function(omega)

Compute the control signal transfer function at the angular frequencies of the omega array.

convolve(filter)

Shape \(\mathbf{h}\) filter by convolving with filter

filter_lag()

Return the lag of the filter.

fir_filter_transfer_function([Ts])

Compute the FFT of the system impulse response (FIR filter coefficients).

lookback()

Return lookback size \(K1\).

noise_transfer_function(omega)

Compute the noise transfer function (NTF) at the angular frequencies of the omega array.

set_iterator(control_signal_sequence)

Set iterator of control signals

signal_transfer_function(omega)

Compute the signal transfer function (STF) at the angular frequencies of the omega array.

warm_up()

Warm up filter by population control signals.

write_C_header(filename)

Write the FIR filter coefficients h into a C header file.

control_signal_transfer_function(omega: numpy.ndarray)

Compute the control signal transfer function at the angular frequencies of the omega array.

Specifically, computes

\(\begin{pmatrix}\hat{u}_1(\omega) / s_1(\omega) & \dots & \hat{u}_1(\omega) / s_M(\omega) \\ \vdots & \ddots & \vdots \\ \hat{u}_L(\omega) / s_1(\omega) & \dots & \hat{u}_L(\omega) / s_M(\omega) \end{pmatrix}= \mathbf{G}( \omega)^\mathsf{H} \left( \mathbf{G}( \omega)\mathbf{G}( \omega)^\mathsf{H} + \eta^2 \mathbf{I}_N \right)^{-1} \bar{\mathbf{G}}( \omega)\)

for each angular frequency in omega where where \(\bar{\mathbf{G}}( \omega)= \mathbf{C}^\mathsf{T} \left(\mathbf{A} - i \omega \mathbf{I}_N\right)^{-1} \mathbf{\Gamma} \in\mathbb{R}^{N \times M}\) is the transfer function from the control signals to the output and \(\mathbf{I}_N\) represents a square identity matrix.

Parameters

omega (array_like, shape=(K,)) – an array_like object containing the angular frequencies for evaluation.

Returns

return STF evaluated at K different angular frequencies.

Return type

array_like, shape=(L, M, K)

convolve(filter: numpy.ndarray)

Shape \(\mathbf{h}\) filter by convolving with filter

Parameters

filter (array_like, shape=(K)) – filter to be applied for each digital control filter equivalently.

filter_lag()

Return the lag of the filter.

K1 | K2 |

u_hat[k]

Returns

The filter lag.

Return type

int

fir_filter_transfer_function(Ts: float = 1.0)

Compute the FFT of the system impulse response (FIR filter coefficients).

Parameters

Ts (float) – the sample period of the corresponding impulse response.

Returns

the FFT of the corresponding impulse responses.

Return type

array_like, shape=(L, K3 // 2, M)

lookback()

Return lookback size \(K1\).

Returns

lookback size.

Return type

int

noise_transfer_function(omega: numpy.ndarray)

Compute the noise transfer function (NTF) at the angular frequencies of the omega array.

Specifically, computes

\(\text{NTF}( \omega) = \mathbf{G}( \omega)^\mathsf{H} \left( \mathbf{G}( \omega)\mathbf{G}( \omega)^\mathsf{H} + \eta^2 \mathbf{I}_N \right)^{-1}\)

for each angular frequency in omega where where \(\mathbf{G}(\omega)\in\mathbb{R}^{N \times L}\) is the ATF matrix of the analog system and \(\mathbf{I}_N\) represents a square identity matrix.

Parameters

omega (array_like, shape=(K,)) – an array_like object containing the angular frequencies for evaluation.

Returns

return NTF evaluated at K different angular frequencies.

Return type

array_like, shape=(L, N_tilde, K)

set_iterator(control_signal_sequence: Iterator[numpy.ndarray])

Set iterator of control signals

Parameters

control_signal_sequence (iterator) – a iterator which outputs a sequence of control signals.

signal_transfer_function(omega: numpy.ndarray)

Compute the signal transfer function (STF) at the angular frequencies of the omega array.

Specifically, computes

\(\text{STF}( \omega) = \mathbf{G}( \omega)^\mathsf{H} \left( \mathbf{G}( \omega)\mathbf{G}( \omega)^\mathsf{H} + \eta^2 \mathbf{I}_N \right)^{-1} \mathbf{G}( \omega)\)

for each angular frequency in omega where where \(\mathbf{G}(\omega)\in\mathbb{R}^{N \times L}\) is the ATF matrix of the analog system and \(\mathbf{I}_N\) represents a square identity matrix.

Parameters

omega (array_like, shape=(K,)) – an array_like object containing the angular frequencies for evaluation.

Returns

return STF evaluated at K different angular frequencies.

Return type

array_like, shape=(L, K)

warm_up()

Warm up filter by population control signals.

Specifically fills up internal control signal buffer with K2 control signals.

write_C_header(filename: str)

Write the FIR filter coefficients h into a C header file.

Parameters

filename (str) – filename of header file.

Examples using cbadc.digital_estimator.FIRFilter