031 — High-confidence window selection (reference)

031 — High-confidence window selection (reference)#

Reference implementation of calibration-window selection from cycle quality scores. Superseded by notebook 032 (physically grounded selector) for production runs; kept here for methodology audit.

The library function is the same — WindowSelector.score_cycles() + identify_windows() — only the config thresholds differ.

import pandas as pd
from palmwtc.config import DataPaths
from palmwtc.windows import WindowSelector

paths = DataPaths.resolve()
print(paths.describe())
DataPaths (source=sample (bundled synthetic), site=libz):
  raw_dir       = /home/runner/work/palmwtc/palmwtc/src/palmwtc/data/sample/synthetic
  processed_dir = /home/runner/work/palmwtc/palmwtc/src/palmwtc/data/sample/Data/Integrated_QC_Data
  exports_dir   = /home/runner/work/palmwtc/palmwtc/src/palmwtc/data/sample/exports
  config_dir    = /home/runner/work/palmwtc/palmwtc/src/palmwtc/data/sample/config
  extras        = <none>
cycles_path = paths.exports_dir / "digital_twin" / "01_chamber_cycles.csv"
if not cycles_path.exists():
    print("[note] cycles not built yet; run notebook 030 first or `palmwtc run`.")
else:
    cycles = pd.read_csv(cycles_path)
    if "flux_datetime" not in cycles.columns and "flux_date" in cycles.columns:
        cycles["flux_datetime"] = pd.to_datetime(cycles["flux_date"])

    selector = WindowSelector(cycles_df=cycles)
    selector.score_cycles()
    selector.identify_windows()
    n_windows = len(selector.windows_df) if selector.windows_df is not None else 0
    print(f"{n_windows} windows selected from {len(cycles)} cycles (reference config)")
0 windows selected from 3 cycles (reference config)

032 is the production selector — it adds physical-grounding constraints (SNR floor, duration, cross-chamber agreement) on top of these scores.