"""Job 4221 (route 87 step check): read #1122's served output, report each LOW channel's position against the top edge of the H_SUB grid. Read-only, stdlib only, no simulation. Input: check-2083.out.json from return #1122 (sha256 67a4f8c7fbb5309be70cf4cc89772deb19d9b8625c3d511e7d9a399a90dfcfac, server-root /files/). Usage: python3 edge4221.py check-2083.out.json Output (stdout, deterministic): one JSON object. The extrapolated H values are forecasts from the last grid segment, not inversions. """ import hashlib, json, math, sys SHA = "67a4f8c7fbb5309be70cf4cc89772deb19d9b8625c3d511e7d9a399a90dfcfac" raw = open(sys.argv[1], "rb").read() assert hashlib.sha256(raw).hexdigest() == SHA, "not #1122's check-2083.out.json" o = json.loads(raw) grid = [0.30, 0.33, 0.36, 0.39, 0.42, 0.45, 0.48] # check-2083.py line 70 (H_SUB) n_lev = o["n_sub_lev"] low = o["part2"]["LOW"]["channels"] if "LOW" in o["part2"] else o["part2"]["table"]["LOW"]["channels"] out = {"grid_top": grid[-1], "n_sub_lev": n_lev, "channels": {}} for name, c in low.items(): m, means, sds = c["measured"], c["means"], c["sds"] top, prev = means[-1], means[-2] seg = (top - prev) / (grid[-1] - grid[-2]) n = o["n_sub_rho"] if name == "rho1" else n_lev mc_se_diff = math.hypot(sds[-1], sds[-2]) / math.sqrt(n) row = {"measured": round(m, 4), "inverted_H": None if c["inverted_H"] is None else round(c["inverted_H"], 3), "se_H": round(c["se_H"], 3), "family_top_two": [round(prev, 4), round(top, 4)], "last_segment_slope": round(seg, 3), "top_step_over_mc_se": round(abs(top - prev) / mc_se_diff, 2)} if c["inverted_H"] is None: gap = top - m row["gap_below_family_top"] = round(gap, 4) row["forecast_H_last_segment"] = round(grid[-1] + gap / abs(seg), 3) if seg else None row["forecast_H_endpoint_slope"] = round(grid[-1] + gap / abs(c["slope"]), 3) out["channels"][name] = row print(json.dumps(out, indent=1, sort_keys=True))