#!/usr/bin/env python3 """Our check of the storm facts in Tacza et al. (2026), J. Space Weather Space Clim. 16, 36 ("Our analysis"). Usage: python3 -I storm_facts.py DOWNLOADS_FOLDER [OUT_JSON] Standard library only (Python 3.9 or later). It reads, as data, files fetched on 2026-11-15 into DOWNLOADS_FOLDER: omni/omni2_2024.dat OMNI hourly (NASA/GSFC SPDF; J. H. King and N. E. Papitashvili) omni/omni_min202405.asc OMNI 1-min, May 2024 gfz-kp/Kp_ap_since_1932.txt GFZ Kp, CC BY 4.0 (Matzka et al. 2021, doi:10.5880/Kp.0001) kyoto-dst/dst_provisional_202405.html WDC Kyoto provisional hourly Dst, May 2024 (doi:10.17593/14515-74000), for scientific, non-commercial use, with acknowledgement of the WDC and its observatories nmdb/nmdb_8st_hourly_corrp_202405.txt NMDB hourly pressure-corrected counts (www.nmdb.eu; acknowledgement below) nmdb/nmdb_gle_5min_corrp_20240510-12.txt NMDB 5-min counts, 10-11 May 2024 The definitions are fixed in RULES_storm_facts.txt (written before the values were read). Nothing here is the paper's code; the paper's own numbers are quoted in the output for comparison only. NMDB acknowledgement: we acknowledge the NMDB database (www.nmdb.eu), founded under the European Union's FP7 programme (contract no. 213007), and the PIs of individual neutron monitors at Mexico (UNAM), Nor-Amberd (A.I. Alikhanyan National Science Laboratory), Alma-Ata B (Institute of Ionosphere, Almaty), Jungfraujoch (University of Bern), Lomnicky Stit (IEP SAS Kosice), KielRT (University of Kiel), Oulu (Sodankyla Geophysical Observatory) and South Pole (University of Wisconsin, River Falls). NMDB data are free for non-commercial use. """ import datetime as dt import html import json import math import os import re import sys ROOT = sys.argv[1] if len(sys.argv) > 1 else os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "downloads") OUT = sys.argv[2] if len(sys.argv) > 2 else None T0, T1 = dt.datetime(2024, 5, 7), dt.datetime(2024, 5, 17) def omni_hourly(): rows = {} with open(os.path.join(ROOT, "omni", "omni2_2024.dat"), encoding="ascii") as fh: for line in fh: p = line.split() t = dt.datetime(int(p[0]), 1, 1) + dt.timedelta(days=int(p[1]) - 1, hours=int(p[2])) if not (T0 <= t < T1): continue f = lambda i, fill: (None if float(p[i - 1]) >= fill else float(p[i - 1])) rows[t] = {"B": f(9, 999.9), "Bz": f(17, 999.9), "V": f(25, 9999.), "P": f(29, 99.99), "Kp10": int(p[38]), "Dst": int(p[40]), "pf10": f(46, 99999.99), "pf60": f(48, 99999.99)} return rows def omni_minute(): rows = {} path = os.path.join(ROOT, "omni", "omni_min202405.asc") with open(path, encoding="ascii") as fh: for line in fh: p = line.split() t = dt.datetime(int(p[0]), 1, 1) + dt.timedelta(days=int(p[1]) - 1, hours=int(p[2]), minutes=int(p[3])) if not (dt.datetime(2024, 5, 10, 12) <= t < dt.datetime(2024, 5, 11, 12)): continue B = float(p[13]); P = float(p[27]); symh = int(p[41]); bz = float(p[18]) rows[t] = {"B": None if B >= 9999 else B, "P": None if P >= 99 else P, "SYMH": symh, "Bz": None if bz >= 9999 else bz} return rows def gfz_kp(): out = [] with open(os.path.join(ROOT, "gfz-kp", "Kp_ap_since_1932.txt"), encoding="utf-8") as fh: for line in fh: if line.startswith("#") or not line.strip(): continue p = line.split() t = dt.datetime(int(p[0]), int(p[1]), int(p[2]), int(float(p[3]))) if T0 <= t < T1: out.append((t, float(p[7]), int(p[9]))) return out def kyoto_dst(): t = open(os.path.join(ROOT, "kyoto-dst", "dst_provisional_202405.html"), encoding="utf-8", errors="replace").read() txt = html.unescape(re.sub(r"<[^>]+>", "", t)) assert "PROVISIONAL" in txt, "expected Kyoto's provisional table" vals = {} for line in txt.splitlines(): m = re.match(r"^\s?(\d{1,2})\s+(-?\d.*)$", line) if not m: continue day = int(m.group(1)) nums = re.findall(r"-?\d+", m.group(2)) if len(nums) != 24: continue for h, v in enumerate(nums): # Kyoto column h+1 is the hour from h:00 to h+1:00 UT vals[dt.datetime(2024, 5, day, h)] = int(v) return vals def nmdb(fname): t = open(os.path.join(ROOT, "nmdb", fname), encoding="utf-8", errors="replace").read() body = html.unescape(re.search(r"(.*?)", t, flags=re.S).group(1)) names, data = None, {} for line in body.splitlines(): if not line.strip() or line.startswith("#"): continue if ";" not in line: names = line.split() continue p = line.split(";") tt = dt.datetime.strptime(p[0].strip(), "%Y-%m-%d %H:%M:%S") data[tt] = [None if x.strip() in ("null", "") else float(x) for x in p[1:]] return names, data def kp_str(k): n = round(k * 3) base, r = divmod(n, 3) return {0: "%do" % base, 1: "%d+" % base, 2: "%d-" % (base + 1)}[r] def shue(bz, p): return (10.22 + 1.29 * math.tanh(0.184 * (bz + 8.14))) * p ** (-1 / 6.6) def main(): res = {} om = omni_hourly() hrs = sorted(om) H = lambda d, h: dt.datetime(2024, 5, d, h) # D1 Dst (Kyoto provisional) dst = kyoto_dst() win = [t for t in dst if H(10, 0) <= t <= H(12, 23)] tmin = min(win, key=lambda t: dst[t]) pre = max([t for t in dst if H(10, 15) <= t <= H(10, 19)], key=lambda t: dst[t]) d12 = [t for t in sorted(dst) if t.date() == dt.date(2024, 5, 12)] stay = next(t for t in d12 if all(dst[u] > -100 for u in d12 if u >= t)) res["D1_dst"] = {"min": dst[tmin], "min_hour_start_UT": str(tmin), "peak_before": dst[pre], "peak_hour_start_UT": str(pre), "first_hour_12May_staying_above_-100": str(stay), "dst_at_12May_14UT": dst[H(12, 14)], "omni_dst_min": min(om[t]["Dst"] for t in hrs if H(10, 0) <= t <= H(12, 23)), "paper": "-406 nT at 02:00 UT on 11 May; from 66 nT at shock onset; above -100 nT by 14:00 UT on 12 May"} # D2 |B| bmax_t = max([t for t in hrs if H(10, 0) <= t <= H(11, 23) and om[t]["B"] is not None], key=lambda t: om[t]["B"]) omin = omni_minute() mins = sorted(omin) bm_t = max([t for t in mins if omin[t]["B"] is not None], key=lambda t: omin[t]["B"]) res["D2_B"] = {"hourly_max": om[bmax_t]["B"], "hourly_max_hour": str(bmax_t), "B_10May_16UT": om[H(10, 16)]["B"], "B_10May_17UT": om[H(10, 17)]["B"], "min1_max": omin[bm_t]["B"], "min1_max_time": str(bm_t), "paper": "from 15.5 nT to 68.9 nT by 23:00 UT; ~70 nT at L1 (abstract)"} # D3 shock arrival (1-min) and SSC proxy from SYM-H base = [omin[t]["B"] for t in mins if H(10, 15) <= t < H(10, 16) and omin[t]["B"] is not None] bmean = sum(base) / len(base) shock = next(t for t in mins if H(10, 16) <= t <= H(10, 18) and omin[t]["B"] is not None and omin[t]["B"] > 2 * bmean) best, best_t = -1e9, None for t in mins: if not (H(10, 16) <= t <= H(10, 18)): continue t2 = t + dt.timedelta(minutes=10) if t2 in omin: d = omin[t2]["SYMH"] - omin[t]["SYMH"] if d > best: best, best_t = d, t res["D3_shock"] = {"B_mean_15_16UT": round(bmean, 2), "first_minute_B_doubles": str(shock), "largest_10min_SYMH_rise_start": str(best_t), "rise_nT": best, "paper": "17:00 UT (sec. 3); 17:05 UT (sec. 1, after Hayakawa et al. 2025)"} # D4 pressure pmax_t = max([t for t in hrs if t.date() == dt.date(2024, 5, 10) and om[t]["P"] is not None], key=lambda t: om[t]["P"]) res["D4_P"] = {"max": om[pmax_t]["P"], "hour": str(pmax_t), "paper": "55.9 nPa at 20:00 UT"} # D5 Bz first_s = next(t for t in hrs if H(10, 16) <= t and om[t]["Bz"] is not None and om[t]["Bz"] <= -10) bzmin_t = min([t for t in hrs if H(10, 0) <= t <= H(11, 23) and om[t]["Bz"] is not None], key=lambda t: om[t]["Bz"]) not_south = [(str(t), om[t]["Bz"]) for t in hrs if first_s <= t <= H(11, 16) and (om[t]["Bz"] is None or om[t]["Bz"] > -10)] res["D5_Bz"] = {"first_hour_le_-10": str(first_s), "min": om[bzmin_t]["Bz"], "min_hour": str(bzmin_t), "hours_not_below_-10_until_11May16UT": not_south, "n_hours_window": sum(1 for t in hrs if first_s <= t <= H(11, 16)), "paper": "southward at 18:00 UT, -31 nT near 23:00 UT, below -10 nT until 16:00 UT on 11 May"} # D6 speed vmax_t = max([t for t in hrs if H(10, 0) <= t <= H(13, 23) and om[t]["V"] is not None], key=lambda t: om[t]["V"]) seq = [t for t in hrs if H(13, 0) <= t <= H(14, 23)] below = next((t for t in seq if all(om[u]["V"] is not None and om[u]["V"] < 600 for u in seq if u >= t)), None) res["D6_V"] = {"V_10May_16UT": om[H(10, 16)]["V"], "V_10May_23UT": om[H(10, 23)]["V"], "max": om[vmax_t]["V"], "max_hour": str(vmax_t), "first_hour_13-14May_staying_below_600": str(below), "paper": "400 to 700 km/s by 23:00 UT 10 May; 1006 km/s at 01:00 UT 12 May; below 600 km/s at 00:00 UT 14 May"} # D7 Kp (GFZ definitive) kp = gfz_kp() first9 = next((t, k) for t, k, d in kp if k >= 8.666) last7 = [t for t, k, d in kp if H(11, 0) <= t <= H(12, 21) and k >= 6.666] sec = max([(k, t) for t, k, d in kp if H(12, 18) <= t <= H(13, 3)]) res["D7_Kp"] = {"first_ge_9-": [str(first9[0]), kp_str(first9[1])], "last_interval_ge_7-_on_11-12May": str(max(last7)), "max_12May18_13May06": [kp_str(sec[0]), str(sec[1])], "series_10_13May": [(str(t), kp_str(k), d) for t, k, d in kp if H(10, 0) <= t <= H(13, 21)], "paper": "9 at 00:00 UT 11 May; >=7 until 05:00 UT 12 May; secondary ~6 between 21 UT 12 May and 05 UT 13 May"} # D8 Shue r0 r0 = {t: shue(om[t]["Bz"], om[t]["P"]) for t in hrs if om[t]["Bz"] is not None and om[t]["P"] is not None} rmin_t = min([t for t in r0 if t.date() == dt.date(2024, 5, 10)], key=lambda t: r0[t]) first6 = next(t for t in sorted(r0) if t.date() == dt.date(2024, 5, 11) and r0[t] >= 6) res["D8_r0"] = {"r0_10May_12UT": round(r0[H(10, 12)], 2), "min_10May": round(r0[rmin_t], 2), "min_hour": str(rmin_t), "first_hour_11May_ge_6": str(first6), "paper": "11.4 RE at 12 UT; 4.9 RE at 20 UT; above 6 RE by 04 UT 11 May"} # D9 Forbush decrease (NMDB hourly) names, nm = nmdb("nmdb_8st_hourly_corrp_202405.txt") fd = {} for i, s in enumerate(names): for lab, a, b in (("7-9May", H(7, 0), H(9, 23)), ("7-8May", H(7, 0), H(8, 23))): bl = [nm[t][i] for t in nm if a <= t <= b and nm[t][i] is not None] m0 = sum(bl) / len(bl) w = [(nm[t][i] / m0 * 100, t) for t in nm if H(10, 0) <= t <= H(12, 23) and nm[t][i] is not None] lo = min(w) near0 = [(round(nm[t][i] / m0 * 100, 2), str(t)) for t in nm if H(10, 22) <= t <= H(11, 3) and nm[t][i] is not None] fd.setdefault(s, {})[lab] = {"min_pct": round(lo[0], 2), "min_hour": str(lo[1]), "n_base": len(bl), "10May22_11May03": near0} res["D9_FD"] = {"by_station": fd, "paper": "86-90 % around 00 UT 11 May; SOPO 86, OULU 88; JUNG1/AATB/NANM/MXCO 92-94; KIEL2/LMKS 88-91; FD ~10-14 % (sec. 4)"} # D10 GLE in 5-min NMDB (descriptive only) names5, nm5 = nmdb("nmdb_gle_5min_corrp_20240510-12.txt") g = {} for i, s in enumerate(names5): ser = [(t, nm5[t][i]) for t in sorted(nm5) if nm5[t][i] is not None] pre = [v for t, v in ser if H(11, 0) + dt.timedelta(minutes=30) <= t < H(11, 1) + dt.timedelta(minutes=15)] if not pre: continue p0 = sum(pre) / len(pre) post = [(v / p0 * 100 - 100, t) for t, v in ser if H(11, 1) <= t <= H(11, 10)] pk = max(post) g[s] = {"pre_mean_0030_0115": round(p0, 3), "peak_pct_above_pre": round(pk[0], 2), "peak_time": str(pk[1])} res["D10_GLE_5min"] = {"by_station": g, "note": "Increase over the 00:30-01:15 UT mean, inside the Forbush decrease; " "not the GLE database's de-trended increase. Published onsets 01:15-02:30 UT, peaks 02:20-04:30 UT " "(Papaioannou et al. 2025, Table 1); 'from 2 UT to 10 UT' is Hayakawa et al.'s wording."} # D11 GOES >10 MeV (OMNI copy) pf = [(t, om[t]["pf10"]) for t in hrs if om[t]["pf10"] is not None] if pf: first10 = next((t for t, v in pf if t >= H(9, 0) and v >= 10), None) pk10 = max([(v, t) for t, v in pf if H(9, 0) <= t <= H(14, 0)]) res["D11_GOES"] = {"first_hour_ge_10pfu": str(first10), "peak_10MeV": pk10[0], "peak_hour": str(pk10[1])} else: res["D11_GOES"] = {"note": "OMNI hourly carries no GOES proton fluxes for May 2024 (all fill values); see the SEP list instead"} txt = json.dumps(res, indent=1, default=str) print(txt) if OUT: with open(OUT, "w", encoding="utf-8", newline="\n") as fh: fh.write(txt + "\n") if __name__ == "__main__": main()