"""RULES_meped_crosscheck.txt: do NOAA's two MEPED products give the same L profiles? (An added check, not a pre- registered test.) 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 Processes NOAA-15's MEPED 90-degree >300 keV channel for 18-27 March 2013 from both NOAA products that meped_test.py uses (the 2-second proc.nc fluxes and the 16-second text count rates), exactly as meped_test.py does, and compares the daily log10 profiles over L 2.0-6.5 (the median offset between products, then the median absolute deviation from it) and the persistent slots that method A finds in each. 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_crosscheck.py (fetch_inputs.py --meped saves them with the others in /meped/noaa15_proc and .../noaa15_txt.) """ 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) != 4: sys.exit("usage: python3 meped_crosscheck.py ") d0, d1 = dt.date(2013, 3, 18), dt.date(2013, 3, 27) res = {} daily = {} for kind, folder, reader in (("proc", sys.argv[1], M.read_proc), ("txt", sys.argv[2], M.read_txt)): files = M.files_for("n15proc" if kind == "proc" else "n15txt", {"n15proc": folder, "n15txt": folder}, d0, d1) times, mean, n = M.bin6h(files, reader, d0, d1) days, dm = A.daily_means(times, mean[:, :, None], 6.0) daily[kind] = (days, dm[:, :, 0]) r = A.analyse(days, dm, M.LC, dict(A.PRIMARY), 1)[0] res[kind] = dict(files=len(files), persistent_slots=[dict(first=str(days[t["first"]]), last=str(days[t["last"]]), L=round(t["Lmed"], 2), depth=round(t["pmed"], 3)) for t in r["slot_tracks"] if t["persistent"]]) sel = (M.LC > 2.0) & (M.LC < 6.5) a = np.log10(daily["proc"][1][:, sel]) b = np.log10(daily["txt"][1][:, sel]) ok = np.isfinite(a) & np.isfinite(b) diff = (b - a)[ok] off = float(np.median(diff)) mad = float(np.median(np.abs(diff - off))) res["offset_txt_minus_proc_dec"] = round(off, 3) res["median_abs_deviation_after_offset_dec"] = round(mad, 4) res["cells"] = int(ok.sum()) res["equivalent_for_rule"] = mad < 0.10 with open(sys.argv[3], "w", newline="\n", encoding="utf-8") as f: json.dump(res, f, indent=1) print(json.dumps(res, indent=1)) if __name__ == "__main__": main()