#!/usr/bin/env python3 """S0's special report of November 9, 2026, against the field models: every number tagged "Our analysis" on https://factchecked.science/s0-news-2026-11-09/ (Fact-Checked Science, November 2026). Standard library only. Run it python3 -I -B special_report_numbers.py [folder] The folder (default: the script's own) must hold, or will receive, the six inputs below. A missing file is downloaded from its maker under the plain client name "factchecked-research/1.0"; every file is then checked against the SHA-256 of the copy we used on November 9, 2026 (a different hash means the maker changed the file, so numbers may differ). The script prints a summary and writes s0-news-2026-11-09-numbers.json into the folder. It takes about a minute. Inputs (all public) igrf14coeffs.txt IGRF-14 Gauss coefficients 1900-2025 and secular variation 2025-30 (IAGA Working Group V-MOD): https://www.ngdc.noaa.gov/IAGA/vmod/coeffs/igrf14coeffs.txt COV-OBS.x2-int COV-OBS.x2 mean model, 1840-2020 (Huder et al. 2020, CC BY 4.0), DTU Space: https://www.spacecenter.dk/files/magnetic-models/COV-OBSx2/COV-OBS.x2-int CHAOS-8.7_spline-coefficients.dat CHAOS-8.7 core field (Kloss et al., DTU Space, September 30, 2026, CC BY 4.0, doi:10.5281/zenodo.22959079), from the "Latest release" page of https://www.spacecenter.dk/files/magnetic-models/CHAOS-8/ gufm1.txt gufm1, 1590-1990 (Jackson, Jonkers and Walker 2000): https://geomag.colorado.edu/images/GUFM/gufm1.txt Before 1840 its axial dipole follows an imposed trend of about 15 nT a year, so its pre-1840 strengths are that convention, not measurements; its directions are fitted to observations. WMM2025COF.zip World Magnetic Model 2025 with NOAA's 12 test values (to check the field code) and its own g10 forecast: https://www.ncei.noaa.gov/sites/default/files/2025-01/WMM2025COF.zip NP.xy NOAA's yearly north dip pole positions, 1590-2025: https://www.ngdc.noaa.gov/geomag/data/poles/NP.xy What it computes (the tests were registered before they were run: RULES_articles.txt, RULES_pole.txt, RULES_rates.txt and RULES_direction.txt, hosted beside this script) V Checks: NOAA's WMM2025 test values; IGRF-14's dipole moment against /field-loss-projections/; gufm1's axial dipole in 1840 and 1900. A The three articles the report links, and the report's own timeline: the loss of the dipole moment M, of the axial dipole |g10| and of the average field strength at the surface over the spans each article describes (A1-A8), with the share of Earth's surface that weakened, lost 10% or 15% or more, and the median change. P The north dip pole's yearly speed in IGRF-14 (linear between five-year epochs), COV-OBS.x2, CHAOS-8.7 and NOAA's positions: its "jumps", where they fall (as a share of the squared and of the unsquared year-to-year change), the largest rise and fall in each series, its peaks and its slowdown; and the geomagnetic (dipole) pole's motion beside it. Pole conventions follow our check of the note (/south-atlantic-anomaly-growth/): IGRF-14 to degree 13, COV-OBS.x2 and gufm1 to 14, CHAOS-8.7 to 20, the WGS84 surface, 1 January positions. R The axial dipole's loss rate: IGRF-14's five-year rates and 2025-30 forecast, COV-OBS.x2's and CHAOS-8.7's rates from their splines, the forecast against CHAOS-8.7, and what halving the dipole by 2031-2045 would take. D Before 1840 (descriptive): declination at London and Paris, the dipole's tilt and where the South Atlantic weak spot lay, from gufm1's directions, to its full degree (14), as in our check of the 2006 paper. C The series behind the page's two charts. Conventions: Schmidt semi-normalised Legendre functions; IGRF coefficients interpolated linearly between epochs and carried past 2025 with the 2025-30 secular variation, as IGRF is defined; COV-OBS.x2, CHAOS-8.7 and gufm1 from their B-splines; X north, Y east, Z down; reference radius a = 6371.2 km; field strengths at the WGS84 surface (h = 0) to degree 13 on a 1-degree grid weighted by exact cell areas on the ellipsoid. Losses are positive when the field weakens; per century and per decade are the change over the span divided by its length. Distances between poles are great circles on a sphere of radius 6371.0 km. Credit: the field synthesis, IGRF interpolation, B-spline evaluation, WGS84 conversion, grid and WMM check are adapted from the site's field_loss.py (/field-loss-projections/), which follows field_decline.py (/magnetic-field-guide/); here the degree is a parameter, so that CHAOS-8.7 can be evaluated to degree 20. """ import hashlib import json import math import os import sys import urllib.request import zipfile UA = "factchecked-research/1.0" URLS = { "igrf14coeffs.txt": "https://www.ngdc.noaa.gov/IAGA/vmod/coeffs/igrf14coeffs.txt", "COV-OBS.x2-int": "https://www.spacecenter.dk/files/magnetic-models/COV-OBSx2/COV-OBS.x2-int", "CHAOS-8.7_spline-coefficients.dat": "https://www.spacecenter.dk/files/magnetic-models/CHAOS-8/_downloads/" "d51e04c49142b02b19f7544b6d32bec8/CHAOS-8.7_spline-coefficients.dat", "gufm1.txt": "https://geomag.colorado.edu/images/GUFM/gufm1.txt", "WMM2025COF.zip": "https://www.ncei.noaa.gov/sites/default/files/2025-01/WMM2025COF.zip", "NP.xy": "https://www.ngdc.noaa.gov/geomag/data/poles/NP.xy", } HASHES = { "igrf14coeffs.txt": "8f8d88403028fc4ee92c4f38d97b46e0a87e2cfc496045b43c9e26c1d6b0903c", "COV-OBS.x2-int": "6c588becf4e3896b07be80c3f24697d299432120a7f4ab1139a914395f9d2a17", "CHAOS-8.7_spline-coefficients.dat": "f759e725b763dd300cb97be07f44cda655226babde0cfe23f9e37ed7a425d203", "gufm1.txt": "135716e3962947dcb41e107f36d8bb3d4633902602107ee8c4ef583fcd6670b1", "WMM2025COF.zip": "999080a12c95122c2031aeac8be77229d97584530e87e0f1a6df7d946ecf90c5", "NP.xy": "7c329dcebbc2dc40dce7a8b109a27bcd5b80a439b296d304d16efc12a0f913e7", } A_REF = 6371.2 # km, the models' reference radius R_POLE = 6371.0 # km, for great-circle distances between poles WGS84_A = 6378.137 WGS84_F = 1.0 / 298.257223563 WGS84_E2 = WGS84_F * (2.0 - WGS84_F) WGS84_B = WGS84_A * (1.0 - WGS84_F) MU0_OVER_4PI = 1.0e-7 NM = 20 # largest degree any array holds (CHAOS-8.7's) SURFACE_N = 13 # degree for field strength at the surface (registered in RULES_articles.txt) POLE_N = {"IGRF-14": 13, "COV-OBS.x2": 14, "gufm1": 14, "CHAOS-8.7": 20} # ------------------------------------------------------------------ inputs def fetch(folder, name): path = os.path.join(folder, name) if not os.path.exists(path): print("downloading", URLS[name]) req = urllib.request.Request(URLS[name], headers={"User-Agent": UA}) with urllib.request.urlopen(req, timeout=120) as r, open(path, "wb") as f: f.write(r.read()) with open(path, "rb") as f: digest = hashlib.sha256(f.read()).hexdigest() if digest != HASHES[name]: print("Note: %s differs from the copy we used (SHA-256 %s...); results may differ." % (name, HASHES[name][:16])) return path, digest def zeros(): return [[0.0] * (NM + 1) for _ in range(NM + 1)] # ------------------------------------------------------------------ IGRF-14 def read_igrf(path): epochs, rows = None, {} with open(path, encoding="ascii") as f: for line in f: if line.startswith("g/h"): epochs = [float(x) for x in line.split()[3:-1]] elif line[:1] in "gh" and not line.startswith("g/h"): p = line.split() rows[(p[0], int(p[1]), int(p[2]))] = [float(x) for x in p[3:]] return {"epochs": epochs, "main": {k: v[:-1] for k, v in rows.items()}, "sv": {k: v[-1] for k, v in rows.items()}} def igrf_at(m, t): epochs, main, sv = m["epochs"], m["main"], m["sv"] g, h = zeros(), zeros() if t >= epochs[-1]: for (gh, n, k), v in main.items(): (g if gh == "g" else h)[n][k] = v[-1] + (t - epochs[-1]) * sv[(gh, n, k)] else: i0 = max(i for i, e in enumerate(epochs) if e <= t) w = (t - epochs[i0]) / (epochs[i0 + 1] - epochs[i0]) for (gh, n, k), v in main.items(): (g if gh == "g" else h)[n][k] = v[i0] + w * (v[i0 + 1] - v[i0]) return g, h # ------------------------------------------------------------------ B-spline models (COV-OBS.x2, CHAOS-8.7, gufm1) def span_index(nb, p, u, U): if u >= U[nb]: return nb - 1 if u <= U[p]: return p lo, hi = p, nb mid = (lo + hi) // 2 while u < U[mid] or u >= U[mid + 1]: lo, hi = (lo, mid) if u < U[mid] else (mid, hi) mid = (lo + hi) // 2 return mid def basis_derivs(i, u, p, n, U): """Non-zero B-splines and their derivatives (Piegl and Tiller, The NURBS Book, algorithm A2.3).""" ndu = [[0.0] * (p + 1) for _ in range(p + 1)] left, right = [0.0] * (p + 1), [0.0] * (p + 1) ndu[0][0] = 1.0 for j in range(1, p + 1): left[j], right[j] = u - U[i + 1 - j], U[i + j] - u saved = 0.0 for r in range(j): ndu[j][r] = right[r + 1] + left[j - r] temp = ndu[r][j - 1] / ndu[j][r] ndu[r][j] = saved + right[r + 1] * temp saved = left[j - r] * temp ndu[j][j] = saved ders = [[0.0] * (p + 1) for _ in range(n + 1)] for j in range(p + 1): ders[0][j] = ndu[j][p] a = [[0.0] * (p + 1) for _ in range(2)] for r in range(p + 1): s1, s2 = 0, 1 a[0][0] = 1.0 for k in range(1, n + 1): d, rk, pk = 0.0, r - k, p - k if r >= k: a[s2][0] = a[s1][0] / ndu[pk + 1][rk] d = a[s2][0] * ndu[rk][pk] j1 = 1 if rk >= -1 else -rk j2 = k - 1 if (r - 1) <= pk else p - r for j in range(j1, j2 + 1): a[s2][j] = (a[s1][j] - a[s1][j - 1]) / ndu[pk + 1][rk + j] d += a[s2][j] * ndu[rk + j][pk] if r <= pk: a[s2][k] = -a[s1][k - 1] / ndu[pk + 1][r] d += a[s2][k] * ndu[r][pk] ders[k][r] = d s1, s2 = s2, s1 r = p for k in range(1, n + 1): for j in range(p + 1): ders[k][j] *= r r *= (p - k) return ders class Spline: """A B-spline core-field model: Gauss coefficients and their time derivatives, in the order g10, g11, h11, g20 ...""" def __init__(self, name, nmax, nspl, order, knots, vals): n = nmax * (nmax + 2) assert len(vals) == nspl * n, "unexpected layout in " + name self.name, self.nmax, self.nspl, self.p, self.knots = name, nmax, nspl, order - 1, knots self.coefs = [vals[j * n:(j + 1) * n] for j in range(nspl)] self.t_first, self.t_last = knots[order - 1], knots[nspl] def gh(self, t, deriv=0, nmax=None): nmax = min(nmax or self.nmax, self.nmax, NM) i = span_index(self.nspl, self.p, t, self.knots) w = basis_derivs(i, t, self.p, deriv, self.knots)[deriv] size = nmax * (nmax + 2) c = [0.0] * size for j in range(self.p + 1): if w[j]: row = self.coefs[i - self.p + j] for q in range(size): c[q] += w[j] * row[q] g, h = zeros(), zeros() for n in range(1, nmax + 1): base = (n - 1) * (n + 1) g[n][0] = c[base] for k in range(1, n + 1): g[n][k] = c[base + 2 * k - 1] h[n][k] = c[base + 2 * k] return g, h def read_chaos(path): nums, header = [], None with open(path, encoding="ascii") as f: for line in f: s = line.strip() if not s or s.startswith("#"): continue parts = s.split() if header is None: try: vals = [int(x) for x in parts] except ValueError: continue # a title line if len(vals) == 3: header = vals continue nums.extend(float(x) for x in parts) nmax, nspl, order = header return Spline("CHAOS-8.7", nmax, nspl, order, nums[:nspl + order], nums[nspl + order:]) def read_covobs(path): lines = open(path, encoding="ascii").read().split("\n") head = lines[1].split() nmax, nspl, order = int(head[0]), int(head[1]), int(head[2]) vals = [float(x) for line in lines[2:] for x in line.split()] return Spline("COV-OBS.x2", nmax, nspl, order, [float(x) for x in head[3:]], vals) def read_gufm1(path): lines = open(path, encoding="ascii").read().split("\n") toks = [x for line in lines[1:] for x in line.split()] nmax, nspl, order = int(toks[0]), int(toks[1]), 4 vals = [float(x) for x in toks[2:]] return Spline("gufm1", nmax, nspl, order, vals[:nspl + order], vals[nspl + order:]) def gh_at(model, t, deriv=0, nmax=None): if isinstance(model, dict): # IGRF-14 (degree 13 at most) if deriv: raise ValueError("use igrf rates directly") return igrf_at(model, t) return model.gh(t, deriv, nmax) def read_wmm(zpath): z = zipfile.ZipFile(zpath) names = {os.path.basename(n): n for n in z.namelist()} cof = z.read(names["WMM.COF"]).decode("ascii") tests = z.read(names["WMM2025_TEST_VALUES.txt"]).decode("ascii") g, h, gd, hd = zeros(), zeros(), zeros(), zeros() lines = cof.splitlines() epoch = float(lines[0].split()[0]) for line in lines[1:]: p = line.split() if len(p) < 6 or p[0].startswith("9999"): continue n, k = int(p[0]), int(p[1]) g[n][k], h[n][k], gd[n][k], hd[n][k] = map(float, p[2:6]) return epoch, g, h, gd, hd, tests # ------------------------------------------------------------------ field synthesis on the WGS84 surface def geodetic_to_geocentric(lat_deg, h_km): phi = math.radians(lat_deg) s, c = math.sin(phi), math.cos(phi) N = WGS84_A / math.sqrt(1.0 - WGS84_E2 * s * s) x = (N + h_km) * c z = (N * (1.0 - WGS84_E2) + h_km) * s phic = math.atan2(z, x) return math.hypot(x, z), phic, phi - phic def legendre(theta, nmax): ct, st = math.cos(theta), math.sin(theta) P = [[0.0] * (nmax + 1) for _ in range(nmax + 1)] D = [[0.0] * (nmax + 1) for _ in range(nmax + 1)] P[0][0], P[1][0], D[1][0], P[1][1], D[1][1] = 1.0, ct, -st, st, ct for n in range(2, nmax + 1): k = math.sqrt((2.0 * n - 1.0) / (2.0 * n)) P[n][n] = k * st * P[n - 1][n - 1] D[n][n] = k * (ct * P[n - 1][n - 1] + st * D[n - 1][n - 1]) for m in range(n): a2 = math.sqrt((n - 1.0) ** 2 - m * m) if n - 1 >= m else 0.0 den = math.sqrt(n * n - m * m) P2 = P[n - 2][m] if n - 2 >= m else 0.0 D2 = D[n - 2][m] if n - 2 >= m else 0.0 P[n][m] = ((2.0 * n - 1.0) * ct * P[n - 1][m] - a2 * P2) / den D[n][m] = ((2.0 * n - 1.0) * (ct * D[n - 1][m] - st * P[n - 1][m]) - a2 * D2) / den return P, D class Row: def __init__(self, lat_deg, nmax, h_km=0.0): self.nmax = nmax self.r, phic, self.delta = geodetic_to_geocentric(lat_deg, h_km) theta = math.pi / 2.0 - phic self.st = math.sin(theta) self.P, self.D = legendre(theta, nmax) self.rr = [(A_REF / self.r) ** (n + 2) for n in range(nmax + 1)] def sums(self, g, h): out = [] for m in range(self.nmax + 1): s = [0.0] * 6 for n in range(max(1, m), self.nmax + 1): f, P, D = self.rr[n], self.P[n][m], self.D[n][m] s[0] += (n + 1) * f * g[n][m] * P s[1] += (n + 1) * f * h[n][m] * P s[2] += f * g[n][m] * D s[3] += f * h[n][m] * D s[4] += f * g[n][m] * P s[5] += f * h[n][m] * P out.append(s) return out def xyz(self, sums, cosm, sinm): bt = bp = br = 0.0 for m, (gr, hr, gt, ht, gp, hp) in enumerate(sums): c, s = cosm[m], sinm[m] br += gr * c + hr * s bt -= gt * c + ht * s bp -= m * (-gp * s + hp * c) bp /= self.st xc, zc = -bt, -br cd, sd = math.cos(self.delta), math.sin(self.delta) return xc * cd + zc * sd, bp, zc * cd - xc * sd def trig(lon_deg, nmax): lam = math.radians(lon_deg) return [math.cos(m * lam) for m in range(nmax + 1)], [math.sin(m * lam) for m in range(nmax + 1)] def field(g, h, lat, lon, nmax, hkm=0.0): row = Row(lat, nmax, hkm) c, s = trig(lon, nmax) return row.xyz(row.sums(g, h), c, s) def validate_wmm(epoch, g, h, gd, hd, tests): worst, n = 0.0, 0 for line in tests.splitlines(): if line.startswith("#") or not line.strip(): continue p = [float(x) for x in line.split()] t, hkm, lat, lon = p[0], p[1], p[2], p[3] gg = [[g[i][j] + (t - epoch) * gd[i][j] for j in range(NM + 1)] for i in range(NM + 1)] hh = [[h[i][j] + (t - epoch) * hd[i][j] for j in range(NM + 1)] for i in range(NM + 1)] X, Y, Z = field(gg, hh, lat, lon, 12, hkm) F = math.sqrt(X * X + Y * Y + Z * Z) Xd, Yd, Zd = field(gd, hd, lat, lon, 12, hkm) Fd = (X * Xd + Y * Yd + Z * Zd) / F for mine, ref in ((X, p[4]), (Y, p[5]), (Z, p[6]), (F, p[8]), (Xd, p[12]), (Yd, p[13]), (Zd, p[14]), (Fd, p[16])): worst = max(worst, abs(mine - ref)) n += 1 return {"test_points": n, "largest_abs_difference_nT_or_nT_per_yr": round(worst, 3), "pass_within_0.1": worst <= 0.1} # ------------------------------------------------------------------ the dipole def dipole_moment(g, h): b0 = math.sqrt(g[1][0] ** 2 + g[1][1] ** 2 + h[1][1] ** 2) return (A_REF * 1e3) ** 3 * (b0 * 1e-9) / MU0_OVER_4PI / 1e22 def M_of(model, t): return dipole_moment(*gh_at(model, t)) def g10abs(model, t): return abs(gh_at(model, t)[0][1][0]) def loss_pct(a, b): return 100.0 * (a - b) / a # ------------------------------------------------------------------ the grid def band_area(lat1, lat2): e = math.sqrt(WGS84_E2) def q(phi): s = math.sin(phi) return s / (1 - WGS84_E2 * s * s) + (1 / (2 * e)) * math.log((1 + e * s) / (1 - e * s)) return 0.5 * WGS84_B ** 2 * (q(math.radians(lat2)) - q(math.radians(lat1))) class Grid: def __init__(self, step=1.0, nmax=SURFACE_N): n_lat, n_lon = int(round(180 / step)), int(round(360 / step)) self.nmax = nmax self.lat = [-90 + step / 2 + i * step for i in range(n_lat)] self.lon = [-180 + step / 2 + j * step for j in range(n_lon)] self.rows = [Row(la, nmax) for la in self.lat] self.trigs = [trig(lo, nmax) for lo in self.lon] self.area = [band_area(la - step / 2, la + step / 2) * math.radians(step) for la in self.lat] def F(self, g, h): out = [] for row in self.rows: s = row.sums(g, h) out.append([math.sqrt(sum(x * x for x in row.xyz(s, c, sn))) for (c, sn) in self.trigs]) return out def mean(self, F): tot = w = 0.0 for i, r in enumerate(F): tot += sum(r) * self.area[i] w += len(r) * self.area[i] return tot / w def weighted_median(pairs): pairs = sorted(pairs) tot, acc = sum(w for _, w in pairs), 0.0 for v, w in pairs: acc += w if acc >= tot / 2.0: return v return pairs[-1][0] def change_stats(G, F0, F1): cells = [(100.0 * (F1[i][j] - F0[i][j]) / F0[i][j], G.area[i], la, lo) for i, la in enumerate(G.lat) for j, lo in enumerate(G.lon)] tot = sum(c[1] for c in cells) lo_c, hi_c = min(cells), max(cells) return {"share_weakened_pct": round(100.0 * sum(c[1] for c in cells if c[0] < 0) / tot, 2), "share_strengthened_pct": round(100.0 * sum(c[1] for c in cells if c[0] > 0) / tot, 2), "share_lost_at_least_10_pct": round(100.0 * sum(c[1] for c in cells if c[0] <= -10.0) / tot, 2), "share_lost_at_least_15_pct": round(100.0 * sum(c[1] for c in cells if c[0] <= -15.0) / tot, 2), "median_change_pct": round(weighted_median([(c[0], c[1]) for c in cells]), 2), "median_change_among_weakened_pct": round(weighted_median([(c[0], c[1]) for c in cells if c[0] < 0]), 2), "largest_loss_pct_at": [round(lo_c[0], 2), lo_c[2], lo_c[3]], "largest_gain_pct_at": [round(hi_c[0], 2), hi_c[2], hi_c[3]]} # ------------------------------------------------------------------ poles def horizontal_uv(g, h, lat, lon, nmax): X, Y, _ = field(g, h, lat, lon, nmax) c, s = math.cos(math.radians(lon)), math.sin(math.radians(lon)) return -X * c - Y * s, -X * s + Y * c, math.hypot(X, Y) def uv_to_latlon(u, v): return 90.0 - math.hypot(u, v), math.degrees(math.atan2(v, u)) def dip_pole(g, h, nmax, lat0, lon0, tol=0.01, step=1e-3, maxit=60): """North dip pole (H = 0) on the WGS84 surface, by Newton iteration in a frame centred on the geographic pole.""" colat = 90.0 - lat0 u, v = colat * math.cos(math.radians(lon0)), colat * math.sin(math.radians(lon0)) for _ in range(maxit): la, lo = uv_to_latlon(u, v) fu, fv, H = horizontal_uv(g, h, la, lo, nmax) if H < tol: return la, lo, H au, av, _ = horizontal_uv(g, h, *uv_to_latlon(u + step, v), nmax) bu, bv, _ = horizontal_uv(g, h, *uv_to_latlon(u, v + step), nmax) j11, j21, j12, j22 = (au - fu) / step, (av - fv) / step, (bu - fu) / step, (bv - fv) / step det = j11 * j22 - j12 * j21 du, dv = (-fu * j22 + fv * j12) / det, (-j11 * fv + j21 * fu) / det nrm = math.hypot(du, dv) if nrm > 2.0: du, dv = du * 2.0 / nrm, dv * 2.0 / nrm u, v = u + du, v + dv la, lo = uv_to_latlon(u, v) return la, lo, horizontal_uv(g, h, la, lo, nmax)[2] def gc_km(lat1, lon1, lat2, lon2): p1, p2 = math.radians(lat1), math.radians(lat2) c = math.sin(p1) * math.sin(p2) + math.cos(p1) * math.cos(p2) * math.cos(math.radians(lon2 - lon1)) return R_POLE * math.acos(max(-1.0, min(1.0, c))) def geomagnetic_north_pole(g, h): b0 = math.sqrt(g[1][0] ** 2 + g[1][1] ** 2 + h[1][1] ** 2) return 90.0 - math.degrees(math.acos(-g[1][0] / b0)), math.degrees(math.atan2(-h[1][1], -g[1][1])) def read_npxy(path): rows = {} for line in open(path, encoding="ascii"): p = line.split() if len(p) == 3: lon, lat, yr = float(p[0]), float(p[1]), float(p[2]) rows[round(yr)] = (lat, lon if lon <= 180 else lon - 360.0) return rows def r1(x, nd=1): return round(x, nd) # ------------------------------------------------------------------ A: the articles and the timeline def part_A(igrf, cov, chaos, guf): G = Grid(1.0, SURFACE_N) cache = {} def Fg(model, t, lab): if (lab, t) not in cache: cache[(lab, t)] = G.F(*gh_at(model, t, nmax=SURFACE_N)) return cache[(lab, t)] def span(m0, t0, l0, m1, t1, l1, cells=True): F0, F1 = Fg(m0, t0, l0), Fg(m1, t1, l1) a0, a1 = G.mean(F0), G.mean(F1) M0, M1 = M_of(m0, t0), M_of(m1, t1) g0, g1 = g10abs(m0, t0), g10abs(m1, t1) d = {"from": "%s %.1f" % (l0, t0), "to": "%s %.1f" % (l1, t1), "M_1e22_Am2": [round(M0, 4), round(M1, 4)], "M_loss_pct": round(loss_pct(M0, M1), 2), "absg10_nT": [r1(g0), r1(g1)], "absg10_loss_pct": round(loss_pct(g0, g1), 2), "mean_surface_F_nT": [r1(a0), r1(a1)], "mean_surface_F_loss_pct": round(loss_pct(a0, a1), 2)} if cells: d["cells"] = change_stats(G, F0, F1) return d def judge(x, lo, hi): return "consistent" if lo <= x <= hi else ("lower" if x < lo else "higher") keys = ("M_loss_pct", "absg10_loss_pct", "mean_surface_F_loss_pct") A = {} a = {"COV-OBS.x2 1898-1998": span(cov, 1898.0, "COV-OBS.x2", cov, 1998.0, "COV-OBS.x2"), "IGRF-14 1900-2000": span(igrf, 1900.0, "IGRF-14", igrf, 2000.0, "IGRF-14"), "COV-OBS.x2 1900-2000": span(cov, 1900.0, "COV-OBS.x2", cov, 2000.0, "COV-OBS.x2")} for d in a.values(): d["A1_caption_about_10pct"] = {k: judge(d[k], 7.5, 12.5) for k in keys} c = d["cells"] d["A2_most_places_decreased"] = c["share_weakened_pct"] > 50.0 med, medw = -c["median_change_pct"], -c["median_change_among_weakened_pct"] d["A2_typically_ten_percent"] = ("holds" if 7.5 <= med <= 12.5 else "holds only among the places that weakened" if 7.5 <= medw <= 12.5 else "not supported") A["A1_A2_sciam_1998"] = a a3 = {"COV-OBS.x2 1840-1998": span(cov, 1840.0, "COV-OBS.x2", cov, 1998.0, "COV-OBS.x2", False), "COV-OBS.x2 1850-1998": span(cov, 1850.0, "COV-OBS.x2", cov, 1998.0, "COV-OBS.x2", False)} for t0 in (1840.0, 1850.0): M0, M1, g0, g1 = M_of(guf, t0), M_of(igrf, 1998.0), g10abs(guf, t0), g10abs(igrf, 1998.0) a3["gufm1 %d -> IGRF-14 1998" % t0] = {"M_loss_pct": round(loss_pct(M0, M1), 2), "absg10_loss_pct": round(loss_pct(g0, g1), 2)} for d in a3.values(): d["A3_report_about_10pct"] = {k: judge(d[k], 7.5, 12.5) for k in keys if k in d} A["A3_report_10pct_since_mid_1800s"] = a3 a4 = {"COV-OBS.x2 1863 -> CHAOS-8.7 2013": span(cov, 1863.0, "COV-OBS.x2", chaos, 2013.0, "CHAOS-8.7", False), "COV-OBS.x2 1863-2013": span(cov, 1863.0, "COV-OBS.x2", cov, 2013.0, "COV-OBS.x2"), "COV-OBS.x2 1862-2012": span(cov, 1862.0, "COV-OBS.x2", cov, 2012.0, "COV-OBS.x2", False)} for d in a4.values(): d["A4_esa_about_15pct"] = {k: judge(d[k], 12.5, 17.5) for k in keys} A["A4_esa_15pct_over_150_years"] = a4 a5 = {"gufm1 1820 -> IGRF-14 2020": span(guf, 1820.0, "gufm1", igrf, 2020.0, "IGRF-14", False), "COV-OBS.x2 1840-2020": span(cov, 1840.0, "COV-OBS.x2", cov, 2020.0, "COV-OBS.x2", False)} for d in a5.values(): d["A5_esa_2020_around_9pct"] = {k: judge(d[k], 7.0, 11.0) for k in keys} A["A5_esa_2020_9pct_over_200_years"] = a5 a6 = {} for lab, mod in (("IGRF-14", igrf), ("CHAOS-8.7", chaos)): M0, M1 = M_of(mod, 2014.0), M_of(mod, 2026.0) pdec = loss_pct(M0, M1) / 12.0 * 10.0 a6[lab] = {"M_2014.0": round(M0, 5), "M_2026.0": round(M1, 5), "loss_pct_per_decade": round(pdec, 3), "times_smaller_than_5pct_per_decade": round(5.0 / pdec, 1), "A6": "consistent" if pdec >= 4.0 else "not consistent"} A["A6_livescience_5pct_per_decade"] = a6 a7 = {} M0, M1, g0, g1 = M_of(cov, 1840.0), M_of(igrf, 2025.0), g10abs(cov, 1840.0), g10abs(igrf, 2025.0) a7["COV-OBS.x2 1840 -> IGRF-14 2025"] = {"M_loss_pct_per_century": round(loss_pct(M0, M1) / 1.85, 2), "absg10_loss_pct_per_century": round(loss_pct(g0, g1) / 1.85, 2)} M0, M1, g0, g1 = M_of(guf, 1826.0), M_of(igrf, 2026.0), g10abs(guf, 1826.0), g10abs(igrf, 2026.0) a7["gufm1 1826 -> IGRF-14 2026 (gufm1's pre-1840 convention)"] = { "M_loss_pct_per_century": round(loss_pct(M0, M1) / 2.0, 2), "absg10_loss_pct_per_century": round(loss_pct(g0, g1) / 2.0, 2)} g0c = g10abs(guf, 1840.0) + 14 * 2.28 a7["|g10| 1826 -> 2026 with 2.28 nT/yr before 1840 (Gubbins et al.)"] = { "absg10_loss_pct_per_century": round(loss_pct(g0c, g1) / 2.0, 2)} for d in a7.values(): d["A7"] = {k: judge(v, 4.0, 6.0) for k, v in list(d.items())} A["A7_report_5pct_per_century_for_200_years"] = a7 a8 = {"IGRF-14 2000-2010": span(igrf, 2000.0, "IGRF-14", igrf, 2010.0, "IGRF-14", False), "CHAOS-8.7 2000-2010": span(chaos, 2000.0, "CHAOS-8.7", chaos, 2010.0, "CHAOS-8.7", False), "COV-OBS.x2 1850 -> IGRF-14 2010": span(cov, 1850.0, "COV-OBS.x2", igrf, 2010.0, "IGRF-14", False)} for k in ("IGRF-14 2000-2010", "CHAOS-8.7 2000-2010"): a8[k]["A8_a_decade_to_lose_another_five"] = {m: ("consistent" if a8[k][m] >= 4.0 else "not consistent") for m in keys} A["A8_report_15pct_by_2010"] = a8 return A # ------------------------------------------------------------------ P: the poles def part_P(igrf, cov, chaos, guf, npxy): def track(model, label, times): n = POLE_N[label] pos, prev = [], None for t in times: seed = prev or npxy.get(int(round(t)), (80.0, -100.0)) g, h = gh_at(model, t, nmax=n) la, lo, H = dip_pole(g, h, n, seed[0], seed[1]) if H > 0.01: s2 = npxy.get(int(round(t)), (80.0, -100.0)) la, lo, H = dip_pole(g, h, n, s2[0], s2[1]) pos.append((t, la, lo, H)) prev = (la, lo) return pos def speeds(pos): return [((a[0] + b[0]) / 2, gc_km(a[1], a[2], b[1], b[2]) / (b[0] - a[0])) for a, b in zip(pos, pos[1:])] years = lambda a, b: [float(y) for y in range(a, b + 1)] pos = {"IGRF-14": track(igrf, "IGRF-14", years(1900, 2030)), "COV-OBS.x2": track(cov, "COV-OBS.x2", years(1840, 2020)), "CHAOS-8.7": track(chaos, "CHAOS-8.7", years(1999, 2027)), "gufm1": track(guf, "gufm1", years(1590, 1900))} fine = track(chaos, "CHAOS-8.7", [1999.5 + 0.1 * k for k in range(275)]) S = {k: speeds(v) for k, v in pos.items()} yrs = sorted(y for y in npxy if 1900 <= y <= 2025) S["NOAA NP.xy"] = [(a + 0.5, gc_km(*npxy[a], *npxy[b]) / (b - a)) for a, b in zip(yrs, yrs[1:])] P = {"conventions": "WGS84 surface, 1 January positions, great circles on R = 6371.0 km; degrees " + json.dumps(POLE_N), "largest_H_at_solutions_nT": max(p[3] for v in list(pos.values()) + [fine] for p in v)} def seg(k, y): r = [s for s in S[k] if abs(s[0] - (y + 0.5)) < 1e-6] return r1(r[0][1]) if r else None # P1 jumps (more than 5 km/yr from one yearly segment to the next), 1900-2026 jumps = {} for k in ("IGRF-14", "COV-OBS.x2", "CHAOS-8.7", "NOAA NP.xy"): sp = [s for s in S[k] if 1900.0 <= s[0] <= 2026.0] ch = [(b[0], b[1] - a[1]) for a, b in zip(sp, sp[1:])] js = [{"into_segment": "%d-%d" % (int(t - 0.5), int(t + 0.5)), "increase_km_per_yr": r1(d)} for t, d in ch if d > 5.0] up, dn = max(ch, key=lambda x: x[1]), min(ch, key=lambda x: x[1]) seg_of = lambda t: "%d-%d" % (int(t - 0.5), int(t + 0.5)) jumps[k] = {"n_jumps": len(js), "largest_year_to_year_change_km_per_yr": r1(max(abs(d) for _, d in ch)), "jumps": js, "largest_rise_km_per_yr": [r1(up[1]), "into " + seg_of(up[0])], "largest_fall_km_per_yr": [r1(dn[1]), "into " + seg_of(dn[0])]} ig = [s for s in S["IGRF-14"] if 1900.0 <= s[0] <= 2030.0] ch = [(b[0], b[1] - a[1]) for a, b in zip(ig, ig[1:])] at_epoch = [(t, d) for t, d in ch if int(round(t - 0.5)) % 5 == 0] jumps["IGRF-14"]["share_of_squared_change_at_epochs_pct"] = r1(100.0 * sum(d * d for _, d in at_epoch) / sum(d * d for _, d in ch)) jumps["IGRF-14"]["share_of_absolute_change_at_epochs_pct"] = r1(100.0 * sum(abs(d) for _, d in at_epoch) / sum(abs(d) for _, d in ch)) jumps["IGRF-14"]["epoch_changes_out_of_all"] = [len(at_epoch), len(ch)] jumps["IGRF-14"]["epoch_changes_share_of_all_pct"] = r1(100.0 * len(at_epoch) / len(ch)) jumps["IGRF-14"]["all_jumps_at_epochs"] = all(int(j["into_segment"][:4]) % 5 == 0 for j in jumps["IGRF-14"]["jumps"]) fd = [b[1] - a[1] for a, b in zip(speeds(fine), speeds(fine)[1:])] jumps["CHAOS-8.7 every 0.1 yr"] = {"largest_change_between_steps_km_per_yr": round(max(abs(x) for x in fd), 2)} P["P1_jumps"] = jumps # P2 peaks, crests and the slowdown pk = {} for k in ("IGRF-14", "COV-OBS.x2", "CHAOS-8.7", "NOAA NP.xy"): top = max(S[k], key=lambda s: s[1]) pk[k] = {"peak_km_per_yr": r1(top[1]), "peak_segment": "%d-%d" % (int(top[0] - 0.5), int(top[0] + 0.5)), "segments": {"%d-%d" % (y, y + 1): seg(k, y) for y in (1975, 1990, 1994, 1995, 1999, 2000, 2002, 2005, 2009, 2010, 2012, 2014, 2015, 2016, 2019, 2020, 2024, 2025, 2026, 2029) if seg(k, y) is not None}} sf = speeds(fine) topf = max(sf, key=lambda s: s[1]) pk["CHAOS-8.7 every 0.1 yr"] = {"peak_km_per_yr": r1(topf[1]), "at": round(topf[0], 2)} crests = [] ch_y = [s for s in S["CHAOS-8.7"]] for a, b, c in zip(ch_y, ch_y[1:], ch_y[2:]): if b[1] > a[1] and b[1] > c[1]: crests.append({"segment": "%d-%d" % (int(b[0] - 0.5), int(b[0] + 0.5)), "km_per_yr": r1(b[1])}) pk["CHAOS-8.7 yearly crests"] = crests P["P2_peaks_and_slowdown"] = pk latest, peak = seg("CHAOS-8.7", 2025), max(pk["CHAOS-8.7"]["peak_km_per_yr"], pk["COV-OBS.x2"]["peak_km_per_yr"]) none_after_1970 = all(not [j for j in jumps[k]["jumps"] if int(j["into_segment"][:4]) > 1970] for k in ("COV-OBS.x2", "CHAOS-8.7")) P["P3_rule"] = {"continuous_models_jump_after_1970": not none_after_1970, "CHAOS_2025_2026": latest, "peak_continuous": peak, "latest_over_peak": round(latest / peak, 2), "result": "contradicted" if none_after_1970 and latest < 0.75 * peak else "mixed or supported"} # P4 the geomagnetic (dipole) pole against the dip pole, gufm1 to 1900, IGRF-14 from 1900 def gpole(model, t): return geomagnetic_north_pole(*gh_at(model, t)) gp = [(float(y),) + gpole(guf, float(y)) for y in range(1840, 1901)] + [(float(y),) + gpole(igrf, float(y)) for y in range(1900, 2026)] dp = [(p[0], p[1], p[2]) for p in pos["gufm1"] if p[0] >= 1840.0] + [(p[0], p[1], p[2]) for p in pos["IGRF-14"] if p[0] <= 2025.0] def path(series, a, b): tot = 0.0 for x, y in zip(series, series[1:]): if x[0] == y[0]: continue # the 1900 splice: one model ends, the next begins if a <= x[0] and y[0] <= b: tot += gc_km(x[1], x[2], y[1], y[2]) return tot tilt = {str(t): round(90.0 - gpole(igrf, t)[0], 2) for t in (1900.0, 2000.0, 2025.0)} tilt.update({str(t) + " (gufm1)": round(90.0 - gpole(guf, t)[0], 2) for t in (1590.0, 1700.0, 1840.0)}) P["P4_geomagnetic_pole"] = { "position_2025": [round(x, 2) for x in gpole(igrf, 2025.0)], "tilt_deg": tilt, "dipole_moment_2025_1e22_Am2": round(M_of(igrf, 2025.0), 4), "path_km_1840_2025": {"geomagnetic_pole": round(path(gp, 1840.0, 2025.0)), "dip_pole": round(path(dp, 1840.0, 2025.0))}, "path_km_1900_2025": {"geomagnetic_pole": round(path(gp, 1900.0, 2025.0)), "dip_pole": round(path(dp, 1900.0, 2025.0))}, "mean_speed_2000_2025_km_per_yr": {"geomagnetic_pole": r1(path(gp, 2000.0, 2025.0) / 25.0), "dip_pole": r1(path(dp, 2000.0, 2025.0) / 25.0)}} ig_np = [gc_km(p[1], p[2], *npxy[int(p[0])]) for p in pos["IGRF-14"] if int(p[0]) in npxy and p[0] <= 2018.0] P["P5_igrf14_against_NPxy_1900_2018_km"] = {"median": round(sorted(ig_np)[len(ig_np) // 2], 2), "max": round(max(ig_np), 2)} chart = {k: [[round(t, 1), r1(v)] for t, v in S[k] if 1960.0 <= t <= 2030.0] for k in ("IGRF-14", "COV-OBS.x2", "CHAOS-8.7")} return P, chart, pos # ------------------------------------------------------------------ R: the axial dipole's loss rate def part_R(igrf, cov, chaos, guf, wmm_g10_sv): ep = igrf["epochs"] segs = [{"span": "%d-%d" % (a, b), "nT_per_yr": round((g10abs(igrf, a) - g10abs(igrf, b)) / (b - a), 2)} for a, b in zip(ep, ep[1:])] fc = (g10abs(igrf, 2025.0) - g10abs(igrf, 2030.0)) / 5.0 segs.append({"span": "2025-2030 forecast", "nT_per_yr": round(fc, 2)}) def rate(model, t): g, h = model.gh(t, 0, 1) gd, hd = model.gh(t, 1, 1) b0 = math.sqrt(g[1][0] ** 2 + g[1][1] ** 2 + h[1][1] ** 2) db0 = (g[1][0] * gd[1][0] + g[1][1] * gd[1][1] + h[1][1] * hd[1][1]) / b0 return (gd[1][0] if g[1][0] < 0 else -gd[1][0]), -1e4 * db0 / b0 cv = [(y + 0.5, rate(cov, y + 0.5)[0]) for y in range(1840, 2020)] cv10 = [(cv[k][0] + 0.5, sum(v for _, v in cv[k - 4:k + 6]) / 10.0) for k in range(4, len(cv) - 5)] def ext(series, a, b, fn): t, v = fn([(t, v) for t, v in series if a <= t <= b], key=lambda x: x[1]) return {"year": t, "nT_per_yr": round(v, 2)} sv = [(int(s["span"][:4]) + 2.5, s["nT_per_yr"]) for s in segs[:-1]] R = {"igrf14_five_year_rates_nT_per_yr": segs, "R1_peaks_troughs": { "IGRF-14 five-year": {"peak_1900_1935": ext(sv, 1900, 1935, max), "peak_1955_1995": ext(sv, 1955, 1995, max), "trough_1935_1955": ext(sv, 1935, 1955, min), "trough_1995_2020": ext(sv, 1995, 2020, min)}, "COV-OBS.x2 ten-year mean": {"peak_1900_1935": ext(cv10, 1900, 1935, max), "peak_1955_1995": ext(cv10, 1955, 1995, max), "trough_1935_1955": ext(cv10, 1935, 1955, min), "trough_1995_2015": ext(cv10, 1995, 2015, min)}, "COV-OBS.x2 yearly": {"peak_1900_1935": ext(cv, 1900, 1935, max), "peak_1955_1995": ext(cv, 1955, 1995, max)}}} chy = [(y + 0.5,) + rate(chaos, y + 0.5) for y in range(1999, 2027)] R["chaos87_yearly"] = [{"mid": t, "g10_nT_per_yr": round(a, 2), "M_pct_per_century": round(b, 2)} for t, a, b in chy] a25, a26, a2675 = (abs(chaos.gh(t)[0][1][0]) for t in (2025.0, 2026.0, 2026.75)) m25, m26, m2675 = (M_of(chaos, t) for t in (2025.0, 2026.0, 2026.75)) mi25, mi30 = M_of(igrf, 2025.0), M_of(igrf, 2030.0) diff = (a25 - a2675) / 1.75 - fc R["R3_forecast_against_chaos87"] = { "igrf14_forecast_2025_2030": {"g10_nT_per_yr": round(fc, 2), "M_pct_per_century": round(1e4 * (mi25 - mi30) / mi25 / 5, 2)}, "wmm2025_g10_forecast_nT_per_yr": round(wmm_g10_sv, 2), "chaos87_2025.0_2026.0": {"g10_nT_per_yr": round(a25 - a26, 2), "M_pct_per_century": round(1e4 * (m25 - m26) / m25, 2)}, "chaos87_2025.0_2026.75": {"g10_nT_per_yr": round((a25 - a2675) / 1.75, 2), "M_pct_per_century": round(1e4 * (m25 - m2675) / m25 / 1.75, 2)}, "chaos87_rate_at_2026.5": round(rate(chaos, 2026.5)[0], 2), "chaos_minus_forecast_nT_per_yr": round(diff, 2), "result": "faster than forecast" if diff > 1 else "slower than forecast" if diff < -1 else "about as forecast"} p_early = max(R["R1_peaks_troughs"]["IGRF-14 five-year"]["peak_1900_1935"]["nT_per_yr"], R["R1_peaks_troughs"]["COV-OBS.x2 ten-year mean"]["peak_1900_1935"]["nT_per_yr"]) p_mid = max(R["R1_peaks_troughs"]["IGRF-14 five-year"]["peak_1955_1995"]["nT_per_yr"], R["R1_peaks_troughs"]["COV-OBS.x2 ten-year mean"]["peak_1955_1995"]["nT_per_yr"]) now = max(chy[-1][1], fc) R["R2_recent_rise"] = {"chaos87_low_2018.5": round(rate(chaos, 2018.5)[0], 2), "chaos87_mean_2018.0_2019.0": round(abs(chaos.gh(2018.0)[0][1][0]) - abs(chaos.gh(2019.0)[0][1][0]), 2), "present": round(now, 2), "earlier_peaks": [p_early, p_mid], "present_as_share": [round(now / p_early, 2), round(now / p_mid, 2)], "result": "bigger" if now > p_early and now > p_mid else "smaller"} era = lambda m0, a, m1, b: round((g10abs(m0, a) - g10abs(m1, b)) / (b - a), 2) R["R4_era_averages_nT_per_yr"] = {"1840-1900 gufm1": era(guf, 1840.0, guf, 1900.0), "1840-1900 COV-OBS.x2": era(cov, 1840.0, cov, 1900.0), "1900-1950 IGRF-14": era(igrf, 1900.0, igrf, 1950.0), "1950-2000 IGRF-14": era(igrf, 1950.0, igrf, 2000.0), "1900-2000 IGRF-14": era(igrf, 1900.0, igrf, 2000.0), "2000-2025 IGRF-14": era(igrf, 2000.0, igrf, 2025.0), "2015-2020 IGRF-14": era(igrf, 2015.0, igrf, 2020.0), "2020-2025 IGRF-14": era(igrf, 2020.0, igrf, 2025.0), "gufm1_minus_igrf14_absg10_1900_nT": round(g10abs(guf, 1900.0) - g10abs(igrf, 1900.0), 2), "drop_1840_gufm1_to_2025_igrf14_pct": round(loss_pct(g10abs(guf, 1840.0), g10abs(igrf, 2025.0)), 4)} R["R5_gufm1_1590_1840"] = {"absg10_1590": r1(g10abs(guf, 1590.0)), "absg10_1840": round(g10abs(guf, 1840.0), 2), "slope_nT_per_yr": round((g10abs(guf, 1590.0) - g10abs(guf, 1840.0)) / 250.0, 2)} g25 = g10abs(igrf, 2025.0) R["R6_halving_absg10_from_2025"] = {"absg10_2025": g25, "by": {str(y): {"nT_per_yr": r1(g25 / 2.0 / (y - 2025)), "times_forecast": r1(g25 / 2.0 / (y - 2025) / fc)} for y in (2031, 2036, 2045)}, "hundred_times_forecast_nT_per_yr": round(100 * fc), "years_to_halve_at_that_rate": r1(g25 / 2.0 / (100 * fc))} chart = {"IGRF-14 five-year": [[int(s["span"][:4]), int(s["span"][5:9]), s["nT_per_yr"]] for s in segs[:-1]], "IGRF-14 forecast": [2025, 2030, round(fc, 2)], "COV-OBS.x2 ten-year mean": [[t, round(v, 2)] for t, v in cv10], "CHAOS-8.7 yearly": [[t, round(a, 2)] for t, a, _ in chy]} return R, chart # ------------------------------------------------------------------ D: before 1840 (descriptive) def part_D(igrf, guf, npxy): def DI(model, t, lat, lon, n): X, Y, Z = field(*gh_at(model, t, nmax=n), lat, lon, n) return [round(math.degrees(math.atan2(Y, X)), 2), round(math.degrees(math.atan2(Z, math.hypot(X, Y))), 2)] D = {"D1_declination_inclination": {}} for name, (la, lo) in {"London": (51.5, -0.1), "Paris": (48.85, 2.35)}.items(): d = {str(t): DI(guf, float(t), la, lo, POLE_N["gufm1"]) for t in (1590, 1650, 1700, 1750, 1800, 1820, 1840, 1900)} d["2025 (IGRF-14)"] = DI(igrf, 2025.0, la, lo, POLE_N["IGRF-14"]) D["D1_declination_inclination"][name] = d gp = {} for t in (1590.0, 1700.0, 1800.0, 1840.0): la, lo = geomagnetic_north_pole(*gh_at(guf, t)) gp[str(t)] = {"pole": [round(la, 2), round(lo, 2)], "tilt_deg": round(90.0 - la, 2)} gp["displacement_1590_1840_km"] = round(gc_km(*gp["1590.0"]["pole"], *gp["1840.0"]["pole"])) D["D2_geomagnetic_pole"] = gp G = Grid(1.0, POLE_N["gufm1"]) weak = {} for t in (1600.0, 1700.0, 1800.0, 1840.0): F = G.F(*gh_at(guf, t, nmax=POLE_N["gufm1"])) best = min(((F[i][j], la, lo) for i, la in enumerate(G.lat) for j, lo in enumerate(G.lon) if -60.0 <= la <= 10.0 and -100.0 <= lo <= 30.0)) weak[str(t)] = [best[1], best[2]] D["D4_south_atlantic_weakest_cell_lat_lon"] = weak return D def main(): folder = os.path.abspath(sys.argv[1]) if len(sys.argv) > 1 else os.path.dirname(os.path.abspath(__file__)) paths, hashes = {}, {} for name in URLS: paths[name], hashes[name] = fetch(folder, name) igrf = read_igrf(paths["igrf14coeffs.txt"]) cov = read_covobs(paths["COV-OBS.x2-int"]) chaos = read_chaos(paths["CHAOS-8.7_spline-coefficients.dat"]) guf = read_gufm1(paths["gufm1.txt"]) npxy = read_npxy(paths["NP.xy"]) ep, g, h, gd, hd, tests = read_wmm(paths["WMM2025COF.zip"]) out = {"what": "S0's special report of November 9, 2026, against the field models (factchecked.science, Our analysis)", "inputs_sha256": hashes, "valid_spans": {"COV-OBS.x2": [cov.t_first, cov.t_last], "CHAOS-8.7": [round(chaos.t_first, 3), round(chaos.t_last, 3)], "gufm1": [guf.t_first, guf.t_last]}} m14, m26 = M_of(igrf, 2014.0), M_of(igrf, 2026.0) out["V_checks"] = {"wmm2025_test_values": validate_wmm(ep, g, h, gd, hd, tests), "igrf14_M_2014_2026": [round(m14, 5), round(m26, 5), round(loss_pct(m14, m26) / 1.2, 3)], "gufm1_absg10_1840_1900": [round(g10abs(guf, 1840.0), 2), round(g10abs(guf, 1900.0), 2)]} print("checks:", json.dumps(out["V_checks"])) out["A_articles"] = part_A(igrf, cov, chaos, guf) print("A done") out["P_poles"], pole_chart, _ = part_P(igrf, cov, chaos, guf, npxy) print("P done") out["R_rates"], rate_chart = part_R(igrf, cov, chaos, guf, gd[1][0]) out["D_before_1840"] = part_D(igrf, guf, npxy) out["C_chart_series"] = {"pole_speed_km_per_yr": pole_chart, "axial_dipole_loss_nT_per_yr": rate_chart} with open(os.path.join(folder, "s0-news-2026-11-09-numbers.json"), "w", encoding="utf-8", newline="\n") as f: json.dump(out, f, indent=1, ensure_ascii=False) for k in ("P_poles", "R_rates"): print(k, json.dumps({kk: vv for kk, vv in out[k].items() if not kk.startswith(("chaos87_yearly", "igrf14_five"))})[:3000]) print("Wrote", os.path.join(folder, "s0-news-2026-11-09-numbers.json")) if __name__ == "__main__": main()