"""Compact tables (and chart data) from the outputs of belts_a.py, belts_b.py, meped_test.py, meped_robust.py and dst.py. 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). Nothing is recomputed here; the scripts' outputs are only collected. Needs Python 3.9+ (standard library only). Run python3 make_tables.py [] where the belts output folder holds the outputs of belts_a.py and of belts_b.py run with "0.10 med3", "0.10 none" and "0.05 none". Writes, in the tables folder belts_event_table.csv one row per statement of the paper and channel: method A (pre-registered and no smoothing), robustness, method B, and (last six columns, post hoc, RULES_belts_amendment1.txt) the settings G2 and G3: no smoothing with up to 2 or 3 missed days tolerated in tracking belts_daily.csv one row per event, channel and day: belts and the L of each persistent slot present that day (the slot track's median L), under the pre-registered setting and setting X1 (no smoothing) belts_daily_posthoc_G.csv the same rows under the post-hoc settings G2 and G3 (a separate file keeps each under 200 kB) meped_results.csv one row per MEPED window, setting and statistic: longest run in the window, its first day, the slots on it, and the same statistic's longest run in the pre-storm baseline and, if a chart folder is given, chart_2024.csv, chart_events.csv and chart_meped_history.csv there. """ import csv import datetime as dt import json import os import sys FILE_KEYS = ["2024may", "2024oct", "2025jun", "2026jan", "2026jul", "meped2024"] EVENT_NAME = {"2024may": "May-Jun 2024", "2024oct": "Oct-Nov 2024", "2025jun": "Jun-Jul 2025", "2026jan": "Jan-Feb 2026", "2026jul": "Jul-Aug 2026", "meped2024": "May-Jun 2024"} INSTRUMENT = {"meped2024": "MetOp-C MEPED 90-degree (authors' file)"} EPT_CHANNELS = ["ch1 0.5-0.6 MeV", "ch2 0.6-0.7 MeV", "ch3 0.7-0.8 MeV", "ch4 0.8-1.0 MeV", "ch5 1.0-2.4 MeV", "ch6 2.4-8 MeV"] def load_json(path): with open(path, encoding="utf-8") as f: return json.load(f) def read_csv(path): with open(path, encoding="utf-8", newline="") as f: return list(csv.DictReader(f)) def write_csv(path, header, rows, comment=None): with open(path, "w", newline="\n", encoding="utf-8") as f: w = csv.writer(f, lineterminator="\n") if comment: w.writerow(["# " + comment]) w.writerow(header) w.writerows(rows) G_QUESTION = {"T1a": ("Q1_June2024_four_belts", "named"), "T1e": ("Q4_MEPED_June2024", "named"), "T2": ("Q3_Oct2024_three_belts", "named"), "T3": ("Q3_Jun2025_three_belts", "named"), "T4": ("Q3_Feb2026_three_belts", "named"), "T5": ("Q3_Jul2026_three_belts", "three_or_more")} G_SETTINGS = ["G2_nosmooth_miss2", "G3_nosmooth_miss3"] def g_cells(G, tid, ch): """Post hoc (RULES_belts_amendment1.txt): days in window, longest run and its dates under G2 and G3.""" qid, part = G_QUESTION[tid] cells = [] for s in G_SETTINGS: e = G["questions"][qid][s][ch][part] lr = e["longest_run"] cells += [e["days_in_window"], lr[2] if lr else 0, f"{lr[0]}..{lr[1]}" if lr else "-"] return cells def event_table(bdir, tdir): """The table of our report (its first 17 columns as there), plus the post-hoc G2 and G3 columns.""" A = load_json(os.path.join(bdir, "belts_A_summary.json")) G = load_json(os.path.join(bdir, "belts_A_G_summary.json")) B = {k: load_json(os.path.join(bdir, f"belts_B_{k}_summary.json")) for k in ("thr0.10_med3", "thr0.10_none", "thr0.05_none")} events = [("T1a", "June 2024, four belts (slots 1.9, 2.4, 3.8)", "1-30 Jun 2024; >4 weeks"), ("T1e", "June 2024, MEPED >300 keV four belts", "1-30 Jun 2024"), ("T2", "Oct-Nov 2024, three belts (slots <2.4, 2.5)", "12 Oct - 8 Nov 2024"), ("T3", "Jun-Jul 2025, three belts (slots 2, 2.5)", "10 Jun - 15 Jul 2025"), ("T4", "Feb 2026, three belts (slots 1.9, 2.5)", "1-27 Feb 2026"), ("T5", "Jul 2026, three belts", "5-15 Jul 2026")] aset = ["primary", "R1_P0.05", "R2_P0.20", "R3_kernel5", "R4_strict", "R5_L1.3-6.0"] rows = [] for tid, title, win in events: t = A["tests"][tid] for ch, v in t["primary"]["per_channel"].items(): def cfg(s): vv = t[s]["per_channel"][ch] n = vv.get("named_configuration_post_hoc") if n: lr = n["longest_run"] return n["days_in_window"], vv["window_days"], (lr[2] if lr else 0), (f"{lr[0]}..{lr[1]}" if lr else "-") br = vv["best_run"] return vv["days_in_window"], vv["window_days"], vv["best_run_len"], (f"{br[0]}..{br[1]}" if br else "-") p = cfg("primary") x = cfg("X1_nosmooth_P0.10") same = sum(1 for s in aset[1:6] if s in t and t[s]["per_channel"][ch]["outcome"] == v["outcome"]) slots = "; ".join(f"{L:.2f}, {d:.2f}, {sp}" for L, d, sp in v["slots_on_best_run"]) bch = ch.split()[0] if tid != "T1e" else ">300" def brun(k): e = B[k]["tests"].get(tid, {}).get(bch) if not e: return "-" if "named_post_hoc" in e: return str(e["named_post_hoc"]["longest_run"][0]) return str(e["longest_run_components"][0]) rows.append([tid, title, win, ch, v["outcome"], p[0], p[1], p[2], p[3], x[0], x[2], x[3], slots, f"{same}/5", brun("thr0.10_med3"), brun("thr0.10_none"), brun("thr0.05_none")] + g_cells(G, tid, ch)) write_csv(os.path.join(tdir, "belts_event_table.csv"), ["test", "statement", "paper_window", "channel", "A_primary_outcome", "A_primary_days_in_window", "window_days", "A_primary_longest_run_days", "A_primary_longest_run_dates", "A_X1_days_in_window", "A_X1_longest_run_days", "A_X1_longest_run_dates", "slots_on_primary_run_L_depth_span", "robustness_R1-R5_same_outcome", "B_med3_P0.10_run", "B_nosmooth_P0.10_run", "B_nosmooth_P0.05_run", "posthoc_G2_days_in_window", "posthoc_G2_longest_run_days", "posthoc_G2_longest_run_dates", "posthoc_G3_days_in_window", "posthoc_G3_longest_run_days", "posthoc_G3_longest_run_dates"], rows) return A, G def daily_pairs(bdir, key): """{(date, channel): (belts_prereg, slots_prereg, belts_x1, slots_x1, belts_g2, slots_g2, belts_g3, slots_g3)} from method A's daily files.""" pre = read_csv(os.path.join(bdir, f"belts_A_{key}_daily.csv")) other = {} for tag in ("-X1nosmooth", "-G2", "-G3"): other[tag] = {(r["date"], r["channel"]): r for r in read_csv(os.path.join(bdir, f"belts_A{tag}_{key}_daily.csv"))} out = {} for r in pre: k = (r["date"], r["channel"]) vals = [r["belts_count"], r["persistent_slot_track_L"]] for tag in ("-X1nosmooth", "-G2", "-G3"): vals += [other[tag][k]["belts_count"], other[tag][k]["persistent_slot_track_L"]] out[k] = tuple(vals) return out def belts_daily(bdir, tdir): """belts_daily.csv (pre-registered and X1, as before) and, to keep each file under 200 kB, the post-hoc G2 and G3 columns in belts_daily_posthoc_G.csv (same rows, same order).""" rows, grows = [], [] for key in FILE_KEYS: chans = [">300 keV"] if key == "meped2024" else EPT_CHANNELS pairs = daily_pairs(bdir, key) for ch in chans: for (d, c), vals in sorted(pairs.items()): if c == ch: head = [EVENT_NAME[key], INSTRUMENT.get(key, "PROBA-V EPT"), ch, d] rows.append(head + list(vals[:4])) grows.append(head + list(vals[4:])) write_csv(os.path.join(tdir, "belts_daily.csv"), ["event", "instrument", "channel", "date", "belts_prereg", "slot_L_prereg", "belts_nosmooth_X1", "slot_L_nosmooth_X1"], rows, comment="Data: Winant, Pierrard & Botek (2026), BIRA-IASB, doi:10.18758/lu12i2kq, CC BY 4.0. Analysis: " "Fact-Checked Science (belts_a.py). belts = 1 + persistent slots present that day (empty: no " "data); slot L = median L of each persistent slot track present that day, separated by ';'.") write_csv(os.path.join(tdir, "belts_daily_posthoc_G.csv"), ["event", "instrument", "channel", "date", "belts_posthoc_G2", "slot_L_posthoc_G2", "belts_posthoc_G3", "slot_L_posthoc_G3"], grows, comment="POST HOC (RULES_belts_amendment1.txt, after the fresh review): settings G2 and G3 = no smoothing, " "prominence 0.10 decade, up to 2 or 3 missed days tolerated in tracking. Same rows as " "belts_daily.csv. Data: Winant, Pierrard & Botek (2026), doi:10.18758/lu12i2kq, CC BY 4.0. " "Analysis: Fact-Checked Science (belts_a.py).") MEPED_CASES = ["control_metop03_2024", "control_noaa15_2024", "W1_2000-04", "W2_2000-07", "W3_2001-03", "W4_2001-11", "W5_2003-10", "W6_2004-11", "W7_2015-03", "W8_2015-06"] SAT = {"control_metop03_2024": ("MetOp-C", "l1b proc.nc (2-s)"), "control_noaa15_2024": ("NOAA-15", "l1b proc.nc (2-s)"), "W7_2015-03": ("NOAA-15", "l1b proc.nc (2-s)"), "W8_2015-06": ("NOAA-15", "l1b proc.nc (2-s)")} def run_slots(mdir, case, setting, start, length, min_L): if not start or not length: return "" rows = read_csv(os.path.join(mdir, f"meped_daily_{case}_{setting}.csv")) d0 = dt.date.fromisoformat(start) days = {(d0 + dt.timedelta(days=i)).isoformat() for i in range(length)} count = {} for r in rows: if r["date"] in days: for x in r["persistent_slot_track_L"].split(";"): if x: count[x] = count.get(x, 0) + 1 keep = sorted((x for x, n in count.items() if n >= length / 2.0 and float(x) >= min_L), key=float) return ";".join(keep) def meped_results(mdir, tdir): summ = load_json(os.path.join(mdir, "meped_test_summary.json"))["cases"] rob = load_json(os.path.join(mdir, "meped_robustness.json")) rows = [] for case in MEPED_CASES: sat, prod = SAT.get(case, ("NOAA-15", "l2 txt (16-s)")) c = summ[case] for setting in ("primary", "X1_nosmooth"): for stat, key, min_L in (("S1 outer split (2+ persistent slots at L>=2.0)", "S1_outer_split_run", 2.0), ("S2 three or more belts (L 1.2-6.5)", "S2_three_or_more_run", 0.0), ("S2 four or more belts (L 1.2-6.5)", "S2_four_or_more_run", 0.0)): n, start = c[setting]["window"][key] rows.append([case, sat, prod, setting, stat, n, start or "", run_slots(mdir, case, setting, start, n, min_L), c[setting]["baseline"][key][0]]) for setting in ("R1_P0.05", "R2_P0.20", "R3_kernel5", "R4_strict", "R5_L1.3-6.0"): r = rob[case][setting] rows.append([case, sat, prod, setting, "S1 outer split (2+ persistent slots at L>=2.0)", r["S1"], "", "", r["S1_base"]]) for setting in ("primary", "R1_P0.05", "R2_P0.20", "R3_kernel5", "R4_strict", "R5_L1.3-6.0", "X1_nosmooth"): r = rob[case][setting] rows.append([case, sat, prod, setting, "outer split, slots at L 2.2-3.2 and 3.3-4.5 (post hoc)", r["outer_split_Lrestricted"], "", "", r["outer_split_Lrestricted_base"]]) write_csv(os.path.join(tdir, "meped_results.csv"), ["window", "satellite", "product", "setting", "statistic", "run_days", "run_start", "slot_L_on_run", "baseline_run_days"], rows, comment="NOAA NCEI POES/MetOp SEM-2 (public domain), MEPED 90-degree E3 (>300 keV). Analysis: " "Fact-Checked Science (meped_test.py, meped_robust.py), rules RULES_meped.txt. Windows and " "baselines as in RULES_meped.txt; slot_L_on_run = slot tracks present on at least half the run.") return summ, rob def chart_2024(A, G, bdir, cdir): t1a, t1e = A["tests"]["T1a"], A["tests"]["T1e"] rows = [] series = [("2024may", ch, t1a, "Q1_June2024_four_belts") for ch in EPT_CHANNELS[:5]] + \ [("meped2024", ">300 keV", t1e, "Q4_MEPED_June2024")] for key, ch, t, qid in series: pairs = daily_pairs(bdir, key) named_p = set(t["primary"]["per_channel"][ch]["named_configuration_post_hoc"]["dates"]) named_x = set(t["X1_nosmooth_P0.10"]["per_channel"][ch]["named_configuration_post_hoc"]["dates"]) named_g = [set(G["questions"][qid][s][ch]["named"]["dates"]) for s in G_SETTINGS] label = f"EPT {ch}" if key == "2024may" else "MEPED >300 keV (MetOp-C, authors' file)" for (d, c), (bp, sp, bx, sx, bg2, sg2, bg3, sg3) in sorted(pairs.items()): if c == ch and "2024-05-01" <= d <= "2024-06-30": rows.append([d, label, bp, sp, int(d in named_p), bx, sx, int(d in named_x), bg2, sg2, int(d in named_g[0]), bg3, sg3, int(d in named_g[1])]) write_csv(os.path.join(cdir, "chart_2024.csv"), ["date", "series", "belts_prereg", "slot_L_prereg", "paper_four_belt_config_prereg", "belts_nosmooth", "slot_L_nosmooth", "paper_four_belt_config_nosmooth", "belts_G2", "slot_L_G2", "paper_four_belt_config_G2", "belts_G3", "slot_L_G3", "paper_four_belt_config_G3"], rows, comment="Data: Winant, Pierrard & Botek (2026), doi:10.18758/lu12i2kq, CC BY 4.0; analysis: Fact-Checked " "Science. belts = 1 + persistent slots that day; slot L = median L of each persistent slot track; " "paper_four_belt_config = slots near L 1.9, 2.4 and 3.8 (within 0.25) all present (post hoc). " "G2, G3 (post hoc, RULES_belts_amendment1.txt) = no smoothing, up to 2 or 3 missed days tolerated " "in tracking; G2 is the one we would draw.") def chart_events(A, bdir, cdir): rows = [] for tid, key in (("T2", "2024oct"), ("T3", "2025jun"), ("T4", "2026jan"), ("T5", "2026jul")): t = A["tests"][tid] ch = EPT_CHANNELS[0] pairs = daily_pairs(bdir, key) np_ = t["primary"]["per_channel"][ch].get("named_configuration_post_hoc") nx = t["X1_nosmooth_P0.10"]["per_channel"][ch].get("named_configuration_post_hoc") named_p = set(np_["dates"]) if np_ else None named_x = set(nx["dates"]) if nx else None for (d, c), (bp, sp, bx, sx, *_g) in sorted(pairs.items()): if c != ch: continue fp = int(d in named_p) if named_p is not None else (int(int(bp) >= 3) if bp else 0) fx = int(d in named_x) if named_x is not None else (int(int(bx) >= 3) if bx else 0) rows.append([EVENT_NAME[key], d, bp, sp, fp, bx, sx, fx]) write_csv(os.path.join(cdir, "chart_events.csv"), ["event", "date", "belts_prereg", "slot_L_prereg", "paper_three_belt_config_prereg", "belts_nosmooth", "slot_L_nosmooth", "paper_three_belt_config_nosmooth"], rows, comment="EPT ch1 (0.5-0.6 MeV). Data: Winant, Pierrard & Botek (2026), doi:10.18758/lu12i2kq, CC BY 4.0; " "analysis: Fact-Checked Science. paper_three_belt_config = the slots the paper states for the event " "all present (post hoc; July 2026 states none, so there: three belts or more).") def chart_meped_history(summ, rob, ddir, cdir): big = read_csv_skip_comment(os.path.join(ddir, "dst_storms_le_-250_1998-2023.csv")) minima = {r["window"]: r for r in read_csv_skip_comment(os.path.join(ddir, "dst_storm_minima.csv"))} def storms_between(a, b): out = [f"{r['hour_UT'][:10]} ({r['min_dst_nT']} nT, {r['status']})" for r in big if a <= r["hour_UT"][:10] <= b] return "; ".join(out) windows = {"control_metop03_2024": ("2024-05-11 .. 2024-06-25", f"2024-05-11 ({minima['May 2024']['min_dst_nT']} nT, " f"{minima['May 2024']['status']})"), "control_noaa15_2024": ("2024-05-11 .. 2024-06-25", f"2024-05-11 ({minima['May 2024']['min_dst_nT']} nT, " f"{minima['May 2024']['status']})"), "W1_2000-04": ("2000-04-08 .. 2000-05-22", storms_between("2000-04-01", "2000-04-30")), "W2_2000-07": ("2000-07-16 .. 2000-08-30", storms_between("2000-07-01", "2000-07-31")), "W3_2001-03": ("2001-03-31 .. 2001-05-26", storms_between("2001-03-01", "2001-04-30")), "W4_2001-11": ("2001-11-06 .. 2001-12-21", storms_between("2001-11-01", "2001-11-30")), "W5_2003-10": ("2003-10-30 .. 2004-01-04", storms_between("2003-10-01", "2003-11-30")), "W6_2004-11": ("2004-11-08 .. 2004-12-23", storms_between("2004-11-01", "2004-11-30")), "W7_2015-03": ("2015-03-17 .. 2015-05-01", f"2015-03-17 ({minima['March 2015']['min_dst_nT']} nT, " f"{minima['March 2015']['status']})"), "W8_2015-06": ("2015-06-23 .. 2015-08-07", f"2015-06-23 ({minima['June 2015']['min_dst_nT']} nT, " f"{minima['June 2015']['status']})")} rows = [] for case in MEPED_CASES: sat, prod = SAT.get(case, ("NOAA-15", "l2 txt (16-s)")) r = rob[case] rr = [r[s]["S1"] for s in ("R1_P0.05", "R2_P0.20", "R3_kernel5", "R4_strict", "R5_L1.3-6.0")] rb = [r[s]["S1_base"] for s in ("R1_P0.05", "R2_P0.20", "R3_kernel5", "R4_strict", "R5_L1.3-6.0")] rows.append([case, windows[case][0], windows[case][1], sat, prod, r["primary"]["S1"], min(rr), max(rr), r["primary"]["S1_base"], max(rb), r["X1_nosmooth"]["S1"], r["X1_nosmooth"]["S1_base"]]) write_csv(os.path.join(cdir, "chart_meped_history.csv"), ["window", "window_days", "storms_min_dst", "satellite", "product", "outer_split_run_prereg_days", "outer_split_run_R1_R5_min", "outer_split_run_R1_R5_max", "baseline_run_prereg_days", "baseline_run_R1_R5_max", "outer_split_run_nosmooth_X1_days", "baseline_run_nosmooth_X1_days"], rows, comment="Outer split = 2+ persistent slots at L>=2.0 (S1 of RULES_meped.txt), longest run in days. NOAA NCEI " "POES/MetOp SEM-2 (public domain); Dst: WDC for Geomagnetism, Kyoto (final/provisional). " "Analysis: Fact-Checked Science.") def read_csv_skip_comment(path): with open(path, encoding="utf-8", newline="") as f: lines = [ln for ln in f if not ln.startswith("#") and not ln.startswith('"#')] return list(csv.DictReader(lines)) def main(): if len(sys.argv) not in (5, 6): sys.exit("usage: python3 make_tables.py " " []") bdir, mdir, ddir, tdir = sys.argv[1:5] os.makedirs(tdir, exist_ok=True) A, G = event_table(bdir, tdir) belts_daily(bdir, tdir) summ, rob = meped_results(mdir, tdir) if len(sys.argv) == 6: cdir = sys.argv[5] os.makedirs(cdir, exist_ok=True) chart_2024(A, G, bdir, cdir) chart_events(A, bdir, cdir) chart_meped_history(summ, rob, ddir, cdir) print("tables written to", tdir, "and charts to", sys.argv[5] if len(sys.argv) == 6 else "(none)") if __name__ == "__main__": main()