Files
aimsight-optimizer/sessions/WILDSTRUBEL_2026-09-24T0230_2026-10-06T1945_20261118T1119Z/tools/thermal_split.py
T

19 lines
933 B
Python

# Reads thermal_days.out; for thresholds K on the largest dev2, the labelled and unlabelled instants kept and dropped, per station.
# Usage: python3 thermal_split.py <thermal_days.out> K [K ...]
import re
import sys
rows = []
for line in open(sys.argv[1]):
m = re.match(r"(\S+) .* n=\s*(\d+) lab=\s*(\d+) dev2=\[(.*)\]", line)
if m:
top = [float(x) for x in m.group(4).split(",") if x.strip()]
rows.append((m.group(1), int(m.group(2)), int(m.group(3)), top[0] if top else 0.0))
for k in map(float, sys.argv[2:]):
print(f"K={k}")
for st in sorted({r[0] for r in rows}):
rs = [r for r in rows if r[0] == st]
lab = sum(r[2] for r in rs); unl = sum(r[1] - r[2] for r in rs)
lab_drop = sum(r[2] for r in rs if r[3] < k); unl_drop = sum(r[1] - r[2] for r in rs if r[3] < k)
print(f" {st:12} labelled {lab:5} dropped {lab_drop:5} | unlabelled {unl:5} dropped {unl_drop:5}")