OzWrapper.OzAnomaly.checks

The ten statistical / heuristic anomaly checks (e1..e10).

Each public check_* function consumes a column-oriented numpy Window (plus the device config where needed) and returns a dict whose keys are the error-coded field names the detector will emit. Every function handles the empty / None window case by returning {}.

The error codes are:

  • e1 constant data (per parameter)

  • e2 threshold breach, lower/upper (per parameter, _l/_u suffix)

  • e3 data completeness (global)

  • e4 dust-order violation (global)

  • e5 low humidity / low t2 (single flag)

  • e6 missing parameter keys (per parameter) — delegated

  • e7 temperature below dew point (condensing environment)

  • e8 RH-affected dust (global flag)

  • e9 VOC sensor fault (v21)

  • e10 RH-affected VOC (global flag)

Attributes

Functions

_row_count(→ int)

Total rows in the window (uses the t column which is always present).

_skip_evaluation_constant(→ bool)

Return True when the constant-data check (e1) should skip sensor_code.

_skip_evaluation_threshold(→ bool)

Return True when the threshold-breach check (e2) should skip sensor_code.

check_constant_instances(→ Dict[str, int])

Detect long runs of identical values per sensor column (e1).

check_data_completeness(→ Dict[str, int])

Report the shortfall from expected sample count (e3).

check_dust_order(→ Dict[str, float])

Flag violations of the dust-size ordering invariant (e4).

check_missing_parameters(→ Dict[str, int])

Flag parameters expected by config but absent from the window (e6).

check_rh_affected_dust(→ Dict[str, Any])

Humidity vs dust (e8). Wraps detect_pm_voc() with mode='pm'.

check_rh_affected_voc(→ Dict[str, Any])

Humidity vs VOC (e10). Wraps detect_pm_voc() with mode='voc'.

check_temp_dewpoint(→ Dict[str, int])

Flag a likely condensing environment (e7).

check_threshold_breach(→ Dict[str, int])

Flag columns where >30% of samples sit outside their bounds (e2, e5).

check_voc_sensor_fault(→ Dict[str, int])

Flag a stuck VOC sensor (e9).

detect_pm_voc(→ Dict[str, Any])

Test whether humidity drives PM (mode="pm") or VOC (mode="voc") signal.

Module Contents

OzWrapper.OzAnomaly.checks._row_count(window: OzWrapper.OzAnomaly.data_provider.Window) int[source]

Total rows in the window (uses the t column which is always present).

OzWrapper.OzAnomaly.checks._skip_evaluation_constant(ogs_list: list, sensor_code: str) bool[source]

Return True when the constant-data check (e1) should skip sensor_code.

OzWrapper.OzAnomaly.checks._skip_evaluation_threshold(ogs_label: str | None, sensor_code: str) bool[source]

Return True when the threshold-breach check (e2) should skip sensor_code.

OzWrapper.OzAnomaly.checks.check_constant_instances(config: Dict[str, Any], device_type: str | None, window: OzWrapper.OzAnomaly.data_provider.Window | None) Dict[str, int][source]

Detect long runs of identical values per sensor column (e1).

OzWrapper.OzAnomaly.checks.check_data_completeness(config: Dict[str, Any], window: OzWrapper.OzAnomaly.data_provider.Window | None) Dict[str, int][source]

Report the shortfall from expected sample count (e3).

OzWrapper.OzAnomaly.checks.check_dust_order(window: OzWrapper.OzAnomaly.data_provider.Window | None) Dict[str, float][source]

Flag violations of the dust-size ordering invariant (e4).

OzWrapper.OzAnomaly.checks.check_missing_parameters(window: OzWrapper.OzAnomaly.data_provider.Window | None, config: Dict[str, Any]) Dict[str, int][source]

Flag parameters expected by config but absent from the window (e6).

OzWrapper.OzAnomaly.checks.check_rh_affected_dust(window: OzWrapper.OzAnomaly.data_provider.Window | None) Dict[str, Any][source]

Humidity vs dust (e8). Wraps detect_pm_voc() with mode='pm'.

OzWrapper.OzAnomaly.checks.check_rh_affected_voc(window: OzWrapper.OzAnomaly.data_provider.Window | None) Dict[str, Any][source]

Humidity vs VOC (e10). Wraps detect_pm_voc() with mode='voc'.

OzWrapper.OzAnomaly.checks.check_temp_dewpoint(window: OzWrapper.OzAnomaly.data_provider.Window | None) Dict[str, int][source]

Flag a likely condensing environment (e7).

OzWrapper.OzAnomaly.checks.check_threshold_breach(config: Dict[str, Any], device_type: str | None, window: OzWrapper.OzAnomaly.data_provider.Window | None) Dict[str, int][source]

Flag columns where >30% of samples sit outside their bounds (e2, e5).

OzWrapper.OzAnomaly.checks.check_voc_sensor_fault(window: OzWrapper.OzAnomaly.data_provider.Window | None) Dict[str, int][source]

Flag a stuck VOC sensor (e9).

If the max-min range of v21 across the window is below 3 mV, the sensor is treated as faulty.

OzWrapper.OzAnomaly.checks.detect_pm_voc(window: OzWrapper.OzAnomaly.data_provider.Window | None, mode: str, rh_col: str = 'hum', cols: list | None = None, degree: int = 2, rh_threshold: Tuple[float, float] | None = None, r2_threshold: float = 0.3, spike_rh_min: float = 80, spike_z_thresh: float = 1.0, cluster_dist: float = 1.0, min_cluster_points: int = 3) Dict[str, Any][source]

Test whether humidity drives PM (mode=”pm”) or VOC (mode=”voc”) signal.

Pure numpy implementation — no scikit-learn. Polynomial fit via np.polyfit; R² computed manually; spike detection via z-score threshold; cluster decision via O(n²) distance check.

OzWrapper.OzAnomaly.checks.CONSTANT_CHECK_COL_IGNORE_LIST = ['v25']
OzWrapper.OzAnomaly.checks.logger