34 lines
2.3 KiB
Python
34 lines
2.3 KiB
Python
"""Per measurement instant: median corr_x/corr_y of the targets (minus each target's level over the window),
|
|||
|
|
the spread of the targets, the gap REF42 - REFG43N in raw x, y (minus its level), the pose, the temperature
|
||
|
|
of the hour (median of sensor_*_deg_c), and of the previous/next hours. Usage: table.py START END"""
|
||
|
|
import sys, statistics as st
|
||
|
|
sys.path.insert(0, "tools/scripts")
|
||
|
|
import data
|
||
|
|
|
||
|
|
start, end = data.parse_time(sys.argv[1]), data.parse_time(sys.argv[2])
|
||
|
|
F = "data/MICHIGAN"
|
||
|
|
m = data.load(F)
|
||
|
|
cam = {p["t"].replace(second=0, microsecond=0): p for p in data.load_camera(F)}
|
||
|
|
temp = {t: v for t, v in data.load_temperature(F)}
|
||
|
|
tg = [s for s in m if not data.is_reference(m[s])]
|
||
|
|
W = {s: [x for x in data.filter_window(m[s], start, end)] for s in m}
|
||
|
|
lvl = {s: (st.median([x["corr_x"] for x in W[s] if x["corr_x"] is not None]),
|
||
|
|
st.median([x["corr_y"] for x in W[s] if x["corr_y"] is not None])) for s in tg}
|
||
|
|
times = [x["t"] for x in W["REF42"]]
|
||
|
|
r1 = {x["t"]: x for x in W["REF42"]}; r2 = {x["t"]: x for x in W["REFG43N"]}
|
||
|
|
gx = {t: r1[t]["x"] - r2[t]["x"] for t in times}; gy = {t: r1[t]["y"] - r2[t]["y"] for t in times}
|
||
|
|
gxl, gyl = st.median(gx.values()), st.median(gy.values())
|
||
|
|
print("time cx_med cx_min cx_max | cy_med cy_min cy_max | gapx gapy | ev42 evG43 | pan tilt rot scale | T-1h T T+1h")
|
||
|
|
from datetime import timedelta
|
||
|
|
for t in times:
|
||
|
|
by = {x["t"]: x for s in tg for x in W[s] if x["t"] == t}
|
||
|
|
cx = [x["corr_x"] - lvl[s][0] for s in tg for x in W[s] if x["t"] == t and x["corr_x"] is not None]
|
||
|
|
cy = [x["corr_y"] - lvl[s][1] for s in tg for x in W[s] if x["t"] == t and x["corr_y"] is not None]
|
||
|
|
k = t.replace(second=0, microsecond=0); p = cam.get(k, {})
|
||
|
|
h = k.replace(minute=0)
|
||
|
|
T = [temp.get(h + timedelta(hours=d)) for d in (-1, 0, 1)]
|
||
|
|
f = lambda v, n=6, d=3: (f"{v:{n}.{d}f}" if v is not None else " " * (n - 1) + "-")
|
||
|
|
print(f"{data.iso(t)} {f(st.median(cx))} {f(min(cx))} {f(max(cx))} | {f(st.median(cy))} {f(min(cy))} {f(max(cy))} | "
|
||
|
|
f"{f(gx[t]-gxl,6,3)} {f(gy[t]-gyl,6,3)} | {f(r1[t]['error_value'],5,3)} {f(r2[t]['error_value'],5,3)} | "
|
||
|
|
f"{f(p.get('pan'),8,4)} {f(p.get('tilt'),7,4)} {f(p.get('rotation'),8,4)} {f(p.get('scale'),8,5)} | "
|
||
|
|
+ " ".join(f(v, 5, 1) for v in T))
|