sox.sensor.fault¶

Module Contents¶

Classes¶

Fault

Base class for sensor faults

Offset

Offset fault models a constant offset in the sensor readings.

Scaling

Scaling fault occurs when a sensor reports values that are scaled by a factor.

Drift

Drift fault occurs when a sensor values change over time.

StuckAt

Stuck-at fault occurs when a sensor reports the same value, regardless of the true value.

class sox.sensor.fault.Fault(fault_probability=None, random_seed=None, start_time=None, stop_time=None)¶

Base class for sensor faults

Parameters:
  • fault_probability (float) – Probability of fault occurring.

  • random_seed (int) – Random seed for reproducibility.

  • start_time (float) – Start time of fault.

  • stop_time (float) – Stop time of fault.

is_active(time)¶

Returns True if fault is active at given time, False otherwise

Parameters:

time (float) – Time in seconds.

Returns:

True if fault is active at given time, False otherwise.

Return type:

bool

apply(*args, **kwargs)¶

Applies fault to sensor reading

static validate_inputs(fault_probability, start_time, stop_time)¶

Validate inputs for Fault class and subclasses

class sox.sensor.fault.Offset(offset, *args, **kwargs)¶

Bases: Fault

Offset fault models a constant offset in the sensor readings.

Offset or bias fault occurs when a sensor consistently reports values that are higher or lower than the true values. This is modeled by adding a constant offset to the sensor readings.

Parameters:

offset (float) – Offset value.

apply(time, value)¶

Applies offset fault to sensor reading

class sox.sensor.fault.Scaling(scale, *args, **kwargs)¶

Bases: Fault

Scaling fault occurs when a sensor reports values that are scaled by a factor.

Scaling or gain fault changes the sensitivity of the sensor, causing it to report values that are scaled by a factor. This is modeled by multiplying the sensor readings by a scaling factor.

Parameters:

scale (float) – Scaling factor.

apply(time, value)¶

Applies scaling fault to sensor reading

class sox.sensor.fault.Drift(rate, *args, **kwargs)¶

Bases: Fault

Drift fault occurs when a sensor values change over time. This is modeled by adding a linear drift to the sensor readings. The expected behavior for t > stop_time is to return the true value.

Parameters:

rate (float) – Drift rate in units of value per second.

apply(time, value)¶

Applies drift fault to sensor reading over time

class sox.sensor.fault.StuckAt(value, *args, **kwargs)¶

Bases: Fault

Stuck-at fault occurs when a sensor reports the same value, regardless of the true value. This is modeled by replacing the sensor readings with a constant value.

Parameters:

value (float) – Stuck-at value.

apply(time, value)¶

Applies stuck-at fault to sensor reading