"""Compare event-c and event-d (same N_samples) to find header vs data bytes.""" import sys sys.path.insert(0, ".") from analysis.load_bundle import load_bundle def main(): bc = load_bundle("event-c") bd = load_bundle("event-d") # Compare prefixes nc, nd = len(bc.body), len(bd.body) n = min(nc, nd) diffs = [] for i in range(n): if bc.body[i] != bd.body[i]: diffs.append(i) print(f"event-c body={nc}, event-d body={nd}") print(f"Total diffs (first {n}): {len(diffs)}") # Show common prefix same_prefix = 0 for i in range(n): if bc.body[i] == bd.body[i]: same_prefix += 1 else: break print(f"Common prefix length: {same_prefix}") print(f"event-c prefix: {bc.body[:same_prefix].hex(' ')}") # Look for runs of common bytes print(f"\nFirst 32 diff positions: {diffs[:32]}") # Show the "diff fingerprint" of the first 100 bytes print(f"\n pos c d") for i in range(0, 100): marker = " " if bc.body[i] == bd.body[i] else "*" bd_b = bd.body[i] if i < nd else None print(f" {i:>3} {bc.body[i]:02x}{marker} {bd_b:02x}" if bd_b is not None else f" {i:>3} {bc.body[i]:02x}{marker}") if __name__ == "__main__": main()