errordriftcalc.py¶
- class IDriftCalculator[source]¶
Bases:
ABC
Interface (abstract base class) for applying a function to cause a sensor array measurement to drift (normally over time). The initialiser for the concrete implementation of this class specifies the function parameters and a unified method is provided to calculate the drift based on the input.
- abstractmethod calc_drift(drift_var)[source]¶
Abstract method. Used to calculate the drift function based on the input drift variable (useually the time steps).
- Parameters:
drift_var (
np.ndarray
) – Array of values (normally time steps) that are used to calculate the drift errors.- Returns:
np.ndarray
– Array of drift errors having the same shape as the input drift_var array.
- class DriftConstant(offset)[source]¶
Bases:
IDriftCalculator
Class for applying a constant drift error over time.
Implements the IDriftCalculator interface.
- calc_drift(drift_var)[source]¶
Calculates the drift errors based on the input drift variable array.
- Parameters:
drift_var (
np.ndarray
) – Array of values (normally time steps) that are used to calculate the drift errors.- Returns:
np.ndarray
– Array of drift errors having the same shape as the input drift_var array.
- class DriftLinear(slope, offset=0.0)[source]¶
Bases:
IDriftCalculator
Class for applying a linear drift error over time.
Implements the IDriftCalculator interface.
- __init__(slope, offset=0.0)[source]¶
- Parameters:
slope (
float
) – Slope of the drift error function.offset (
float
, optional) – Offset (intercept) of the drift error function, by default 0.0.
- calc_drift(drift_var)[source]¶
Calculates the drift errors based on the input drift variable array.
- Parameters:
drift_var (
np.ndarray
) – Array of values (normally time steps) that are used to calculate the drift errors.- Returns:
np.ndarray
– Array of drift errors having the same shape as the input drift_var array.
- class DriftPolynomial(coeffs)[source]¶
Bases:
IDriftCalculator
Class for applying a polynomial drift error over time. The coefficients of the polynomial are specified with a numpy array from constant term to highest power.
Implements the IDriftCalculator interface.
- __init__(coeffs)[source]¶
- Parameters:
coeffs (
np.ndarray
) – Array of polynomial coefficients from constant to highest power.
- calc_drift(drift_var)[source]¶
Calculates the drift errors based on the input drift variable array.
- Parameters:
drift_var (
np.ndarray
) – Array of values (normally time steps) that are used to calculate the drift errors.- Returns:
np.ndarray
– Array of drift errors having the same shape as the input drift_var array.