"""Verify decode_waveform_v2 against BW ASCII truth for all fixtures.""" import sys sys.path.insert(0, ".") from analysis.load_bundle import _parse_txt from minimateplus.waveform_codec import decode_waveform_v2 def main(): for stem in ("M529LL1A.SP0", "M529LL1A.SS0", "M529LL1A.SV0", "M529LL1L.JQ0", "M529LL1L.V70"): path = f"tests/fixtures/5-11-26/{stem}" with open(path, "rb") as f: body = f.read()[43:-26] _, samples = _parse_txt(path + ".TXT") decoded = decode_waveform_v2(body) if decoded is None: print(f"{stem}: decoder returned None") continue print(f"\n=== {stem} ===") for ch in ("Tran", "Vert", "Long"): truth = [round(v * 200) for v in samples[ch]] pred = decoded[ch] n = min(len(pred), len(truth)) matches = sum(1 for i in range(n) if pred[i] == truth[i]) div = next((i for i in range(n) if pred[i] != truth[i]), -1) print(f" {ch}: decoded={len(pred):>5} truth={len(truth):>5} " f"matches={matches:>5}/{n:<5} first div={div}") if __name__ == "__main__": main()