Files
aimsight-labeling/auto/analyses/CLARIDEN_2026-10-01T0000_2026-10-11T0000/scripts/tilt_fig.py
T

40 lines
1.6 KiB
Python

"""Figure: D-303-B corrected vertical curve against the camera tilt, 5 to 11 October (hourly medians).
Usage: .venv/bin/python tilt_fig.py OUT.png"""
import sys, statistics
from collections import defaultdict
sys.path.insert(0, "tools/scripts")
import data
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
p = data.parse_time
t0, t1 = p("2026-10-05T11:00Z"), p("2026-10-11T00:00Z")
M = data.load("data/CLARIDEN")
P = data.load_camera("data/CLARIDEN")
def hourly(pairs):
h = defaultdict(list)
for t, v in pairs:
h[t.replace(minute=0, second=0, microsecond=0)].append(v)
return sorted((k, statistics.median(v)) for k, v in h.items())
tilt = hourly([(q["t"], q["tilt"]) for q in P if t0 <= q["t"] <= t1 and q["tilt"] is not None])
cy = hourly([(m["t"], m["corr_y"]) for m in M["D-303-B"] if t0 <= m["t"] <= t1 and m["corr_y"] is not None])
fig, ax = plt.subplots(figsize=(11, 4))
ax.plot([t for t, _ in cy], [v for _, v in cy], color="tab:blue", label="D-303-B corrected vertical [px]")
ax.set_ylabel("D-303-B corrected vertical [px]", color="tab:blue")
ax2 = ax.twinx()
ax2.plot([t for t, _ in tilt], [v for _, v in tilt], color="tab:red", label="camera tilt [deg] (axis reversed)")
ax2.invert_yaxis()
ax2.set_ylabel("camera tilt [deg], reversed", color="tab:red")
for a, b in [("2026-10-06T13:00Z", "2026-10-06T13:30Z"), ("2026-10-08T08:50Z", "2026-10-08T09:10Z")]:
ax.axvspan(p(a), p(b), color="grey", alpha=0.3)
ax.set_title("CLARIDEN: D-303-B follows the camera tilt (hourly medians, UTC); grey: the two tilt steps")
fig.autofmt_xdate()
fig.tight_layout()
fig.savefig(sys.argv[1], dpi=90)
print(sys.argv[1])