English: README, CLAUDE.md, archive note; sessions/ (ex seances); the session of the 2026-11-16 trial (NORDEND, S1 kept)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2cb0c88a2b
commit
63bebbc415
19 files changed
+689
-39
No files matched your search
@@ -0,0 +1,30 @@
|
||||
"""Compare two outputs of bench/regression.py: print the station/family lines that changed, flagging a regression (found or correct down by more than 2 points). Usage: python3 bench_diff.py BEFORE.txt AFTER.txt"""
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def parse(path):
|
||||
out, station = {}, None
|
||||
for line in open(path, encoding="utf-8"):
|
||||
if line and not line.startswith(" ") and line.strip():
|
||||
station = line.split(":")[0].strip()
|
||||
continue
|
||||
m = re.match(r"\s+(\S.*?)\s{2,}(\S+(?: \(\d+ %\))?|—)\s+(\S+(?: \(\d+ %\))?|—)\s*$", line)
|
||||
if m and m.group(1) != "found":
|
||||
out[(station, m.group(1))] = (m.group(2), m.group(3))
|
||||
return out
|
||||
|
||||
|
||||
def pct(x):
|
||||
m = re.match(r"(\d+)/(\d+)", x)
|
||||
return 100 * int(m.group(1)) / int(m.group(2)) if m and int(m.group(2)) else None
|
||||
|
||||
|
||||
a, b = parse(sys.argv[1]), parse(sys.argv[2])
|
||||
for k in sorted(set(a) | set(b)):
|
||||
va, vb = a.get(k, ("—", "—")), b.get(k, ("—", "—"))
|
||||
if va != vb:
|
||||
reg = [n for n, x, y in zip(("found", "correct"), va, vb)
|
||||
if pct(x) is not None and pct(y) is not None and pct(y) < pct(x) - 2]
|
||||
print(f"{k[0]:<12} {k[1]:<22} found {va[0]} → {vb[0]} | correct {va[1]} → {vb[1]}",
|
||||
"REGRESSION " + ",".join(reg) if reg else "")
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
"""Classify a long window (as the benchmark does: the labels' whole range, 3 days of history) and print only the events touching a shorter sub-window. Usage: python3 events_in_window.py <detectors dir> <station folder> FROM TO SHOW_FROM SHOW_TO"""
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
|
||||
sys.path.insert(0, sys.argv[1] + "/scripts")
|
||||
import categories # noqa: E402
|
||||
from data import iso, load, parse_time # noqa: E402
|
||||
|
||||
folder, a, b, sa, sb = sys.argv[2:7]
|
||||
ms = load(folder)
|
||||
h, e = parse_time(a) - timedelta(days=3), parse_time(b)
|
||||
chunk = {s: k for s, x in ms.items() if (k := [m for m in x if h <= m["t"] < e])}
|
||||
sa, sb = iso(parse_time(sa)), iso(parse_time(sb))
|
||||
for v in categories.events(chunk, folder=folder):
|
||||
if v["end"] >= sa and v["start"] < sb:
|
||||
print(v["start"], "→", v["end"], f"{v['category']:<20}", f"| {v['episodes'][0]['label']}",
|
||||
f"| {len(v['sensors'])}:", ",".join(v["sensors"][:6]), "| absorbed:",
|
||||
", ".join(f"{x['label']} {x['start'][5:16]}" for x in v["episodes"][1:])[:200] or "—")
|
||||
@@ -0,0 +1,34 @@
|
||||
"""Per instant of a window: the sensors visibility.py calls high (point 1), the rejected ones (R), and the median MAD gap of point 8, on the range plus 3 days of history. Usage: python3 high_sensors.py <detectors dir> <station folder> FROM TO SHOW_FROM SHOW_TO"""
|
||||
import statistics
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
|
||||
sys.path.insert(0, sys.argv[1] + "/scripts")
|
||||
import visibility as v # noqa: E402
|
||||
from data import iso, load, parse_time # noqa: E402
|
||||
|
||||
folder, a, b, sa, sb = sys.argv[2:7]
|
||||
ms = load(folder)
|
||||
h, e = parse_time(a) - timedelta(days=3), parse_time(b)
|
||||
chunk = {s: k for s, x in ms.items() if (k := [m for m in x if h <= m["t"] < e])}
|
||||
refs = {s for s, x in chunk.items() if x[0]["pattern_type"] == "global_ref"}
|
||||
rows = {}
|
||||
for s, x in chunk.items():
|
||||
ev = [m["error_value"] for m in x if m["error_value"] is not None]
|
||||
med = statistics.median(ev)
|
||||
mad = statistics.median(abs(y - med) for y in ev) or 1e-9
|
||||
for m in x:
|
||||
y = m["error_value"]
|
||||
if y is None or not (sa <= iso(m["t"]) <= sb):
|
||||
continue
|
||||
rej = m["error_threshold"] and y > m["error_threshold"]
|
||||
hi = y > med + v.K_MAD * mad and (y > v.FACTOR * med or rej and y > v.REJECT_FACTOR * med)
|
||||
r = rows.setdefault(iso(m["t"]), {"hi": [], "rej": [], "z": []})
|
||||
r["z"].append((y - med) / mad)
|
||||
if hi:
|
||||
r["hi"].append(s + ("*" if s in refs else ""))
|
||||
if rej:
|
||||
r["rej"].append(s + ("*" if s in refs else ""))
|
||||
for t in sorted(rows):
|
||||
r = rows[t]
|
||||
print(t, f"z={statistics.median(r['z']):5.1f}", "high:", ",".join(sorted(r["hi"])), "| R:", ",".join(sorted(r["rej"])))
|
||||
@@ -0,0 +1,26 @@
|
||||
"""Print the raw episodes of every detector (before classification) touching a range, computed on the range plus its 3 days of history (as score.py). Usage: python3 raw_episodes.py <detectors dir> <station folder> FROM TO [detector names, comma-separated]"""
|
||||
import inspect
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
|
||||
sys.path.insert(0, sys.argv[1] + "/scripts")
|
||||
import categories # noqa: E402
|
||||
from data import iso, load, parse_time # noqa: E402
|
||||
|
||||
folder, start, end = sys.argv[2], iso(parse_time(sys.argv[3])), iso(parse_time(sys.argv[4]))
|
||||
only = sys.argv[5].split(",") if len(sys.argv) > 5 else None
|
||||
ms = load(folder)
|
||||
h, b = parse_time(start) - timedelta(days=3), parse_time(end)
|
||||
chunk = {s: k for s, v in ms.items() if (k := [m for m in v if h <= m["t"] < b])}
|
||||
for mod in categories.detectors():
|
||||
name = mod.__name__.removeprefix("detector_")
|
||||
if only and name not in only:
|
||||
continue
|
||||
params = inspect.signature(mod.detect).parameters
|
||||
kw = {k: categories._context(folder, k) for k in categories.CONTEXT if k in params}
|
||||
if "end" in params:
|
||||
kw["end"] = None
|
||||
for e in mod.detect(chunk, **kw):
|
||||
if e["end"] >= start and e["start"] < end:
|
||||
print(name, e["start"], "→", e["end"], e["kind"], "|", e["label"], e.get("level", ""), "|", len(e["sensors"]),
|
||||
",".join(e["sensors"][:6]), "|", e["text"][:90])
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
"""Print error_value (with its ratio to the sensor's median over the window read and to its threshold) and corr_x, corr_y of given sensors on a window. Usage: python3 sensor_values.py <detectors dir> <station folder> SENSORS(comma) FROM TO [MEDIAN_FROM]"""
|
||||
import statistics
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, sys.argv[1] + "/scripts")
|
||||
from data import iso, load # noqa: E402
|
||||
|
||||
folder, sensors, a, b = sys.argv[2], sys.argv[3].split(","), sys.argv[4], sys.argv[5]
|
||||
m0 = sys.argv[6] if len(sys.argv) > 6 else "0000"
|
||||
ms = load(folder)
|
||||
for s in sensors:
|
||||
ev = [m["error_value"] for m in ms[s] if m["error_value"] is not None and m0 <= iso(m["t"]) < b]
|
||||
med = statistics.median(ev)
|
||||
print(f"== {s} median {med:.3f}")
|
||||
for m in ms[s]:
|
||||
if a <= iso(m["t"]) <= b:
|
||||
e, th = m["error_value"], m["error_threshold"]
|
||||
f = lambda x: " - " if x is None else f"{x:7.3f}" # noqa: E731
|
||||
print(iso(m["t"]), f(e), f"x{e / med:4.2f}" if e else "", f"/th {e / th:4.2f}" if e and th else "",
|
||||
f(m["corr_x"]), f(m["corr_y"]))
|
||||
@@ -0,0 +1,17 @@
|
||||
"""Print the hourly gap profile (share of amplitude from the night level) that thermal_displacement.py uses for its bounds, for corr and raw positions, on a range plus 3 days of history. Usage: python3 thermal_gaps.py <detectors dir> <station folder> FROM TO"""
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
|
||||
sys.path.insert(0, sys.argv[1] + "/scripts")
|
||||
import thermal_displacement as td # noqa: E402
|
||||
from data import load, parse_time # noqa: E402
|
||||
|
||||
folder, a, b = sys.argv[2:5]
|
||||
ms = load(folder)
|
||||
h, e = parse_time(a) - timedelta(days=3), parse_time(b)
|
||||
chunk = {s: k for s, x in ms.items() if (k := [m for m in x if h <= m["t"] < e])}
|
||||
for cols in (("corr_x", "corr_y"), ("x", "y")):
|
||||
concerned, n = td.cycle(chunk, cols)
|
||||
print(cols, f"{len({c[0] for c in concerned})}/{n} targets")
|
||||
if concerned:
|
||||
print(" ".join(f"{h:02d}:{g:.2f}" for h, g in enumerate(td.gaps(concerned))))
|
||||
Reference in new issue
Block a user