errorsysindep.py¶
- class ErrSysOffset(offset, err_dep=EErrDep.INDEPENDENT)[source]¶
Bases:
IErrSimulatorSystematic error calculator applying a constant offset to all simulated sensor measurements. Implements the IErrSimulator interface.
- __init__(offset, err_dep=EErrDep.INDEPENDENT)[source]¶
- Parameters:
offset (
float) – Constant offset to apply to all simulated measurements from the sensor array.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.
- class ErrSysOffsetPercent(offset_percent, err_dep=EErrDep.INDEPENDENT)[source]¶
Bases:
IErrSimulatorSystematic error calculator applying a constant offset as a percentage of the sensor reading to each individual simulated sensor measurement. Implements the IErrSimulator interface.
- __init__(offset_percent, err_dep=EErrDep.INDEPENDENT)[source]¶
- Parameters:
offset_percent (
float) – Percentage offset to apply to apply to all simulated measurements from the sensor array.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.
- class ErrSysGen(generator, err_dep=EErrDep.INDEPENDENT)[source]¶
Bases:
IErrSimulatorSystematic error calculator for applying a unique offset to each sensor by sample from a user specified probability distribution (an implementation of the IGeneratorRandom interface).
Implements the IErrSimulator interface.
- __init__(generator, err_dep=EErrDep.INDEPENDENT)[source]¶
- Parameters:
generator (
IGenRandom) – Random generator object used to calculate the systematic error in simulation units.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.
- class ErrSysGenPercent(generator, err_dep=EErrDep.INDEPENDENT)[source]¶
Bases:
IErrSimulatorSystematic error calculator for applying a unique percentage offset to each sensor by sample from a user specified probability distribution (an implementation of the IGeneratorRandom interface). This class assumes the random generator is for a percentage error based on the input error basis and therefore it supports error dependence.
The percentage error is calculated based on the ground truth if the error dependence is INDEPENDENT or based on the accumulated sensor measurement if the dependence is DEPENDENT.
Implements the IErrSimulator interface.
- __init__(generator, err_dep=EErrDep.INDEPENDENT)[source]¶
- Parameters:
generator (
IGenRandom) – Random generator which returns a percentage error in the range (0,100)err_dep (
EErrDep, optional) – Error calculation dependence, by default EErrDep.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.