Files
aimsight-labeling/auto/analyses/BREITHORN_2026-10-03T0000_2026-10-13T0000/scripts/thermal_table.py
T

40 lines
2.1 KiB
Python

"""Per measurement instant: housing temperature, camera pose (scale, rotation), corr_y of the sensors carrying the
morning signature of BREITHORN's thermal labels (REFPOU22, COLH20 up; REFG44N, REFI'21, COLI21 down), minus their
median over the evening measurements (12, 16, 20 UTC) of the previous day. Usage: thermal_table.py FOLDER START END"""
import sys, statistics
from datetime import timedelta
sys.path.insert(0, "tools/scripts")
import data
folder, start, end = sys.argv[1], data.parse_time(sys.argv[2]), data.parse_time(sys.argv[3])
S = ["REFPOU22", "COLH20", "REFG44N", "REFI'21", "COLI21", "COLH20'''", "POUI24"]
meas = data.load(folder)
temp = dict(data.load_temperature(folder))
cam = {p["t"]: p for p in data.load_camera(folder)}
series = {s: {m["t"].replace(second=0, microsecond=0): m for m in meas[s]} for s in S}
times = sorted(t for t in series["COLH20"] if start <= t <= end)
def ref(s, col, t):
d0 = t.replace(hour=0, minute=0) - timedelta(days=1)
vals = [series[s][d0 + timedelta(hours=h)][col] for h in (12, 16, 20)
if d0 + timedelta(hours=h) in series[s] and series[s][d0 + timedelta(hours=h)][col] is not None]
return statistics.median(vals) if vals else None
def camref(c, t):
d0 = t.replace(hour=0, minute=0) - timedelta(days=1)
v = [cam[d0 + timedelta(hours=h)][c] for h in (12, 16, 20) if d0 + timedelta(hours=h) in cam]
return statistics.median(v) if v else None
print("time temp dscale*1e5 drot*1e3 " + " ".join(f"{s}:cy" for s in S) + " (x1000, minus previous evening)")
for t in times:
tt = temp.get(t)
p = cam.get(t)
ds = (p["scale"] - camref("scale", t)) * 1e5 if p and camref("scale", t) else float("nan")
dr = (p["rotation"] - camref("rotation", t)) * 1e3 if p and camref("rotation", t) else float("nan")
row = []
for s in S:
m = series[s].get(t)
r = ref(s, "corr_y", t)
row.append("rej" if m is None or m["corr_y"] is None else ("-" if r is None else f"{(m['corr_y'] - r) * 1000:+.0f}"))
print(f"{data.iso(t)} {tt if tt is None else round(tt, 2)} {ds:+.1f} {dr:+.2f} " + " ".join(f"{v:>6}" for v in row))