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:
1 parent
c779de7720
commit
ddb17c2189
321 files changed
+18464
-3426
No files matched your search
@@ -0,0 +1,36 @@
|
||||
"""Rolling deviation (median of 12 measurements each side, without the point) in own noises
|
||||
(median |successive difference| over the window), at each instant of a window, for given sensors:
|
||||
does the instant of a label stand out from its neighbours? Also counts, over the window, the
|
||||
instants where |deviation| exceeds the value at the label instant.
|
||||
Usage: .venv/bin/python neighbours.py START END LABEL_INSTANT SENSOR[,SENSOR...]|targets
|
||||
"""
|
||||
import sys, statistics
|
||||
sys.path.insert(0, "tools/scripts")
|
||||
import data
|
||||
REFS = {"8002","8004","8011","8012","8013","8014","8017","8019","92H"}
|
||||
s, e, at = (data.parse_time(x) for x in sys.argv[1:4])
|
||||
d = data.load("data/LENZSPITZE")
|
||||
names = [n for n in d if n not in REFS] if sys.argv[4] == "targets" else sys.argv[4].split(",")
|
||||
rows = {}
|
||||
for n in names:
|
||||
for c in ("corr_x", "corr_y"):
|
||||
ms = [(m["t"], m[c]) for m in d[n] if s <= m["t"] <= e and m[c] is not None]
|
||||
if len(ms) < 30: continue
|
||||
v = [x for _, x in ms]
|
||||
noise = statistics.median(abs(a - b) for a, b in zip(v[1:], v[:-1]))
|
||||
devs = []
|
||||
for i, (t, x) in enumerate(ms):
|
||||
nb = v[max(0, i-12):i] + v[i+1:i+13]
|
||||
devs.append((t, (x - statistics.median(nb)) / noise))
|
||||
k_at = [k for t, k in devs if t == at]
|
||||
if not k_at: continue
|
||||
k_at = k_at[0]
|
||||
n_more = sum(1 for t, k in devs if t != at and abs(k) >= abs(k_at))
|
||||
rows[(n, c)] = (k_at, n_more, len(devs))
|
||||
top = sorted(rows.items(), key=lambda kv: -abs(kv[1][0]))[:10]
|
||||
for (n, c), (k, nm, tot) in top:
|
||||
print(f"{n:6s} {c}: {k:+.1f} noises at the label instant; {nm} other instants of {tot} at least as far")
|
||||
# common-mode: number of targets beyond 5 at each instant
|
||||
cnt = {}
|
||||
for n in names:
|
||||
pass
|
||||
@@ -0,0 +1,100 @@
|
||||
"""Requalify each label of requalify_input.jsonl under the noise rule.
|
||||
|
||||
For each label, runs tools/scripts/ranges.py (--k 5, corr_x,corr_y) on a window
|
||||
around the label, level and noise computed outside the label (--outside), and
|
||||
keeps the ranges that overlap the label (strictly inside its bounds).
|
||||
Modes:
|
||||
plain : level = median of the window outside the label (thermal: the night level)
|
||||
rolling : --rolling N measurements on each side (brief events under a cycle)
|
||||
Prints, per label, the largest |deviation| in noises among targets and among
|
||||
references, with sensor, column and instant, and the list of targets > 5.
|
||||
Usage: python3 requalify.py <input.jsonl> [ids...]
|
||||
"""
|
||||
import json, subprocess, sys
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
REFS = {"8002", "8004", "8011", "8012", "8013", "8014", "8017", "8019", "92H"}
|
||||
FMT = "%Y-%m-%dT%H:%MZ"
|
||||
B0 = datetime(2026, 10, 15, 0, 0)
|
||||
B1 = datetime(2026, 10, 24, 6, 0)
|
||||
|
||||
|
||||
def t(s):
|
||||
return datetime.strptime(s, FMT)
|
||||
|
||||
|
||||
def run(start, end, outside, rolling=None):
|
||||
cmd = ["python3", "tools/scripts/ranges.py", "data/LENZSPITZE", "--columns", "corr_x,corr_y",
|
||||
"--k", "5", "--merge", "0min", "--start", start.strftime(FMT), "--end", end.strftime(FMT),
|
||||
"--outside", outside]
|
||||
if rolling:
|
||||
cmd += ["--rolling", str(rolling)]
|
||||
out = subprocess.run(cmd, capture_output=True, text=True).stdout
|
||||
res = []
|
||||
col = None
|
||||
inr = False
|
||||
for line in out.splitlines():
|
||||
if ": ranges more than" in line:
|
||||
col = line.split(":")[0]
|
||||
inr = True
|
||||
continue
|
||||
if line.startswith("=="):
|
||||
inr = False
|
||||
continue
|
||||
if inr and line.strip() and not line.startswith("sensor"):
|
||||
p = line.split()
|
||||
if len(p) < 8:
|
||||
continue
|
||||
try:
|
||||
res.append(dict(sensor=p[0], col=col, start=t(p[1]), end=t(p[2]), n=int(p[3]),
|
||||
val=float(p[4]), noises=float(p[5]), at=p[6], rej=p[7]))
|
||||
except ValueError:
|
||||
continue
|
||||
return res
|
||||
|
||||
|
||||
def analyse(lab, mode):
|
||||
s, e = t(lab["start"]), t(lab["end"])
|
||||
thermal = lab["family"] == "Thermal displacement"
|
||||
dur = e - s
|
||||
if thermal or mode == "plain":
|
||||
margin = timedelta(hours=8) if thermal else max(timedelta(hours=3), dur)
|
||||
ws, we = max(B0, s - margin), min(B1, e + margin)
|
||||
rr = run(ws, we, f"{lab['start']}/{lab['end']}")
|
||||
else:
|
||||
margin = max(timedelta(hours=3), dur * 2)
|
||||
ws, we = max(B0, s - margin), min(B1, e + margin)
|
||||
rr = run(ws, we, f"{lab['start']}/{lab['end']}", rolling=mode)
|
||||
inside = [r for r in rr if r["end"] > s and r["start"] < e]
|
||||
tg = [r for r in inside if r["sensor"] not in REFS]
|
||||
rf = [r for r in inside if r["sensor"] in REFS]
|
||||
return tg, rf
|
||||
|
||||
|
||||
def fmt(r):
|
||||
return f"{r['sensor']} {r['col']} {r['noises']:+.1f} at {r['at'][11:16]} ({r['n']} meas)"
|
||||
|
||||
|
||||
def main():
|
||||
labs = [json.loads(l) for l in open(sys.argv[1]) if l.strip()]
|
||||
mode = sys.argv[2] if len(sys.argv) > 2 else "plain"
|
||||
ids = set(sys.argv[3:])
|
||||
for lab in labs:
|
||||
if ids and lab["id"] not in ids:
|
||||
continue
|
||||
if lab["family"] == "No data":
|
||||
continue
|
||||
tg, rf = analyse(lab, mode)
|
||||
tg.sort(key=lambda r: -abs(r["noises"]))
|
||||
rf.sort(key=lambda r: -abs(r["noises"]))
|
||||
best = fmt(tg[0]) if tg else "none"
|
||||
bestr = fmt(rf[0]) if rf else "none"
|
||||
sens = sorted({r["sensor"] for r in tg})
|
||||
print(f"{lab['id']:14s} {lab['start']} {lab['end']} {lab['family'][:12]:12s} "
|
||||
f"targets>5: {len(sens):2d} max {best} | refs max {bestr}")
|
||||
if tg:
|
||||
print(" top:", "; ".join(fmt(r) for r in tg[:6]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,67 @@
|
||||
"""Thermal labels: does the corrected curve keep the cycle beyond 5 noises of the night level?
|
||||
|
||||
For each Thermal displacement label: night level = median of corr over the night before
|
||||
(20:00-03:00 UTC of the previous evening; on the first day, the measurements before the label),
|
||||
own noise = median |difference between two measurements| over that night (as ranges.py);
|
||||
then the hourly median of corr within the label minus the night level, in noises (the hourly
|
||||
median removes the agitation of the visibility labels that overlap the thermal days).
|
||||
Prints the targets whose hourly deviation exceeds 5 noises, largest first, in px and mm.
|
||||
Usage: .venv/bin/python thermal.py <input.jsonl>
|
||||
"""
|
||||
import json, sys, statistics
|
||||
from datetime import datetime, timedelta, timezone
|
||||
sys.path.insert(0, "tools/scripts")
|
||||
import data
|
||||
|
||||
REFS = {"8002", "8004", "8011", "8012", "8013", "8014", "8017", "8019", "92H"}
|
||||
|
||||
|
||||
def T(s):
|
||||
return datetime.strptime(s, "%Y-%m-%dT%H:%MZ").replace(tzinfo=timezone.utc)
|
||||
|
||||
|
||||
def main():
|
||||
labs = [json.loads(l) for l in open(sys.argv[1]) if l.strip()]
|
||||
labs = [l for l in labs if l["family"] == "Thermal displacement"]
|
||||
d = data.load("data/LENZSPITZE")
|
||||
for lab in labs:
|
||||
s, e = T(lab["start"]), T(lab["end"])
|
||||
day = s.replace(hour=0, minute=0)
|
||||
n0, n1 = day - timedelta(hours=4), day + timedelta(hours=3)
|
||||
if s.day == 16:
|
||||
n0, n1 = day, s
|
||||
out = []
|
||||
for name, ms in d.items():
|
||||
if name in REFS:
|
||||
continue
|
||||
for c in ("corr_x", "corr_y"):
|
||||
night = [m[c] for m in ms if n0 <= m["t"] < n1 and m[c] is not None]
|
||||
if len(night) < 6:
|
||||
continue
|
||||
lvl = statistics.median(night)
|
||||
noise = statistics.median(abs(a - b) for a, b in zip(night[1:], night[:-1]))
|
||||
if noise <= 0:
|
||||
continue
|
||||
hours = {}
|
||||
for m in ms:
|
||||
if s < m["t"] < e and m[c] is not None:
|
||||
hours.setdefault(m["t"].replace(minute=0), []).append(m[c])
|
||||
best = None
|
||||
for h, v in hours.items():
|
||||
if len(v) < 6:
|
||||
continue
|
||||
dev = statistics.median(v) - lvl
|
||||
if best is None or abs(dev) > abs(best[0]):
|
||||
best = (dev, h)
|
||||
if best and abs(best[0]) / noise > 5:
|
||||
k = (ms[0].get("corr_x_mm") or 0) / ms[0]["corr_x"] if ms[0].get("corr_x_mm") and ms[0]["corr_x"] else None
|
||||
mm = f" ({best[0]*k:+.2f} mm)" if k else ""
|
||||
out.append((abs(best[0]) / noise, f"{name} {c} {best[0]:+.3f} px{mm} = {best[0]/noise:+.1f} noises, hour {best[1]:%H}"))
|
||||
out.sort(reverse=True)
|
||||
print(f"{lab['id']} {lab['start']} -> {lab['end']}: {len(out)} target-columns > 5 noises (hourly median vs night {n0:%d %H}-{n1:%d %H})")
|
||||
for _, txt in [o for o in out if (len(sys.argv) < 3 or o[1].split()[0] == sys.argv[2])][:8]:
|
||||
print(" ", txt)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user