110 lines
4.5 KiB
Python
110 lines
4.5 KiB
Python
"""Extract trade_lbm_v1 baseline ranges from validation_20260608_205129 outputs.
|
|
|
|
Pulls:
|
|
- scalars (asymmetry, coherence, regime_product) from events_*.jsonl per-snapshot rows
|
|
- minute_idx for splitting quiet vs active windows
|
|
- density/divergence/vorticity profile stats from the Fractonaut question text
|
|
"""
|
|
import json, sys, re, os
|
|
from statistics import mean, median, pstdev
|
|
|
|
RUN = "/mnt/d/Resonance_Engine/traj/validation_20260608_205129"
|
|
|
|
def pct(xs, p):
|
|
if not xs: return None
|
|
s = sorted(xs)
|
|
k = max(0, min(len(s)-1, int(round((p/100.0)*(len(s)-1)))))
|
|
return s[k]
|
|
|
|
def summarise(name, xs):
|
|
if not xs:
|
|
print(f" {name}: (no data)")
|
|
return
|
|
print(f" {name}: n={len(xs)} min={min(xs):.4f} p05={pct(xs,5):.4f} p25={pct(xs,25):.4f} "
|
|
f"median={median(xs):.4f} p75={pct(xs,75):.4f} p95={pct(xs,95):.4f} max={max(xs):.4f} mean={mean(xs):.4f}")
|
|
|
|
def load_events(label):
|
|
path = os.path.join(RUN, f"events_{label}.jsonl")
|
|
return [json.loads(l) for l in open(path)]
|
|
|
|
def load_frames(label):
|
|
path = os.path.join(RUN, f"frames_{label}.jsonl")
|
|
return [json.loads(l) for l in open(path)]
|
|
|
|
def split_scalars(rows, lo=None, hi=None):
|
|
asy, coh, reg = [], [], []
|
|
for r in rows:
|
|
m = r.get("minute_idx", 0)
|
|
if lo is not None and m < lo: continue
|
|
if hi is not None and m > hi: continue
|
|
asy.append(float(r.get("field_asy", r.get("asymmetry", 0))))
|
|
coh.append(float(r.get("field_coh", r.get("coherence", 0))))
|
|
reg.append(float(r.get("regime_product", 0)))
|
|
return asy, coh, reg
|
|
|
|
# === EVENT B (consolidation, 12 h) ===
|
|
ev_b = load_events("EVENT_B_consolidation")
|
|
fr_b = load_frames("EVENT_B_consolidation")
|
|
print(f"=== EVENT B (consolidation 12h) events={len(ev_b)} frames={len(fr_b)} ===")
|
|
asy, coh, reg = split_scalars(ev_b)
|
|
print("[all rows, both warmup and post]")
|
|
summarise("asymmetry", asy)
|
|
summarise("coherence", coh)
|
|
summarise("regime_product", reg)
|
|
|
|
asy2, coh2, reg2 = split_scalars(ev_b, lo=30)
|
|
print("[post-warmup rows, minute_idx>=30]")
|
|
summarise("asymmetry", asy2)
|
|
summarise("coherence", coh2)
|
|
summarise("regime_product", reg2)
|
|
|
|
# === EVENT A (breakout, 3 h) ===
|
|
ev_a = load_events("EVENT_A_breakout")
|
|
fr_a = load_frames("EVENT_A_breakout")
|
|
print(f"\n=== EVENT A (breakout 3h) events={len(ev_a)} frames={len(fr_a)} ===")
|
|
asy, coh, reg = split_scalars(ev_a)
|
|
print("[all rows]")
|
|
summarise("asymmetry", asy)
|
|
summarise("coherence", coh)
|
|
summarise("regime_product", reg)
|
|
|
|
asy_q, coh_q, reg_q = split_scalars(ev_a, lo=0, hi=88) # before move
|
|
asy_m, coh_m, reg_m = split_scalars(ev_a, lo=89, hi=149) # during move
|
|
asy_p, coh_p, reg_p = split_scalars(ev_a, lo=150) # after
|
|
print("[quiet pre-move, minute_idx in 0..88]")
|
|
summarise("asymmetry", asy_q); summarise("coherence", coh_q); summarise("regime_product", reg_q)
|
|
print("[active move, minute_idx in 89..149]")
|
|
summarise("asymmetry", asy_m); summarise("coherence", coh_m); summarise("regime_product", reg_m)
|
|
print("[post-move, minute_idx >= 150]")
|
|
summarise("asymmetry", asy_p); summarise("coherence", coh_p); summarise("regime_product", reg_p)
|
|
|
|
# === Density / divergence / vorticity profile stats from Fractonaut Q text ===
|
|
fract = [json.loads(l) for l in open(os.path.join(RUN, "fractonaut_validation.jsonl"))]
|
|
dens_mean, dens_std, div_std, vort_std, dens_min, dens_max, div_min, div_max = [],[],[],[],[],[],[],[]
|
|
re_dens = re.compile(r"density_profile.*?min=([\-\d.]+)\s+max=([\-\d.]+)\s+mean=([\-\d.]+)\s+std=([\-\d.]+)")
|
|
re_div = re.compile(r"divergence_profile.*?min=([\-\d.]+)\s+max=([\-\d.]+)\s+mean=([\-\d.]+)\s+std=([\-\d.]+)")
|
|
re_vort = re.compile(r"vorticity_profile.*?min=([\-\d.]+)\s+max=([\-\d.]+)\s+mean=([\-\d.]+)\s+std=([\-\d.]+)")
|
|
for j in fract:
|
|
q = j.get("question", "")
|
|
m = re_dens.search(q)
|
|
if m:
|
|
dens_min.append(float(m.group(1))); dens_max.append(float(m.group(2)))
|
|
dens_mean.append(float(m.group(3))); dens_std.append(float(m.group(4)))
|
|
m = re_div.search(q)
|
|
if m:
|
|
div_min.append(float(m.group(1))); div_max.append(float(m.group(2)))
|
|
div_std.append(float(m.group(4)))
|
|
m = re_vort.search(q)
|
|
if m:
|
|
vort_std.append(float(m.group(4)))
|
|
|
|
print(f"\n=== Profile stats sampled at event firings (n={len(dens_mean)}) ===")
|
|
summarise("density_min", dens_min)
|
|
summarise("density_max", dens_max)
|
|
summarise("density_mean", dens_mean)
|
|
summarise("density_std", dens_std)
|
|
summarise("divergence_min", div_min)
|
|
summarise("divergence_max", div_max)
|
|
summarise("divergence_std", div_std)
|
|
summarise("vorticity_std", vort_std)
|