Files
aimsight-labeling/auto/analyses/LENZSPITZE_2026-10-16T0235_2026-10-23T2355/scripts/neighbours.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

37 lines
1.7 KiB
Python

"""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