Files
aimsight-labeling/auto/analyses/NEBRASKA_2026-10-22T0000_2026-11-01T0000/scripts/night_level.py
T
maximeandClaude Opus 5.5 ddb17c2189 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>
2026-11-17 23:58:00 +01:00

31 lines
1.8 KiB
Python

"""Per label: deviation of each target from the level before the label (median of the 24 h before start),
in its own noise (median absolute successive difference /0.6745/sqrt2 over the whole range, as a check of ranges.py)."""
import json, sys, statistics
from datetime import datetime, timedelta, timezone
sys.path.insert(0, "tools/scripts")
import data
D = "labeling/auto/analyses/NEBRASKA_2026-10-22T0000_2026-11-01T0000"
m = data.load("data/NEBRASKA")
T0 = datetime(2026,10,22,tzinfo=timezone.utc); T1 = datetime(2026,11,1,4,tzinfo=timezone.utc)
def P(s): return datetime.strptime(s, "%Y-%m-%dT%H:%MZ").replace(tzinfo=timezone.utc)
for l in open(f"{D}/work/requalify_input.jsonl"):
lab = json.loads(l); s, e = P(lab["start"]), P(lab["end"])
best = []
for sen, ms in m.items():
if sen.startswith("REF"): continue
for col in ("corr_x", "corr_y", "corr_x_mm", "corr_y_mm"):
allv = [(x["t"], x[col]) for x in ms if T0 <= x["t"] <= T1 and x[col] is not None]
if len(allv) < 10: continue
d = [abs(b[1]-a[1]) for a, b in zip(allv, allv[1:])]
noise = statistics.median(d) / 0.6745 / 2**0.5
pre = [v for t, v in allv if s - timedelta(hours=24) <= t < s]
ins = [(t, v) for t, v in allv if s < t < e]
if not pre or not ins or noise == 0: continue
lev = statistics.median(pre)
t, v = max(ins, key=lambda tv: abs(tv[1]-lev))
best.append((abs(v-lev)/noise, sen, col, (v-lev)/noise, v-lev, t.strftime("%m-%dT%H")))
best.sort(reverse=True)
print(lab["id"], lab["start"], lab["end"])
for b in [x for x in best if "mm" not in x[2]][:4]: print(" %-7s %-7s %+6.1f noises %+.4f px at %s" % b[1:])
for b in [x for x in best if "mm" in x[2]][:3]: print(" %-7s %-9s %+6.1f noises %+.2f mm at %s" % b[1:])