Signal
This module implements the signals class and its derivatives
Signals are dynamic quantities with associated uncertainties, quantity and time units. A signal has to be defined together with a time axis.
Note
This module is work in progress!
- class PyDynamic.signals.Signal(time: ndarray, values: ndarray, Ts: float | None = None, Fs: float | None = None, uncertainty: float | ndarray | None = None)[source]
Signal class which represents a common signal in digital signal processing
- Parameters:
time (np.ndarray) – the time axis as
np.ndarray
of floats, number of elements must coincide with number of valuesvalues (np.ndarray) – signal values’ magnitudes, number of elements must coincide with number of elements in time
Ts (float, optional) – the sampling interval length, i.e. the difference between each two time stamps, defaults to the reciprocal of the sampling frequency if provided and the mean of all unique interval lengths otherwise
Fs (float, optional) – the sampling frequency, defaults to the reciprocal of the sampling interval length
uncertainty (float or np.ndarray, optional) –
the uncertainties associated with the signal values, depending on the type and shape the following should be provided:
float: constant standard uncertainty for all values
1D-array: element-wise standard uncertainties
2D-array: covariance matrix
- apply_filter(b: ndarray, a: ndarray | None = array([1.]), filter_uncertainty: ndarray | None = None, MonteCarloRuns: int | None = 10000)[source]
Apply digital filter (b, a) to the signal values
Apply digital filter (b, a) to the signal values and propagate the uncertainty associated with the signal. Time vector is assumed to be equidistant, as well as corresponding values should represent evenly spaced signal magnitudes.
- Parameters:
b (np.ndarray) – filter numerator coefficients
a (np.ndarray, optional) – filter denominator coefficients, defaults to \(a=(1)\) for FIR-type filter
filter_uncertainty (np.ndarray, optional) –
For IIR-type filter provide covariance matrix \(U_{\theta}\) associated with filter coefficient vector \(\theta=(a_1,\ldots,a_{N_a}, b_0,\ldots,b_{N_b})^T\). For FIR-type filter provide one of the following:
1D-array: coefficient-wise standard uncertainties of filter
2D-array: covariance matrix associated with theta
if the filter is fully certain, use filter_uncertainty = None (default) to make use of more efficient calculations.
MonteCarloRuns (int, optional) – number of Monte Carlo runs, defaults to 10.000, only considered for IIR-type filters. Otherwise
FIRuncFilter
is applied directly