This commit is contained in:
david rice
2026-05-07 12:10:02 +01:00
5 changed files with 390 additions and 35 deletions

View File

@@ -892,12 +892,27 @@ def analyze_lp_file(path: Path) -> "LPMetrics":
HS : voltage in mid-range with high oscillation (rolling std > HS_OSC_STD_V)
trans : everything else (transitions between states)
"""
m = re.match(r"(\d{8}_\d{6})_lp_(\d+)_(clk|dat)\.csv", path.name, re.IGNORECASE)
# Accept three filename formats:
# legacy: "_lp_0001_"
# watch: "_lp_c001_01_"
# segmented: "_lp_c001_01_seg005_" (one segment exploded from H5)
m = re.match(
r"(\d{8}_\d{6})_lp_(c\d+_\d+(?:_seg\d+)?|\d+)_(clk|dat)\.csv",
path.name, re.IGNORECASE,
)
if not m:
raise ValueError(f"Filename does not match lp pattern: {path.name}")
timestamp, cap_str, channel = m.groups()
capture_num = int(cap_str)
# Derive an int capture_num from whatever digits the id contains, so it
# remains sortable (e.g., c001_01_seg005 → 1*1_000_000 + 1*1_000 + 5).
digit_groups = re.findall(r"\d+", cap_str)
if len(digit_groups) == 1:
capture_num = int(digit_groups[0])
else:
capture_num = 0
for i, d in enumerate(reversed(digit_groups)):
capture_num += int(d) * (1000 ** i)
times, volts = _read_csv(path)
dt = float(np.diff(times).mean())