"""fetch_inputs.py -- downloads the inputs of this page's analysis and checks them against the copies we used. python3 fetch_inputs.py [inputs-folder] (default: ./inputs) Each file is fetched by URL with the plain client name "factchecked-research/1.0" (skipped if already present), then its SHA-256 is compared with the copy we used on 19 November 2026. A different hash is reported, not fatal: sources get updated, and our results then may differ slightly. Standard library only. The paper's figure images are fetched for the digitization re-run only; they are the authors' (CC BY 4.0) and are not redistributed by us. """ import hashlib import os import sys import urllib.request UA = "factchecked-research/1.0" IOP = "https://content.cld.iop.org/journals/0004-637X/1012/1/79/revision2/" SCRIPPS = "https://keelinglabsites.ucsd.edu/websitedatao2/" INPUTS = { # name: (url, sha256 of our copy) "apjaeb6abf4_hr.jpg": (IOP + "apjaeb6abf4_hr.jpg", "c0d483d85471eeae8301d1f6d5dd1ad96b76346f0ddd5ec2e3d78208bb0750b5"), "apjaeb6abf5_hr.jpg": (IOP + "apjaeb6abf5_hr.jpg", "59cdfc2e8b0914ddf3b34d5483e59205e39206f005992cfaa257b13e09e4ac62"), "apjaeb6abf6_hr.jpg": (IOP + "apjaeb6abf6_hr.jpg", "48ea35ea37b55a5317430aeafb4ef8286f5d5e9d576794ac0b143cfad6b10c63"), "igrf14coeffs.txt": ("https://www.ngdc.noaa.gov/IAGA/vmod/coeffs/igrf14coeffs.txt", "8f8d88403028fc4ee92c4f38d97b46e0a87e2cfc496045b43c9e26c1d6b0903c"), "pymagglobal_gufm1": ("https://git.gfz-potsdam.de/api/v4/projects/1055/repository/blobs/" "ff898addfea89c06f99096b3e343382ba45286ad/raw", "81b7d25a754011de1fe2453999ed20242fb88ac6c2f8c8750b63537df80ac9fe"), "monthly_o2_alt.csv": (SCRIPPS + "monthly_o2_alt.csv", "0da1663e89058ed6255c38844dc78c26ca3bae76165632da8930eb7681ed4561"), "monthly_o2_ljo.csv": (SCRIPPS + "monthly_o2_ljo.csv", "76dfbb54b09b05729b53d0b21aec30bc1e733bf57f15762ae7f949a0d693e769"), "monthly_o2_cgo.csv": (SCRIPPS + "monthly_o2_cgo.csv", "74f921ada8095940a39d389875f3301df45b79126d5bf57fe7550be62e593c6d"), "monthly_o2_spo.csv": (SCRIPPS + "monthly_o2_spo.csv", "e7dfc16451ce72c6b66776d2f6bda49ca5adefcaf607583db0ccc82fa79fff0d"), # our own earlier page's results (O2 inventory, the measured O2 decline, Slapak et al.'s annual mean escape) "oxygen-budget.json": ("https://factchecked.science/ring-current-oxygen/oxygen-budget.json", "2bdb504714917bc8a8ea1e2cdba26c981198c30326c80c3d08ee79ad790dfa95"), } def main(): folder = sys.argv[1] if len(sys.argv) > 1 else "inputs" os.makedirs(folder, exist_ok=True) ok = True for name, (url, want) in INPUTS.items(): path = os.path.join(folder, name) if not os.path.exists(path): print("fetching", url) req = urllib.request.Request(url, headers={"User-Agent": UA}) try: with urllib.request.urlopen(req, timeout=180) as r: data = r.read() except Exception as e: # a refusal is an answer: report it, don't retry print(" could not fetch %s: %s" % (name, e)) ok = False continue with open(path, "wb") as f: f.write(data) with open(path, "rb") as f: got = hashlib.sha256(f.read()).hexdigest() if got == want: print(" %-22s SHA-256 matches the copy we used" % name) else: ok = False print(" %-22s differs from the copy we used (ours %s..., yours %s...)" % (name, want[:16], got[:16])) print("all inputs match" if ok else "some inputs are missing or differ; see above") if __name__ == "__main__": main()