#!/usr/bin/env python3 """Re-run every number of ours on /preseismic-geomagnetic-network/. Standard library only. 1. Download SwarmA-MagSet.zip from Zenodo, https://doi.org/10.5281/zenodo.17862825 (CC BY 4.0). 2. python3 -I fetch_public_inputs.py --accept-esa-terms (read the terms at the top of that script first; without the flag, the two steps that need ESA's files are skipped) 3. python3 -I run_all.py It runs each script next to it in order, reading the zip without extracting it, and writes the outputs to the out folder. They should match the files hosted on the page, unless GFZ, OMNI or USGS have revised what they serve. A few minutes on an ordinary computer. """ import subprocess import sys from pathlib import Path HERE = Path(__file__).resolve().parent def main(): if len(sys.argv) != 4: sys.exit(__doc__) zpath, inputs, out = sys.argv[1], Path(sys.argv[2]), Path(sys.argv[3]) out.mkdir(parents=True, exist_ok=True) idx, ibi, usgs = str(inputs / "indices"), str(inputs / "ibi"), str(inputs / "usgs") o = str(out) has_esa = any((inputs / "ibi").glob("SW_OPER_IBIATMS_2F_*.ZIP")) esa_steps = {"swarma_date_proof.py", "swarma_baselines.py"} steps = [ ("swarma_structure.py", zpath, o), ("swarma_kp_search.py", str(out / "swarma_samples.csv"), str(inputs / "indices" / "Kp_ap_since_1932.txt")), ("swarma_dating.py", zpath, idx, o), ("swarma_date_proof.py", zpath, ibi, idx, o), ("swarma_chart_data.py", idx, o), ("swarma_baselines.py", zpath, ibi, o), ("swarma_pa_recipe.py", zpath, o), ("swarma_pa_check.py", zpath, o), ("swarma_catalogue.py", zpath, usgs, o), ("swarma_shift_test.py", zpath, usgs, o), ("swarma_extremes.py", zpath, str(out / "swarma_samples_dated.csv")), ("base_rate.py", usgs, o), ] for script, *args in steps: print(f"\n=== {script}", flush=True) if script in esa_steps and not has_esa: print("Skipped: it needs ESA's files, and the ibi folder holds none. Its hosted output stands unchecked.", flush=True) continue subprocess.run([sys.executable, "-I", str(HERE / script), *args], check=True) print("\nDone. Outputs are in", out) if __name__ == "__main__": main()