errorsyscalib.py

class ErrSysCalibration(assumed_calib, truth_calib, cal_range, n_cal_divs=10000, err_dep=EErrDep.INDEPENDENT)[source]

Bases: IErrSimulator

Systematic error calculator for calibration errors. The user specifies an assumed calibration and a ground truth calibration function. The ground truth calibration function is inverted and linearly interpolated numerically based on the number of divisions specified by the user.

Implements the IErrSimulator interface.

__init__(assumed_calib, truth_calib, cal_range, n_cal_divs=10000, err_dep=EErrDep.INDEPENDENT)[source]
Parameters:
  • assumed_calib (Callable[[np.ndarray],np.ndarray]) – Assumed calibration function taking the input unitless ‘signal’ and converting it to the same units as the physical field being sampled by the sensor array.

  • truth_calib (Callable[[np.ndarray],np.ndarray]) – Assumed calibration function taking the input unitless ‘signal’ and converting it to the same units as the physical field being sampled by the sensor array.

  • cal_range (tuple[float,float]) – Range over which the calibration functions are valid. This is normally based on a voltage range such as (0,10) volts.

  • n_cal_divs (int, optional) – Number of divisions to discretise the the truth calibration function for numerical inversion, by default 10000.

  • err_dep (EErrDependence, optional) – Error calculation dependence, by default EErrDependence.INDEPENDENT.

get_error_dep()[source]

Gets the error dependence enumeration value. Independent errors are calculated based on the ground truth and ignore other errors in the error chain. Dependent errors are calculated based on the accumulated measurement value at their place in the error chain.

Returns:

EErrDep – Enumeration definining INDEPENDENT or DEPENDENT error dependence.

set_error_dep(dependence)[source]

Sets the error dependence for errors that support changing the dependence. Independent errors are calculated based on the ground truth and ignore other errors in the error chain. Dependent errors are calculated based on the accumulated measurement value at their place in the error chain.

Parameters:

dependence (EErrDep) – Enumeration definining INDEPENDENT or DEPENDENT error dependence.

get_error_type()[source]

Gets the error type enumeration as either random or systematic. Random errors sample at every time step and systematic errors typically apply a bias that is constant over time.

Returns:

EErrType – Enumeration definining RANDOM or SYSTEMATIC error types.

reseed(seed=None)[source]

Reseeds the random generators of the error simulator. Mainly used for multi-processed simulations which inherit the same seed as the main process so need to be reseeded. If the error simulator does not have any random generators then this function implementation will be empty.

Parameters:

seed (int | None, optional) – Integer seed for the random number generator, by default None. If None then the seed is generated using OS entropy (see numpy docs).

sim_errs(err_basis, sens_data)[source]

Creates the simulated error array based on the input error basis array. The output error array will be the same shape as the input error basis array.

Parameters:
  • err_basis (np.ndarray) – Used as the base array for calculating the returned error. If the error is independent this will be the ‘truth’ array and if the error is dependent this will be the accumulated sensor measurement array at this point in the error chain.

  • sens_data (SensorData) – Sensor data object holding the current sensor state before applying this error calculation.

Returns:

tuple[np.ndarray, SensorData] – Tuple containing the error array from this calculator and a SensorData object with the current accumulated sensor state starting from the nominal state up to and including this error calculator in the error chain. Note that many errors do not modify the sensor data so the sensor data class is passed through this function unchanged.