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:
1 parent
8a81c53cd9
commit
0cfbd1b7bc
363 files changed
+30822
No files matched your search
@@ -0,0 +1,38 @@
|
||||
# Prints, per target and axis, the slow-drift figures of displacement.py (whole-window Theil-Sen drift, median daily amplitude, max day step, ratio) on a window. Args: detectors_dir station_dir FROM TO [--levels]
|
||||
import statistics, sys
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
det = Path(sys.argv[1]).resolve()
|
||||
sys.path[:0] = [str(det / "scripts"), str(det.parents[0] / "aimsight-tools" / "scripts"), "/home/maxime/aimsight-tools/scripts"]
|
||||
import displacement as D
|
||||
from data import load, is_reference
|
||||
day = lambda d: datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=timezone.utc)
|
||||
ms_all = load(sys.argv[2])
|
||||
a, b = day(sys.argv[3]), day(sys.argv[4])
|
||||
for s, ms in sorted(ms_all.items()):
|
||||
ms = [m for m in ms if a <= m["t"] < b]
|
||||
if not ms or is_reference(ms):
|
||||
continue
|
||||
for col in ("corr_x", "corr_y"):
|
||||
ds, lv, ampl, _ = D._days(ms, col)
|
||||
if len(ds) < 3:
|
||||
continue
|
||||
pairs = [(i, j) for i in range(len(ds)) for j in range(i + 1, len(ds))]
|
||||
slope = statistics.median((lv[j] - lv[i]) / (ds[j] - ds[i]).days for i, j in pairs)
|
||||
d = slope * (ds[-1] - ds[0]).days
|
||||
step = max(abs(y - x) for x, y in zip(lv, lv[1:]))
|
||||
flag = "WHOLE" if abs(d) >= D.SIZE * ampl and step <= abs(d) / 2 else ""
|
||||
sg = 1 if d >= 0 else -1 # retreat: largest move back against the drift's direction
|
||||
top, back = sg * lv[0], 0
|
||||
for v in lv:
|
||||
top = max(top, sg * v)
|
||||
back = max(back, top - sg * v)
|
||||
if "--flagged" in sys.argv and not flag:
|
||||
continue
|
||||
x = [(e - ds[0]).days for e in ds] # residuals of the levels around the Theil-Sen line
|
||||
icpt = statistics.median(v - slope * xi for v, xi in zip(lv, x))
|
||||
res = [v - icpt - slope * xi for v, xi in zip(lv, x)]
|
||||
mad = statistics.median(abs(r) for r in res)
|
||||
print(f"{s:<8}{col:<7} days={len(ds):>3} drift={d:+8.3f} ampl={ampl:7.3f} ratio={abs(d)/ampl if ampl else 0:5.2f} step={step:6.3f} back/drift={back/abs(d) if d else 0:5.2f} resMAD/drift={mad/abs(d) if d else 0:5.2f} resMAX/drift={max(map(abs,res))/abs(d) if d else 0:5.2f} resMAD/ampl={mad/ampl if ampl else 0:5.2f} {flag}")
|
||||
if "--levels" in sys.argv and flag:
|
||||
print(" ", " ".join(f"{v:+.2f}" for v in lv))
|
||||
@@ -0,0 +1,8 @@
|
||||
# Lists the labels of a JSONL file touching a range: id, start, end, family, description (cut). Args: labels.jsonl FROM TO [width]
|
||||
import json, sys
|
||||
path, fr, to = sys.argv[1:4]
|
||||
w = int(sys.argv[4]) if len(sys.argv) > 4 else 160
|
||||
for line in open(path):
|
||||
d = json.loads(line)
|
||||
if d['start'] < to and d['end'] >= fr:
|
||||
print(f"{d['id']:<14} {d['start']} {d['end']} {d['family']:<22} {d['description'][:w]}")
|
||||
@@ -0,0 +1,17 @@
|
||||
# Counts, per station, the gaps between instants (minute-truncated, as no_data.py) by multiple of the cadence: (1,1.5], (1.5,2.5], >2.5 steps; and the share of last instants of a day not on the cadence grid. Args: data_dir STATION...
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path[:0] = ["/home/maxime/aimsight-detectors/scripts", "/home/maxime/aimsight-tools/scripts"]
|
||||
from data import load
|
||||
from episodes import cadence
|
||||
for st in sys.argv[2:]:
|
||||
ms = load(str(Path(sys.argv[1]) / st))
|
||||
ts = sorted({m["t"].replace(second=0, microsecond=0) for v in ms.values() for m in v})
|
||||
step = cadence(ms)
|
||||
c = [0, 0, 0]
|
||||
for a, b in zip(ts, ts[1:]):
|
||||
r = (b - a) / step
|
||||
if 1 < r <= 1.5: c[0] += 1
|
||||
elif 1.5 < r <= 2.5: c[1] += 1
|
||||
elif r > 2.5: c[2] += 1
|
||||
print(f"{st:<12} step={step} gaps (1,1.5]={c[0]} (1.5,2.5]={c[1]} >2.5={c[2]} instants={len(ts)}")
|
||||
Reference in new issue
Block a user