auto: labels requalified under the 5-noise rules (only what stands out from the noise): 32 analyses refined, the 6 paused periods verified, the long labels requalified with the fixes the period analysts found; 1153 -> 961 labels

- 32 analyses: each label kept, rewritten or removed by its analyst (section Requalification of the report; mm magnitudes where the targets have them)
- SNCF01 x3, WILDSTRUBEL 2026-09-01 -> 2026-10-06 x3: verified from their existing labels under the new rules
- long labels (no analysis): auto/analyses/long-labels/<STATION>/; NORDEND-169 and -195 run to 07/11, so NORDEND-283 and -284 (their continuation) are removed
- reading-rules.md, stations.md: the citations of removed or rewritten labels point to their successor, or to [expert]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-17 23:58:00 +01:00
1 parent c779de7720
commit ddb17c2189
321 files changed
+18464 -3426

No files matched your search

@@ -0,0 +1,30 @@
"""Per label: the largest deviation in noises of a target inside the label's bounds only
(batch level of ranges.py, and level of the 3 h before the start), CTR02-04 excluded.
Optional argv: label id and sub-windows to exclude, 'ID:T1/T2'."""
import sys, json, statistics
sys.argv, extra = sys.argv[:1], sys.argv[1:]
exec(open("labeling/auto/analyses/NORDEND_2026-08-10T0115_2026-08-23T0515/scripts/requalify.py").read().rsplit("\nfor line in open", 1)[0])
excl = {}
for e in extra:
i, w = e.split(":", 1); a, b = w.split("/"); excl.setdefault(i, []).append((T(a), T(b)))
lev = {}
for line in open(f"{D}/work/rq/ranges_k5.txt"):
p = line.split()
if line.startswith("== corr_"): col = line[3:9]
if p and p[0][:2] in ("PR", "CT") and len(p) >= 5 and p[1].isdigit(): lev[(col, p[0])] = float(p[2])
for line in open(f"{D}/work/requalify_input.jsonl"):
L = json.loads(line); a, b = T(L["start"]), T(L["end"])
out = []
for (s, c), pts in data.items():
if s in REFS or (c, s) not in noise: continue
n = noise[(c, s)]
pre = [v for t, v in pts if a - timedelta(hours=3) <= t < a]
w = [(t, v) for t, v in pts if a <= t <= b and not any(x <= t <= y for x, y in excl.get(L["id"], []))]
if not w: continue
t1, v1 = max(w, key=lambda tv: abs(tv[1] - lev[(c, s)]))
out.append((abs(v1 - lev[(c, s)]) / n, f"{s} {c[-1]} {(v1-lev[(c,s)])/n:+.1f}@{t1:%d %H:%M}"))
if len(pre) >= 3:
m = statistics.median(pre); t2, v2 = max(w, key=lambda tv: abs(tv[1] - m))
out.append((abs(v2 - m) / n, f"{s} {c[-1]} pre {(v2-m)/n:+.1f}@{t2:%d %H:%M}"))
out.sort(reverse=True)
print(f"{L['id']:12s} {L['start'][5:16]}→{L['end'][5:16]} {L['family'][:10]:10s} " + "; ".join(x for _, x in out[:5]))
@@ -0,0 +1,94 @@
"""Requalification: per label, the largest deviation in noises of a target over the label's range.
Reads the ranges.py outputs (k 5, plain and rolling 1d) and, for the thermal labels,
computes each target's deviation from its end-of-night level (median of the 3 h before
the label start), hourly median, in its own noise (the noise of ranges.py over the batch).
Standard library only.
"""
import csv, glob, json, re, statistics
from collections import defaultdict
from datetime import datetime, timedelta
D = "labeling/auto/analyses/NORDEND_2026-08-10T0115_2026-08-23T0515"
REFS = {"CTR02", "CTR03", "CTR04"}
T = lambda s: datetime.strptime(s[:16].replace(" ", "T"), "%Y-%m-%dT%H:%M")
def parse(path):
noise, ranges, col, section = {}, [], None, None
for line in open(path):
m = re.match(r"== (corr_[xy]):", line)
if m:
col, section = m.group(1), "noise"; continue
m = re.match(r"(corr_[xy]): ranges", line)
if m:
col, section = m.group(1), "ranges"; continue
p = line.split()
if not p or not re.match(r"(PR|CTR)\d+$", p[0]):
continue
if section == "noise":
noise[(col, p[0])] = float(p[3])
elif section == "ranges" and len(p) >= 8:
ranges.append(dict(col=col, s=p[0], a=T(p[1]), b=T(p[2]), n=int(p[3]), dev=float(p[5]), at=p[6]))
return noise, ranges
noise, plain = parse(f"{D}/work/rq/ranges_k5.txt")
_, roll = parse(f"{D}/work/rq/ranges_k5_r1d.txt")
data = defaultdict(list) # (sensor, col) -> [(t, v)] accepted only
for f in sorted(glob.glob("data/NORDEND/displacement/NORDEND_advanced_202608*.csv")):
for r in csv.DictReader(open(f)):
try:
if float(r["error_value"]) > float(r["error_threshold"]) or r["corr_x"] == "":
continue
except ValueError:
continue
t = T(r["time_utc"])
for c in ("corr_x", "corr_y"):
data[(r["sensor_name"], c)].append((t, float(r[c])))
def top(rs, a, b, k=4):
best = {}
for r in rs:
if r["b"] >= a and r["a"] <= b:
key = (r["s"], r["col"])
if key not in best or abs(r["dev"]) > abs(best[key]["dev"]):
best[key] = r
tg = sorted((r for r in best.values() if r["s"] not in REFS), key=lambda r: -abs(r["dev"]))
txt = ", ".join(f"{r['s']} {r['col'][-1]} {r['dev']:+.1f} ({r['n']}m @{r['at'][5:16]})" for r in tg[:k]) or "-"
return txt, (abs(tg[0]["dev"]) if tg else 0.0)
def night_dev(a, b):
res = []
for (s, c), pts in data.items():
if s in REFS or (c, s) not in noise:
continue
pre = [v for t, v in pts if a - timedelta(hours=3) <= t < a]
if len(pre) < 3:
continue
lvl = statistics.median(pre)
hours = defaultdict(list)
for t, v in pts:
if a <= t <= b:
hours[t.replace(minute=0)].append(v - lvl)
if not hours:
continue
h, d = max(((h, statistics.median(v)) for h, v in hours.items()), key=lambda x: abs(x[1]))
res.append((abs(d) / noise[(c, s)], s, c[-1], d / noise[(c, s)], h))
res.sort(reverse=True)
return ", ".join(f"{s} {c} {d:+.1f} @{h:%d %H:%M}" for _, s, c, d, h in res[:4]), (res[0][0] if res else 0)
for line in open(f"{D}/work/requalify_input.jsonl"):
L = json.loads(line)
a, b = T(L["start"]), T(L["end"])
tp, mp = top(plain, a, b)
tr, mr = top(roll, a, b)
print(f"{L['id']:12s} {L['start'][5:16]} → {L['end'][5:16]} {L['family']:22s} plain max {mp:5.1f} | rolling max {mr:5.1f}")
print(f" plain: {tp}\n roll : {tr}")
if L["family"] == "Thermal displacement":
tn, mn = night_dev(a, b)
print(f" night-level hourly: max {mn:.1f}: {tn}")
@@ -0,0 +1,25 @@
"""Weak thermal labels: per target (all but CTR02-04), deviation from the end-of-night level (3 h before
the start), in noises, over the whole label outside the nested Visibility/Obstruction/No data labels:
the hourly median (the cycle) and the largest single point."""
import json, statistics, sys
ids = sys.argv[1:]; sys.argv = sys.argv[:1]
exec(open("labeling/auto/analyses/NORDEND_2026-08-10T0115_2026-08-23T0515/scripts/requalify.py").read().rsplit("\nfor line in open", 1)[0])
labels = [json.loads(l) for l in open(f"{D}/work/requalify_input.jsonl")]
nested = [(T(l["start"]), T(l["end"])) for l in labels if l["family"] != "Thermal displacement"]
for L in labels:
if L["id"] not in ids: continue
a, b = T(L["start"]), T(L["end"]); hr, pt = [], []
for (s, c), pts in data.items():
if s in REFS or (c, s) not in noise: continue
pre = [v for t, v in pts if a - timedelta(hours=3) <= t < a]
if len(pre) < 3: continue
m = statistics.median(pre); n = noise[(c, s)]; hours = defaultdict(list); w = []
for t, v in pts:
if a <= t <= b and not any(x <= t <= y for x, y in nested):
hours[t.replace(minute=0)].append(v - m); w.append((t, v - m))
if not w: continue
h, d = max(((h, statistics.median(v)) for h, v in hours.items() if len(v) >= 2), key=lambda x: abs(x[1]), default=(a, 0))
hr.append((abs(d) / n, f"{s} {c[-1]} {d/n:+.1f}@{h:%d %H}h"))
t1, d1 = max(w, key=lambda x: abs(x[1])); pt.append((abs(d1) / n, f"{s} {c[-1]} {d1/n:+.1f}@{t1:%d %H:%M}"))
hr.sort(reverse=True); pt.sort(reverse=True)
print(f"{L['id']} hourly: " + "; ".join(x for _, x in hr[:5]) + "\n points: " + "; ".join(x for _, x in pt[:5]))
@@ -0,0 +1,25 @@
"""Thermal labels: hourly-median deviation of PR14-PR18 (the targets that carry the camera cycle)
from their end-of-night level (3 h before the label start), in noises, over the first 12 h of the label,
outside the nested Visibility/Obstruction labels."""
import json, statistics
exec(open("labeling/auto/analyses/NORDEND_2026-08-10T0115_2026-08-23T0515/scripts/requalify.py").read().rsplit("\nfor line in open", 1)[0])
labels = [json.loads(l) for l in open(f"{D}/work/requalify_input.jsonl")]
nested = [(T(l["start"]), T(l["end"])) for l in labels if l["family"] in ("Visibility", "Obstruction")]
for L in labels:
if L["family"] != "Thermal displacement": continue
a, b = T(L["start"]), min(T(L["end"]), T(L["start"]) + timedelta(hours=12))
res = []
for s in ("PR14", "PR15", "PR16", "PR17", "PR18"):
for c in ("corr_x", "corr_y"):
pts = data[(s, c)]
pre = [v for t, v in pts if a - timedelta(hours=3) <= t < a]
if len(pre) < 3: continue
m = statistics.median(pre); hours = defaultdict(list)
for t, v in pts:
if a <= t <= b and not any(x <= t <= y for x, y in nested):
hours[t.replace(minute=0)].append(v - m)
if not hours: continue
h, d = max(((h, statistics.median(v)) for h, v in hours.items()), key=lambda x: abs(x[1]))
res.append((abs(d) / noise[(c, s)], f"{s} {c[-1]} {d/noise[(c,s)]:+.1f}@{h:%d %H}h"))
res.sort(reverse=True)
print(f"{L['id']:12s} {L['start'][5:16]} " + "; ".join(x for _, x in res[:4]))