errorsysfield.py¶
- class ErrFieldData(pos_offset_xyz=None, ang_offset_zyx=None, time_offset=None, pos_rand_xyz=(None, None, None), ang_rand_zyx=(None, None, None), time_rand=None, spatial_averager=None, spatial_dims=None, pos_lock_xyz=None, ang_lock_zyx=None, time_drift=None)[source]¶
Bases:
objectDataclass for controlling sensor parameter perturbations for field based systematic errors (i.e. errors that require interpolation of the physical field).
- pos_offset_xyz¶
Array of offsets to apply to the sensor positions for error calculation. shape=(num_sensors,3) where the columns represent the X, Y and Z offsets in simulation world coordinates. If None then no position offset is applied.
- ang_offset_zyx¶
Array of offsets to apply to the sensor angles for error calculation. shape=(num_sensors,3) where the columns represent rotations about offsets about the Z, Y and X axis of the sensor in sensor local coordinates. If None then no angular offsets are applied.
- time_offset¶
Array of offsets to apply to the sampling times for all sensors. shape=( num_time_steps,). If None then no time offset is applied.
- pos_rand_xyz¶
Tuple of random generators (implementations of IGenRandom interface) for perturbing the sensor positions. The generators perturb the X, Y and Z coordinates in order. If None then that axis is not randomly perturbed from the nominal sensor position. Note that the random generators should return position perturbations consistent with the simulation units.
- ang_rand_zyx¶
Tuple of random generators (implementations of IGenRandom interface) for perturbing the sensor angles. The generators perturb rotations about the the Z, Y and X axis in order. If None then that axis is not randomly perturbed from the nominal sensor position.
- time_rand¶
Random generator for perturbing sensor array sampling times for the purpose of calculating field based errors. If None then sensor sampling times will not be perturbed from the nominal times.
- spatial_averager¶
Type of spatial averaging to use for this sensor array for the purpose of calculating field based errors. If None then no spatial averaging is performed.
- spatial_dims¶
The spatial dimension of the sensor in its local X,Y,Z coordinates for the purpose of calculating field errors. Only used if spatial averager is specified above. shape=(3,)
- pos_lock_xyz¶
Boolean array with shape=(num_sensors,coord[X,Y,Z]), Setting equal to True will lock the axis for the particular sensor so that it will not have it’s position perturbed.
- ang_lock_zyx¶
Boolean array with shape=(num_sensors,ang[Z,Y,X]), Setting equal to True will lock the rotation about that axis for the particular sensor.
- time_drift¶
Temporal drift calculation
- __init__(pos_offset_xyz=None, ang_offset_zyx=None, time_offset=None, pos_rand_xyz=(None, None, None), ang_rand_zyx=(None, None, None), time_rand=None, spatial_averager=None, spatial_dims=None, pos_lock_xyz=None, ang_lock_zyx=None, time_drift=None)¶
- class ErrSysField(field, field_err_data, err_dep=EErrDep.DEPENDENT)[source]¶
Bases:
IErrSimulatorClass for calculating field based systematic errors. Field based errors are errors that require interpolation or sampling of the simulated physical field such as perturbations of the sensor position or sampling time.
All perturbations to the sensor parameters (positions, sample times, angles area averaging) are calculated first before performing a single interpolation with the perturbed sensor state.
Implements the IErrSimulator interface.
- __init__(field, field_err_data, err_dep=EErrDep.DEPENDENT)[source]¶
- Parameters:
field (
IField) – The physical field to interpolate which will be an implementation of the IField interface. This will be a FieldScalar, FieldVector or FieldTensor object.field_err_data (
ErrFieldData) – Dataclass specifying which sensor array parameters will be perturbed and how they will be perturbed. See the ErrFieldData class for more detailerr_dep (
EErrDep, optional) – Error calculation dependence, by default EErrDep.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.