#!/usr/bin/env python3 """POST HOC SENSITIVITY for RULES_A A5 (not pre-registered): a harder stand-in for the SEP/GCR ratio near 1 GV. A5 used the largest standard neutron-monitor increase (~10 %) as the SEP/GCR ratio above ~1 GV. Neutron monitors weight high rigidities, so that may understate the SEP share. Here we instead take GOES-16's P11 channel (>500 MeV, i.e. >1.09 GV): its 11 May maximum over its 00:00-01:00 UT level gives the SEP/GCR ratio above 1.09 GV at geostationary orbit. Spectra as in A5 (SEP: gamma = 5, no roll-off, harder than every published fit; GCR: P^-2.7): share(Rc) = ratio_1.09 x (Rc/1.09)^-(5-1) / (Rc/1.09)^-1.7 = ratio_1.09 x (Rc/1.09)^-2.3 Usage: python3 -I a5_sensitivity_post_hoc.py OUT_DIR (reads OUT_DIR/AB_results.json and descriptive_post_hoc.json) """ import json import os import sys sys.stdout.reconfigure(encoding="utf-8") OUT = sys.argv[1] ab = json.load(open(os.path.join(OUT, "AB_results.json"), encoding="utf-8")) dp = json.load(open(os.path.join(OUT, "descriptive_post_hoc.json"), encoding="utf-8")) g = dp["goes16_30min_11May"] res = {"note": "post hoc sensitivity, not pre-registered"} for u in (0, 1): base = (g["2024-05-11 00:00:00"][f"unit{u}_P11"] + g["2024-05-11 00:30:00"][f"unit{u}_P11"]) / 2 peak = ab["B"]["B5_goes16"][f"unit{u}"]["P11"]["max_11May"][0] ratio = (peak - base) / base rec = {"P11_base_pfu": round(base, 3), "P11_max_pfu": peak, "ratio_above_1.09GV": round(ratio, 2)} for site in ("KAK", "CHF", "BGL", "PRL"): for lab, rc in (("quiet", ab["A1"][site]["Rc_grid_2015_GV"]), ("cut50", ab["A3"]["cut_50pct"][site]), ("cut57", ab["A3"]["cut_57pct"][site])): rec[f"{site}_{lab}_Rc{rc}"] = f"{100 * ratio * (rc / 1.09) ** -2.3:.2g} %" res[f"unit{u}"] = rec json.dump(res, open(os.path.join(OUT, "A5_sensitivity_post_hoc.json"), "w", encoding="utf-8", newline="\n"), indent=1) print(json.dumps(res, indent=1))