"""Quick inspection of the new high-amplitude events.""" import os, re, sys sys.path.insert(0, ".") from analysis.load_bundle import _parse_txt from minimateplus.waveform_codec import walk_body, find_data_start ROOT = "decode-re/5-11-26" def main(): for stem in ("M529LL1A.SP0", "M529LL1A.SS0", "M529LL1A.SV0"): bin_path = os.path.join(ROOT, stem) txt_path = bin_path + ".TXT" with open(bin_path, "rb") as f: raw = f.read() body = raw[43:-26] meta, samples = _parse_txt(txt_path) n = len(samples["Tran"]) print(f"\n=== {stem} ===") print(f" file={len(raw)}, body={len(body)}, N_samples={n}") print(f" rectime={meta.get('Record Time')} pretrig={meta.get('Pre-trigger Length')}") print(f" PPV(T,V,L)={meta.get('Tran PPV')} / {meta.get('Vert PPV')} / {meta.get('Long PPV')}") # Show first few non-trivial samples print(f" First 5 truth samples (in/s):") for i in range(5): print(f" T={samples['Tran'][i]:8.3f} V={samples['Vert'][i]:8.3f} " f"L={samples['Long'][i]:8.3f} M={samples['MicL'][i]:8.3f}") # Peak sample positions for ch in ("Tran", "Vert", "Long"): vals = samples[ch] peak_i = max(range(n), key=lambda i: abs(vals[i])) print(f" {ch}: peak {vals[peak_i]:.3f} at sample {peak_i} (t={peak_i/1024:.3f}s)") # Body structure start = find_data_start(body) blocks = walk_body(body, start) types = {} for b in blocks: types[b.tag_hi] = types.get(b.tag_hi, 0) + 1 print(f" body start={start}, total blocks walked: {len(blocks)}") print(f" block tag counts: {types}") # How far the walker got if blocks: last = blocks[-1] walked = last.offset + last.length print(f" walker stopped at offset {walked}/{len(body)} ({100*walked/len(body):.0f}%)") if __name__ == "__main__": main()