"""Fetch the inputs of our analysis and check each against the SHA-256 of the copy we used. 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). What it fetches (identifying itself as "factchecked-research/1.0") /bira/ the six netCDF files of Winant, Pierrard & Botek (2026), "L-Time average of EPT and MEPED electron observations following strong geomagnetic storms", BIRA-IASB, doi:10.18758/lu12i2kq (CC BY 4.0), from data.aeronomie.be (about 12 MB) /kyoto/ hourly Dst from the HAPI server of the World Data Center for Geomagnetism, Kyoto (doi:10.17593/14515-74000): final 1998-2020 and provisional 2021 to September 2026, the same three queries we made (about 7 MB). Kyoto's terms: scientific, non-commercial use with acknowledgement, https://wdc.kugi.kyoto-u.ac.jp/wdc/Sec3.html. The WDC revises provisional values from time to time, so a later download of the provisional file may not match our copy. /field/ magnetic-field-guide-numbers.json, the IGRF-14 dipole series of factchecked.science With --meped: NOAA NCEI POES/MetOp SEM-2 (MEPED) daily files listed in meped_files.txt (URL, bytes, SHA-256), into /meped/metop03, /meped/noaa15_proc and /meped/noaa15_txt. That is 616 files, about 2.5 GB: the script only says so and stops, unless --yes is also given. Needs Python 3.9+ (standard library only). Run python3 fetch_inputs.py python3 fetch_inputs.py --meped [] --yes Files already present with the right SHA-256 are kept. On any mismatch the script stops and says which file differs; the downloaded file is kept as .mismatch so that it can be inspected. """ import hashlib import os import sys import urllib.error import urllib.request UA = "factchecked-research/1.0" BIRA = "https://data.aeronomie.be/dataset/438f2e25-aee0-42ea-a4de-8b6dabe78b03/resource/" INPUTS = [ ("bira", "electrons_3h_0.1_lt_2024_may_jul.nc", BIRA + "2dc07410-9ef8-4d33-a497-057cde183708/download/electrons_3h_0.1_lt_2024_may_jul.nc", "e56ef1107b3435f0c8aa5d9759f17d61ccb5844895bc742c81801564b51a3c10"), ("bira", "electrons_3h_0.1_lt_2024_oct_dec.nc", BIRA + "2732b922-4397-466b-af43-0c28eb90431a/download/electrons_3h_0.1_lt_2024_oct_dec.nc", "3c56310e3b007e4ddcbae87e4c7e4f5cfc0e664eb52b64f487b28c94d038d74a"), ("bira", "electrons_3h_lt_2025_jun_jul.nc", BIRA + "7233ac44-84a2-48b2-9092-56fc111b9d62/download/electrons_3h_lt_2025_jun_jul.nc", "16850c369f1592e938afd94b23e41a462773779a6dfde368e2e95d8fe4f26578"), ("bira", "electrons_3h_lt_2026_jan_feb.nc", BIRA + "d461ca03-b95d-402b-878d-87f0a0d05005/download/electrons_3h_lt_2026_jan_feb.nc", "185214ce8463ac2c93b8282a7986b450bd53bb5b9d182f76c22727a2534d35a2"), ("bira", "electrons_3h_0.05_lt_2026_jul_aug.nc", BIRA + "1794b9e0-7301-4679-9cc0-2b4855943239/download/electrons_3h_0.05_lt_2026_jul_aug.nc", "db479d6f78842305bfc279abefecde2aae045348be2cd873f5bd655b3c612600"), ("bira", "poes_e90_6hav_0.1l_2024_may_jun.nc", BIRA + "6058b094-fbbd-4f97-8d89-b5f76e4c5f3e/download/poes_e90_6hav_0.1l_2024_may_jun.nc", "8adfc4c50d7c317ac5b699708e6dc76f580296412fa9d16e2526b00b61468162"), ("kyoto", "dst_final_1998_2003-09.csv", "https://wdc.kugi.kyoto-u.ac.jp/hapi/data?id=hour_dst_final&time.min=1998-01-01T00:29:30Z" "&time.max=2003-10-01T00:29:30Z&format=csv", "e2acef21e55e0c915e9a84e8e10825770f854310b6108849bece24a34f343fd2"), ("kyoto", "dst_final_2003-10_2020.csv", "https://wdc.kugi.kyoto-u.ac.jp/hapi/data?id=hour_dst_final&time.min=2003-10-01T00:29:30Z" "&time.max=2021-01-01T00:29:30Z&format=csv", "8532c70110d6b3e24a949db882458cd48fa7e0fe040c73b61563e298a07fb1ea"), ("kyoto", "dst_provisional_2021_2026-09.csv", "https://wdc.kugi.kyoto-u.ac.jp/hapi/data?id=hour_dst_provisional&time.min=2021-01-01T00:29:30Z" "&time.max=2026-10-01T00:29:30Z&format=csv", "e3846d08142639dd2b8e07669aebb66ab88ed83c1fd206a67985636be2499454"), ("field", "magnetic-field-guide-numbers.json", "https://factchecked.science/magnetic-field-guide/magnetic-field-guide-numbers.json", "cb6cfee622898a281e64b8e725dae1240d36f8d3b3bbafbeeb5fc92f101974fd"), ] def sha256(path): h = hashlib.sha256() with open(path, "rb") as f: for chunk in iter(lambda: f.read(1 << 20), b""): h.update(chunk) return h.hexdigest() def fetch(url, path, want): if os.path.exists(path) and sha256(path) == want: print("have ", path) return part = path + ".part" req = urllib.request.Request(url, headers={"User-Agent": UA}) try: with urllib.request.urlopen(req, timeout=600) as r, open(part, "wb") as f: while True: chunk = r.read(1 << 20) if not chunk: break f.write(chunk) except urllib.error.HTTPError as e: if os.path.exists(part): os.remove(part) sys.exit(f"STOP: {url} answered HTTP {e.code}. Nothing was retried; fetch it by hand if you can, or ask the " f"site's owner.") except urllib.error.URLError as e: if os.path.exists(part): os.remove(part) sys.exit(f"STOP: could not reach {url}: {e.reason}") got = sha256(part) if got != want: os.replace(part, path + ".mismatch") sys.exit(f"STOP: {os.path.basename(path)} differs from the copy we used.\n URL: {url}\n ours: {want}\n" f" yours: {got}\nThe source may have been revised (Kyoto revises provisional Dst; NOAA reprocesses " f"files), so results computed from it may differ from ours. The file is kept as " f"{path}.mismatch.") os.replace(part, path) print("fetched", path) def meped(folder, listfile, yes): rows = [] with open(listfile, encoding="utf-8") as f: for line in f: if line.startswith("#") or not line.strip(): continue url, size, want = line.rstrip("\n").split("\t") rows.append((url, int(size), want)) total = sum(r[1] for r in rows) print(f"{len(rows)} MEPED files, {total / 1e9:.2f} GB in all.") if not yes: sys.exit("Not fetching: add --yes to download them (about 2.5 GB).") for url, size, want in rows: name = url.rsplit("/", 1)[1] sub = "metop03" if "/metop03/" in url else ("noaa15_proc" if name.endswith("_proc.nc") else "noaa15_txt") os.makedirs(os.path.join(folder, "meped", sub), exist_ok=True) fetch(url, os.path.join(folder, "meped", sub, name), want) def main(): args = sys.argv[1:] if not args or args[0].startswith("-"): sys.exit("usage: python3 fetch_inputs.py [--meped [] [--yes]]") folder = args[0] if "--meped" in args: i = args.index("--meped") listfile = args[i + 1] if i + 1 < len(args) and not args[i + 1].startswith("-") else \ os.path.join(os.path.dirname(os.path.abspath(__file__)), "meped_files.txt") meped(folder, listfile, "--yes" in args) return for sub, name, url, want in INPUTS: os.makedirs(os.path.join(folder, sub), exist_ok=True) fetch(url, os.path.join(folder, sub, name), want) print("All inputs present and matching our copies.") if __name__ == "__main__": main()