#!/usr/bin/env python3 """qseries.py — run rendersnap across dual_b1q_*.rpp configs, extract steady scratch/FIR at bins 43/171 into one table vs the real cuts from NOTES 22x.""" import glob import os import subprocess import sys import numpy as np QS = ['0.1', '0.2', '0.3', '0.5', '0.7', '1.0', '1.5', '2.0', '3.0', '5.0', '10.0'] REAL = { # from NOTES_LEVEL 22x table: cut@500, cut@2000 '0.1': (10.32, 15.33), '0.5': (10.32, 11.82), '1.0': (10.32, 10.78), '3.0': (10.29, 10.32), '10': (9.94, 10.25), } RES2000 = {'0.1': 0.216, '0.5': 0.839, '1.0': 1.353, '3.0': 1.880, '10': 1.988} def steady_scratch(tag): fs = sorted(glob.glob(f'/tmp/opencode/rendersnap/phase*.npz')) best = None for f in fs[::-1]: z = np.load(f) sc = z['0x540628'] if abs(sc[43]) > 1e-6 and abs(sc[171] - sc[43]) > 1e-6 or (abs(sc[43]) > 1e-6): best = (sc[43], sc[171]) if abs(sc[171] - sc[43]) > 1e-4: break return best def main(): rows = [] for q in QS: rpp = f'/home/m/soothe-bt/dual_b1q_{q}.rpp' if not os.path.exists(rpp): continue subprocess.run( ['timeout', '100', 'python3', '/home/m/re-tools/scripts/rendersnap.py', rpp], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) st = steady_scratch(q) if not st: print(q, 'NO DATA') continue s43, s171 = st f43 = -20 * np.log10(np.exp(0.984 * s43)) f171 = -20 * np.log10(np.exp(0.984 * s171)) rc = REAL.get(q.rstrip('.0') if q.endswith('.0') else q) row = dict(q=q, scr43=round(s43, 4), scr171=round(s171, 4), fir43=round(f43, 2), fir171=round(f171, 2), x18_43=round(f43 * 1.805, 2), x18_171=round(f171 * 1.805, 2)) if rc: row['real43'], row['real171'] = rc row['ratio'] = round(rc[0] / f43, 3), round(rc[1] / f171, 3) if q in RES2000: row['res2000'] = RES2000[q] rows.append(row) print(row, flush=True) np.save('/tmp/opencode/qseries.npy', rows, allow_pickle=True) if __name__ == '__main__': main()