diff --git a/CLAUDE.md b/CLAUDE.md index e13cf44..bd7efd0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,7 +4,7 @@ AIMsight anomaly detectors (Python 3, standard library only) and their benchmark ## Contract (do not break) -- `scripts/categories.py` runs the detectors of `DETECTORS` (modules of `scripts/`: `visibility`, `target_issue`, `thermal_displacement`, `no_data`, `displacement`) and makes their episodes events. A module returns every family it finds: `visibility` also gives Brief obstruction and `target_issue` Target obscured (Obstruction). `common.py` holds the helpers they share. +- `scripts/categories.py` runs the detectors of `DETECTORS` (modules of `scripts/`: `visibility`, `target_issue`, `thermal_displacement`, `no_data`, `displacement`) and makes their episodes events. A module returns every family it finds: `visibility` also gives Brief obstruction and `target_issue` Target obscured (Obstruction). `episodes.py` holds the helpers they share. - `detect(measurements)` (`no_data`: also `end`, the end of the window read) returns episodes with the keys `start`, `end`, `kind` (the family), `label` (the variety), `text` (the sentence shown), `ignore`, `sensors`; a Poor visibility also has `level`. - The measurements are read by `scripts/data.py` of the tools repository, the sibling `~/aimsight-tools` (`categories.py` puts it on the path); a reading fix is made there. - Label files (JSONL): `id`, `start`, `end`, `family`, `description` (and `review`, `analysis`); the project uses `labeling/auto` only. diff --git a/README.md b/README.md index f4ec222..746c53b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Five modules in `scripts/`, one per kind of reading; each gives episodes of one | `no_data.py` | the cadence of the measurements | No data | | `displacement.py` | jumps and slow drift of the corrected curves | Displacement (Sudden jump, back to normal; Lasting shift; Jump, not back yet; Slow drift) | -`common.py` holds their shared helpers. `categories.py` runs them all and classifies their episodes into events (a jump back joins the visibility loss or the obstruction that explains it; the same variety less than an hour apart, one event), one line per event. The measurements are read by `scripts/data.py` of the tools repository, the sibling `~/aimsight-tools`. +`episodes.py` holds their shared helpers. `categories.py` runs them all and classifies their episodes into events (a jump back joins the visibility loss or the obstruction that explains it; the same variety less than an hour apart, one event), one line per event. The measurements are read by `scripts/data.py` of the tools repository, the sibling `~/aimsight-tools`. ```bash python3 scripts/categories.py --from YYYY-MM-DD --to YYYY-MM-DD # --chunk N, --history N diff --git a/scripts/categories.py b/scripts/categories.py index b97e220..1fbb739 100644 --- a/scripts/categories.py +++ b/scripts/categories.py @@ -25,7 +25,7 @@ from pathlib import Path # (a copy of this repository elsewhere, e.g. extracted by git archive). HERE = Path(__file__).resolve().parent sys.path[:0] = [str(HERE), str(HERE.parents[1] / "aimsight-tools" / "scripts"), str(Path.cwd() / "tools" / "scripts")] -from common import targets # noqa: E402 +from episodes import targets # noqa: E402 from data import iso, load # noqa: E402 DETECTORS = ("displacement", "no_data", "target_issue", "thermal_displacement", "visibility") diff --git a/scripts/displacement.py b/scripts/displacement.py index 6712e3e..520a04c 100644 --- a/scripts/displacement.py +++ b/scripts/displacement.py @@ -12,7 +12,7 @@ import statistics from datetime import timedelta -from common import episode, noise +from episodes import episode, noise from data import is_reference K = 20 # E-001: at 15, two healthy targets are greyed (17 and 18 noises); the trains of E-005 are visibility's diff --git a/scripts/common.py b/scripts/episodes.py similarity index 100% rename from scripts/common.py rename to scripts/episodes.py diff --git a/scripts/no_data.py b/scripts/no_data.py index 7b2b64f..0290cb6 100644 --- a/scripts/no_data.py +++ b/scripts/no_data.py @@ -1,6 +1,6 @@ -"""No data family: no measurement in the export for more than MISSING steps of its cadence (common.cadence), between two +"""No data family: no measurement in the export for more than MISSING steps of its cadence (episodes.cadence), between two measurements or, when the caller gives the end of the window read, between the last measurement and that end.""" -from common import cadence, episode +from episodes import cadence, episode MISSING = 2 # more than 2 missing steps is a hole (user's rule, 2026-10-23); also up to the end (CLARIDEN, batch 01) diff --git a/scripts/target_issue.py b/scripts/target_issue.py index 0055d0c..bd60210 100644 --- a/scripts/target_issue.py +++ b/scripts/target_issue.py @@ -10,7 +10,7 @@ own usual level, so a target almost always rejected looks normal to it. For a fe """ from datetime import timedelta -from common import cadence, episode +from episodes import cadence, episode SHARE = 0.25 # wf-improve Target issue, mod. 1, S1 (WILDSTRUBEL R3 rejected from 04:00 to 16:00 every day, 30 to 45 %) MIN_HOURS = 3 # wf-improve NEBRASKA, batch 01 (one measurement every 4 h: as hours, not as instants) diff --git a/scripts/thermal_displacement.py b/scripts/thermal_displacement.py index ba325e7..d9702e5 100644 --- a/scripts/thermal_displacement.py +++ b/scripts/thermal_displacement.py @@ -21,7 +21,7 @@ import math import statistics from datetime import datetime, timedelta, timezone -from common import episode, noise, runs +from episodes import episode, noise, runs from data import is_reference MIN_HOURS = 20 # hours of a day of the profile diff --git a/scripts/visibility.py b/scripts/visibility.py index 5c28c9e..e9844d4 100644 --- a/scripts/visibility.py +++ b/scripts/visibility.py @@ -16,7 +16,7 @@ Heat shimmer: end of file. import statistics from datetime import timedelta -from common import cadence, episode, level, runs, targets +from episodes import cadence, episode, level, runs, targets from data import is_reference K_MAD = 10 # E-001 (fog: 11 to 57 MAD), E-005 (rain, trains: 10 to 70 MAD)