#!/usr/bin/env python3 """Reproduction of Popescu (2026), doi:10.1016/j.asr.2026.10.093, from OMNI2, IGRF-14 and GFZ's Kp. Rules: RULES_reproduction.txt (pre-registered). Run: py -3.12 -I reproduce.py Writes out/reproduction/*.csv, *.json and a log. Needs numpy and scipy. """ import csv import json import math import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, HERE) import numpy as np from scipy import stats import omni_common as oc OUTDIR = os.path.join(oc.OUT, "reproduction") os.makedirs(OUTDIR, exist_ok=True) LOG = [] def log(*a): s = " ".join(str(x) for x in a) print(s) LOG.append(s) def wcsv(name, header, rows): with open(os.path.join(OUTDIR, name), "w", encoding="utf-8", newline="\n") as f: w = csv.writer(f, lineterminator="\n") w.writerow(header) w.writerows(rows) def rel(a, b): return (a - b) / b if b else float("nan") def rolling_rows(x, n, minp): out = np.full(len(x), np.nan) for i in range(len(x)): w = x[max(0, i - n + 1):i + 1] w = w[~np.isnan(w)] if len(w) >= minp: out[i] = w.mean() return out def pearson(a, b): ok = ~np.isnan(a) & ~np.isnan(b) return float(np.corrcoef(a[ok], b[ok])[0, 1]), int(ok.sum()) # ---------------------------------------------------------------- hashes log("# reproduce.py run") for name in ("RULES_reproduction.txt",): log("rules", name, oc.sha256(os.path.join(HERE, name))) YEARS = list(range(1963, 2027)) hashes = {} for y in YEARS: hashes["omni2_%d.dat" % y] = oc.sha256(os.path.join(oc.DL, "omni2", "omni2_%d.dat" % y)) hashes["igrf14coeffs.txt"] = oc.sha256(os.path.join(oc.DL, "igrf14", "igrf14coeffs.txt")) hashes["Kp_ap_since_1932.txt"] = oc.sha256(os.path.join(oc.DL, "gfz-kp", "Kp_ap_since_1932.txt")) for n in ("1-s2.0-S0273117726015188-mmc3.csv", "1-s2.0-S0273117726015188-mmc4.csv"): hashes[n] = oc.sha256(os.path.join(oc.SUPP, n)) for k, v in hashes.items(): log("sha256", k, v) # ---------------------------------------------------------------- R1 dipole igrf = oc.read_igrf() bdip = {y: oc.dipole_proxy(float(y), igrf) for y in YEARS} bdip_mid = {y: oc.dipole_proxy(y + 0.5, igrf) for y in YEARS} relp = {y: bdip[y] / bdip[1963] for y in YEARS} fac = {y: relp[y] ** (2.0 / 3.0) for y in YEARS} log("R1 B_dip 1963 %.6f nT; 2025 %.6f; 2026 %.6f" % (bdip[1963], bdip[2025], bdip[2026])) log("R1 relative proxy 2025 %.6f, 2026 %.6f; factor 2025 %.6f, 2026 %.6f; range of factor %.6f..%.6f; total %.3f%%" % (relp[2025], relp[2026], fac[2025], fac[2026], min(fac.values()), max(fac.values()), 100 * (max(fac.values()) - min(fac.values())))) # ---------------------------------------------------------------- R2 hourly epsilon d = oc.read_omni(YEARS) V, BY, BZ, BM = d[oc.W_V], d[oc.W_BY_GSM], d[oc.W_BZ_GSM], d[oc.W_BMAG] valid = ~np.isnan(V) & ~np.isnan(BY) & ~np.isnan(BZ) valid_b = valid & ~np.isnan(BM) log("R2 hours read %d; valid (V, By, Bz) %d; valid with |B| too %d; |B| present %d" % (len(V), valid.sum(), valid_b.sum(), (~np.isnan(BM)).sum())) eps = oc.epsilon(V, BY, BZ) bt = np.sqrt(BY ** 2 + BZ ** 2) i0 = int(np.argmax(valid)) log("R2 first valid hour: %d day %d hour %d; V %.0f By %.1f Bz %.1f; epsilon %.6e W (revision report: 4.159586e9)" % (d["year"][i0], d["doy"][i0], d["hour"][i0], V[i0], BY[i0], BZ[i0], eps[i0])) kp_omni = d[oc.W_KP] / 10.0 # GFZ Kp per hour gfz = oc.read_gfz_kp() kp_gfz = np.full(len(V), np.nan) for i in range(len(V)): key = (int(d["year"][i]), int(d["month"][i]), int(d["dom"][i]), int(d["hour"][i]) // 3 * 3) if key in gfz and gfz[key][0] >= 0: kp_gfz[i] = gfz[key][0] ann_t = {int(r["year"]): r for r in oc.annual_table()} mon_t = {r["month_id"]: r for r in oc.monthly_table()} # annual ann = {} for y in YEARS: sel = (d["year"] == y) m = sel & valid n = int(m.sum()) mb = sel & ~np.isnan(BM) months = [eps[m & (d["month"] == k)].mean() for k in range(1, 13) if (m & (d["month"] == k)).any()] ann[y] = dict(n=n, n_b=int((sel & valid_b).sum()), V=V[m].mean(), B=np.nanmean(BM[m]), B_all=BM[mb].mean(), BT=bt[m].mean(), eps=eps[m].mean(), eps_mm=float(np.mean(months)), kp_omni=np.nanmean(kp_omni[m]), kp_gfz_all=np.nanmean(kp_gfz[sel]), kp_gfz_valid=np.nanmean(kp_gfz[m]), eps_from_means=float(oc.epsilon(np.array([V[m].mean()]), np.array([BY[m].mean()]), np.array([BZ[m].mean()]))[0])) ann[y]["eps_scaled"] = ann[y]["eps"] * fac[y] ann[y]["ratio"] = bdip[y] / ann[y]["B"] ann[y]["ratio_all"] = bdip[y] / ann[y]["B_all"] # monthly mon = {} for y in YEARS: for k in range(1, 13): sel = (d["year"] == y) & (d["month"] == k) m = sel & valid n = int(m.sum()) if n == 0: continue mid = "%04d-%02d" % (y, k) mon[mid] = dict(year=y, n=n, V=V[m].mean(), B=np.nanmean(BM[m]), BT=bt[m].mean(), eps=eps[m].mean(), kp_omni=np.nanmean(kp_omni[m]), kp_gfz_all=np.nanmean(kp_gfz[sel]), kp_gfz_valid=np.nanmean(kp_gfz[m])) mon[mid]["eps_scaled"] = mon[mid]["eps"] * fac[y] ids = sorted(mon) log("R2 months with valid hours: %d (%s to %s); the paper's monthly table has %d rows (%s to %s)" % (len(ids), ids[0], ids[-1], len(mon_t), min(mon_t), max(mon_t))) missing_in_ours = sorted(set(mon_t) - set(mon)) extra_in_ours = sorted(set(mon) - set(mon_t)) log("R2 months in the table but not ours:", missing_in_ours, "; ours but not in the table:", extra_in_ours) # trailing means over rows (primary, as the table appears to be built) on the table's own row set + ours es = np.array([mon[i]["eps_scaled"] for i in ids]) kpo = np.array([mon[i]["kp_omni"] for i in ids]) kpg = np.array([mon[i]["kp_gfz_all"] for i in ids]) kpv = np.array([mon[i]["kp_gfz_valid"] for i in ids]) e60, e132 = rolling_rows(es, 60, 1), rolling_rows(es, 132, 1) k60 = {n: rolling_rows(x, 60, 12) for n, x in (("omni", kpo), ("gfz_all", kpg), ("gfz_valid", kpv))} k132 = {n: rolling_rows(x, 132, 24) for n, x in (("omni", kpo), ("gfz_all", kpg), ("gfz_valid", kpv))} for j, i in enumerate(ids): mon[i].update(e60=e60[j], e132=e132[j], k60=k60["omni"][j], k132=k132["omni"][j]) # ---------------------------------------------------------------- R5 row by row A_COLS = [("valid_hourly_records", "n"), ("solar_wind_speed_mean_km_s", "V"), ("imf_total_magnitude_mean_nT", "B"), ("imf_transverse_magnitude_mean_nT", "BT"), ("epsilon_native_mean_W", "eps"), ("epsilon_scaled_mean_W", "eps_scaled"), ("kp_mean", "kp_omni"), ("dipole_to_imf_proxy_ratio", "ratio")] rows, worst = [], {} for y in YEARS: t = ann_t[y] for col, key in A_COLS: ours, theirs = float(ann[y][key]), float(t[col]) rows.append([y, col, repr(ours), repr(theirs), repr(ours - theirs), repr(rel(ours, theirs))]) if y <= 2025: worst[col] = max(worst.get(col, 0.0), abs(rel(ours, theirs))) for col, ours in (("igrf14_dipole_proxy_nT", bdip[y]), ("igrf14_dipole_proxy_relative_to_1963", relp[y])): theirs = float(t[col]) rows.append([y, col, repr(ours), repr(theirs), repr(ours - theirs), repr(rel(ours, theirs))]) worst[col + "_absdiff"] = max(worst.get(col + "_absdiff", 0.0), abs(ours - theirs)) wcsv("annual_row_by_row.csv", ["year", "column", "ours", "paper_table", "difference", "relative_difference"], rows) log("R5 annual, largest |relative difference| over 1963-2025 by column:") for k, v in worst.items(): log(" %-45s %.3e" % (k, v)) t26 = ann_t[2026] log("R5 annual 2026 (file has grown): ours n=%d eps=%.4e scaled=%.4e Kp=%.3f | table n=%s eps=%.4e scaled=%.4e Kp=%.3f" % (ann[2026]["n"], ann[2026]["eps"], ann[2026]["eps_scaled"], ann[2026]["kp_omni"], t26["valid_hourly_records"], float(t26["epsilon_native_mean_W"]), float(t26["epsilon_scaled_mean_W"]), float(t26["kp_mean"]))) M_COLS = [("valid_hourly_records", "n"), ("solar_wind_speed_mean_km_s", "V"), ("imf_total_magnitude_mean_nT", "B"), ("imf_transverse_magnitude_mean_nT", "BT"), ("epsilon_native_mean_W", "eps"), ("epsilon_scaled_mean_W", "eps_scaled"), ("kp_mean", "kp_omni"), ("epsilon_scaled_60mo_mean_W", "e60"), ("epsilon_scaled_132mo_mean_W", "e132"), ("kp_60mo_mean", "k60"), ("kp_132mo_mean", "k132")] rows, worst_m, worst_m26, nbad = [], {}, {}, {} for mid in sorted(mon_t): t = mon_t[mid] if mid not in mon: rows.append([mid, "(month absent from our series)", "", "", "", ""]) continue for col, key in M_COLS: if t[col] == "": continue ours, theirs = float(mon[mid][key]), float(t[col]) r = rel(ours, theirs) rows.append([mid, col, repr(ours), repr(theirs), repr(ours - theirs), repr(r)]) tgt = worst_m if mid < "2026-01" else worst_m26 tgt[col] = max(tgt.get(col, 0.0), abs(r)) if mid < "2026-01" and abs(r) > 1e-3: nbad[col] = nbad.get(col, 0) + 1 wcsv("monthly_row_by_row.csv", ["month", "column", "ours", "paper_table", "difference", "relative_difference"], rows) log("R5 monthly, largest |relative difference| to 2025-12 by column (rows over 0.1%):") for k, v in worst_m.items(): log(" %-45s %.3e (%d rows)" % (k, v, nbad.get(k, 0))) log("R5 monthly, 2026-01 to 2026-07, largest |relative difference| by column:") for k, v in worst_m26.items(): log(" %-45s %.3e" % (k, v)) for mid in [i for i in sorted(mon_t) if i >= "2026-01"]: t = mon_t[mid] log(" %s ours n=%d eps=%.5e Kp=%.4f | table n=%s eps=%.5e Kp=%.4f" % (mid, mon[mid]["n"], mon[mid]["eps"], mon[mid]["kp_omni"], t["valid_hourly_records"], float(t["epsilon_native_mean_W"]), float(t["kp_mean"]))) log("R5 our 2026 months after the table ends:") for mid in [i for i in ids if i > max(mon_t)]: log(" %s n=%d eps=%.5e scaled=%.5e Kp(OMNI)=%.3f" % (mid, mon[mid]["n"], mon[mid]["eps"], mon[mid]["eps_scaled"], mon[mid]["kp_omni"])) # ---------------------------------------------------------------- stated numbers, section 7.2 def window(y0, y1, key="eps_scaled"): ys = list(range(y0, y1 + 1)) unweighted = float(np.mean([ann[y][key] for y in ys])) weighted = float(np.sum([ann[y][key] * ann[y]["n"] for y in ys]) / np.sum([ann[y]["n"] for y in ys])) return unweighted, weighted, float(np.mean([ann[y]["n"] for y in ys])) for (a, b) in ((2023, 2025), (2000, 2002), (2023, 2026)): u, w, n = window(a, b) log("S7.2 %d-%d: mean of annual scaled means %.4e W; hour-weighted %.4e W; mean valid hours %.1f" % (a, b, u, w, n)) # the paper's own 2026 (table) with our 2023-2025 u_paper26 = (sum(ann[y]["eps_scaled"] for y in (2023, 2024, 2025)) + float(t26["epsilon_scaled_mean_W"])) / 4.0 n_paper26 = (sum(ann[y]["n"] for y in (2023, 2024, 2025)) + int(t26["valid_hourly_records"])) / 4.0 log("S7.2 2023-2026 with the table's own 2026 row: %.4e W; mean valid hours %.1f" % (u_paper26, n_paper26)) # ---------------------------------------------------------------- R3 regression of the ratio def ols_report(yrs, yv, label): t = np.array(yrs, dtype=float) - 1995.0 X = np.column_stack([np.ones_like(t), t]) n, k = X.shape XtXi = np.linalg.inv(X.T @ X) beta = XtXi @ X.T @ yv e = yv - X @ beta s2 = float(e @ e) / (n - k) se = math.sqrt(s2 * XtXi[1, 1]) tstat = beta[1] / se p_cl = 2 * stats.t.sf(abs(tstat), n - k) dw = float(np.sum(np.diff(e) ** 2) / np.sum(e ** 2)) # Ljung-Box lb = [] den = float(e @ e) q = 0.0 for h in range(1, 6): rho = float(e[h:] @ e[:-h]) / den q += rho * rho / (n - h) Q = n * (n + 2) * q lb.append((h, rho, Q, float(stats.chi2.sf(Q, h)))) # HC3 hii = np.einsum("ij,jk,ik->i", X, XtXi, X) u = e / (1.0 - hii) V3 = XtXi @ (X.T * (u ** 2)) @ X @ XtXi se3 = math.sqrt(V3[1, 1]) # Newey-West, Bartlett, L lags def nw(L, corr): S = (X.T * (e ** 2)) @ X for l in range(1, L + 1): w = 1.0 - l / (L + 1.0) G = (X[l:].T * (e[l:] * e[:-l])) @ X[:-l] S = S + w * (G + G.T) Vh = XtXi @ S @ XtXi if corr: Vh = Vh * n / (n - k) return math.sqrt(Vh[1, 1]) res = dict(label=label, n=n, slope=float(beta[1]), intercept=float(beta[0]), se_classical=se, p_classical=float(p_cl), durbin_watson=dw, ljung_box=[dict(lag=h, rho=r, Q=Q, p=p) for h, r, Q, p in lb], se_hc3=se3, p_hc3_normal=float(2 * stats.norm.sf(abs(beta[1] / se3))), p_hc3_t=float(2 * stats.t.sf(abs(beta[1] / se3), n - k))) for L in (1, 2, 3, 4): for corr in (False, True): s = nw(L, corr) res["nw_L%d_%s" % (L, "corr" if corr else "nocorr")] = dict( se=s, p_normal=float(2 * stats.norm.sf(abs(beta[1] / s))), p_t=float(2 * stats.t.sf(abs(beta[1] / s), n - k))) return res yrs = list(range(1995, 2026)) reg = {} for label, key in (("ratio, <|B|> over valid hours (primary)", "ratio"), ("ratio, <|B|> over all hours with |B|", "ratio_all")): reg[key] = ols_report(yrs, np.array([ann[y][key] for y in yrs]), label) reg["paper_table"] = ols_report(yrs, np.array([float(ann_t[y]["dipole_to_imf_proxy_ratio"]) for y in yrs]), "the paper's own table column") for key, r in reg.items(): log("R3 [%s] n=%d slope %.4f /yr, intercept %.2f, classical SE %.4f p %.4f; DW %.4f" % (r["label"], r["n"], r["slope"], r["intercept"], r["se_classical"], r["p_classical"], r["durbin_watson"])) log(" Ljung-Box: " + "; ".join("lag %d rho %.3f Q %.2f p %.2g" % (x["lag"], x["rho"], x["Q"], x["p"]) for x in r["ljung_box"])) log(" HC3 SE %.4f, p normal %.4f, p t %.4f" % (r["se_hc3"], r["p_hc3_normal"], r["p_hc3_t"])) for L in (1, 2, 3, 4): a, b = r["nw_L%d_nocorr" % L], r["nw_L%d_corr" % L] log(" Newey-West %d lags: SE %.4f p normal %.4f p t %.4f | with n/(n-k): SE %.4f p normal %.4f p t %.4f" % (L, a["se"], a["p_normal"], a["p_t"], b["se"], b["p_normal"], b["p_t"])) # ---------------------------------------------------------------- R4 correlations cors = {} for name, kp in (("omni_valid_hours", kpo), ("gfz_all_intervals", kpg), ("gfz_valid_hours", kpv)): key = {"omni_valid_hours": "omni", "gfz_all_intervals": "gfz_all", "gfz_valid_hours": "gfz_valid"}[name] cors[name] = dict(monthly=pearson(es, kp), m60=pearson(e60, k60[key]), m132=pearson(e132, k132[key])) log("R4 rows-window, Kp %s: monthly r=%.4f (n=%d); 60-month r=%.4f (n=%d); 132-month r=%.4f (n=%d)" % (name, *cors[name]["monthly"], *cors[name]["m60"], *cors[name]["m132"])) # restricted to the table's rows (through 2026-07, its own partial July replaced by ours) sel = np.array([i in mon_t for i in ids]) for name, key, kp in (("omni_valid_hours", "omni", kpo),): log("R4 same, only the table's months: monthly r=%.4f (n=%d); 60-month r=%.4f (n=%d); 132-month r=%.4f (n=%d)" % (*pearson(es[sel], kp[sel]), *pearson(e60[sel], k60[key][sel]), *pearson(e132[sel], k132[key][sel]))) # the table's own columns tm = [mon_t[i] for i in sorted(mon_t)] f = lambda c: np.array([float(r[c]) if r[c] != "" else np.nan for r in tm]) log("R4 from the paper's own table columns: monthly r=%.4f (n=%d); 60-month r=%.4f (n=%d); 132-month r=%.4f (n=%d)" % (*pearson(f("epsilon_scaled_mean_W"), f("kp_mean")), *pearson(f("epsilon_scaled_60mo_mean_W"), f("kp_60mo_mean")), *pearson(f("epsilon_scaled_132mo_mean_W"), f("kp_132mo_mean")))) # calendar-window variant: complete windows only allm = ["%04d-%02d" % (y, k) for y in YEARS for k in range(1, 13)] allm = [m for m in allm if ids[0] <= m <= ids[-1]] ec = np.array([mon[m]["eps_scaled"] if m in mon else np.nan for m in allm]) kc = np.array([mon[m]["kp_omni"] if m in mon else np.nan for m in allm]) def roll_cal(x, n): out = np.full(len(x), np.nan) for i in range(n - 1, len(x)): w = x[i - n + 1:i + 1] if not np.isnan(w).any(): out[i] = w.mean() return out log("R4 calendar windows, complete only (Kp OMNI): 60-month r=%.4f (n=%d); 132-month r=%.4f (n=%d)" % (*pearson(roll_cal(ec, 60), roll_cal(kc, 60)), *pearson(roll_cal(ec, 132), roll_cal(kc, 132)))) log("R4 Kp means, ours (OMNI word, valid hours) minus GFZ thirds over valid hours: annual max |diff| %.4f" % max(abs(ann[y]["kp_omni"] - ann[y]["kp_gfz_valid"]) for y in YEARS)) # ---------------------------------------------------------------- extras E1-E4 log("E1 epsilon from annual-mean inputs / mean of hourly epsilon, 1995-2025: min %.3f, median %.3f, max %.3f" % (min(ann[y]["eps_from_means"] / ann[y]["eps"] for y in yrs), float(np.median([ann[y]["eps_from_means"] / ann[y]["eps"] for y in yrs])), max(ann[y]["eps_from_means"] / ann[y]["eps"] for y in yrs))) def ranks(years, key): order = sorted(years, key=lambda y: -ann[y][key]) return order for span, ys in (("1995-2025", yrs), ("1963-2025", list(range(1963, 2026)))): for key in ("eps", "eps_scaled"): o = ranks(ys, key) log("E2 %s annual %s, top 8: " % (span, key) + ", ".join("%d %.3e (n=%d)" % (y, ann[y][key], ann[y]["n"]) for y in o[:8])) log("E2 rank of 2023: %d, 2024: %d, 2025: %d of %d" % (o.index(2023) + 1, o.index(2024) + 1, o.index(2025) + 1, len(o))) w3 = {y: float(np.mean([ann[y + j][key] for j in range(3)])) for y in ys if y + 2 <= 2025} o3 = sorted(w3, key=lambda y: -w3[y]) log("E2 %s three-year windows of %s (mean of annual means), top 8: " % (span, key) + ", ".join("%d-%d %.3e" % (y, y + 2, w3[y]) for y in o3[:8])) log("E2 rank of 2023-2025: %d of %d" % (o3.index(2023) + 1, len(o3))) for (a, b, c) in ((1978, 1980, 21), (1988, 1990, 22), (2000, 2002, 23), (2013, 2015, 24), (2023, 2025, 25)): u, w, n = window(a, b, "eps") us, ws, _ = window(a, b) log("E3 Cycle %d maximum window %d-%d: native %.3e W (hour-weighted %.3e), scaled %.3e; mean valid hours %.0f; mean V %.0f, |B| %.2f, Kp(GFZ, all hours) %.3f" % (c, a, b, u, w, us, n, np.mean([ann[y]["V"] for y in range(a, b + 1)]), np.mean([ann[y]["B"] for y in range(a, b + 1)]), np.mean([ann[y]["kp_gfz_all"] for y in range(a, b + 1)]))) # E4 January-July jj = {} for y in YEARS: m = (d["year"] == y) & valid & (d["month"] <= 7) if m.sum(): jj[y] = (float(eps[m].mean()), int(m.sum())) o = sorted([y for y in jj if y >= 1995], key=lambda y: -jj[y][0]) log("E4 January-July means since 1995, top 8: " + ", ".join("%d %.3e (n=%d)" % (y, jj[y][0], jj[y][1]) for y in o[:8])) log("E4 rank of 2026: %d of %d" % (o.index(2026) + 1, len(o))) # ---------------------------------------------------------------- outputs wcsv("annual_ours.csv", ["year", "valid_hours", "valid_hours_with_B", "V_mean_km_s", "B_mean_nT", "B_mean_all_hours_nT", "BT_mean_nT", "eps_native_W", "eps_native_mean_of_monthly_W", "B_dip_nT", "rel_1963", "factor_2_3", "eps_scaled_W", "ratio", "ratio_all_hours", "kp_omni_valid", "kp_gfz_all", "kp_gfz_valid", "eps_from_annual_mean_inputs_W"], [[y, ann[y]["n"], ann[y]["n_b"], repr(float(ann[y]["V"])), repr(float(ann[y]["B"])), repr(float(ann[y]["B_all"])), repr(float(ann[y]["BT"])), repr(float(ann[y]["eps"])), repr(ann[y]["eps_mm"]), repr(bdip[y]), repr(relp[y]), repr(fac[y]), repr(float(ann[y]["eps_scaled"])), repr(float(ann[y]["ratio"])), repr(float(ann[y]["ratio_all"])), repr(float(ann[y]["kp_omni"])), repr(float(ann[y]["kp_gfz_all"])), repr(float(ann[y]["kp_gfz_valid"])), repr(ann[y]["eps_from_means"])] for y in YEARS]) wcsv("monthly_ours.csv", ["month", "valid_hours", "V_mean_km_s", "B_mean_nT", "BT_mean_nT", "eps_native_W", "eps_scaled_W", "eps_scaled_60row_W", "eps_scaled_132row_W", "kp_omni_valid", "kp_gfz_all", "kp_gfz_valid"], [[i, mon[i]["n"], repr(float(mon[i]["V"])), repr(float(mon[i]["B"])), repr(float(mon[i]["BT"])), repr(float(mon[i]["eps"])), repr(float(mon[i]["eps_scaled"])), repr(float(mon[i]["e60"])), repr(float(mon[i]["e132"])), repr(float(mon[i]["kp_omni"])), repr(float(mon[i]["kp_gfz_all"])), repr(float(mon[i]["kp_gfz_valid"]))] for i in ids]) with open(os.path.join(OUTDIR, "regression.json"), "w", encoding="utf-8", newline="\n") as f: json.dump(reg, f, indent=1) with open(os.path.join(OUTDIR, "dipole.json"), "w", encoding="utf-8", newline="\n") as f: json.dump({str(y): dict(B_dip=bdip[y], B_dip_midyear=bdip_mid[y], rel=relp[y], factor=fac[y]) for y in YEARS}, f, indent=1) with open(os.path.join(OUTDIR, "hashes.json"), "w", encoding="utf-8", newline="\n") as f: json.dump(hashes, f, indent=1) # hourly cache for the response test (our own derived arrays) os.makedirs(oc.WORK, exist_ok=True) np.savez_compressed(os.path.join(oc.WORK, "hourly_cache.npz"), year=d["year"], month=d["month"], dom=d["dom"], hour=d["hour"], doy=d["doy"], V=V, BY=BY, BZ=BZ, BM=BM, eps=eps, valid=valid, kp_omni=kp_omni, dst_omni=d[oc.W_DST], ap_omni=d[oc.W_AP], dens=d[oc.W_DENS], pdyn=d[oc.W_PDYN], by_gse=d[oc.W_BY_GSE], bz_gse=d[oc.W_BZ_GSE]) with open(os.path.join(OUTDIR, "reproduce_log.txt"), "w", encoding="utf-8", newline="\n") as f: f.write("\n".join(LOG) + "\n")