#!/usr/bin/env python3 """Test 3b, step 1: the pre-registered list of great storms, 1859-1963. Rules: RULES_newspapers.txt. Fact-Checked Science, verification of florida-aurora-cycle-25. Standard library only; reads GFZ's Kp file as data. python3 -I great_storms.py S1: every storm of 1932-1963 in which a three-hour Kp reached 9o: runs of UT days holding a 9o value, gaps of at most one day merged. S2: the sixteen storms before 1932 in Love et al. (2025), Table 1, with D >= 250 nT (typed below from the copy of the paper saved for the 1 November page); a storm's days are Table 1's date and the day before. For each storm: the primary search window (first day to three days after the last) and the secondary (to ten days after). """ import csv import datetime as dt import os import sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) # our own code folder; -I leaves it out import fclib as F # noqa: E402 S2 = [("1859-09-02", 964, "discrete"), ("1872-02-04", 801, "discrete"), ("1882-11-18", 386, "discrete"), ("1903-10-31", 513, "discrete"), ("1907-02-09", 340, "discrete"), ("1908-09-12", 280, "discrete"), ("1909-05-14", 278, "diffuse"), ("1909-09-25", 595, "discrete"), ("1915-06-17", 255, "discrete"), ("1916-08-26", 260, "discrete"), ("1919-08-11", 300, "discrete"), ("1920-03-23", 377, "discrete"), ("1921-05-15", 907, "discrete"), ("1926-04-15", 252, "discrete"), ("1926-10-15", 302, "discrete"), ("1928-07-07", 389, "discrete")] def main(): kp, day = F.read_kp(sys.argv[1]) days = sorted({t.date() for t, v in kp.items() if v >= 9.0 - 1e-3 and dt.date(1932, 1, 1) <= t.date() <= dt.date(1963, 12, 31)}) runs = [] for d in days: if runs and (d - runs[-1][-1]).days <= 2: # a gap of at most one day between 9o days runs[-1].append(d) else: runs.append([d]) rows = [] for date, D, kind in S2: d = dt.date.fromisoformat(date) rows.append(["S2", (d - dt.timedelta(days=1)).isoformat(), d.isoformat(), f"D = {D} nT ({kind} list), Love et al. 2025 Table 1"]) for r in runs: d0, d1 = r[0], r[-1] n9 = sum(1 for t, v in kp.items() if d0 <= t.date() <= d1 and v >= 9.0 - 1e-3) ap = max(day[d][0] for d in day if d0 <= d <= d1) rows.append(["S1", d0.isoformat(), d1.isoformat(), f"Kp 9o in {n9} three-hour interval{'s' if n9 != 1 else ''}; highest daily Ap {ap}"]) with open(sys.argv[2], "w", encoding="utf-8", newline="\n") as f: w = csv.writer(f, lineterminator="\n") w.writerow(["list", "first_day", "last_day", "basis", "primary_window_start", "primary_window_end", "secondary_window_end"]) for lst, a, b, basis in rows: d0, d1 = dt.date.fromisoformat(a), dt.date.fromisoformat(b) w.writerow([lst, a, b, basis, a, (d1 + dt.timedelta(days=3)).isoformat(), (d1 + dt.timedelta(days=10)).isoformat()]) sys.stdout.reconfigure(encoding="utf-8", newline="\n") for r in rows: print(*r, sep=" | ") print(len(rows), "storms:", sum(1 for r in rows if r[0] == "S2"), "in S2,", sum(1 for r in rows if r[0] == "S1"), "in S1") if __name__ == "__main__": main()