"""Per-file accuracy + sample-count details.""" from __future__ import annotations import sys from pathlib import Path REPO = Path(__file__).resolve().parents[1] sys.path.insert(0, str(REPO)) from micromate.idf_file import read_idf_file from analysis_idf.recon import load_sidecar_samples def main(): root = REPO / "tests/fixtures/THORDATA_example" files = sorted([f for f in root.rglob("*.IDFW") if not str(f).endswith(".CDB")]) GEO_LSB = 0.0003 # Limit to first 15 successful files for detail. shown = 0 for f in files: try: res = read_idf_file(f) except Exception: continue sc_path = f.parent / "TXT" / f"{f.name}.txt" if not sc_path.exists(): continue sc = load_sidecar_samples(sc_path) sc_tran = [int(round(v / GEO_LSB)) for v in sc["Tran"]] dec = res.samples.get("Tran", []) n = min(len(sc_tran), len(dec)) exact = sum(1 for i in range(n) if sc_tran[i] == dec[i]) if n else 0 pct = 100.0 * exact / n if n else 0.0 print(f"{f.name:40s} size={f.stat().st_size:6d} sc_n={len(sc_tran):4d} dec_n={len(dec):4d} exact={pct:.1f}%") shown += 1 if shown >= 20: break if __name__ == "__main__": main()