#!/usr/bin/env python3 """Fetch every input of our check of S0 News's research note 001 into /downloads/, by URL. python3 -I fetch_inputs.py - S0 News's derived CSVs come from the note's public Drive folder. We don't host them. - The Sierra Nevada station team's f1 series come from the University of Granada's repository, as HTTP byte ranges of one zip: about 17.5 MB of a 602 MB file. Each member is checked against the zip's own CRC-32. - GFZ's Kp, international quiet days and F10.7 come whole. Every request sends the plain client name below, with TLS verification on. Nothing fetched is ever run. Each file's SHA-256 is compared with the copy behind the page. The station series and the quiet-day lists must match. GFZ's whole-record files grow every day, and S0 News could edit its files, so a difference there is reported, not fatal. Then run the scripts with the same , e.g. python3 -I 02_placebo_f1.py ; outputs go to /out/. """ import hashlib, os, struct, sys, time, urllib.request, zlib UA = 'factchecked-research/1.0' DRIVE = { # Drive folder 1RPHVwpZ0MKYb88VyK4rtM8bEy10H0uHo, as listed on 2026-11-06 'early_window_per_episode.csv': '1JW5Iody80xFXXAdFzsx3GkDzNexb0Rjk', 'episodes_inventory.csv': '1Hvr9nF_Uo6TKBpTJvzWYoWe8bfzIWTfF', 'epoch_composite_NS_f1.csv': '1iBOA9yTGqTsg7sp_GQ02EKGxEdwMXadc', 'epoch_composite_TEC.csv': '19Qk-GS0sUJKXcCvZZhzSr13oty8Svl7l', 'KM_curves.csv': '1y_6129BeZ_82hZTq3gznye8rJ6AknhKJ', 'MANIFEST.md': '1XdFKCaoDJ99_rGUyyUp7Eswmj1lu1-gr', 'PipelineA_NS_f1_Trec.csv': '1TVEDZULnzcRcL9Fo_eYpVu8mauhquayu', 'PipelineA_TEC_Trec.csv': '1RXDRyvuCsnKLqhWCRB9oVeDDC2N4FvJp', 'PipelineB_NS_f1_TEC_Trec.csv': '1iujLQsfYWB1xkugo353z-WYHUA8-4NKs', 'quiet_days.csv': '1g-biOiXRPFEJsA4OYveyL_kkfk8ebXxw', 'TABLE1_KM_summary.csv': '10kbvzeapebeik7EnzwTD1Ced2bdXS-mK', 'TABLE_early_window_Holm.csv': '1lA9GfUhACnCS65jF8JN42difth1KnDeH', } ZIP_URL = 'https://digibug.ugr.es/bitstream/10481/78098/1/Study_of_Anomalies.zip' MEMBERS = ['f1_0_t.npy', 'f1_1_t.npy', 'Ma_t_t.npy', 'Ma_0_t.npy', 'Ma_1_t.npy'] GFZ = {'Kp_ap_since_1932.txt': 'https://kp.gfz-potsdam.de/fileadmin/files_for_gfz_cms/Kp_ap_since_1932.txt', 'Kp_ap_Ap_SN_F107_since_1932.txt': 'https://kp.gfz-potsdam.de/fileadmin/files_for_gfz_cms/Kp_ap_Ap_SN_F107_since_1932.txt'} for y in range(2012, 2020): GFZ['QD_days%d.txt' % y] = 'https://datapub.gfz.de/download/10.5880.Kp.0001/Quiet_Disturbed_Days/QD_days%d.txt' % y OURS = { # SHA-256 of the copies behind the page, fetched 2026-11-06 'f1_0_t.npy': '8f5430dfbb91e47cee5dd375dc99cd1712c64fdb1a164d695c535ac6b4b40620', 'f1_1_t.npy': '937dc42ceca9ceeec04cfca31cdc49a184ecdb5f4b3bc2d5db160bc2e6cd4d80', 'Ma_t_t.npy': '93a3d404d1a26d9df4bcd6731ac1521e99762ad785ac5886345c8d64d4d568f8', 'Ma_0_t.npy': '2307935828f5217157162b4eb5796a4ab0151923f94281a38a404da656964a89', 'Ma_1_t.npy': '356fd275e09f76b8d028bdb58e49f1872dd401beb3970876c4174c6a610ddd98', 'QD_days2012.txt': '3ff6cecf991c06d6ad77c044f450c3de962f17686c05ca5e08f18d0435363cc3', 'QD_days2013.txt': 'dac1053212e4b9a35bc43c7ef0f3a114343a2a018bcba787a5183815ac8076d0', 'QD_days2014.txt': '9be0d2c40a565beaa80b6e7c834c46e0f45cbda7320915ad2b3bb6f2cb2f3f85', 'QD_days2015.txt': 'a13688d1408590be02daf5036870a0f837ae66d5a7c37eba7e492201144be899', 'QD_days2016.txt': '8d0671405e87f6c8a3f4159ec3e6d42ad9386b81973aac557274ac74cb5a4551', 'QD_days2017.txt': '55d5d967b2f6e79a4cdfa313eb58f23d0bcb32025ebf119535af09901dd359ca', 'QD_days2018.txt': 'bc9e68409a1fdbc9765bc351db47a51a993f18fa52e3698673cfce1c64b84738', 'QD_days2019.txt': '60eae9e7af15724aaf6154339330e3aee77d87d073594ef601ea5e9ed843ce5c', 'Kp_ap_since_1932.txt': 'f232a06ef2b76cf28ef70f5326aa9741fdf9d27d70c671b95ae52e6b00482fe4', 'Kp_ap_Ap_SN_F107_since_1932.txt': 'af01278a905944bc55a9ea4dbd00942566b56a8e9e7361e2a55808268e7bced8', 'early_window_per_episode.csv': '9ec278a57c75215f46f506cb460e00d630dce84e9b0f204e870b830532ea699b', 'episodes_inventory.csv': 'a120f0e72048d256ce11e36e3aef8ebf16996c0df65aee2b29cd608d5ca1f351', 'epoch_composite_NS_f1.csv': 'd4e470bc1f6a3fb6396793c7f038ec6a9dc8e77aac2cc92f97d22e011897c4ab', 'epoch_composite_TEC.csv': 'b549c00e31ba93e14af3d15424488fdf0ba5ab7bc13d7fd61776912b12a80f5e', 'KM_curves.csv': '3582780649a2b33a9df231248573213de2f845c722db0e834ec0f4c03148f9c5', 'MANIFEST.md': '527201a35e1178099dd7176da4d7816461a16c54ae988ef3aab6b121186bee04', 'PipelineA_NS_f1_Trec.csv': 'be683f2e06dfe01c290737e631c7d376cb3cc593529fd6f48b82fc44f1dbc3a6', 'PipelineA_TEC_Trec.csv': '769b9349e3426951f37b8ea318e1d0f6085f157611e5881e06075ea36d787412', 'PipelineB_NS_f1_TEC_Trec.csv': '81b5e82854409f62127661b8b34a72058082b4ceb87e4b85b325632c411940c3', 'quiet_days.csv': 'af53e8c3fe92a300d919a87c92ea3a8dd39291005106db351f44d108d919ca36', 'TABLE1_KM_summary.csv': 'ed9bc5a1cdfeff785aca6346bd00e2a93914d662bb48c58b73ff8a5d02f2f4eb', 'TABLE_early_window_Holm.csv': '593d6bf85e9d6cbd50ac57100771d7d15a46004afe9fe53a576fd443b322d794', } MUST_MATCH = set(MEMBERS) | {k for k in OURS if k.startswith('QD_days')} LOG = [] def get(url, rng=None, method='GET'): headers = {'User-Agent': UA} if rng: headers['Range'] = 'bytes=%d-%d' % rng req = urllib.request.Request(url, headers=headers, method=method) with urllib.request.urlopen(req, timeout=600) as r: data = r.read() if method == 'GET' else b'' LOG.append((time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()), url + ('#bytes=%d-%d' % rng if rng else ''), r.status, len(data), hashlib.sha256(data).hexdigest() if data else '-')) return r.status, data, r.headers def save(path, data, name): os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, 'wb') as fh: fh.write(data) h = hashlib.sha256(data).hexdigest() want = OURS.get(name) if want and h != want: msg = f'{name}: SHA-256 {h} differs from the copy behind the page ({want})' if name in MUST_MATCH: sys.exit('STOP: ' + msg) print('NOTE: ' + msg) else: print(f'{name}: {len(data)} bytes, SHA-256 matches' if want else f'{name}: {len(data)} bytes') def main(): if len(sys.argv) != 2: sys.exit(__doc__) root = os.path.abspath(sys.argv[1]); dl = os.path.join(root, 'downloads') os.makedirs(os.path.join(root, 'out'), exist_ok=True) for name, fid in DRIVE.items(): st, data, _ = get('https://drive.google.com/uc?export=download&id=' + fid) if data[:15].lower().startswith(b'