"""Robustness of the MEPED outer-split statistic (S1 of RULES_meped.txt) under the settings R1-R5 of RULES_belts.txt. Fact-Checked Science ("Our analysis"), 16 November 2026, for the check of Pierrard et al. (2026), npj Space Exploration 2, 43 (doi:10.1038/s44453-026-00064-7). What it does Reads the 6-hour x 0.1-L MEPED bins that meped_test.py saved (meped_bins_.npz) and recomputes, for every control and storm window and its pre-storm baseline, the longest run of days with a split outer zone: S1 (two or more persistent slots at L >= 2.0, pre-registered) and, post hoc, the same with one slot at L 2.2-3.2 and one at L 3.3-4.5 ("outer_split_Lrestricted"). Settings: the pre-registered ones, R1-R5 and X1 (no smoothing). This reports robustness beside the pre-registered result; it is not a new test. Needs Python 3.9+, numpy, scipy, netCDF4, and belts_a.py and meped_test.py in the same folder as this script. Run python3 meped_robust.py Writes meped_robustness.json in that folder, and prints one line per window: S1/S1_base (Lrestricted/Lrestricted_base). """ import datetime as dt import json import os import sys import warnings import numpy as np sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import belts_a as A # noqa: E402 import meped_test as M # noqa: E402 warnings.simplefilter("ignore", RuntimeWarning) def main(): if len(sys.argv) != 2: sys.exit("usage: python3 meped_robust.py ") folder = sys.argv[1] settings = {"primary": {}, "R1_P0.05": dict(P=0.05), "R2_P0.20": dict(P=0.20), "R3_kernel5": dict(kernel=(1, 4, 6, 4, 1)), "R4_strict": dict(max_miss=0), "R5_L1.3-6.0": dict(Lmin=1.3, Lmax=6.0), "X1_nosmooth": dict(kernel=(1,))} out = {} for name, kind, (d0, d1), window, baseline in M.CASES: z = np.load(os.path.join(folder, f"meped_bins_{name}.npz")) t0 = dt.datetime.combine(d0, dt.time()) times = [t0 + dt.timedelta(hours=6 * k + 3) for k in range(z["mean"].shape[0])] days, daily = A.daily_means(times, z["mean"][:, :, None], 6.0) row = {} for sname, ch in settings.items(): s = dict(A.PRIMARY) s.update(ch) r = A.analyse(days, daily, M.LC, s, 1)[0] ok = np.array([any(2.2 <= tr["Lmed"] < 3.2 for tr in r["present"][t]) and any(3.3 <= tr["Lmed"] <= 4.5 for tr in r["present"][t]) for t in range(len(days))]) s1 = np.array([sum(1 for tr in r["present"][t] if tr["Lmed"] >= 2.0) >= 2 for t in range(len(days))]) row[sname] = dict(S1=M.longest_run(s1, days, *window)[0], S1_base=M.longest_run(s1, days, *baseline)[0], outer_split_Lrestricted=M.longest_run(ok, days, *window)[0], outer_split_Lrestricted_base=M.longest_run(ok, days, *baseline)[0]) out[name] = row print(name.ljust(22), " | ".join(f"{k}: {v['S1']}/{v['S1_base']} ({v['outer_split_Lrestricted']}/" f"{v['outer_split_Lrestricted_base']})" for k, v in row.items())) with open(os.path.join(folder, "meped_robustness.json"), "w", newline="\n", encoding="utf-8") as f: json.dump(out, f, indent=1) if __name__ == "__main__": main()