41 lines
2.0 KiB
Python
41 lines
2.0 KiB
Python
"""Per-instant table of one column for all sensors, plus pose and number of references kept.
|
|
usage: python3 q.py START END COLUMN [delta] (delta: print difference from previous measurement)"""
|
|
import sys, pickle, os
|
|
sys.path.insert(0, "tools/scripts")
|
|
import data
|
|
|
|
CACHE = os.path.join(os.path.dirname(__file__), "..", "work", "cache.pkl")
|
|
if os.path.exists(CACHE):
|
|
S, P = pickle.load(open(CACHE, "rb"))
|
|
else:
|
|
a, b = data.parse_time("2026-10-20T00:00Z"), data.parse_time("2026-11-02T00:00Z")
|
|
S = {s: [dict(m, t=m["t"].replace(second=0, microsecond=0)) for m in ms if a <= m["t"] <= b] for s, ms in data.load("data/JUNGFRAU").items()}
|
|
P = {p["t"].replace(second=0, microsecond=0): p for p in data.load_camera("data/JUNGFRAU") if a <= p["t"] <= b}
|
|
pickle.dump((S, P), open(CACHE, "wb"))
|
|
|
|
start, end, col = data.parse_time(sys.argv[1]), data.parse_time(sys.argv[2]), sys.argv[3]
|
|
delta = len(sys.argv) > 4
|
|
names = [s for s in S if s != "PM_G"]
|
|
refs = ["REF_CT", "REF_D", "REF_G"]
|
|
order = refs + sorted(n for n in names if n not in refs)
|
|
print("time " + " ".join(f"{n[:7]:>7}" for n in order) + " tilt pan rot scale sig0 nref")
|
|
prev = {}
|
|
by = {s: {m["t"]: m for m in S[s]} for s in order}
|
|
times = sorted({t for s in order for t in by[s] if start <= t <= end})
|
|
for t in times:
|
|
row = []
|
|
for s in order:
|
|
m = by[s].get(t)
|
|
v = m.get(col) if m else None
|
|
rej = m and data.rejected(m)
|
|
if v is None:
|
|
row.append(f"{'r' if rej else '-':>7}")
|
|
continue
|
|
out = v - prev[s] if delta and s in prev else (v if not delta else 0.0)
|
|
prev[s] = v
|
|
row.append(f"{out:7.3f}" + ("" if not rej else ""))
|
|
p = P.get(t)
|
|
nref = sum(1 for r in refs if by[r].get(t) and by[r][t].get("inlier") == 1)
|
|
pose = f"{p['tilt']:7.4f} {p['pan']:7.4f} {p['rotation']:6.3f} {p['scale']:.5f} {p['sigma0'] if p['sigma0'] is not None else float('nan'):5.2f}" if p else " no pose"
|
|
print(t.strftime("%d %H:%M") + " " + " ".join(row) + " " + pose + f" {nref}")
|