31 lines
1.4 KiB
Python
31 lines
1.4 KiB
Python
"""Per-instant table of one column for all sensors + pose, over a window. Usage: table.py COL START END"""
|
|||
|
|
import sys
|
||
|
|
sys.path.insert(0, "tools/scripts")
|
||
|
|
import data
|
||
|
|
from datetime import datetime, timezone
|
||
|
|
col, s, e = sys.argv[1], sys.argv[2], sys.argv[3]
|
||
|
|
p = lambda v: datetime.fromisoformat(v.replace("Z", "+00:00"))
|
||
|
|
s, e = p(s), p(e)
|
||
|
|
by = data.load("data/NEBRASKA")
|
||
|
|
names = [n for n in by if not n.startswith("REF")] if col.startswith("corr") else list(by)
|
||
|
|
pose = {}
|
||
|
|
try:
|
||
|
|
for r in data.load_camera("data/NEBRASKA"):
|
||
|
|
pose[r["t"].replace(second=0, microsecond=0)] = r
|
||
|
|
except Exception as ex:
|
||
|
|
print("pose:", ex)
|
||
|
|
times = sorted({m["t"].replace(second=0, microsecond=0) for n in by for m in by[n] if s <= m["t"] <= e})
|
||
|
|
idx = {n: {m["t"].replace(second=0, microsecond=0): m for m in by[n]} for n in by}
|
||
|
|
print("time " + " ".join(f"{n[:8]:>8}" for n in names) + " tilt*1e3 pan*1e3 rot*1e3 scale-1*1e5")
|
||
|
|
for t in times:
|
||
|
|
row = []
|
||
|
|
for n in names:
|
||
|
|
m = idx[n].get(t)
|
||
|
|
v = None if m is None else m.get(col)
|
||
|
|
rej = m is not None and m.get("error_value") is not None and m["error_value"] > m["error_threshold"]
|
||
|
|
row.append(f"{v:8.3f}" if v is not None else (" rej" if rej else " -"))
|
||
|
|
ps = ""
|
||
|
|
q = pose.get(t)
|
||
|
|
if q:
|
||
|
|
ps = f" {q['tilt']*1e3:8.2f} {q['pan']*1e3:8.2f} {q['rotation']*1e3:7.2f} {(q['scale']-1)*1e5:8.2f}"
|
||
|
|
print(t.strftime("%m-%d %H:%M") + " " + " ".join(row) + ps)
|