"""Fetch every input of the halloween-storm-explosions check into /downloads/, under the plain client name.
python3 -I fetch_inputs.py
Then run the other scripts with /downloads (see the page's "Repeat our numbers" section). Standard library only.
S0 News's notes and tables carry no licence, so they are fetched here by URL, never hosted with the page.
GFZ's Kp files are CC BY 4.0 (Matzka et al. 2021, doi:10.5880/Kp.0001); NOAA's files are US government work;
IGRF-14 is IAGA's; the tz database is public domain. Several of these files change over time: GFZ's preliminary Kp
becomes definitive, and SWPC's alerts.json, 30-day DGD file and 7-day Kp file roll forward, while the last quarterly
DGD file grows. So the script compares each file with the copy we used on 7 November 2026 and says where it differs;
our results, and the text of the three SWPC alerts the page cites, are hosted with the page. It stops at the first
refusal (HTTP 403 or 429), and never retries another way. (Version 2, after the fresh review: Kyoto's Dst pages are no
longer fetched, because the page no longer uses them.)
"""
import hashlib
import sys
import urllib.error
import urllib.request
from pathlib import Path
UA = "factchecked-research/1.0"
DRIVE = "https://drive.google.com/uc?export=download&id="
SWPC_FTP = "ftp://ftp.swpc.noaa.gov/pub/indices/old_indices/"
# (relative path, URL, SHA-256 of the copy we used on 2026-11-07)
FILES = [
("note005/note005.txt", "https://docs.google.com/document/d/16sNZI0RVGs2c5Xh0YGpIFrvWEayYJBNKRnxFCAWX_s4/export?format=txt",
"27e6821e1bed28dfc90e60213e0056fd54f84dd1f060e6be916cce3f0ddfd147"),
("note003/note003.txt", "https://docs.google.com/document/d/1cKzJwk0dvn2srK4tBnG-WmY8M3idm-9VG1UOEkEYOF0/export?format=txt",
"9550eb05c827429249a3de95b0a8d8975e4be4eb313a452d063b878db9ddb394"),
("drive003/EE_events__1IFujv.csv", DRIVE + "1IFujv_Lrq1WWBGfRFZi0Kptw7T-qvvc5",
"b49acfd2ec81edd49a8cb0000bfecdec156f91e3089bc40645f1c3978a2f72a5"),
("drive003/EE_events__1UeNcri.csv", DRIVE + "1UeNcri-M9Ix7M_wB__R-O0SG-iV_r-d6",
"b49acfd2ec81edd49a8cb0000bfecdec156f91e3089bc40645f1c3978a2f72a5"),
("drive003/MANIFEST__11NQ4s.md", DRIVE + "11NQ4sWNLJYZ9SSCTW45iL2CxVn6iaVky",
"b334f4467d636352e3b259835bcb916c3d9fb0841746c7f37231a2e86da8584e"),
("drive003/daily_ee_kp.csv", DRIVE + "1CvXqhDhOmAqL3pNAeTmfk5jhXEE05BL0",
"43fff9235387afaac7fed99f80d5e7f592bc8ca140247ade1711da5403ab8b61"),
("drive003/PipelineA_storm_threshold_table.csv", DRIVE + "1EjNonKz7oCXWO7zmC5jd2fIoOjzUBfvy",
"285a0eb222cc377ac8f164a16383c4a252f60aa78e78ca576d648622e533ee29"),
("drive003/PipelineA_TABLE1_results.csv", DRIVE + "1gABGOJAlTooOSbAqRaOtRekxq6zywfyy",
"0bd774fc48d80b8bc8b1d90ecd1e73680713f1c8946114e4be275d3345d90a86"),
("gfz/Kp_ap_Ap_SN_F107_since_1932.txt", "https://kp.gfz.de/app/files/Kp_ap_Ap_SN_F107_since_1932.txt",
"20f204e2daef813016a3fae93a3d84363e1e66d4eb9f1a01ffb03755925e5068"),
("gfz/Kp_ap_nowcast.txt", "https://kp.gfz.de/app/files/Kp_ap_nowcast.txt",
"77bf1a91f79502475de717c6e7370bc50a77f9a3717a35f4a2dca31a9bee19f0"),
("swpc/alerts.json", "https://services.swpc.noaa.gov/products/alerts.json",
"1ce8e27e9f0e94344f1b84a96f96de608a670489011cb95867bfb421d0075762"),
("swpc/daily-geomagnetic-indices.txt", "https://services.swpc.noaa.gov/text/daily-geomagnetic-indices.txt",
"2e6bbedbda0c02372b254209b7e4517770ff49a899dc1888e40d8e9e581e5ce2"),
("swpc/noaa-planetary-k-index.json", "https://services.swpc.noaa.gov/products/noaa-planetary-k-index.json",
"8268a95d67654e5470812cc2ab88ec33b5c857ccf25a7107bf91409c0d447e17"),
("igrf/igrf14coeffs.txt", "https://www.ngdc.noaa.gov/IAGA/vmod/coeffs/igrf14coeffs.txt",
"8f8d88403028fc4ee92c4f38d97b46e0a87e2cfc496045b43c9e26c1d6b0903c"),
("iana/northamerica", "https://data.iana.org/time-zones/tzdb/northamerica",
"da7366f6e0862ed15cb787dd056dca3a255df2ec50d19ff0a9f54eeb1562083a"),
]
DGD = {"2024Q1": "4bab3960da537c4610f25667af4c376464a36eb6df47f6b60e24079d082d099e",
"2024Q2": "95ce37b6c50a2ed850cd1165f28506ec836e7f863c68e33eea34aad61060b378",
"2024Q3": "aaf0e7717b0e8fce97f5e1ce5810cced6eeff4ced8fe06b2f80bc127502d6c00",
"2024Q4": "9f32be20a13dbd21a4fea58dfa5237eb4153c90f93f7365d71c30020dbe40e6d",
"2025Q1": "8fe2c06650acb2680005e8ea08c54aabf5ecce8b8c6791388bea9a2b59fdb968",
"2025Q2": "996fee4152e143446a6e18c79c218f927aed177f9034af697effa934c999ee00",
"2025Q3": "2171a20c07b5f2b3e9ec894c27383bfa63d1e353fa16353e16cf6f1042ad0a3a",
"2025Q4": "3e34e8b860fa999fbab96d37f7756d17f72a6bade0bff91d4f8caf484eba502b",
"2026Q1": "16ae9ae600363499d6a3d7f3da34dd5a882783b487265fb92496d83dfbc9034c",
"2026Q2": "d5848aeb96d20ce521feca8dbf8bec8a780d56f539db7a14dda5e6fe51f0e715",
"2026Q3": "0349ea0cc18e03aec3c4514f33c2e1d9aac55dd543cd4c669d06a74bc4a3e4f7",
"2026Q4": "739364ae9497f65d1795e60619ad242fdc64cf9e46de3f4c77752a52a768309a"}
FILES += [(f"swpc/dgd/{q}_DGD.txt", f"{SWPC_FTP}{q}_DGD.txt", h) for q, h in DGD.items()]
def fetch(url, out):
req = urllib.request.Request(url, headers={"User-Agent": UA}) if url.startswith("http") else url
try:
with urllib.request.urlopen(req, timeout=180) as r:
data = r.read()
except urllib.error.HTTPError as e:
if e.code in (403, 429):
sys.exit(f"Refused ({e.code}) at {url}: stopping, as the page's rules ask. Nothing was retried.")
raise
out.parent.mkdir(parents=True, exist_ok=True)
out.write_bytes(data)
return data
def main():
if len(sys.argv) != 2:
sys.exit(__doc__)
base = Path(sys.argv[1]) / "downloads"
for rel, url, ours in FILES:
data = fetch(url, base / rel)
h = hashlib.sha256(data).hexdigest()
note = "same as ours" if h == ours else "differs from ours (expected for files that update)"
print(f"{rel:46s} {len(data):>9,} bytes {h[:12]}… {note}")
print("Done. Next: check_freeze.py, check_storms.py, swpc_alerts.py, baserate.py, amendment2.py, context_numbers.py "
"and charts.py, each with the downloads folder (see each script's first lines).")
if __name__ == "__main__":
main()