auto: the WYOMING analysis of 6-16 November and its labels; three old analyses removed (LENZSPITZE 1 Nov, NORDEND 4-7 and 5 Nov)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4fd623b3e1
commit
528336f9e5
51 files changed
+433
-657
No files matched your search
@@ -0,0 +1,43 @@
|
||||
"""Per hour: agitation of the far group (median over target_07..target_11 of |corr_y step| between consecutive
|
||||
measurements) and of the far references (|raw y step| of target_12, target_13), against MeteoSwiss wind, humidity,
|
||||
air temperature; then correlations. Also the lag between dx_RD and the housing temperature.
|
||||
|
||||
usage: python3 agitation.py
|
||||
"""
|
||||
import csv, statistics, sys
|
||||
sys.path.insert(0, "tools/scripts")
|
||||
import data
|
||||
|
||||
D = "labeling/auto/analyses/WYOMING_2026-11-06T0805_2026-11-16T0627/work/"
|
||||
start, end = data.parse_time("2026-11-06T08:15Z"), data.parse_time("2026-11-16T06:15Z")
|
||||
meas = data.load("data/WYOMING")
|
||||
w = {data.parse_time(r["time_utc"]): r for r in csv.DictReader(open(D + "weather_geneve.csv"))}
|
||||
FAR = ["target_%02d" % i for i in range(7, 12)]
|
||||
hours = {}
|
||||
for s in FAR + ["target_12", "target_13"]:
|
||||
v = [m for m in meas[s] if start <= m["t"] <= end]
|
||||
for a, b in zip(v, v[1:]):
|
||||
h = b["t"].replace(minute=0, second=0, microsecond=0)
|
||||
if s in FAR:
|
||||
if a["corr_y"] is not None and b["corr_y"] is not None:
|
||||
hours.setdefault(h, {}).setdefault("tgt", []).append(abs(b["corr_y"] - a["corr_y"]))
|
||||
elif not data.rejected(a) and not data.rejected(b):
|
||||
hours.setdefault(h, {}).setdefault("ref", []).append(abs(b["y"] - a["y"]))
|
||||
rows = []
|
||||
for h in sorted(hours):
|
||||
if h in w and "tgt" in hours[h] and "ref" in hours[h]:
|
||||
f = lambda k: float(w[h][k]) if w[h][k] else None
|
||||
rows.append((h, statistics.median(hours[h]["tgt"]), statistics.median(hours[h]["ref"]), f("wind_speed_kmh"),
|
||||
f("wind_gust_kmh"), f("humidity_pct"), f("temperature_c"), f("global_radiation_wm2")))
|
||||
by_day = {}
|
||||
for r in rows:
|
||||
by_day.setdefault(r[0].strftime("%m-%d"), []).append(r)
|
||||
print("day agit_tgt agit_ref wind gust (daily medians)")
|
||||
for d, rs in by_day.items():
|
||||
print(d, "%.3f %.3f %.1f %.1f" % tuple(statistics.median([x[i] for x in rs]) for i in (1, 2, 3, 4)))
|
||||
def corr(i, j):
|
||||
p = [(r[i], r[j]) for r in rows if r[i] is not None and r[j] is not None]
|
||||
return statistics.correlation(*zip(*p))
|
||||
for name, j in (("wind", 3), ("gust", 4), ("humidity", 5), ("air", 6), ("radiation", 7)):
|
||||
print(f"r(agit_tgt, {name}) = {corr(1, j):+.2f}; r(agit_ref, {name}) = {corr(2, j):+.2f}")
|
||||
print(f"r(agit_tgt, agit_ref) = {corr(1, 2):+.2f}; n = {len(rows)}")
|
||||
@@ -0,0 +1,25 @@
|
||||
"""Per 15-min measurement: median raw x and y shift of the far group (target_03..target_13) from its window median,
|
||||
RD and target_01 raw x shift, and corr_x of target_14, between hours H1 and H2 of each day.
|
||||
|
||||
usage: python3 far.py START END H1 H2
|
||||
"""
|
||||
import statistics, sys
|
||||
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])
|
||||
h1, h2 = int(sys.argv[3]), int(sys.argv[4])
|
||||
meas = data.load(F)
|
||||
FAR = ["target_%02d" % i for i in range(3, 14)]
|
||||
by = {s: {m["t"].replace(second=0, microsecond=0): m for m in v} for s, v in meas.items()}
|
||||
win = {s: [m for m in v if start <= m["t"] <= end] 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 win.items()}
|
||||
for t in sorted(by["RD"]):
|
||||
if not (start <= t <= end and h1 <= t.hour < h2):
|
||||
continue
|
||||
fx = statistics.median([by[s][t]["x"] - base[s][0] for s in FAR if t in by[s]])
|
||||
fy = statistics.median([by[s][t]["y"] - base[s][1] for s in FAR if t in by[s]])
|
||||
rd = by["RD"][t]["x"] - base["RD"][0]
|
||||
c14 = by["target_14"][t]["corr_x"]
|
||||
print(t.strftime("%m-%dT%H:%M"), "far_dx %+.2f far_dy %+.2f RD_dx %+.2f c14 %s" % (fx, fy, rd, "-" if c14 is None else "%+.2f" % c14))
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Figure for the report: housing temperature, raw sideways shift of the nearest prism (RD, target_01) against the far
|
||||
prisms, and corr_x of target_02, target_14, target_15, target_01, hourly medians from table.py's output.
|
||||
|
||||
usage: .venv/bin/python figure.py TABLE OUT.png
|
||||
"""
|
||||
import sys
|
||||
from datetime import datetime
|
||||
import matplotlib
|
||||
matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
rows = [l.rstrip("\n").split("\t") for l in open(sys.argv[1])]
|
||||
head, rows = rows[0], [r for r in rows[1:] if r[0] >= "11-06T08"]
|
||||
col = {h: i for i, h in enumerate(head)}
|
||||
t = [datetime.strptime("2026-" + r[0], "%Y-%m-%dT%H:%M") for r in rows]
|
||||
def v(name):
|
||||
return [float(r[col[name]]) if r[col[name]] != "-" else None for r in rows]
|
||||
fig, ax = plt.subplots(3, 1, figsize=(13, 9), sharex=True)
|
||||
ax[0].plot(t, v("temp"), "k"); ax[0].set_ylabel("camera housing\ntemperature [°C]")
|
||||
ax[1].plot(t, v("dx_RD"), label="RD (reference, same prism as target_01)"); ax[1].plot(t, v("dx_01"), label="target_01")
|
||||
for s in ("02", "14", "15"):
|
||||
ax[1].plot(t, v("dx_" + s), label="target_" + s)
|
||||
ax[1].set_ylabel("sideways shift in the image,\nagainst the far prisms [px]"); ax[1].legend(fontsize=8)
|
||||
for s in ("02", "14", "15", "01"):
|
||||
ax[2].plot(t, v("cx" + s), label="target_" + s)
|
||||
ax[2].set_ylabel("corrected curve in x [px]"); ax[2].legend(fontsize=8)
|
||||
for a in ax:
|
||||
a.grid(alpha=.3)
|
||||
fig.suptitle("WYOMING: the nearest prism shifts with the temperature, and the targets between the references take the shift (hourly, UTC)")
|
||||
fig.tight_layout(); fig.savefig(sys.argv[2], dpi=90); print(sys.argv[2])
|
||||
@@ -0,0 +1,35 @@
|
||||
"""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])
|
||||
@@ -0,0 +1,31 @@
|
||||
"""At chosen instants (and the measurement before and after): per sensor, corr_x and corr_y minus the median of the
|
||||
4 measurements on each side (without the instants +-1), error_value; R = rejected.
|
||||
|
||||
usage: python3 instants.py T1,T2,...
|
||||
"""
|
||||
import statistics, sys
|
||||
from datetime import timedelta
|
||||
sys.path.insert(0, "tools/scripts")
|
||||
import data
|
||||
|
||||
meas = data.load("data/WYOMING")
|
||||
by = {s: {m["t"].replace(second=0, microsecond=0): m for m in v} for s, v in meas.items()}
|
||||
q = timedelta(minutes=15)
|
||||
for txt in sys.argv[1].split(","):
|
||||
t0 = data.parse_time(txt)
|
||||
print("=== around", txt)
|
||||
for t in (t0 - q, t0, t0 + q):
|
||||
cells = []
|
||||
for s in sorted(by):
|
||||
if t not in by[s]:
|
||||
cells.append(s[-2:] + ":-"); continue
|
||||
m = by[s][t]
|
||||
if data.rejected(m):
|
||||
cells.append(s[-2:] + ":R"); continue
|
||||
nb = [by[s].get(t0 + k * q) for k in list(range(-6, -1)) + list(range(2, 7))]
|
||||
nb = [n for n in nb if n and n["corr_x"] is not None]
|
||||
dx = m["corr_x"] - statistics.median([n["corr_x"] for n in nb])
|
||||
dy = m["corr_y"] - statistics.median([n["corr_y"] for n in nb])
|
||||
flag = "*" if max(abs(dx), abs(dy)) > 0.08 else ""
|
||||
cells.append("%s:%+.2f/%+.2f%s" % (s[-2:], dx, dy, flag))
|
||||
print(t.strftime("%dT%H:%M"), " ".join(cells))
|
||||
@@ -0,0 +1,48 @@
|
||||
"""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)
|
||||
@@ -0,0 +1,42 @@
|
||||
"""Join the MeteoSwiss hourly weather (work/weather_geneve.csv) with table.py's hourly output (work/table_1h.txt):
|
||||
prints the joined table (every N hours) and correlations of dx_RD, temp (housing) with the weather columns, plus lags.
|
||||
|
||||
usage: python3 weather.py [EVERY]
|
||||
"""
|
||||
import csv, statistics, sys
|
||||
|
||||
D = "labeling/auto/analyses/WYOMING_2026-11-06T0805_2026-11-16T0627/work/"
|
||||
every = int(sys.argv[1]) if len(sys.argv) > 1 else 1
|
||||
w = {r["time_utc"][5:16]: r for r in csv.DictReader(open(D + "weather_geneve.csv"))}
|
||||
rows = [l.rstrip("\n").split("\t") for l in open(D + "table_1h.txt")]
|
||||
head, rows = rows[0], rows[1:]
|
||||
c = {h: i for i, h in enumerate(head)}
|
||||
W = ["temperature_c", "sunshine_min", "global_radiation_wm2", "precipitation_mm", "humidity_pct", "wind_speed_kmh", "wind_direction_deg"]
|
||||
joined = []
|
||||
for r in rows:
|
||||
k = r[0]
|
||||
if k in w:
|
||||
def f(x):
|
||||
try: return float(x)
|
||||
except ValueError: return None
|
||||
joined.append((k, f(r[c["temp"]]), f(r[c["dx_RD"]]), f(r[c["cx14"]]), *[f(w[k][x]) for x in W]))
|
||||
print("time housing dx_RD cx14 air sun rad rain hum wind wdir")
|
||||
for i, j in enumerate(joined):
|
||||
if i % every == 0 and j[0] >= "11-06T08":
|
||||
print(" ".join("-" if v is None else (v if isinstance(v, str) else "%.1f" % v) for v in j))
|
||||
|
||||
def corr(a, b):
|
||||
p = [(x, y) for x, y in zip(a, b) if x is not None and y is not None]
|
||||
xs, ys = zip(*p)
|
||||
return statistics.correlation(xs, ys), len(p)
|
||||
|
||||
sel = [j for j in joined if j[0] >= "11-06T08"]
|
||||
cols = {"housing": 1, "dx_RD": 2, "air": 4, "sun": 5, "rad": 6, "hum": 8, "wind": 9}
|
||||
for a in ("housing", "dx_RD"):
|
||||
for b in ("air", "rad", "sun", "hum", "wind") + (("housing",) if a == "dx_RD" else ()):
|
||||
r, n = corr([s[cols[a]] for s in sel], [s[cols[b]] for s in sel])
|
||||
print(f"r({a}, {b}) = {r:+.2f} (n={n})")
|
||||
# lag: dx_RD against air temperature shifted by L hours (air earlier)
|
||||
for L in (0, 1, 2, 3, 4, 6):
|
||||
a = [s[2] for s in sel[L:]]; b = [s[4] for s in sel[:len(sel) - L]]
|
||||
print(f"lag {L} h: r(dx_RD, air earlier) = {corr(a, b)[0]:+.2f}; r(housing, air earlier) = {corr([s[1] for s in sel[L:]], b)[0]:+.2f}")
|
||||
Reference in new issue
Block a user