"""Single entry point of the impact_window study. python3 code/run_all.py # download (or reuse cached raw files), compute, draw python3 code/run_all.py --no-fetch # skip the download step and use the CSVs already in data/ Regenerates every table in data/, data/results.json and every figure in figures/, and runs independent_check.py (a re-computation of one model that shares no code with model.py). Runtime: about ten minutes on one free core (single-threaded by construction). Needs numpy, scipy, pandas, matplotlib and the `pdftotext` command (poppler) for the two PDF sources. """ from __future__ import annotations import os import sys import time # one thread only: the machine is shared, and oversubscribed BLAS threads slow the run tenfold for _v in ("OMP_NUM_THREADS", "OPENBLAS_NUM_THREADS", "MKL_NUM_THREADS"): os.environ.setdefault(_v, "1") sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import config as cfg # noqa: E402 def main(): t0 = time.time() if "--no-fetch" not in sys.argv: import fetch_data counts = fetch_data.run() print("data:", counts, flush=True) import analysis import figures res = analysis.main() figs = figures.make(res) print("figures:", figs) import independent_check print("\nIndependent check of Neukum 1983 x main-belt shape (shares no code with model.py):") print(independent_check.compare().to_string(index=False)) s = res["summary"] for cond in cfg.HSE_MAIN: print(f"\nHeadline numbers, {cfg.HSE_LABEL[cond]} (mixture over 7 chronologies x 3 size distributions)") for D in (190, 440, 740, 2000): k = s["by_hse"][cond][f"ge{D}"] print(f" last impactor >= {D} km: median {k['median_last_ALL']:.2f} Ga, 10% chance younger than " f"{k['q90_ALL']:.2f} Ga (median by chronology {k['median_last_range_chron'][0]:.2f}-" f"{k['median_last_range_chron'][1]:.2f}); P(none after 4.404 / 4.2 / 3.9 Ga) = " f"{k['P_none_since_4p404_ALL']:.2f} / {k['P_none_ALL']['4.2']:.2f} / {k['P_none_ALL']['3.9']:.2f}") for lab, d in s["bayes"][cond].items(): b = d["ge440"] print(f" {lab}: B(m=1) survive {b['B_survive'][1]:.1f}, sterilise>=440 km {b['B_sterilise'][1]:.1f}, " f"50:50 {b['B_mixed50'][1]:.1f}; sterilise>=190 km {d['ge190']['B_sterilise'][1]:.1f}; " f">=740 km {d['ge740']['B_sterilise'][1]:.1f}; >=2000 km {d['ge2000']['B_sterilise'][1]:.1f}") print(f"done in {time.time() - t0:.0f} s; tables in {cfg.DATA}, figures in {cfg.FIGS}") if __name__ == "__main__": main()