OzWrapper.OzCal.OzCal.OzCal

class OzWrapper.OzCal.OzCal.OzCal

On-device sensor calculation module. Port of the gateway’s shadow.js. Processes raw electrode readings into calibrated gas concentrations, PM humidity correction, wet-bulb temperature, and temp/hum adjustments.

_resolve_temp_nullish(d: dict, key: str, cfg_key: dict) float

Mirrors JS ?? (nullish coalescing): falls back only on None/missing, not on 0 — so a valid 0°C reading is preserved.

_round2(v: float) float
_round3(v: float) float
_tf_case1_default(temp: float, delta: list) float
_tf_case2(temp: float, delta: list) float
_tf_case3(temp: float, delta: list, data: dict, config: dict, key: str) float
adjust_values_final(config: dict, key: str, data: dict, pure_no2: float, no2_working: str, hum_corrected_v21: bool = False) float | None
apply_drift(config: dict, key: str, data: dict) float
apply_dynamic_weights(config: dict, key: str, data: dict, pure_no2: float, no2_working: str, hum_corrected_v21: bool = False) float
apply_humidity_compensation(data: dict, config: dict) float | None

Divide v21 by a humidity-indexed scale factor from config[‘v2’].hum_delta. Falls back to the original v21 when the table is absent or on error.

calculate_gas(data: dict, key: str, config: dict, pure_no2: float, hum_corrected_v21: bool = False) float
calculate_hum(value: float, config: dict) float
calculate_pm(data: dict, key: str, config: dict) float
calculate_temp(value: float, config: dict) float
calculate_wbt(d: dict, config: dict) float
correct_concentrations(config: dict, key: str, data: dict, pure_no2: float, no2_working: str, hum_corrected_v21: bool = False) float | None
equations(config: dict, data: dict, key: str) dict
generate_shadow_data(data: dict, config: dict, device_id: str = '', is_light: bool = False, fallback_hum: float | None = None, fallback_temp: float | None = None) None

Mutates data[“payload”][“d”] in place — mirrors the original JS contract. Caller should pass a copy of data if the original must be preserved.

get_corrected_working(config: dict, key: str, data: dict, pure_no2: float, hum_corrected_v21: bool = False) float | None
get_scf(temp: float, key: str, config: dict) float
get_temp_function(temp: float, delta, data: dict, config: dict, key: str, algo: int = 1) float
polynomial_evaluate(config: dict, key: str, d: dict) float
_DEFAULT_SCF: ClassVar[Dict[str, List[float]]]
_DEFAULT_WEIGHT_DICT: ClassVar[Dict[str, List[list]]]
_GLOBAL_FALLBACK: ClassVar[Dict[str, float]]
_device_state: Dict[str, Dict[str, float]]