#!/usr/bin/env python3 """Single entry point: regenerates every number, figure and the report. python3 code/run_all.py # full run (~15 min on one core once # the raw data are downloaded) python3 code/run_all.py --quick # fewer bootstrap resamples (~9 min) python3 code/run_all.py --no-fetch # never touch the network Steps 1. fetch_data download raw catalogues (skipped if already present) into $HEADSTART_RAW (default fermi_raw/headstart/) 2. age_scales star-by-star comparison of the catalogue age scales 3. analysis_xr LAMOST subgiant tracers (Xiang & Rix 2022): column SFH, cut-flow, layer test, systematics table 4. analysis_nataf Nataf+ 2024 subgiants: second tracer sample 5. analysis_gaia_sg Gaia-only subgiants within 200 pc (cross-check) 6. age_scales paired age-swap test (LAMOST stars with Nataf+24 ages) 7. analysis_ms unevolved Sun-like dwarfs: GCS, Gaia FLAME, solar twins 8. published_sfh published CMD-fit SFHs re-integrated 9. fermi_clock head-start summary, adopted value, Sun's rank, Fermi clock 10. figures figures/fig1..fig5 11. make_report report.md, filled in from the tables in data/ All derived tables go to data/, figures to figures/. Random seeds are fixed. """ import os import sys import time sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) def main(argv): quick = "--quick" in argv t0 = time.time() def stamp(msg): print(f"\n===== [{time.time() - t0:6.0f} s] {msg} =====", flush=True) if "--no-fetch" not in argv: stamp("1/11 fetch raw data (idempotent)") import fetch_data fetch_data.main() stamp("2/11 catalogue age scales") import age_scales age_scales.main() stamp("3/11 LAMOST subgiant tracers (Xiang & Rix 2022)") import analysis_xr analysis_xr.main(n_boot=20 if quick else 100) stamp("4/11 Nataf+ 2024 subgiant tracers") import analysis_nataf analysis_nataf.main(n_boot=10 if quick else 50) stamp("5/11 Gaia-only 200 pc subgiant tracers (cross-check)") import analysis_gaia_sg analysis_gaia_sg.main(n_boot=8 if quick else 30) stamp("6/11 paired age-swap test") print(age_scales.age_swap_test()) stamp("7/11 unevolved Sun-like dwarfs (GCS, FLAME, solar twins)") import analysis_ms analysis_ms.main() stamp("8/11 published star-formation histories") import published_sfh import numpy as np tab = published_sfh.table() tab.to_csv(os.path.join(analysis_xr.C.DATA, "published_sfh_table.csv")) print(tab[["kind", "f_gt_0", "f_gt_1", "f_gt_3", "f_gt_5", "mean_headstart_older", "young_frac_lt2"]].round(3).to_string()) f = np.array([m["f_gt_0"] for m in published_sfh.mazzi_mc()]) print("Mazzi+24 f_older with quoted bin errors: %.3f (+%.3f/-%.3f)" % (np.median(f), np.percentile(f, 84) - np.median(f), np.median(f) - np.percentile(f, 16))) stamp("9/11 head-start summary and Fermi clock") import fermi_clock fermi_clock.main() stamp("10/11 figures") import figures figures.main() stamp("11/11 report") import make_report make_report.main(runtime_s=time.time() - t0, quick=quick) stamp("done") if __name__ == "__main__": main(sys.argv[1:])