errorrand.py¶
- class ErrRandGen(generator, err_dep=EErrDep.INDEPENDENT)[source]¶
Bases:
IErrSimulatorSensor random error calculator based on sampling a user specified random number generator implementing the IGeneratorRandom interface.
Implements the IErrSimulator interface.
- __init__(generator, err_dep=EErrDep.INDEPENDENT)[source]¶
- Parameters:
generator (
IGeneratorRandom) – Interface for a user specified random number generator.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 ErrRandGenPercent(generator, err_dep=EErrDep.INDEPENDENT)[source]¶
Bases:
IErrSimulatorRandom error calculator based on sampling a user specified random number generator implementing 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 (
IGeneratorRandom) – Interface for a user specified random number generator.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.