Files
aimsight-labeling/auto/analyses/NORDEND_2026-10-24T1630_2026-11-07T1400/scripts/requal_thermal.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

62 lines
3.6 KiB
Python

"""Thermal labels: deviation of each target's corr_x/corr_y from a night level (median 22:00-04:00 UTC of the
night before the label, then of the night at its end), in its own noise (ranges.py batch noise), on a
3-measurement running median, excluding the instants covered by the non-thermal labels of the batch (spikes of
lost references, fog, rain, cobweb nights) and, for PR04, its Target-issue label NORDEND-152 (to 26/10 20:45)."""
import json, re, sys, statistics as st
from datetime import timedelta
sys.path.insert(0, 'tools/scripts')
import data
labels = [json.loads(l) for l in open(sys.argv[1])]
noise = {}; col = None
for line in open(sys.argv[2]):
if line.startswith('== corr_x'): col = 'corr_x'
elif line.startswith('== corr_y'): col = 'corr_y'
elif line.startswith('corr_'): col = None
m = re.match(r'^(PR\d+|CTR01)\s+\d+\s+\S+\s+(\S+)\s', line)
if m and col: noise[(m.group(1), col)] = float(m.group(2))
P = data.parse_time
# whole windows: rain, fog, low sun, pose jolts; per target: the obstructions of single targets (and PR04's
# NORDEND-152); per instant: any measurement where a reference CTR02-04 is rejected or out of the compensation.
excl = [(P(l['start']), P(l['end'])) for l in labels
if l['id'] in ('NORDEND-215', 'NORDEND-222', 'NORDEND-227', 'NORDEND-289', 'NORDEND-243')]
per_target = {'PR04': [('2026-10-24T16:30Z', '2026-10-26T20:45Z'), ('2026-11-07T11:15Z', '2026-11-07T11:45Z')],
'PR07': [('2026-11-02T19:15Z', '2026-11-03T06:00Z'), ('2026-11-07T13:45Z', '2026-11-07T14:00Z')],
'PR08': [('2026-11-02T19:15Z', '2026-11-03T06:00Z')],
'PR09': [('2026-11-05T03:00Z', '2026-11-05T09:45Z'), ('2026-11-05T14:45Z', '2026-11-05T15:15Z')],
'PR10': [('2026-11-06T09:15Z', '2026-11-06T09:45Z')]}
per_target = {k: [(P(a), P(b)) for a, b in v] for k, v in per_target.items()}
meas = data.load('data/NORDEND')
bad_t = set()
for r in ('CTR02', 'CTR03', 'CTR04'):
for m in meas[r]:
if data.rejected(m) or (m.get('inlier') is not None and m['inlier'] != 1):
bad_t.add(m['t'])
def ok(sen, t):
return (t not in bad_t and not any(a < t < b for a, b in excl)
and not any(a < t < b for a, b in per_target.get(sen, [])))
for L in labels:
if L['family'] != 'Thermal displacement': continue
s, e = P(L['start']), P(L['end'])
for ref in ('night before', 'night after'):
d0 = (s if ref == 'night before' else e).replace(hour=0, minute=0)
if ref == 'night before' and s.hour >= 20: d0 += timedelta(days=1)
n0, n1 = d0 - timedelta(hours=2), d0 + timedelta(hours=4)
res = []
for sen, ms in meas.items():
if not sen.startswith('PR'): continue
for c in ('corr_x', 'corr_y'):
nz = noise.get((sen, c))
night = [m[c] for m in ms if n0 <= m['t'] <= n1 and m[c] is not None and ok(sen, m['t'])]
if not nz or len(night) < 5: continue
lvl = st.median(night)
pts = [m for m in ms if s < m['t'] < e and m[c] is not None and ok(sen, m['t'])]
best = (0, None)
for i in range(1, len(pts) - 1):
k = (st.median([pts[i-1][c], pts[i][c], pts[i+1][c]]) - lvl) / nz
if abs(k) > abs(best[0]): best = (k, pts[i]['t'])
if best[1]: res.append((abs(best[0]), sen, c, best[0], best[1]))
res.sort(reverse=True)
over = [r for r in res if r[0] > 5]
print(L['id'], L['start'][5:16], L['end'][5:16], f"{ref:12s} n={len(res):2d} >5: {len(over):2d} |",
'; '.join(f"{r[1]} {r[2][-1]} {r[3]:+.1f} @{data.iso(r[4])[5:16]}" for r in res[:6]))