30 lines
1.7 KiB
Python
30 lines
1.7 KiB
Python
"""Per label: the largest deviation in noises of a target inside the label's bounds only
|
|||
|
|
(batch level of ranges.py, and level of the 3 h before the start), CTR02-04 excluded.
|
||
|
|
Optional argv: label id and sub-windows to exclude, 'ID:T1/T2'."""
|
||
|
|
import sys, json, statistics
|
||
|
|
sys.argv, extra = sys.argv[:1], sys.argv[1:]
|
||
|
|
exec(open("labeling/auto/analyses/NORDEND_2026-08-10T0115_2026-08-23T0515/scripts/requalify.py").read().rsplit("\nfor line in open", 1)[0])
|
||
|
|
excl = {}
|
||
|
|
for e in extra:
|
||
|
|
i, w = e.split(":", 1); a, b = w.split("/"); excl.setdefault(i, []).append((T(a), T(b)))
|
||
|
|
lev = {}
|
||
|
|
for line in open(f"{D}/work/rq/ranges_k5.txt"):
|
||
|
|
p = line.split()
|
||
|
|
if line.startswith("== corr_"): col = line[3:9]
|
||
|
|
if p and p[0][:2] in ("PR", "CT") and len(p) >= 5 and p[1].isdigit(): lev[(col, p[0])] = float(p[2])
|
||
|
|
for line in open(f"{D}/work/requalify_input.jsonl"):
|
||
|
|
L = json.loads(line); a, b = T(L["start"]), T(L["end"])
|
||
|
|
out = []
|
||
|
|
for (s, c), pts in data.items():
|
||
|
|
if s in REFS or (c, s) not in noise: continue
|
||
|
|
n = noise[(c, s)]
|
||
|
|
pre = [v for t, v in pts if a - timedelta(hours=3) <= t < a]
|
||
|
|
w = [(t, v) for t, v in pts if a <= t <= b and not any(x <= t <= y for x, y in excl.get(L["id"], []))]
|
||
|
|
if not w: continue
|
||
|
|
t1, v1 = max(w, key=lambda tv: abs(tv[1] - lev[(c, s)]))
|
||
|
|
out.append((abs(v1 - lev[(c, s)]) / n, f"{s} {c[-1]} {(v1-lev[(c,s)])/n:+.1f}@{t1:%d %H:%M}"))
|
||
|
|
if len(pre) >= 3:
|
||
|
|
m = statistics.median(pre); t2, v2 = max(w, key=lambda tv: abs(tv[1] - m))
|
||
|
|
out.append((abs(v2 - m) / n, f"{s} {c[-1]} pre {(v2-m)/n:+.1f}@{t2:%d %H:%M}"))
|
||
|
|
out.sort(reverse=True)
|
||
|
|
print(f"{L['id']:12s} {L['start'][5:16]}→{L['end'][5:16]} {L['family'][:10]:10s} " + "; ".join(x for _, x in out[:5]))
|