OzWrapper.OzAnomaly.preprocessing

Config parsing and window-shape normalisation helpers.

These helpers translate a device’s raw config dict into the flat list of parameter codes we expect to see in sensor data, and rename the dust-channel columns into the z1..z4 scheme that the threshold table uses.

No I/O happens here — everything is pure transformation on dicts and column-oriented numpy windows.

Attributes

Functions

filter_and_rename_columns(...)

Rename dust columns to z1..z4 for threshold lookups.

get_ogs_list(→ List[Dict[str, Any]])

Return the OGS sensor list for skip-check lookups.

para_check(→ Dict[str, int])

Flag parameters expected by config that never appear in the window.

process_config(→ List[str])

Flatten a device config into a sorted list of expected parameter codes.

replace_keys_with_original(→ Dict[str, Any])

Undo the p -> z column rename on output field keys.

select_columns(→ List[str])

Pick the subset of window columns the per-parameter checks care about.

should_drop(→ bool)

Return True if element has any sibling raw-dust channel (pN1..pN4).

Module Contents

OzWrapper.OzAnomaly.preprocessing.filter_and_rename_columns(window: OzWrapper.OzAnomaly.data_provider.Window | None) Tuple[OzWrapper.OzAnomaly.data_provider.Window | None, Dict[str, str]][source]

Rename dust columns to z1..z4 for threshold lookups.

Maps either p1..p4 or p11..p41 to z1..z4 depending on which set is the raw-value set in the window. The rename mapping is returned so the caller can restore original names on the output keys.

OzWrapper.OzAnomaly.preprocessing.get_ogs_list(config: Dict[str, Any], device_type: str | None) List[Dict[str, Any]][source]

Return the OGS sensor list for skip-check lookups.

DUSTROID devices don’t carry gas cartridges, so their config does not hold OGS entries with the lb label that the skip lists key off. We return an empty list for that device type so the skip helpers simply fall through without raising. For every other device type we return the raw config['ogs'] list (or an empty list if absent).

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

Flag parameters expected by config that never appear in the window.

For each parameter returned by process_config() that is not a key in window (and not in the ignore list), emit a {param}_e6: 1 entry.

OzWrapper.OzAnomaly.preprocessing.process_config(config: Dict[str, Any]) List[str][source]

Flatten a device config into a sorted list of expected parameter codes.

Walks the nested config dict, collects every enabled sensor’s sc value plus the gas keys under soft.config, and filters out metadata keys (lat, lon, etc.). For every p1..p4 present we also emit p11..p41 as expected data channels, then drop the p1..p4 stubs.

OzWrapper.OzAnomaly.preprocessing.replace_keys_with_original(output_dict: Dict[str, Any], rename_dict: Dict[str, str]) Dict[str, Any][source]

Undo the p -> z column rename on output field keys.

When filter_and_rename_columns() renamed p11 -> z1, any output key that starts with z1 is restored to p11 so the caller sees the original parameter naming.

OzWrapper.OzAnomaly.preprocessing.select_columns(window: OzWrapper.OzAnomaly.data_provider.Window | None) List[str][source]

Pick the subset of window columns the per-parameter checks care about.

Returns gases (g*1, g*5, o*1, v*1, v*5), dust (z1..z4), and a small fixed list of environmental columns (light, leq, t1, t2, temp, hum, pr).

OzWrapper.OzAnomaly.preprocessing.should_drop(element: str, dust_list: List[str]) bool[source]

Return True if element has any sibling raw-dust channel (pN1..pN4).

Used to pick the raw dust columns over the aggregated ones when both are present.

OzWrapper.OzAnomaly.preprocessing.logger