49 lines
2.5 KiB
Python
49 lines
2.5 KiB
Python
"""Per step: temperature, raw x/y of near sensors minus the far group (translation only), corr_x of chosen targets.
|
|
|
|
usage: python3 table.py START END [STEP_MIN] (UTC, from the aimsight-app root)
|
|
"""
|
|
import statistics, sys
|
|
from datetime import timedelta
|
|
sys.path.insert(0, "tools/scripts")
|
|
import data
|
|
|
|
F = "data/WYOMING"
|
|
start, end = data.parse_time(sys.argv[1]), data.parse_time(sys.argv[2])
|
|
step = int(sys.argv[3]) if len(sys.argv) > 3 else 60
|
|
meas = data.load(F)
|
|
temp = dict(data.load_temperature(F)) or {}
|
|
if not temp:
|
|
temp = dict(data.load_metrics(F).get("temperature_deg_c", []))
|
|
cam = {p["t"].replace(second=0, microsecond=0): p for p in data.load_camera(F)}
|
|
FAR = ["target_%02d" % i for i in range(3, 14)]
|
|
NEAR = ["RD", "target_01", "target_02", "target_14", "target_15"]
|
|
by = {s: {m["t"].replace(second=0, microsecond=0): m for m in v} for s, v in meas.items()}
|
|
base = {s: (statistics.median([m["x"] for m in v]), statistics.median([m["y"] for m in v])) for s, v in meas.items()}
|
|
ts = sorted(by["RD"])
|
|
print("time\ttemp\tscale_e4\tpan_e3\t" + "\t".join("dx_" + s[-2:] for s in NEAR) + "\t" + "\t".join("dy_" + s[-2:] for s in NEAR[:2]) + "\tcx02\tcx14\tcx15\tcx01\tev_RD\tev_01")
|
|
t = start
|
|
while t <= end:
|
|
sel = [u for u in ts if t <= u < t + timedelta(minutes=step)]
|
|
if sel:
|
|
row = []
|
|
def med(f):
|
|
v = [f(u) for u in sel]
|
|
v = [x for x in v if x is not None]
|
|
return statistics.median(v) if v else None
|
|
def far(u, c, k):
|
|
return statistics.median([by[s][u][c] - base[s][k] for s in FAR if u in by[s] and by[s][u]["corr_x"] is not None] or [0])
|
|
th = t.replace(minute=0)
|
|
row.append(temp.get(th))
|
|
row.append(med(lambda u: (cam[u]["scale"] - 1) * 1e4 if u in cam else None))
|
|
row.append(med(lambda u: cam[u]["pan"] * 1e3 if u in cam else None))
|
|
for s in NEAR:
|
|
row.append(med(lambda u: by[s][u]["x"] - base[s][0] - far(u, "x", 0) if u in by[s] else None))
|
|
for s in NEAR[:2]:
|
|
row.append(med(lambda u: by[s][u]["y"] - base[s][1] - far(u, "y", 1) if u in by[s] else None))
|
|
for s in ["target_02", "target_14", "target_15", "target_01"]:
|
|
row.append(med(lambda u: by[s][u]["corr_x"] if u in by[s] else None))
|
|
for s in ["RD", "target_01"]:
|
|
row.append(med(lambda u: by[s][u]["error_value"] if u in by[s] else None))
|
|
print(t.strftime("%m-%dT%H:%M") + "\t" + "\t".join("-" if v is None else "%.2f" % v for v in row))
|
|
t += timedelta(minutes=step)
|