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: Optional[float] = None, Fs: Optional[float] = None, uncertainty: Optional[Union[float, ndarray]] = 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 values

  • values (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

property Fs: float

Sampling frequency, i.e. the sampling interval Ts’ reciprocal

property Ts: float

Sampling interval, i.e. (averaged) difference between each two time stamps

apply_filter(b: ndarray, a: Optional[ndarray] = array([1.]), filter_uncertainty: Optional[ndarray] = None, MonteCarloRuns: Optional[int] = 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

property name: str

Signal name

property standard_uncertainties: ndarray

Element-wise standard uncertainties associated to values

property time: ndarray

Signal’s time axis

property uncertainty: ndarray

Uncertainties associated with the signal values

Depending on the uncertainties provided during initialization, one of following will be provided:

  • 1D-array: element-wise standard uncertainties

  • 2D-array: covariance matrix

property unit_time: str

Unit of the time vector

property unit_values: str

Unit of the values vector

property values: ndarray

Signal values’ magnitudes