Files
aimsight-labeling/auto/analyses/FLORIDA_2026-10-01T0000_2026-10-11T0945/scripts/requal.py
T

24 lines
1.1 KiB
Python
Raw Normal View History

"""Max deviation (in noises) of the real targets within each label, from ranges.py outputs."""
import json, re, sys
from datetime import datetime
T = ["Massif 2", "Sellette 4", "Sellette 5", "Sellette 6"]
def p(s): return datetime.strptime(s, "%Y-%m-%dT%H:%MZ")
def parse(f):
out, col = [], None
for l in open(f):
m = re.match(r"(corr_[xy]): ranges", l)
if m: col = m.group(1); continue
if col is None: continue
for t in T:
if l.startswith(t + " ") or l.startswith(t + "2"):
d = re.findall(r"\d{4}-\d\d-\d\dT\d\d:\d\dZ", l)
if len(d) < 3: continue
rest = l[len(t):].split()
out.append((t, col, p(d[0]), p(d[1]), float(rest[4]), d[2]))
return out
rs = parse(sys.argv[2])
for l in open(sys.argv[1]):
L = json.loads(l); a, b = p(L["start"]), p(L["end"])
hits = [r for r in rs if r[2] <= b and r[3] >= a]
best = sorted(hits, key=lambda r: -abs(r[4]))[:4]
print(L["id"], L["start"], L["end"], L["family"][:10], " | ".join(f"{t} {c} {v:+.1f}@{x[11:16]}" for t, c, _, _, v, x in best) or "none")