"""Run ranges.py (k=5) around a label and list the ranges that overlap its bounds, max |noises| per sensor. Usage: requal.py LABEL_START LABEL_END WIN_START WIN_END [extra ranges.py args...]""" import subprocess, sys, re s, e, ws, we, *extra = sys.argv[1:] out = subprocess.run(["python3", "tools/scripts/ranges.py", "data/CLARIDEN", "--columns", __import__("os").environ.get("COLS","corr_x,corr_y"), "--k", "5", "--start", ws, "--end", we] + extra, capture_output=True, text=True).stdout col = None; best = [] for line in out.splitlines(): m = re.match(r"(corr_[xy](?:_mm)?): ranges", line) if m: col = m.group(1); continue p = line.split() if col and len(p) >= 8 and re.match(r"\d{4}-", p[1] or ""): rs, re_ = p[1], p[2] if rs <= e and re_ >= s: best.append((abs(float(p[5])), col, p[0], rs, re_, p[3], p[5], p[6], p[4])) for b in sorted(best, reverse=True): print(f"{b[1]} {b[2]:8s} {b[3]} -> {b[4]} n={b[5]} value {b[8]} = {b[6]} noises at {b[7]}") if not best: print("no range beyond 5 noises inside the label")