fault_injector.fault_lib module

DriftFault

class fault_injector.fault_lib.DriftFault(params: dict = None)[source]

Bases: BaseFault

Simulate a Drift Fault: a gradual, systematic deviation of sensor readings from their true values over time.

Parameters:

params (dict, optional) – Dictionary containing the drift_rate key. drift_rate corresponds to the slope of the fault-induced offset. If None, defaults to drift_rate of 1.

__call__(x: ArrayLike) ndarray[source]

The call method generates the drift fault

Parameters:

x (np.array) – array containing numeric values that represent the original value

Returns:

array containing the altered values

Return type:

np.ndarray

NormalNoiseFault

class fault_injector.fault_lib.NormalNoiseFault(params: dict = None)[source]

Bases: BaseFault

Simulates a normal (gaussian) noise fault

Parameters:

params (dict, optional) –

  • mu (numeric): Mean of the Gaussian noise distribution

  • sigma (numeric): Standard deviation of the Gaussian noise distribution. Must be non-negative.

__call__(x: ArrayLike) ndarray[source]

The call method generates the normal noise fault

Parameters:

x (ArrayLike) – array containing numeric values that represent the original value

Returns:

array containing the altered values

Return type:

np.ndarray

NaNFault

class fault_injector.fault_lib.NaNFault[source]

Bases: BaseFault

Simulate a NaN fault: models a sensor failure where readings are completely missing for a continuous period of time

__call__(x: ArrayLike) ndarray[source]

The call method generates the NaN fault

Parameters:

x (np.array) – array containing numeric values that represent the original value

Returns:

array containing the NaN values

Return type:

np.ndarray

OffsetFault

class fault_injector.fault_lib.OffsetFault(params: dict = None)[source]

Bases: BaseFault

Simulate an Offset Fault: models a sensor error where a constant bias is added to the measured values during a specific time window.

Parameters:

params (dict, optional) – dictionary expecting the offset_by key. This is the value that is constantly added to the true values. If set to None, offset_by defaults to 1.

__call__(x: ArrayLike) ndarray[source]

The call method generates the offset fault

Parameters:

x (ArrayLike) – array containing numeric values that represent the original value

Returns:

array containing the altered values

Return type:

np.ndarray

StuckValueFault

class fault_injector.fault_lib.StuckValueFault(params: dict = None)[source]

Bases: BaseFault

Simulate a stuck value by repeating the stuck value for the desired length of values.

Parameters:

params (dict, optional) – dictionary containing the stuck_val key, which corresponds to the repeated value in the output. If set to None, defaults to a stuck_val of 1.

__call__(x: ArrayLike) ndarray[source]

The call method generates the stuck value fault

Parameters:

x (ArrayLike) – array containing numeric values that represent the original value

Returns:

array containing the altered values

Return type:

np.ndarray

UniformNoiseFault

class fault_injector.fault_lib.UniformNoiseFault(params: dict = None)[source]

Bases: BaseFault

Simulate uniform noise fault.

Parameters:

params (dict) –

  • min_val (numeric): Mean of the Gaussian noise distribution.

  • max_val (numeric): Standard deviation of the Gaussian noise distribution. Must be non-negative.

__call__(x: ArrayLike) ndarray[source]

The call method generates the uniform noise fault

Parameters:

x (ArrayLike) – array containing numeric values that represent the original value

Returns:

array containing the altered values

Return type:

np.ndarray