# Hosted copy (Fact-Checked Science, /amundsen-low-solar-cycle/): reads its inputs from the folder given as the # first argument, filled by fetch_inputs.py, and writes its outputs to /out/. Run it with Python 3.10+, # numpy and scipy, from the folder that holds this script, asl_lib.py, surr_lib.py and the RULES files. """05b_sam_posthoc.py — POST HOC, exploratory: why S1 (-0.879) differs from the note's -0.883. Tries small lags and window variants for ASL v3 sector pressure vs NOAA CPC AAO, 60-month CMAs. Fact-Checked Science, 2026-11-15. Usage: py -3.12 -I 05b_sam_posthoc.py""" import os, sys here = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, here) import numpy as np import asl_lib as A root = os.path.abspath(sys.argv[1]) if len(sys.argv) > 1 else os.getcwd() dl = root v3, _ = A.load_v3(os.path.join(dl, "asli_calculation_latest.csv")) d = {} for line in open(os.path.join(dl, "monthly.aao.index.b79.current.ascii"), encoding="utf-8"): p = line.split() if len(p) == 3 and p[0].isdigit(): d[int(p[0]) * 12 + int(p[1]) - 1] = float(p[2]) aao = A._from_dict(d) out = [] for end_asl in ("2026-07", "2026-08"): asl = v3.restrict(A.ym("1979-01"), A.ym(end_asl)) for w in (60,): for odd in (False, True): ac, xc = A.cma(asl, w, odd), A.cma(aao.restrict(A.ym("1979-01"), aao.end), w, odd) for L in range(-6, 7): x, y, _ = A.pair(xc, ac, L) # AAO at t, ASL at t+L out.append((A.pearson(x, y), end_asl, odd, L, len(x))) for r, e, o, L, n in sorted(out, key=lambda z: abs(z[0] + 0.883))[:8]: print(f"r = {r:.4f} ASL to {e} odd={o} ASL lag {L:+d} m n = {n}")