sessions of 2026-11-18 (the optimization campaign; three runs without summary, interrupted and rerun)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-18 17:47:59 +01:00
1 parent 8a81c53cd9
commit 0cfbd1b7bc
363 files changed
+30822

No files matched your search

@@ -0,0 +1,39 @@
# For each label of a family over a window, prints per instant (from 1 h before to 1 h after) what visibility.py reads: the median error_value z (MAD above each sensor's median), the number of 'high' sensors (K_MAD and FACTOR), the number rejected. Args: <detectors dir> <station folder> <labels.jsonl> <from> <to> [family]
import sys, json, statistics
from datetime import datetime, timedelta, timezone
from pathlib import Path
det = Path(sys.argv[1]).resolve()
sys.path[:0] = [str(det / "scripts"), str(det.parents[0] / "aimsight-tools" / "scripts"), str(Path.cwd() / "tools" / "scripts")]
import visibility as V
from episodes import level
from data import load, parse_time, iso
day = lambda d: datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=timezone.utc)
start, end = day(sys.argv[4]), day(sys.argv[5])
fam = sys.argv[6] if len(sys.argv) > 6 else "Visibility"
ms = load(sys.argv[2])
chunk = {s: k for s, v in ms.items() if (k := [m for m in v if start - timedelta(days=3) <= m["t"] < end])}
z, high, rej = {}, {}, {}
for s, v in chunk.items():
e = [m["error_value"] for m in v if m["error_value"] is not None]
if len(e) < 10:
continue
med, mad = level(e)
for m in v:
x = m["error_value"]
if x is None:
continue
z.setdefault(m["t"], []).append((x - med) / mad)
if x > med + V.K_MAD * mad and x > V.FACTOR * med:
high.setdefault(m["t"], set()).add(s)
if m["error_threshold"] and x > m["error_threshold"]:
rej.setdefault(m["t"], set()).add(s)
labels = [json.loads(l) for l in open(sys.argv[3]) if l.strip()]
for L in labels:
if L["family"] != fam or not (L["start"] < sys.argv[5] and L["end"] >= sys.argv[4]):
continue
a, b = parse_time(L["start"]) - timedelta(hours=1), parse_time(L["end"]) + timedelta(hours=1)
print(L["id"], L["start"], L["end"])
for t in sorted(z):
if a <= t <= b:
inside = "*" if L["start"] < iso(t) < L["end"] else " "
print(f" {inside} {iso(t)} zmed={statistics.median(z[t]):6.2f} high={len(high.get(t, ())):2d} rej={len(rej.get(t, ())):2d} n={len(z[t])}")