"""High-frequency comparison from a match.py analysis file. Usage: python3 hfcheck.py OUT_PREFIX ... For each prefix, prints the level of the recording and the simulation in the bands from 2.3 to 5.7 kHz at a few times after the onset, relative to 0.1 s, and the static balance (recording minus simulation at 0.1 s) of the 3.6 to 9 kHz bands relative to the 356 to 2263 Hz mids. """ import sys, numpy as np for out in sys.argv[1:]: a = np.load(f"{out}_analysis.npz") t, Er, Es, C, floor = a["t"], a["Er"], a["Es"], a["centers"], a["floor"] i0 = np.searchsorted(t, 0.1) times = [0.3, 0.6, 1.0, 1.5] idx = [np.searchsorted(t, x) for x in times] G0 = (Er - Es)[:, i0] mid = G0[(C >= 356) & (C <= 2263)].mean() hf = G0[(C >= 3592) & (C <= 9051)].mean() print(f"== {out}: high band excess of the simulation at the attack {mid - hf:+.1f} dB (0 = balanced)") print(" band recording drop (dB) at 0.3/0.6/1.0/1.5 s simulation drop recording floor") for c in (2263, 2851, 3592, 4525, 5702): b = int(np.argmin(np.abs(C - c))) r = " ".join(f"{Er[b, i] - Er[b, i0]:6.0f}" for i in idx) s = " ".join(f"{Es[b, i] - Es[b, i0]:6.0f}" for i in idx) print(f" {C[b]:5.0f} Hz {r} {s} {floor[b] - Er[b, i0]:6.0f}")