#!/usr/bin/env python3 """ADDED AFTER THE FIRST RUN (not pre-registered): the note's Gubbins alternative as a whole-field rescaling. Every gufm1 coefficient at time t < 1840 is multiplied by s = |g10|_alt(t) / |g10|_gufm1(t), with |g10|_alt(t) = |g10|_gufm1(1840) + rate x (1840 - t). Directions are unchanged by a uniform rescaling, so this keeps gufm1's fit to the pre-1840 directional data; changing g10 alone (RULES M10) does not. Usage: py -3.12 -I gubbins_scaled.py """ import json import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, HERE) import fieldlib as fl # noqa: E402 V = sys.argv[1] gu = fl.SplineModel(os.path.join(V, "downloads", "gufm1", "gufm1.txt"), "gufm1") grid = fl.Grid(step=0.25, nmax=14) g1840 = abs(float(gu.flat(1840.0)[0])) out = {"absg10_1840": g1840} for label, rate in (("central_2.28", 2.28), ("lo_-0.44", 2.28 - 2.72), ("hi_5.00", 2.28 + 2.72)): for t in (1800.0, 1820.0): g, h = gu.gh(t) s = (g1840 + rate * (1840.0 - t)) / abs(g[1, 0]) a = fl.anomaly(grid, g * s, h * s, 14) out["%s_%d" % (label, t)] = {"scale": s, "min_F": a["min_F"], "min_lat": a["min_lat"], "min_lon": a["min_lon"], "area_Mkm2": a["area_km2_8"] / 1e6, "area_pct": a["area_pct_8"]} g, h = gu.gh(1800.0) base = fl.anomaly(grid, g, h, 14) out["gufm1_1800"] = {"min_F": base["min_F"], "area_Mkm2": base["area_km2_8"] / 1e6} c = out["central_2.28_1800"] out["lowers_min_by"] = base["min_F"] - c["min_F"] out["raises_area_by_Mkm2"] = c["area_Mkm2"] - base["area_km2_8"] / 1e6 json.dump(out, open(os.path.join(V, "results", "gubbins_scaled.json"), "w", newline="\n"), indent=1) print(json.dumps(out, indent=1))