Files
aimsight-labeling/auto/analyses/long-labels/NIEDERHORN/scripts/specific.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

47 lines
2.6 KiB
Python

"""For each studied target, over a window: corr minus the median of the healthy targets at the same instant
(common mode removed), then its own noise (median abs consecutive diff of the raw corr, as ranges.py) and the
measurements whose residual deviates from its rolling-1d median by more than K noises. Also the healthy targets,
leave-one-out, for comparison. Usage: specific.py START END SENSOR[,SENSOR] [K]"""
import sys, statistics
from datetime import timedelta
sys.path.insert(0, "tools/scripts")
import data, common
start, end = data.parse_time(sys.argv[1]), data.parse_time(sys.argv[2])
studied = sys.argv[3].split(",")
K = float(sys.argv[4]) if len(sys.argv) > 4 else 5
by = data.load("data/NIEDERHORN")
healthy = ["PWD_RMP_B12_020_C09","PWD_IMP_B08_025_C09","PWD_RMP_B15_018_C09","PWD_IMP_B07_017_C09","PWD_RMP_B12_018_C09",
"PWD_RMP_B12_017_C09","PWD_RMP_B15_019_C09","PWD_RMP_B15_020_C09","PWD_RMP_B17_026_C09",
"e02","e06","e09","e10","e13","e14","e15"]
win = {s: [m for m in data.filter_window(ms, start, end)] for s, ms in by.items()}
def series(s, col):
return {m["t"]: m[col] for m in win[s] if m[col] is not None}
for col in ("corr_x", "corr_y"):
H = {s: series(s, col) for s in healthy}
print(f"== {col} (K={K}, rolling ±1d, common mode = median of healthy targets)")
for s in studied + healthy:
own = series(s, col)
if len(own) < 10:
print(f"{s:22s} n={len(own)} (no curve)"); continue
noise = common.own_noise([own[t] for t in sorted(own)])
res = {}
for t, v in own.items():
others = [H[h][t] for h in healthy if h != s and t in H[h]]
if len(others) >= 5:
res[t] = v - statistics.median(others)
ts = sorted(res)
out = []
for t in ts:
nb = [res[u] for u in ts if u != t and abs((u - t).total_seconds()) <= 86400]
if len(nb) < 5: continue
d = (res[t] - statistics.median(nb)) / noise
if abs(d) > K: out.append((t, d))
ext = max(out, key=lambda x: abs(x[1])) if out else None
kmm = None
mm = [m for m in win[s] if m[col + "_mm"] is not None and m[col] not in (None, 0)]
if mm: kmm = mm[0][col + "_mm"] / mm[0][col]
days = len({t.date() for t, _ in out})
e = f"extreme {ext[1]:+.1f} noises ({ext[1]*noise:+.3f} px" + (f", {ext[1]*noise*kmm:+.2f} mm" if kmm else "") + f") at {data.iso(ext[0])}" if ext else ""
tag = "*" if s in studied else " "
print(f"{tag}{s:22s} n={len(own):4d} noise={noise:.4f} beyond: {len(out):3d} ({100*len(out)/max(1,len(res)):4.1f} %) on {days:2d} days {e}")