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