"""Read Kyoto's FINAL hourly Dst for 2015 (the pages fetch_dst_2015.py saves) and list the intense storms. Fact-Checked Science ("Our analysis"), 20 November 2026, for the check of Marschollek, M., AGU26 abstract GH11D-VR9816 (not peer reviewed). Data: WDC for Geomagnetism, Kyoto, Geomagnetic Dst index, doi:10.17593/14515-74000; final values only (the script refuses any page not headed "(FINAL)"). Run: python3 -I kyoto_dst_final.py Kyoto's hour column h (1-24) covers UT h-1 to h. A storm is listed for each run of days whose lowest hourly Dst is -100 nT or lower (the usual "intense" class), with the run's lowest value and its hour. It prints the SHA-256 of the hourly values it writes (, LF) and compares it with ours. Standard library only (Python 3.9+). The WDC's pages carry a contact address; the script never keeps it. """ import datetime as dt import glob import hashlib import html import os import re import sys TSV_SHA256 = "837987ebd900bb24875fc3feb1665b25624fe0eb5fcbb4dac5ca0137939c76c2" MONTHS = ["JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"] def parse_page(path): s = open(path, encoding="utf-8", errors="replace").read() t = html.unescape(re.sub(r"<[^>]+>", "", s)) if "Hourly Equatorial Dst Values (FINAL)" not in t: raise SystemExit("not a FINAL Dst page: " + path) m = re.search(r"\(FINAL\)\s*\n\s*([A-Z]+)\s+(\d{4})", t) year, month = int(m.group(2)), MONTHS.index(m.group(1)) + 1 rows, started = [], False for line in t.splitlines(): if line.strip() == "DAY": started = True continue if not started: continue if re.match(r"^\s?\d{1,2}\s", line) and len(line.rstrip()) >= 100: day = int(line[0:2]) vals = [] for block in (line[3:35], line[36:68], line[69:101]): vals.extend(int(block[4 * i:4 * i + 4]) for i in range(8)) rows.extend((year, month, day, h, v) for h, v in enumerate(vals, start=1)) elif line.strip().startswith("This version"): break return rows def main(folder, out_tsv, out_storms): rows = [] for p in sorted(glob.glob(os.path.join(folder, "dst_final_*.html"))): rows.extend(parse_page(p)) rows.sort() text = "date\thour_end_UT\tdst_nT\n" + "".join( "%04d-%02d-%02d\t%02d\t%d\n" % r for r in rows) with open(out_tsv, "w", encoding="utf-8", newline="\n") as f: f.write(text) sha = hashlib.sha256(text.encode()).hexdigest() print("%d hourly values; SHA-256 of %s: %s (%s)" % ( len(rows), os.path.basename(out_tsv), sha, "same as ours" if sha == TSV_SHA256 else "DIFFERS from ours")) daily = {} for y, mo, d, h, v in rows: if (y, mo, d) not in daily or v < daily[(y, mo, d)][0]: daily[(y, mo, d)] = (v, h) events, cur = [], None for k in sorted(daily): v, h = daily[k] date = dt.date(*k) if v <= -100: if cur and (date - cur["last"]).days <= 1: cur["last"] = date if v < cur["min"]: cur.update(min=v, min_day=date, min_hour=h) else: cur = {"first": date, "last": date, "min": v, "min_day": date, "min_hour": h} events.append(cur) else: cur = None lines = ["Kyoto final Dst, %s to %s: %d hourly values" % (rows[0][:3], rows[-1][:3], len(rows)), "Days with minimum Dst <= -100 nT, merged into events:"] for e in events: lines.append("%s to %s: minimum %d nT on %s, hour %02d (UT %02d-%02d)" % ( e["first"], e["last"], e["min"], e["min_day"], e["min_hour"], e["min_hour"] - 1, e["min_hour"])) lo = min(rows, key=lambda r: r[4]) lines.append("Lowest hourly value of the period: %d nT on %04d-%02d-%02d, hour %02d" % (lo[4], lo[0], lo[1], lo[2], lo[3])) with open(out_storms, "w", encoding="utf-8", newline="\n") as f: f.write("\n".join(lines) + "\n") if __name__ == "__main__": main(sys.argv[1], sys.argv[2], sys.argv[3])