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,38 @@
# Every Brief obstruction episode of visibility.py over each station's label range: its share of the sensors measured at that instant, and the label families covering it; a table share bucket x family per station. Args: <detectors folder> <labels folder> <data folder>
import sys
from collections import Counter
from pathlib import Path
det = Path(sys.argv[1]).resolve()
sys.path[:0] = [str(det / "bench"), str(det / "scripts")]
import score, visibility # noqa: E402
from regression import label_range # noqa: E402
from data import iso, load, parse_time # noqa: E402
tot = Counter()
for path in sorted(Path(sys.argv[2]).glob("*.jsonl")):
folder = Path(sys.argv[3]) / path.stem
if not folder.is_dir():
continue
start, end = label_range(path)
ms = load(str(folder))
h = parse_time(start) - score.HISTORY
chunk = {s: k for s, v in ms.items() if (k := [m for m in v if h <= m["t"] < parse_time(end)])}
labels = score.read_labels(str(path), start, end)
present = {}
for s, v in chunk.items():
for m in v:
if m["error_value"] is not None:
present.setdefault(iso(m["t"]), set()).add(s)
c = Counter()
for e in visibility.detect(chunk):
if e["label"] != "Brief obstruction" or e["start"] < start:
continue
t = e["start"]
share = len(e["sensors"]) / max(1, len(present.get(t, ())))
b = "<1/4" if share < .25 else "1/4-1/2" if share < .5 else "1/2-3/4" if share < .75 else ">=3/4"
fam = ",".join(sorted({l["family"] for l in labels if l["start"] < t < l["end"]} - {"Thermal displacement", "Target issue"})) or "-"
c[(b, fam)] += 1
tot[(b, fam)] += 1
print(path.stem, dict(sorted(c.items())))
print("TOTAL")
for k, v in sorted(tot.items()):
print(" ", k, v)
@@ -0,0 +1,21 @@
# Per UTC day and sensor, the median absolute step of corr_x and corr_y (non-rejected points), x1000, as a table. Args: <station folder> <from> <to> [sensors,...]
import sys
from statistics import median
from pathlib import Path
sys.path[:0] = [str(Path.home() / "aimsight-tools" / "scripts")]
from data import load
folder, a, b = sys.argv[1:4]
only = sys.argv[4].split(",") if len(sys.argv) > 4 else None
ms = load(folder)
days = sorted({m["t"].date().isoformat() for v in ms.values() for m in v if a <= m["t"].date().isoformat() < b})
print("sensor " + " ".join(d[5:] for d in days))
for s in sorted(ms):
if only and s not in only:
continue
ok = [m for m in ms[s] if m["corr_x"] is not None and not (m["error_value"] and m["error_threshold"] and m["error_value"] > m["error_threshold"])]
row = []
for d in days:
p = [m for m in ok if m["t"].date().isoformat() == d]
st = [abs(q[k] - r[k]) for r, q in zip(p, p[1:]) for k in ("corr_x", "corr_y") if q[k] is not None and r[k] is not None]
row.append(f"{1000 * median(st):5.0f}" if st else " -")
print(f"{s:6} " + " ".join(row))
@@ -0,0 +1,17 @@
# Per UTC day and sensor, the median of error_value / error_threshold (x100) as a table. Args: <station folder> <from> <to>
import sys
from statistics import median
from pathlib import Path
sys.path[:0] = [str(Path.home() / "aimsight-tools" / "scripts")]
from data import load
folder, a, b = sys.argv[1:4]
ms = load(folder)
days = sorted({m["t"].date().isoformat() for v in ms.values() for m in v if a <= m["t"].date().isoformat() < b})
print("sensor " + " ".join(d[5:] for d in days))
for s in sorted(ms):
row = []
for d in days:
r = [m["error_value"] / m["error_threshold"] for m in ms[s] if m["t"].date().isoformat() == d
and m["error_value"] is not None and m["error_threshold"]]
row.append(f"{100 * median(r):5.0f}" if r else " -")
print(f"{s:6} " + " ".join(row))
@@ -0,0 +1,19 @@
# Per UTC day, the share of rejected measurements (error_value > error_threshold) of given sensors. Args: <station folder> <from> <to> <sensor,...>
import sys
from pathlib import Path
sys.path[:0] = [str(Path.home() / "aimsight-tools" / "scripts")]
from data import load
folder, a, b, sensors = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4].split(",")
ms = load(folder)
for s in sensors:
days = {}
for m in ms.get(s, []):
d = m["t"].date().isoformat()
if not (a <= d < b):
continue
r = m["error_value"] is not None and m["error_threshold"] is not None and m["error_value"] > m["error_threshold"]
c = days.setdefault(d, [0, 0, 0])
c[0] += r; c[1] += 1; c[2] += m["error_value"] is None
print(s)
for d, (r, n, none) in sorted(days.items()):
print(f" {d} {r:3}/{n:3} {100*r/n:5.1f}% none={none}")
@@ -0,0 +1,15 @@
# The raw episodes of every detector (before categories.py) overlapping a time span. Args: <detectors folder> <station folder> <from YYYY-MM-DDTHH:MM> <to YYYY-MM-DDTHH:MM>
import importlib, sys
from datetime import timedelta
from pathlib import Path
det = Path(sys.argv[1]).resolve()
sys.path[:0] = [str(det / "scripts"), str(Path.home() / "aimsight-tools" / "scripts")]
from data import load, parse_time # noqa: E402
a, b = sys.argv[3] + "Z", sys.argv[4] + "Z"
ms = load(sys.argv[2])
h0, h1 = parse_time(a) - timedelta(days=3), parse_time(b) + timedelta(days=1)
chunk = {s: k for s, v in ms.items() if (k := [m for m in v if h0 <= m["t"] < h1])}
for name in ("visibility", "displacement", "target_issue", "thermal_displacement"):
for e in importlib.import_module(name).detect(chunk):
if e["start"] <= b and e["end"] >= a:
print(name, e["start"], e["end"], e["kind"], e["label"], len(e["sensors"]), ",".join(e["sensors"]))
@@ -0,0 +1,21 @@
# Per family on a range: labels, labels overlapped by an event of the family, events, events overlapping no label of the family. Args: <detectors folder> <station folder> <labels.jsonl> <from YYYY-MM-DD> <to YYYY-MM-DD>
import sys
from pathlib import Path
det = Path(sys.argv[1]).resolve()
sys.path[:0] = [str(det / "bench"), str(det / "scripts")]
import score # noqa: E402
from data import iso, load, parse_time # noqa: E402
start, end = iso(parse_time(sys.argv[4])), iso(parse_time(sys.argv[5]))
labels = score.read_labels(sys.argv[3], start, end)
evts = score.events(load(sys.argv[2]), start, end, sys.argv[2])
ov = lambda a, b: a["start"] <= b["end"] and a["end"] >= b["start"] # noqa: E731
print("| Family | labelled | found | flagged | wrongly |\n|---|---|---|---|---|")
for f in sorted({l["family"] for l in labels} | {e["category"] for e in evts}):
L = [l for l in labels if l["family"] == f]
E = [e for e in evts if e["category"] == f]
found = [l for l in L if any(ov(l, e) for e in E)]
wrong = [e for e in E if not any(ov(l, e) for l in L)]
print(f"| {f} | {len(L)} | {len(found)} | {len(E)} | {len(wrong)} |")
for l in L:
if l not in found:
print(" missed:", l["id"], l["start"], l["end"])