improve: S2
metrics: --sensors A,B adds each sensor's own corr_x, corr_y minus its level (table, r, on the targets' panel) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e17202d596
commit
84cfd6925b
1 file changed
+16
-3
+16
-3
@@ -3,12 +3,14 @@ against the target median of corr_x, corr_y and the camera pose.
|
|||||||
|
|
||||||
Usage: .venv/bin/python tools/scripts/metrics.py data/PS_DES_COUDRES/
|
Usage: .venv/bin/python tools/scripts/metrics.py data/PS_DES_COUDRES/
|
||||||
[--names sensor_A0_deg_c,BusVoltage] [--step 1h] [--stat median|min|max] [--against temperature] [--smoothing 24h]
|
[--names sensor_A0_deg_c,BusVoltage] [--step 1h] [--stat median|min|max] [--against temperature] [--smoothing 24h]
|
||||||
[--metrics-only] [--weather [precipitation_mm,temperature_c,...]] [--start ...] [--end ...] [--out FOLDER]
|
[--metrics-only] [--weather [precipitation_mm,temperature_c,...]] [--sensors A,B] [--start ...] [--end ...]
|
||||||
|
[--out FOLDER]
|
||||||
|
|
||||||
Columns: `temperature` (median of the sensor_*_deg_c components at each hour, as the detectors read it,
|
Columns: `temperature` (median of the sensor_*_deg_c components at each hour, as the detectors read it,
|
||||||
data.load_temperature), then each metric of --names (default: the *_deg_c and BusVoltage present), then,
|
data.load_temperature), then each metric of --names (default: the *_deg_c and BusVoltage present), then,
|
||||||
unless --metrics-only, tgt_corr_x, tgt_corr_y (at each measurement, median over the targets of corr minus the target's
|
unless --metrics-only, tgt_corr_x, tgt_corr_y (at each measurement, median over the targets of corr minus the target's
|
||||||
own level, its median over the window; accepted measurements only) and the raw camera pose (cam_pan,
|
own level, its median over the window; accepted measurements only), with --sensors A,B the same for each of these
|
||||||
|
sensors alone (A_corr_x, A_corr_y: one sensor that follows the temperature where the median does not), and the raw camera pose (cam_pan,
|
||||||
cam_tilt, cam_rotation, cam_scale, cam_sigma0); with --weather, the hourly MeteoSwiss weather of weather/
|
cam_tilt, cam_rotation, cam_scale, cam_sigma0); with --weather, the hourly MeteoSwiss weather of weather/
|
||||||
(data.load_weather; the hour starting at time_utc), one w_<column> column each (default WEATHER), and where it was
|
(data.load_weather; the hour starting at time_utc), one w_<column> column each (default WEATHER), and where it was
|
||||||
measured is printed first. An empty cell of a metrics/ CSV is skipped, not read as zero.
|
measured is printed first. An empty cell of a metrics/ CSV is skipped, not read as zero.
|
||||||
@@ -101,6 +103,7 @@ def main():
|
|||||||
a.add_argument("--metrics-only", action="store_true", help="without tgt_corr_x, tgt_corr_y or the pose")
|
a.add_argument("--metrics-only", action="store_true", help="without tgt_corr_x, tgt_corr_y or the pose")
|
||||||
a.add_argument("--weather", nargs="?", const=WEATHER, metavar="COLUMNS",
|
a.add_argument("--weather", nargs="?", const=WEATHER, metavar="COLUMNS",
|
||||||
help=f"add the weather/ columns, comma-separated (without a value: {WEATHER})")
|
help=f"add the weather/ columns, comma-separated (without a value: {WEATHER})")
|
||||||
|
a.add_argument("--sensors", help="sensors, comma-separated: their own corr_x, corr_y minus their level, as columns")
|
||||||
a.add_argument("--start", type=parse_time)
|
a.add_argument("--start", type=parse_time)
|
||||||
a.add_argument("--end", type=parse_time)
|
a.add_argument("--end", type=parse_time)
|
||||||
a.add_argument("--out", default=os.path.join("out", "diagnostic"), help="folder of the PNG")
|
a.add_argument("--out", default=os.path.join("out", "diagnostic"), help="folder of the PNG")
|
||||||
@@ -128,6 +131,7 @@ def main():
|
|||||||
sys.exit(f"--against {o.against}: not a column ({', '.join(series)}).")
|
sys.exit(f"--against {o.against}: not a column ({', '.join(series)}).")
|
||||||
series[o.against + "_smooth"] = smooth(series[o.against], o.smoothing)
|
series[o.against + "_smooth"] = smooth(series[o.against], o.smoothing)
|
||||||
metric_cols = list(series)
|
metric_cols = list(series)
|
||||||
|
sensor_cols = set() # columns of --sensors
|
||||||
if o.weather:
|
if o.weather:
|
||||||
hours = load_weather(o.folder)
|
hours = load_weather(o.folder)
|
||||||
if not hours:
|
if not hours:
|
||||||
@@ -146,6 +150,14 @@ def main():
|
|||||||
by_sensor = load(o.folder)
|
by_sensor = load(o.folder)
|
||||||
for c in ("corr_x", "corr_y"):
|
for c in ("corr_x", "corr_y"):
|
||||||
series["tgt_" + c] = targets(by_sensor, c, o.start, o.end)
|
series["tgt_" + c] = targets(by_sensor, c, o.start, o.end)
|
||||||
|
for s in o.sensors.split(",") if o.sensors else []:
|
||||||
|
if s not in by_sensor:
|
||||||
|
sys.exit(f"Unknown sensor: {s}. Known: {', '.join(by_sensor)}.")
|
||||||
|
for c in ("corr_x", "corr_y"):
|
||||||
|
ms = [m for m in filter_window(by_sensor[s], o.start, o.end) if m[c] is not None]
|
||||||
|
level = statistics.median(m[c] for m in ms) if ms else 0
|
||||||
|
series[f"{s}_{c}"] = [{"t": m["t"], "v": m[c] - level} for m in ms]
|
||||||
|
sensor_cols.add(f"{s}_{c}")
|
||||||
poses = filter_window(load_camera(o.folder), o.start, o.end)
|
poses = filter_window(load_camera(o.folder), o.start, o.end)
|
||||||
for c in POSE:
|
for c in POSE:
|
||||||
series["cam_" + c] = [{"t": p["t"], "v": p[c]} for p in poses if p[c] is not None]
|
series["cam_" + c] = [{"t": p["t"], "v": p[c]} for p in poses if p[c] is not None]
|
||||||
@@ -213,7 +225,8 @@ def main():
|
|||||||
panels = {} # title -> columns
|
panels = {} # title -> columns
|
||||||
for c in columns:
|
for c in columns:
|
||||||
if any(isinstance(p["v"], float) for p in series[c]):
|
if any(isinstance(p["v"], float) for p in series[c]):
|
||||||
key = "°C" if c.startswith("temperature") or "_deg_c" in c else c
|
key = ("°C" if c.startswith("temperature") or "_deg_c" in c
|
||||||
|
else "tgt_" + c[-6:] if c in sensor_cols else c) # a sensor's corr on the panel of the targets'
|
||||||
panels.setdefault(key, []).append(c)
|
panels.setdefault(key, []).append(c)
|
||||||
if not panels:
|
if not panels:
|
||||||
print("\nNothing to plot.")
|
print("\nNothing to plot.")
|
||||||
|
|||||||
Reference in new issue
Block a user