Files
resonance-engine/sample_baselines.py
T
2026-06-08 20:34:31 +07:00

46 lines
1.6 KiB
Python

"""Sample post-reset baselines for all telemetry fields.
Captures 60 frames (~60 s) from a quiescent lattice and reports mean/std
per field. Output matches the BASELINE_MEAN / BASELINE_STD dict structure
in fractonaut.py so we can paste it straight in.
"""
import zmq, json, time, statistics
FIELDS = ["asymmetry","coherence","vel_mean","vel_max","vel_var",
"vorticity_mean","stress_xx","stress_yy","stress_xy"]
ctx = zmq.Context()
tel = ctx.socket(zmq.SUB); tel.connect("tcp://127.0.0.1:5556")
tel.setsockopt_string(zmq.SUBSCRIBE, "")
time.sleep(0.5)
frames = []
print("Capturing 60 frames...", flush=True)
for i in range(60):
raw = tel.recv_string()
f = json.loads(raw)
if i == 0:
print(f" cycle_start={f['cycle']} khra={f['khra_amp']} gixx={f['gixx_amp']} omega={f['omega']}", flush=True)
frames.append(f)
print(f" cycle_end={frames[-1]['cycle']} ({frames[-1]['cycle']-frames[0]['cycle']} cycles spanned)")
products = []
print("\nBASELINE_MEAN = {")
for f in FIELDS:
vals = [fr[f] for fr in frames]
m = statistics.mean(vals)
print(f' "{f}":{" "*(16-len(f))} {m:.6f},')
print("}")
print("\nBASELINE_STD = {")
for f in FIELDS:
vals = [fr[f] for fr in frames]
s = statistics.stdev(vals) if len(vals) > 1 else 0.0
print(f' "{f}":{" "*(16-len(f))} {max(s, 1e-9):.6f},')
print("}")
# regime product
for fr in frames:
products.append(fr["asymmetry"] * fr["coherence"])
print(f"\nregime_product: mean={statistics.mean(products):.4f} std={statistics.stdev(products):.4f} min={min(products):.4f} max={max(products):.4f}")