errorsysdep.py¶
- class ERoundMethod(value)[source]¶
Bases:
EnumEnumeration used to specify the method for rounding floats to integers.
- ROUND = 1¶
- FLOOR = 2¶
- CEIL = 3¶
- class ErrSysRoundOff(method=ERoundMethod.ROUND, base=1.0, err_dep=EErrDep.DEPENDENT)[source]¶
Bases:
IErrSimulatorSystematic error calculator for round off error. The user can specify the floor, ceiling or nearest integer method for rounding. The user can also specify a base to round to that defaults 1. Implements the IErrSimulator interface.
- __init__(method=ERoundMethod.ROUND, base=1.0, err_dep=EErrDep.DEPENDENT)[source]¶
- Parameters:
method (
ERoundMethod, optional) – Enumeration specifying the rounding method, by default ERoundMethod.ROUND.base (
float, optional) – Base to round to, by default 1.0.err_dep (
EErrDependence, optional) – Error calculation dependence, by default EErrDependence.DEPENDENT.
- 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.
- class ErrSysDigitisation(bits_per_unit, method=ERoundMethod.ROUND, err_dep=EErrDep.DEPENDENT)[source]¶
Bases:
IErrSimulatorSystematic error calculator for digitisation error base on a user specified number of bits per physical unit and rounding method. Implements the IErrSimulator interface.
- __init__(bits_per_unit, method=ERoundMethod.ROUND, err_dep=EErrDep.DEPENDENT)[source]¶
- Parameters:
bits_per_unit (
float) – The number of bits per physical unit used to determine the digitisation error.method (
ERoundMethod, optional) – User specified rounding method, by default ERoundMethod.ROUND.err_dep (
EErrDependence, optional) – Error calculation dependence, by default EErrDependence.DEPENDENT.
- 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.
- class ErrSysSaturation(meas_min, meas_max)[source]¶
Bases:
IErrSimulatorSystematic error calculator for saturation error base on user specified minimum and maximum measurement values. Implements the IErrSimulator interface.
NOTE: For this error to function as expected and clamp the measurement within the specified range it must be placed last in the error chain and the behaviour must be set to: EErrDependence.DEPENDENT.
- __init__(meas_min, meas_max)[source]¶
- Parameters:
meas_min (
float) – Minimum value to saturate the measurement to.meas_max (
float) – Maximum value to saturate the measurement to.
- Raises:
ValueError – Raised if the user specified minimum measurement is greater than the maximum measurement.
- 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.