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,24 @@
"""Per station, per target and axis: its noise (median step) relative to the median noise of the station's targets on that axis, lowest first.
Usage: python3 noises.py <data folder> [STATION ...]
"""
import statistics
import sys
from pathlib import Path
ROOT = Path("/home/maxime/aimsight-optimizer")
sys.path[:0] = [str(ROOT / "detectors" / "scripts"), str(ROOT / "tools" / "scripts")]
from data import load, is_reference # noqa: E402
from episodes import noise # noqa: E402
data = Path(sys.argv[1])
names = sys.argv[2:] or sorted(p.name for p in data.iterdir() if p.is_dir())
for st in names:
ms_all = load(str(data / st))
for ax in ("corr_x", "corr_y"):
ns = {s: noise([m[ax] for m in ms if m[ax] is not None]) for s, ms in ms_all.items() if not is_reference(ms)}
ns = {s: n for s, n in ns.items() if n}
if not ns:
continue
med = statistics.median(ns.values())
low = sorted(ns.items(), key=lambda x: x[1])[:4]
print(st, ax, f"median {med:.4f}", " ".join(f"{s}={n / med:.3f}" for s, n in low))
@@ -0,0 +1,10 @@
"""Replace one exact, unique string in a file (for pruning variants on working copies); fails if absent or not unique.
Usage: python3 patch.py <file> <old> <new>
"""
import sys
path, old, new = sys.argv[1:4]
text = open(path).read()
if text.count(old) != 1:
sys.exit(f"{path}: {text.count(old)} occurrences of {old!r}")
open(path, "w").write(text.replace(old, new))
@@ -0,0 +1,33 @@
"""Per station: references rejected (error_value > threshold and > 2x its median), their error_value/threshold ratio, grouped by the family of the label covering the instant (quartiles).
Usage: python3 refratio.py <data folder> <labels folder> STATION ...
"""
import json
import statistics
import sys
from pathlib import Path
ROOT = Path("/home/maxime/aimsight-optimizer")
sys.path[:0] = [str(ROOT / "detectors" / "scripts"), str(ROOT / "tools" / "scripts")]
from data import load, is_reference, iso # noqa: E402
data, labels = Path(sys.argv[1]), Path(sys.argv[2])
for st in sys.argv[3:]:
labs = [json.loads(x) for x in open(labels / f"{st}.jsonl") if x.strip()]
out = {}
for s, ms in load(str(data / st)).items():
if not is_reference(ms):
continue
e = [m["error_value"] for m in ms if m["error_value"] is not None]
if not e:
continue
med = statistics.median(e)
for m in ms:
x, th = m["error_value"], m["error_threshold"]
if x is None or not th or x <= th or x <= 2 * med:
continue
t = iso(m["t"])
fam = ",".join(sorted({l["family"] for l in labs if l["start"] < t < l["end"]})) or "-"
out.setdefault(fam, []).append(x / th)
for fam, r in sorted(out.items()):
q = statistics.quantiles(r, n=4) if len(r) > 1 else r * 3
print(f"{st:12} {fam:40} n={len(r):4} q1={q[0]:.2f} med={q[1]:.2f} q3={q[2]:.2f}")
@@ -0,0 +1,30 @@
"""Per sensor of a station on a range: noise (median step), MAD, range of corr_x/corr_y, and the K-noise jumps of displacement.py.
Usage: python3 series.py <station folder> <from YYYY-MM-DD> <to YYYY-MM-DD> [sensor ...] (with sensors: prints their series)
"""
import statistics
import sys
from datetime import datetime, timezone
from pathlib import Path
ROOT = Path("/home/maxime/aimsight-optimizer")
sys.path[:0] = [str(ROOT / "detectors" / "scripts"), str(ROOT / "tools" / "scripts")]
from data import load, is_reference # noqa: E402
from episodes import noise # noqa: E402
folder, a, b = sys.argv[1:4]
show = sys.argv[4:]
day = lambda d: datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=timezone.utc) # noqa: E731
ms_all = load(folder)
for s, ms in sorted(ms_all.items()):
ms = [m for m in ms if day(a) <= m["t"] < day(b)]
for ax in ("corr_x", "corr_y"):
v = [m[ax] for m in ms if m[ax] is not None]
if len(v) < 3:
continue
med = statistics.median(v)
mad = statistics.median(abs(x - med) for x in v)
print(f"{s:12} ref={is_reference(ms)!s:5} {ax} n={len(v)} noise={noise(v):.4f} mad={mad:.4f} "
f"min={min(v):.3f} max={max(v):.3f}")
if s in show:
for m in ms:
print(" ", m["t"].strftime("%m-%dT%H:%M"), m["corr_x"], m["corr_y"], m["error_value"], m["error_threshold"])
@@ -0,0 +1,27 @@
"""For a sensor of a station on a range: at each of its rejected instants, how many other sensors are rejected (out of those measured); a histogram.
Usage: python3 shared.py <station folder> <from YYYY-MM-DD> <to YYYY-MM-DD> <sensor>
"""
import sys
from collections import Counter
from datetime import datetime, timezone
from pathlib import Path
ROOT = Path("/home/maxime/aimsight-optimizer")
sys.path[:0] = [str(ROOT / "detectors" / "scripts"), str(ROOT / "tools" / "scripts")]
from data import load, rejected # noqa: E402
folder, a, b, sensor = sys.argv[1:5]
day = lambda d: datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=timezone.utc) # noqa: E731
ms_all = load(folder)
at = {}
for s, ms in ms_all.items():
for m in ms:
if day(a) <= m["t"] < day(b):
at.setdefault(m["t"], {})[s] = rejected(m)
hist = Counter()
for t, r in sorted(at.items()):
if r.get(sensor):
others = {s: x for s, x in r.items() if s != sensor}
hist[(sum(others.values()), len(others))] += 1
for (k, n), c in sorted(hist.items()):
print(f"{k}/{n} others rejected: {c} instants")
@@ -0,0 +1,15 @@
#!/bin/bash
# Make a working copy of the detectors at HEAD named <name> in <workdir>, apply patches (file|old|new triplets, file relative to scripts/), run its benchmark to <workdir>/<name>.txt.
# Usage: variant.sh <workdir> <name> <file> <old> <new> [<file> <old> <new> ...]
set -e
W=$1; N=$2; shift 2
HERE=$(dirname "$(readlink -f "$0")")
mkdir -p "$W/$N/tools"
git -C /home/maxime/aimsight-detectors archive HEAD | tar -x -C "$W/$N"
ln -sfn /home/maxime/aimsight-tools/scripts "$W/$N/tools/scripts"
while [ $# -ge 3 ]; do
python3 -I "$HERE/patch.py" "$W/$N/scripts/$1" "$2" "$3"
shift 3
done
cd "$W/$N"
python3 bench/regression.py --labels /home/maxime/aimsight-optimizer/labeling/auto --data /home/maxime/aimsight-optimizer/data > "$W/$N.txt" 2>&1