Detectors in English, under scripts/; learner tools under scripts/learner/
- data.py (was donnees.py): unused filtrer, heure_image and image sorting removed - score.py: dead functions (validite, marquer, detectes, score, familles) and the validity levels removed; --from/--to - regression.py: history.csv and --seance/--etape removed - categories.py: --from/--to/--chunk/--history; process values images/none/check - benchmark on all stations unchanged (same 132 figures) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9b3ac0ecfe
commit
969637499f
23 files changed
+1877
-1971
No files matched your search
@@ -0,0 +1,31 @@
|
||||
"""For the upgrader: the cadence of the measurements of the range, the number of targets and references, then each event
|
||||
of the range with its sensors (categories.py only gives their number). Same computation as categories.py without
|
||||
--chunk (3 days of history).
|
||||
Usage: python3 detectors/scripts/learner/sensors.py <folder> --from YYYY-MM-DD --to YYYY-MM-DD
|
||||
"""
|
||||
import argparse
|
||||
import statistics
|
||||
import sys
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
import categories # noqa: E402
|
||||
from data import iso, load # noqa: E402
|
||||
|
||||
p = argparse.ArgumentParser(usage=__doc__)
|
||||
p.add_argument("folder")
|
||||
p.add_argument("--from", dest="start", required=True)
|
||||
p.add_argument("--to", dest="end", required=True)
|
||||
a = p.parse_args()
|
||||
day = lambda d: datetime.strptime(d[:10], "%Y-%m-%d").replace(tzinfo=timezone.utc) # noqa: E731
|
||||
start, end = day(a.start), day(a.end)
|
||||
batch = {s: k for s, ms in load(a.folder).items() if (k := [m for m in ms if start - timedelta(days=3) <= m["t"] < end])}
|
||||
ts = sorted({m["t"] for ms in batch.values() for m in ms if m["t"] >= start})
|
||||
steps = [(y - x).total_seconds() / 60 for x, y in zip(ts, ts[1:])]
|
||||
print(f"cadence: {statistics.median(steps):.0f} min (median of the steps between measurements)" if steps else "cadence: no measurement")
|
||||
refs = sum(ms[0]["pattern_type"] == "global_ref" for ms in batch.values())
|
||||
print(f"sensors: {len(batch) - refs} targets, {refs} references")
|
||||
for v in (v for v in categories.events(batch, end, a.folder) if v["end"] >= iso(start)) if batch else []:
|
||||
print(v["start"], "→", v["end"], f"{v['category']:<20}", "|", v["episodes"][0]["label"], "|",
|
||||
", ".join(sorted(v["sensors"])) or "all sensors")
|
||||
Reference in new issue
Block a user