"""Report figure: MeteoSwiss Genève-Cointrin air temperature, wind, sunshine against the housing temperature, the nearest prism's shift (dx_RD) and the hourly agitation of the far targets (from agitation.py's computation). usage: .venv/bin/python figure_weather.py OUT.png """ import csv, statistics, sys sys.path.insert(0, "tools/scripts") import data import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt D = "labeling/auto/analyses/WYOMING_2026-11-06T0805_2026-11-16T0627/" src = open(D + "scripts/agitation.py").read().split("by_day = {}")[0] ns = {} exec(src, ns) rows = ns["rows"] t = [r[0] for r in rows] tab = {l.split("\t")[0]: l.rstrip("\n").split("\t") for l in open(D + "work/table_1h.txt")} house = [float(tab[x.strftime("%m-%dT%H:%M")][1]) for x in t] dx = [float(tab[x.strftime("%m-%dT%H:%M")][4]) for x in t] w = {data.parse_time(r["time_utc"]): r for r in csv.DictReader(open(D + "work/weather_geneve.csv"))} sun = [float(w[x]["sunshine_min"] or 0) for x in t] fig, ax = plt.subplots(4, 1, figsize=(13, 10), sharex=True) ax[0].plot(t, house, "k", label="housing temperature"); a2 = ax[0].twinx() a2.plot(t, [r[6] for r in rows], "tab:red", label="air, Genève-Cointrin"); ax[0].set_ylabel("housing [°C]"); a2.set_ylabel("air [°C]", color="tab:red") ax[1].plot(t, dx, "tab:blue"); ax[1].set_ylabel("RD = target_01 raw x\nminus far prisms [px]") ax[2].plot(t, [r[1] for r in rows], "tab:purple", label="far targets 07-11, |corr_y step|") ax[2].plot(t, [r[2] for r in rows], "tab:orange", alpha=.6, label="refs 12/13, |raw y step|"); ax[2].set_ylabel("agitation [px]"); ax[2].legend(fontsize=8) ax[3].plot(t, [r[3] for r in rows], "tab:green", label="wind [km/h]"); ax[3].bar(t, sun, width=0.04, color="gold", label="sunshine [min/h]") ax[3].set_ylabel("wind, sun"); ax[3].legend(fontsize=8) for a in ax: a.grid(alpha=.3) fig.suptitle("WYOMING against the MeteoSwiss weather of Genève-Cointrin (hourly, UTC)") fig.tight_layout(); fig.savefig(sys.argv[1], dpi=90); print(sys.argv[1])