#!/usr/bin/env python3 """The South Atlantic Anomaly, the north dip pole and the dipole, 1590-2030, from four public field models. Fact-Checked Science, "S0's field note: the numbers reproduce, 'since 1800' is modelled, and the pole is slowing", https://factchecked.science/south-atlantic-anomaly-growth/ ("Our analysis"). Standard library only (Python 3.8+). Run it python3 saa_pole.py [folder] [--quick] [--sphere] The folder (default: the script's own) must hold, or will receive, the inputs below. A missing file is downloaded 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 its maker changed it, so numbers may differ). The script prints a summary and writes saa-pole-numbers.json and four CSV files into the folder. A full run took us about seven minutes; --quick skips the 1900-1990 overlap of the two models and the 0.1-year pole series (about five minutes); --sphere adds the note's "sphere alternate", the minimum on a sphere of 6371.2 km, 1590-2030 (about ten minutes more). Inputs gufm1.txt gufm1 (Jackson, Jonkers & Walker 2000), 1590-1990, degree 14, the URL S0 News's note gives: https://geomag.colorado.edu/images/GUFM/gufm1.txt igrf14coeffs.txt IGRF-14 (IAGA V-MOD), 1900-2025 and its 2025-30 secular variation: https://www.ngdc.noaa.gov/IAGA/vmod/coeffs/igrf14coeffs.txt igrf13coeffs.txt IGRF-13, to test the note's statement that NOAA's 2019-2025 poles use it: https://www.ngdc.noaa.gov/IAGA/vmod/coeffs/igrf13coeffs.txt COV-OBS.x2-int COV-OBS.x2 mean model (Huder et al. 2020), 1840-2020, degree 14: https://www.spacecenter.dk/files/magnetic-models/COV-OBSx2/COV-OBS.x2-int CHAOS-8.7_spline-coefficients.dat CHAOS-8.7 core field (DTU Space, 30 September 2026, CC BY 4.0), degree 20: https://www.spacecenter.dk/files/magnetic-models/CHAOS-8/_downloads/ d51e04c49142b02b19f7544b6d32bec8/CHAOS-8.7_spline-coefficients.dat NP.xy NOAA's yearly north dip pole positions, 1590-2025: https://www.ngdc.noaa.gov/geomag/data/poles/NP.xy WMM2025COF.zip NOAA's WMM2025 coefficients and official test values, to check this script's field evaluation: https://www.ncei.noaa.gov/sites/default/files/2025-01/WMM2025COF.zip The surveyed north magnetic pole positions are typed in below from Newitt, Chulliat & Orgeval (2009), Table 5. Conventions (the note's own Methods) Every 1 January (t = year.0), at sea level on the WGS84 ellipsoid (h = 0, geodetic to geocentric, reference radius a = 6371.2 km); X north, Y east, Z down in the geodetic frame; Schmidt semi-normalised Legendre functions. Degrees: gufm1 14; IGRF-14 10 before 2000 and 13 from 2000, coefficients linear between five-year epochs and extended after 2025 with the 2025-30 secular variation; COV-OBS.x2 14; CHAOS-8.7 20 (13 as a check). gufm1 to 1899, IGRF-14 from 1900; no speed segment crosses 1900. The anomaly: the weakest F on a 0.25-degree grid of cell centres (720 x 1440), refined by Nelder-Mead; the area is the cells below 32,000 nT joined to that minimum (8-neighbour, across 180 degrees), with exact WGS84 cell areas; its centre is the area-weighted mean of the cells' unit vectors (geodetic latitude). To keep this script fast it evaluates a 1-degree grid and refines to 0.25 degrees every 1-degree cell within 3,000 nT of 32,000 nT or next to a cell on the other side; a full 0.25-degree grid gives the same cells. The north dip pole: the point north of 55 N where the horizontal field H = 0, solved by Newton's method to H < 0.001 nT. Speeds: great-circle distance (R = 6371.0 km, geodetic latitudes) between consecutive positions, per year. The dipole moment M = 4 pi a^3 / mu0 x sqrt(g10^2 + g11^2 + h11^2); the geomagnetic (dipole) pole from g10, g11, h11. """ import csv import hashlib import io import json import math import os import sys import time import urllib.request import zipfile UA = "factchecked-research/1.0" INPUTS = { "gufm1.txt": ("https://geomag.colorado.edu/images/GUFM/gufm1.txt", "135716e3962947dcb41e107f36d8bb3d4633902602107ee8c4ef583fcd6670b1"), "igrf14coeffs.txt": ("https://www.ngdc.noaa.gov/IAGA/vmod/coeffs/igrf14coeffs.txt", "8f8d88403028fc4ee92c4f38d97b46e0a87e2cfc496045b43c9e26c1d6b0903c"), "igrf13coeffs.txt": ("https://www.ngdc.noaa.gov/IAGA/vmod/coeffs/igrf13coeffs.txt", "460b8d8beb9b4df84febe4f0b639f0dd54dccfe8ff0970616287b015fa721425"), "COV-OBS.x2-int": ("https://www.spacecenter.dk/files/magnetic-models/COV-OBSx2/COV-OBS.x2-int", "6c588becf4e3896b07be80c3f24697d299432120a7f4ab1139a914395f9d2a17"), "CHAOS-8.7_spline-coefficients.dat": ("https://www.spacecenter.dk/files/magnetic-models/CHAOS-8/_downloads/" "d51e04c49142b02b19f7544b6d32bec8/CHAOS-8.7_spline-coefficients.dat", "f759e725b763dd300cb97be07f44cda655226babde0cfe23f9e37ed7a425d203"), "NP.xy": ("https://www.ngdc.noaa.gov/geomag/data/poles/NP.xy", "7c329dcebbc2dc40dce7a8b109a27bcd5b80a439b296d304d16efc12a0f913e7"), "WMM2025COF.zip": ("https://www.ncei.noaa.gov/sites/default/files/2025-01/WMM2025COF.zip", "999080a12c95122c2031aeac8be77229d97584530e87e0f1a6df7d946ecf90c5"), } # Newitt, Chulliat & Orgeval (2009), Earth Planets Space 61, 703-710, Table 5: observed positions (decimal year, deg N, deg W) SURVEYS = [(1831.4, 70.1, 96.9), (1904.5, 70.5, 96.6), (1948.0, 73.9, 100.9), (1962.5, 75.1, 100.8), (1973.5, 76.0, 100.6), (1983.9, 77.0, 102.3), (1994.0, 78.3, 104.0), (2001.0, 81.30, 110.80), (2007.3, 83.95, 120.72)] A_REF = 6371.2 R_SPEED = 6371.0 WGS84_A = 6378.137 WGS84_F = 1.0 / 298.257223563 E2 = WGS84_F * (2.0 - WGS84_F) WGS84_B = WGS84_A * (1.0 - WGS84_F) THRESHOLD = 32000.0 MARGIN = 3000.0 # ------------------------------------------------------------------ inputs def fetch(folder, name): url, want = INPUTS[name] path = os.path.join(folder, name) if not os.path.exists(path): print("downloading", url, flush=True) req = urllib.request.Request(url, headers={"User-Agent": UA}) with urllib.request.urlopen(req, timeout=180) 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 != want: print("Note: %s differs from the copy we used (SHA-256 %s...); numbers may differ." % (name, want[:16])) return path, digest def zeros(n): return [[0.0] * (n + 1) for _ in range(n + 1)] class Igrf: """IGRF coefficients: linear between five-year epochs, extended with the secular variation after the last one.""" def __init__(self, path): rows, epochs = {}, 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:]] self.epochs = epochs self.nmax = max(n for _, n, _ in rows) ne = len(epochs) self.main = {k: v[:ne] for k, v in rows.items()} self.sv = {k: v[ne] for k, v in rows.items()} self._cubic = None def gh(self, t): g, h = zeros(self.nmax), zeros(self.nmax) e = self.epochs if t >= e[-1]: for (c, n, m), v in self.main.items(): (g if c == "g" else h)[n][m] = v[-1] + (t - e[-1]) * self.sv[(c, n, m)] else: i = max(k for k, x in enumerate(e) if x <= t) w = (t - e[i]) / (e[i + 1] - e[i]) for (c, n, m), v in self.main.items(): (g if c == "g" else h)[n][m] = v[i] + w * (v[i + 1] - v[i]) return g, h def gh_cubic(self, t): """Control: every coefficient through its epoch values and the 2030 forecast, as a not-a-knot cubic spline.""" if self._cubic is None: x = self.epochs + [self.epochs[-1] + 5.0] inv = notaknot_system(x) coef = {} for k, v in self.main.items(): y = v + [v[-1] + 5.0 * self.sv[k]] coef[k] = (y, second_derivatives(inv, x, y)) self._cubic = (x, coef) x, coef = self._cubic i = min(max(k for k in range(len(x) - 1) if x[k] <= t), len(x) - 2) h0 = x[i + 1] - x[i] a, b = x[i + 1] - t, t - x[i] g, h = zeros(self.nmax), zeros(self.nmax) for (c, n, m), (y, M) in coef.items(): val = (M[i] * a ** 3 + M[i + 1] * b ** 3) / (6 * h0) + (y[i] / h0 - M[i] * h0 / 6) * a + (y[i + 1] / h0 - M[i + 1] * h0 / 6) * b (g if c == "g" else h)[n][m] = val return g, h def solve(A, b): n = len(A) M = [row[:] + [bb] for row, bb in zip(A, b)] for i in range(n): p = max(range(i, n), key=lambda k: abs(M[k][i])) M[i], M[p] = M[p], M[i] for k in range(n): if k != i and M[k][i] != 0.0: f = M[k][i] / M[i][i] M[k] = [a - f * c for a, c in zip(M[k], M[i])] return [M[i][n] / M[i][i] for i in range(n)] def notaknot_system(x): """The not-a-knot spline's second-derivative system, returned as its matrix (solved per coefficient).""" n = len(x) - 1 hh = [x[i + 1] - x[i] for i in range(n)] A = [[0.0] * (n + 1) for _ in range(n + 1)] A[0][0], A[0][1], A[0][2] = hh[1], -(hh[0] + hh[1]), hh[0] for i in range(1, n): A[i][i - 1], A[i][i], A[i][i + 1] = hh[i - 1], 2 * (hh[i - 1] + hh[i]), hh[i] A[n][n - 2], A[n][n - 1], A[n][n] = hh[n - 1], -(hh[n - 2] + hh[n - 1]), hh[n - 2] return A, hh def second_derivatives(inv, x, y): A, hh = inv n = len(x) - 1 rhs = [0.0] * (n + 1) for i in range(1, n): rhs[i] = 6 * ((y[i + 1] - y[i]) / hh[i] - (y[i] - y[i - 1]) / hh[i - 1]) return solve(A, rhs) # B-splines (Piegl and Tiller, The NURBS Book, algorithms A2.1 and A2.3), as in /field-loss-projections/'s field_loss.py def span(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): 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 Splines: """gufm1, COV-OBS.x2 or CHAOS spline files; coefficients ordered g10, g11, h11, g20, g21, h21, g22, h22, ...""" def __init__(self, path, kind, nmax_use=None): with open(path, encoding="ascii") as f: lines = [s.strip() for s in f if s.strip() and not s.strip().startswith("#")] if kind == "gufm1": nums = " ".join(lines[1:]).split() nmax, nspl, order, k0 = int(nums[0]), int(nums[1]), 4, 2 elif kind == "covobs": nums = " ".join(lines[1:]).split() nmax, nspl, order, k0 = int(nums[0]), int(nums[1]), int(nums[2]), 3 else: nums = " ".join(lines).split() nmax, nspl, order, k0 = int(nums[0]), int(nums[1]), int(nums[2]), 3 self.knots = [float(x) for x in nums[k0:k0 + nspl + order]] vals = [float(x) for x in nums[k0 + nspl + order:]] nc = nmax * (nmax + 2) assert len(vals) == nspl * nc, "unexpected layout in " + path self.coefs = [vals[j * nc:(j + 1) * nc] for j in range(nspl)] self.nspl, self.p, self.nmax_file = nspl, order - 1, nmax self.nmax = nmax if nmax_use is None else min(nmax, nmax_use) def flat(self, t, deriv=0): i = span(self.nspl, self.p, t, self.knots) w = basis_derivs(i, t, self.p, deriv, self.knots)[deriv] out = [0.0] * len(self.coefs[0]) for j in range(self.p + 1): if w[j]: row = self.coefs[i - self.p + j] for q in range(len(out)): out[q] += w[j] * row[q] return out def gh(self, t, deriv=0): c = self.flat(t, deriv) g, h = zeros(self.nmax), zeros(self.nmax) for n in range(1, self.nmax + 1): base = (n - 1) * (n + 1) g[n][0] = c[base] for m in range(1, n + 1): g[n][m], h[n][m] = c[base + 2 * m - 1], c[base + 2 * m] return g, h # ------------------------------------------------------------------ field synthesis (as in /magnetic-field-guide/'s field_decline.py) def geodetic_to_geocentric(lat_deg, h_km=0.0): phi = math.radians(lat_deg) s, c = math.sin(phi), math.cos(phi) N = WGS84_A / math.sqrt(1.0 - E2 * s * s) x, z = (N + h_km) * c, (N * (1.0 - 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, D = zeros(nmax), zeros(nmax) 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, sphere=False, h_km=0.0): if sphere: self.r, phic, self.delta = A_REF + h_km, math.radians(lat_deg), 0.0 else: self.r, phic, self.delta = geodetic_to_geocentric(lat_deg, h_km) theta = math.pi / 2.0 - phic self.st = math.sin(theta) self.nmax = nmax self.P, self.D = legendre(theta, nmax) self.rr = [(A_REF / self.r) ** (n + 2) for n in range(nmax + 1)] self.cd, self.sd = math.cos(self.delta), math.sin(self.delta) def sums(self, g, h): out = [] nm = min(self.nmax, len(g) - 1) for m in range(nm + 1): s0 = s1 = s2 = s3 = s4 = s5 = 0.0 for n in range(max(1, m), nm + 1): f, P, D = self.rr[n], self.P[n][m], self.D[n][m] gnm, hnm = g[n][m], h[n][m] s0 += (n + 1) * f * gnm * P s1 += (n + 1) * f * hnm * P s2 += f * gnm * D s3 += f * hnm * D s4 += f * gnm * P s5 += f * hnm * P out.append((s0, s1, s2, s3, s4, s5)) return out def xyz(self, sums, cosm, sinm): br = bt = bp = 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 return xc * self.cd + zc * self.sd, bp, zc * self.cd - xc * self.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, sphere=False, h_km=0.0): row = Row(lat, nmax, sphere, h_km) c, s = trig(lon, nmax) return row.xyz(row.sums(g, h), c, s) def F_at(g, h, lat, lon, nmax, sphere=False): X, Y, Z = field(g, h, lat, lon, nmax, sphere) return math.sqrt(X * X + Y * Y + Z * Z) def band_area(lat1, lat2): """WGS84 ellipsoid area between two geodetic latitudes, km^2 per radian of longitude.""" e = math.sqrt(E2) def q(phi): s = math.sin(phi) return s / (1 - 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))) EARTH_AREA = 2 * math.pi * band_area(-90.0, 90.0) def gc_km(lat1, lon1, lat2, lon2, R=R_SPEED): p1, p2 = math.radians(lat1), math.radians(lat2) a = math.sin((p2 - p1) / 2) ** 2 + math.cos(p1) * math.cos(p2) * math.sin(math.radians(lon2 - lon1) / 2) ** 2 return 2 * R * math.asin(math.sqrt(min(1.0, a))) # ------------------------------------------------------------------ the check against NOAA's WMM2025 test values def wmm_check(zpath): z = zipfile.ZipFile(zpath) names = {os.path.basename(n): n for n in z.namelist()} cof = z.read(names["WMM.COF"]).decode("ascii").splitlines() tests = z.read(names["WMM2025_TEST_VALUES.txt"]).decode("ascii").splitlines() g, h, gd, hd = zeros(12), zeros(12), zeros(12), zeros(12) epoch = float(cof[0].split()[0]) for line in cof[1:]: p = line.split() if len(p) < 6 or p[0].startswith("9999"): continue n, m = int(p[0]), int(p[1]) g[n][m], h[n][m], gd[n][m], hd[n][m] = map(float, p[2:6]) worst, k = 0.0, 0 for line in tests: 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(13)] for i in range(13)] hh = [[h[i][j] + (t - epoch) * hd[i][j] for j in range(13)] for i in range(13)] X, Y, Z = field(gg, hh, lat, lon, 12, h_km=hkm) F = math.sqrt(X * X + Y * Y + Z * Z) worst = max(worst, abs(X - p[4]), abs(Y - p[5]), abs(Z - p[6]), abs(F - p[8])) k += 1 return {"test_points": k, "largest_abs_difference_nT": round(worst, 4), "pass_within_0.1_nT": worst <= 0.1} # ------------------------------------------------------------------ minimisation (Nelder-Mead, as scipy's defaults) def nelder_mead(f, x0, step, xatol=1e-7, fatol=1e-6, maxiter=4000): sim = [list(x0), [x0[0] + step, x0[1]], [x0[0], x0[1] + step]] fs = [f(p) for p in sim] for _ in range(maxiter): order = sorted(range(3), key=lambda i: fs[i]) sim, fs = [sim[i] for i in order], [fs[i] for i in order] if max(max(abs(sim[i][k] - sim[0][k]) for k in range(2)) for i in (1, 2)) <= xatol and max(abs(fs[i] - fs[0]) for i in (1, 2)) <= fatol: break c = [(sim[0][k] + sim[1][k]) / 2 for k in range(2)] xr = [c[k] + (c[k] - sim[2][k]) for k in range(2)] fr = f(xr) if fr < fs[0]: xe = [c[k] + 2 * (c[k] - sim[2][k]) for k in range(2)] fe = f(xe) sim[2], fs[2] = (xe, fe) if fe < fr else (xr, fr) elif fr < fs[1]: sim[2], fs[2] = xr, fr else: if fr < fs[2]: xc = [c[k] + 0.5 * (xr[k] - c[k]) for k in range(2)] fc = f(xc) ok = fc <= fr else: xc = [c[k] + 0.5 * (sim[2][k] - c[k]) for k in range(2)] fc = f(xc) ok = fc < fs[2] if ok: sim[2], fs[2] = xc, fc else: for i in (1, 2): sim[i] = [sim[0][k] + 0.5 * (sim[i][k] - sim[0][k]) for k in range(2)] fs[i] = f(sim[i]) i = min(range(3), key=lambda k: fs[k]) return sim[i], fs[i] # ------------------------------------------------------------------ the anomaly class Globe: """A 1-degree grid of cell centres and the 0.25-degree grid inside it (4 x 4 cells to each 1-degree cell).""" def __init__(self, nmax, sphere=False): self.nmax, self.sphere = nmax, sphere self.lat1 = [-89.5 + i for i in range(180)] self.lon1 = [-179.5 + j for j in range(360)] self.rows1 = [Row(la, nmax, sphere) for la in self.lat1] self.trig1 = [trig(lo, nmax) for lo in self.lon1] self.lat4 = [-89.875 + 0.25 * i for i in range(720)] self.lon4 = [-179.875 + 0.25 * j for j in range(1440)] self.rows4 = [Row(la, nmax, sphere) for la in self.lat4] self.trig4 = [trig(lo, nmax) for lo in self.lon4] self.area4 = [band_area(la - 0.125, la + 0.125) * math.radians(0.25) for la in self.lat4] self.coslat4 = [math.cos(math.radians(la)) for la in self.lat4] self.sinlat4 = [math.sin(math.radians(la)) for la in self.lat4] self.ccos, self.csin = [0.0], [0.0] for lo in self.lon4: self.ccos.append(self.ccos[-1] + math.cos(math.radians(lo))) self.csin.append(self.csin[-1] + math.sin(math.radians(lo))) def anomaly(G, g, h): nm = G.nmax F1 = [] for row in G.rows1: s = row.sums(g, h) F1.append([math.sqrt(sum(v * v for v in row.xyz(s, c, sn))) for c, sn in G.trig1]) i1, j1 = min(((i, j) for i in range(180) for j in range(360)), key=lambda p: F1[p[0]][p[1]]) below1 = [[F < THRESHOLD for F in r] for r in F1] mask = [] sums4 = {} def s4(i): if i not in sums4: sums4[i] = G.rows4[i].sums(g, h) return sums4[i] def F4(i, j): c, sn = G.trig4[j] return math.sqrt(sum(v * v for v in G.rows4[i].xyz(s4(i), c, sn))) for i in range(180): base = bytearray(4 * 360) for j in range(360): if below1[i][j]: base[4 * j:4 * j + 4] = b"\x01\x01\x01\x01" for k in range(4): mask.append(bytearray(base)) for i in range(180): for j in range(360): refine = abs(F1[i][j] - THRESHOLD) < MARGIN if not refine: for di in (-1, 0, 1): ii = i + di if 0 <= ii < 180: for dj in (-1, 0, 1): if below1[ii][(j + dj) % 360] != below1[i][j]: refine = True if refine: for k in range(4): for l in range(4): mask[4 * i + k][4 * j + l] = 1 if F4(4 * i + k, 4 * j + l) < THRESHOLD else 0 # the minimum: the best 0.25-degree cell around the best 1-degree cell, then Nelder-Mead best = None for i in range(max(0, 4 * i1 - 4), min(720, 4 * i1 + 8)): for jj in range(4 * j1 - 4, 4 * j1 + 8): j = jj % 1440 F = F4(i, j) if best is None or F < best[0]: best = (F, i, j) _, bi, bj = best x, fmin = nelder_mead(lambda p: F_at(g, h, p[0], p[1], nm, G.sphere), [G.lat4[bi], G.lon4[bj]], 0.25) out = {"min_F": fmin, "min_lat": x[0], "min_lon": ((x[1] + 180.0) % 360.0) - 180.0} # the cells below 32,000 nT joined to the minimum: runs of cells in each row, joined row to row (8-neighbour, wrapping) runs, row_runs = [], [] for i in range(720): r, rr, j = mask[i], [], 0 while j < 1440: if r[j]: s = j while j < 1440 and r[j]: j += 1 rr.append(len(runs)) runs.append((i, s, j - 1)) else: j += 1 row_runs.append(rr) parent = list(range(len(runs))) def find(a): while parent[a] != a: parent[a] = parent[parent[a]] a = parent[a] return a def union(a, b): a, b = find(a), find(b) if a != b: parent[a] = b for i in range(720): rr = row_runs[i] if len(rr) > 1 and runs[rr[0]][1] == 0 and runs[rr[-1]][2] == 1439: union(rr[0], rr[-1]) if i < 719: for a in rr: _, s1, e1 = runs[a] for b in row_runs[i + 1]: _, s2, e2 = runs[b] if (s2 <= e1 + 1 and s1 <= e2 + 1) or (e1 == 1439 and s2 == 0) or (s1 == 0 and e2 == 1439): union(a, b) seed = next(a for a in row_runs[bi] if runs[a][1] <= bj <= runs[a][2]) root = find(seed) area = sx = sy = sz = 0.0 for a, (i, s, e) in enumerate(runs): if find(a) == root: w, n = G.area4[i], e - s + 1 area += w * n sx += w * G.coslat4[i] * (G.ccos[e + 1] - G.ccos[s]) sy += w * G.coslat4[i] * (G.csin[e + 1] - G.csin[s]) sz += w * G.sinlat4[i] * n out.update({"area_km2": area, "area_pct": 100.0 * area / EARTH_AREA, "centre_lon": math.degrees(math.atan2(sy, sx)), "centre_lat": math.degrees(math.atan2(sz, math.hypot(sx, sy)))}) return out # ------------------------------------------------------------------ the north dip pole and the dipole def pole_seed(g, h, nmax): best = None for la in [55.5 + i for i in range(35)]: row = Row(la, nmax) s = row.sums(g, h) for lo in [-179.5 + j for j in range(360)]: X, Y, _ = row.xyz(s, *trig(lo, nmax)) H = math.hypot(X, Y) if best is None or H < best[0]: best = (H, la, lo) return best[1], best[2] def dip_pole(g, h, nmax, seed): def ll(u, v): return 90.0 - math.hypot(u, v), math.degrees(math.atan2(v, u)) def xy(u, v): X, Y, _ = field(g, h, *ll(u, v), nmax) return X, Y c = 90.0 - seed[0] u, v = c * math.cos(math.radians(seed[1])), c * math.sin(math.radians(seed[1])) for _ in range(60): X, Y = xy(u, v) if math.hypot(X, Y) < 1e-7: break d = 1e-5 Xu, Yu = xy(u + d, v) Xv, Yv = xy(u, v + d) a, b, cc, dd = (Xu - X) / d, (Xv - X) / d, (Yu - Y) / d, (Yv - Y) / d det = a * dd - b * cc u -= (dd * X - b * Y) / det v -= (-cc * X + a * Y) / det la, lo = ll(u, v) X, Y, _ = field(g, h, la, lo, nmax) return la, lo, math.hypot(X, Y) def pole_series(gh, nmax, times): out, seed = {}, None for t in times: g, h = gh(t) if seed is None: seed = pole_seed(g, h, nmax) la, lo, H = dip_pole(g, h, nmax, seed) if H >= 1e-3: la, lo, H = dip_pole(g, h, nmax, pole_seed(g, h, nmax)) assert H < 1e-3, "dip pole did not converge at %s" % t out[t] = (la, lo) seed = (la, lo) return out def dipole(g, h): g10, g11, h11 = g[1][0], g[1][1], h[1][1] b0 = math.sqrt(g10 * g10 + g11 * g11 + h11 * h11) return {"absg10": abs(g10), "M": (A_REF * 1e3) ** 3 * (b0 * 1e-9) / 1e-7 / 1e22, "gm_lat": 90.0 - math.degrees(math.acos(-g10 / b0)), "gm_lon": math.degrees(math.atan2(-h11, -g11))} # ------------------------------------------------------------------ series tests def peaks(values, prominence=1.0): """Local maxima with their prominence, as scipy.signal.find_peaks (plateaus at their middle).""" out, n, i = [], len(values), 1 while i < n - 1: if values[i - 1] < values[i]: j = i while j + 1 < n and values[j + 1] == values[i]: j += 1 if j + 1 < n and values[j + 1] < values[i]: k = (i + j) // 2 left = min(values[a] for a in range(max([b for b in range(0, k) if values[b] > values[k]] or [-1]) + 1, k + 1)) right = min(values[a] for a in range(k, (min([b for b in range(k + 1, n) if values[b] > values[k]] or [n])))) p = values[k] - max(left, right) if p >= prominence: out.append((k, values[k], p)) i = j + 1 else: i += 1 return out def step_test(speed, first, last, epochs): ds = {y: speed[y] - speed[y - 1] for y in range(first + 1, last + 1)} b = {y: v for y, v in ds.items() if y in epochs} w = {y: v for y, v in ds.items() if y not in epochs} tot = sum(v * v for v in ds.values()) jumps = sorted(y for y, v in ds.items() if v > 5.0) return {"changes": len(ds), "at_epochs": len(b), "share_of_sum_of_squares_at_epochs": sum(v * v for v in b.values()) / tot, "share_of_sum_of_abs_changes_at_epochs": sum(abs(v) for v in b.values()) / sum(abs(v) for v in ds.values()), "even_spread_share": len(b) / len(ds), "rises_over_5_km_per_yr": {"years": jumps, "at_epochs": sum(1 for y in jumps if y in epochs)}, "rms_at_epochs": math.sqrt(sum(v * v for v in b.values()) / len(b)), "rms_within": math.sqrt(sum(v * v for v in w.values()) / len(w)), "largest_at_epochs": max(b.items(), key=lambda kv: abs(kv[1])), "largest_within": max(w.items(), key=lambda kv: abs(kv[1])), "steps_at_epochs": {str(y): round(v, 2) for y, v in sorted(b.items())}} # ------------------------------------------------------------------ main def main(): sys.stdout.reconfigure(encoding="utf-8") args = [a for a in sys.argv[1:] if not a.startswith("--")] quick, sphere = "--quick" in sys.argv, "--sphere" in sys.argv folder = args[0] if args else os.path.dirname(os.path.abspath(__file__)) t_start = time.time() paths, hashes = {}, {} for name in INPUTS: paths[name], hashes[name] = fetch(folder, name) out = {"what": "South Atlantic Anomaly, north dip pole and dipole (factchecked.science/south-atlantic-anomaly-growth/, Our analysis)", "inputs_sha256": hashes, "check_against_noaa_wmm2025_test_values": wmm_check(paths["WMM2025COF.zip"])} print("Check against NOAA's WMM2025 test values:", out["check_against_noaa_wmm2025_test_values"], flush=True) gu = Splines(paths["gufm1.txt"], "gufm1") ig = Igrf(paths["igrf14coeffs.txt"]) ig13 = Igrf(paths["igrf13coeffs.txt"]) co = Splines(paths["COV-OBS.x2-int"], "covobs") ch = Splines(paths["CHAOS-8.7_spline-coefficients.dat"], "chaos") ch13 = Splines(paths["CHAOS-8.7_spline-coefficients.dat"], "chaos", nmax_use=13) G14 = Globe(14) # 1. the anomaly and the pole every 1 January, 1800-2030: gufm1 to 1899, IGRF-14 from 1900 yearly = {} for y in range(1800, 2031): g, h = gu.gh(float(y)) if y <= 1899 else ig.gh(float(y)) a = anomaly(G14, g, h) a.update(dipole(g, h)) yearly[y] = a if y % 25 == 0: print("%d minimum %.1f nT at %.2f %.2f area below 32,000 nT %.2f%% (%.0f s)" % ( y, a["min_F"], a["min_lat"], a["min_lon"], a["area_pct"], time.time() - t_start), flush=True) poles = pole_series(gu.gh, 14, [float(y) for y in range(1590, 1900)]) poles.update(pole_series(ig.gh, 13, [float(y) for y in range(1900, 2031)])) for y in yearly: yearly[y]["dip_lat"], yearly[y]["dip_lon"] = poles[float(y)] # 2. the 1900-1990 overlap (gufm1 against IGRF-14) overlap = {} if not quick: gp = pole_series(gu.gh, 14, [float(y) for y in range(1900, 1991)]) for y in range(1900, 1991): g, h = gu.gh(float(y)) a = anomaly(G14, g, h) a["dip_lat"], a["dip_lon"] = gp[float(y)] a.update(dipole(g, h)) overlap[y] = a print("overlap done (%.0f s)" % (time.time() - t_start), flush=True) # 3. 1800 under other assumptions about the axial dipole before 1840 g1840 = abs(gu.gh(1840.0)[0][1][0]) alt = {} # Gubbins et al.'s 2.28 +/- 2.72 nT/yr; the open archaeomagnetic models (-1.7 to 10.8 nT/yr, as listed on # /dipole-before-1840/); Suttie et al. as Laj & Kissel summarize it (11-15); Poletti et al. (12.5); gufm1's own 15.2; # and Hellio & Gillet's 16 +/- 2 for rate in (-1.7, 2.28 - 2.72, 2.28, 3.9, 2.28 + 2.72, 8.2, 9.9, 10.8, 11.0, 12.0, 12.5, 14.0, 15.0, 15.2, 16.0, 18.0): label = "%.2f" % rate g, h = gu.gh(1800.0) s = (g1840 + rate * 40.0) / abs(g[1][0]) a = anomaly(G14, [[v * s for v in r] for r in g], [[v * s for v in r] for r in h]) alt["whole field rescaled, %s nT/yr" % label] = {"scale": s, "min_F": a["min_F"], "area_Mkm2": a["area_km2"] / 1e6} if label == "2.28": g2 = [r[:] for r in g] g2[1][0] = -(g1840 + rate * 40.0) a = anomaly(G14, g2, h) alt["g10 alone, 2.28 nT/yr"] = {"min_F": a["min_F"], "area_Mkm2": a["area_km2"] / 1e6} out["alternatives_1800"] = alt # 4. the anomaly in COV-OBS.x2 and CHAOS-8.7 other = [] for name, model, nmax, years in (("COV-OBS.x2", co, 14, (1840, 1900, 1950, 2000, 2020)), ("CHAOS-8.7", ch, 20, (2000, 2014, 2025, 2026))): GG = G14 if nmax == 14 else Globe(20) for y in years: g, h = model.gh(float(y)) a = anomaly(GG, g, h) other.append({"model": name, "year": y, "min_F": round(a["min_F"], 3), "lat": round(a["min_lat"], 4), "lon": round(a["min_lon"], 4), "area_Mkm2": round(a["area_km2"] / 1e6, 4), "area_pct": round(a["area_pct"], 4)}) out["anomaly_other_models"] = other print("alternatives and other models done (%.0f s)" % (time.time() - t_start), flush=True) # 5. pole speeds, year by year, in every model sp = {} def speeds(p, first, last): return {y: gc_km(*p[float(y)], *p[float(y + 1)]) for y in range(first, last)} sp["gufm1"] = speeds(poles, 1590, 1899) sp["gufm1"][1899] = gc_km(*poles[1899.0], *pole_series(gu.gh, 14, [1899.0, 1900.0])[1900.0]) sp["igrf14"] = speeds(poles, 1900, 2030) cub = pole_series(ig.gh_cubic, 13, [float(y) for y in range(1900, 2031)]) sp["igrf14_cubic"] = speeds(cub, 1900, 2030) cop = pole_series(co.gh, 14, [float(y) for y in range(1840, 2021)]) sp["covobs"] = speeds(cop, 1840, 2020) chp = pole_series(ch.gh, 20, [float(y) for y in range(1999, 2027)]) sp["chaos"] = speeds(chp, 1999, 2026) chp13 = pole_series(ch13.gh, 13, [float(y) for y in range(1999, 2027)]) sp["chaos_n13"] = speeds(chp13, 1999, 2026) noaa = {} with open(paths["NP.xy"], encoding="ascii") as f: for line in f: p = line.split() if len(p) == 3: noaa[round(float(p[2]))] = (float(p[1]), ((float(p[0]) + 180.0) % 360.0) - 180.0) sp["noaa"] = {y: gc_km(*noaa[y], *noaa[y + 1]) for y in range(1590, 2025)} print("pole series done (%.0f s)" % (time.time() - t_start), flush=True) s_spl = {y: sp["gufm1"][y] for y in range(1590, 1900)} s_spl.update({y: sp["igrf14"][y] for y in range(1900, 2030)}) # 6. the tests on the yearly speeds epochs = set(range(1905, 2030, 5)) out["step_test"] = {"igrf14_1900_2029": step_test(sp["igrf14"], 1900, 2029, epochs), "igrf14_cubic_control": step_test(sp["igrf14_cubic"], 1900, 2029, epochs), "noaa_1900_2024": step_test(sp["noaa"], 1900, 2024, epochs)} for k, (a, b) in (("covobs", (1840, 2019)), ("chaos", (1999, 2025))): dk = {y: sp[k][y] - sp[k][y - 1] for y in range(a + 1, b + 1)} out["step_test"]["largest_yearly_change_" + k] = max(dk.values(), key=abs) out["step_test"]["rises_over_5_km_per_yr_" + k] = sorted(y for y, v in dk.items() if v > 5.0) out["step_test"]["share_of_sum_of_squares_on_years_divisible_by_5_" + k] = ( sum(v * v for y, v in dk.items() if y % 5 == 0) / sum(v * v for v in dk.values())) pk = {} for k, (a, b) in (("igrf14", (1900, 2029)), ("igrf14_cubic", (1900, 2029)), ("covobs", (1840, 2019)), ("chaos", (1999, 2025)), ("noaa", (1900, 2024))): ys = list(range(a, b + 1)) pk[k] = [{"segment": "%d-%d" % (ys[i], ys[i] + 1), "km_per_yr": round(v, 2), "prominence": round(p, 2)} for i, v, p in peaks([sp[k][y] for y in ys])] out["speed_peaks_prominence_ge_1"] = pk # 7. the surveys, NOAA's poles and the geomagnetic pole sv = [] for (t1, a1, o1), (t2, a2, o2) in zip(SURVEYS[:-1], SURVEYS[1:]): d = gc_km(a1, -o1, a2, -o2) sv.append({"span": "%.1f-%.1f" % (t1, t2), "km": round(d, 1), "km_per_yr": round(d / (t2 - t1), 2)}) out["survey_speeds"] = sv sd = [] for t, la, lo in SURVEYS: p = pole_series(gu.gh if t < 1900 else ig.gh, 14 if t < 1900 else 13, [t])[t] sd.append({"t": t, "model": "gufm1" if t < 1900 else "IGRF-14", "km": round(gc_km(la, -lo, *p), 1)}) out["survey_minus_model_km"] = sd i13 = pole_series(ig13.gh, 13, [float(y) for y in range(2019, 2026)]) out["noaa_np_xy_minus_ours_km"] = { "1590-1891 gufm1, largest": round(max(gc_km(*noaa[y], *poles[float(y)]) for y in range(1590, 1892)), 2), "1892-1899 gufm1, largest (NOAA blends)": round(max(gc_km(*noaa[y], *poles[float(y)]) for y in range(1892, 1900)), 1), "1900-2018 IGRF-14, largest": round(max(gc_km(*noaa[y], *poles[float(y)]) for y in range(1900, 2019)), 2), "2019-2025 IGRF-14, largest": round(max(gc_km(*noaa[y], *poles[float(y)]) for y in range(2019, 2026)), 2), "2019-2025 IGRF-13, largest": round(max(gc_km(*noaa[y], *i13[float(y)]) for y in range(2019, 2026)), 3)} gm = {y: (yearly[y]["gm_lat"], yearly[y]["gm_lon"]) for y in range(1840, 2031)} gu1900 = dipole(*gu.gh(1900.0)) gms = {y: gc_km(*gm[y], *gm[y + 1]) for y in range(1840, 2030)} gms[1899] = gc_km(*gm[1899], gu1900["gm_lat"], gu1900["gm_lon"]) out["geomagnetic_pole"] = { "1840": [round(v, 2) for v in gm[1840]], "1900": [round(v, 2) for v in gm[1900]], "2025": [round(v, 2) for v in gm[2025]], "path_1840_2025_km": round(sum(gms[y] for y in range(1840, 2025))), "path_1900_2025_km": round(sum(gms[y] for y in range(1900, 2025))), "straight_1840_2025_km": round(gc_km(*gm[1840], *gm[2025])), "straight_1900_2025_km": round(gc_km(*gm[1900], *gm[2025])), "fastest_km_per_yr": [max(gms, key=gms.get), round(max(gms.values()), 2)], "2024_2025_km_per_yr": round(gms[2024], 2), "dip_path_1840_2025_km": round(sum(s_spl[y] for y in range(1840, 2025))), "dip_straight_1840_2025_km": round(gc_km(*poles[1840.0], *poles[2025.0])), "dip_path_1900_2025_km": round(sum(sp["igrf14"][y] for y in range(1900, 2025)))} # 8. the axial dipole's loss rates five = [] for e in range(1900, 2030, 5): a, b = dipole(*ig.gh(float(e))), dipole(*ig.gh(float(e + 5))) five.append({"span": "%d-%d" % (e, e + 5), "forecast": e >= 2025, "igrf14_absg10_loss_nT_per_yr": round((a["absg10"] - b["absg10"]) / 5, 4), "igrf14_M_loss_pct_per_century": round(100 * (a["M"] - b["M"]) / a["M"] / 5 * 100, 4)}) for row in five: e = int(row["span"][:4]) if e + 5 <= 2020: row["covobs_absg10_loss_nT_per_yr"] = round((abs(co.gh(float(e))[0][1][0]) - abs(co.gh(float(e + 5))[0][1][0])) / 5, 4) out["axial_dipole_five_year"] = five out["covobs_five_year"] = {str(e): round((abs(co.gh(float(e))[0][1][0]) - abs(co.gh(float(e + 5))[0][1][0])) / 5, 4) for e in range(1840, 2020, 5)} c25, c26 = dipole(*ch.gh(2025.0)), dipole(*ch.gh(2026.0)) out["chaos_2025_2026"] = {"absg10_loss_nT": round(c25["absg10"] - c26["absg10"], 2), "M_loss_pct_per_century": round(100 * (c25["M"] - c26["M"]) / c25["M"] * 100, 2), "dg10_dt_nT_per_yr": {str(t): round(ch.gh(t, deriv=1)[0][1][0], 2) for t in (2025.0, 2025.5, 2026.0, 2026.5)}, "igrf14_forecast_absg10_nT_per_yr": round(ig.sv[("g", 1, 0)], 2)} out["chaos_yearly_absg10_loss_nT"] = {"%d-%d" % (y, y + 1): round(abs(ch.gh(float(y))[0][1][0]) - abs(ch.gh(float(y + 1))[0][1][0]), 4) for y in range(1999, 2026)} Y = yearly for k, v in alt.items(): v["deepening_to_2025_nT"] = v["min_F"] - Y[2025]["min_F"] v["growth_to_2025"] = Y[2025]["area_km2"] / 1e6 / v["area_Mkm2"] dec = list(range(1800, 2021, 10)) + [2025] out["every_decade_1800_2025"] = { "deeper": all(Y[b]["min_F"] < Y[a]["min_F"] for a, b in zip(dec[:-1], dec[1:])), "wider": all(Y[b]["area_km2"] > Y[a]["area_km2"] for a, b in zip(dec[:-1], dec[1:])), "further_west": all(Y[b]["min_lon"] < Y[a]["min_lon"] for a, b in zip(dec[:-1], dec[1:]))} out["deepening_nT_per_yr"] = {"%d-%d" % (a, b): round((Y[a]["min_F"] - Y[b]["min_F"]) / (b - a), 1) for a, b in ((1800, 1840), (1840, 1900), (1900, 1950), (1950, 2000), (2000, 2025), (2025, 2030))} out["area_growth_million_km2_per_yr"] = {"%d-%d" % (a, b): round((Y[b]["area_km2"] - Y[a]["area_km2"]) / 1e6 / (b - a), 2) for a, b in ((1800, 1840), (1840, 1900), (1900, 1950), (1950, 2000), (2000, 2025))} out["minimum_moved_km_per_yr"] = {"%d-%d" % (a, b): round(gc_km(Y[a]["min_lat"], Y[a]["min_lon"], Y[b]["min_lat"], Y[b]["min_lon"]) / (b - a), 1) for a, b in ((1800, 2025), (1900, 2025))} m = lambda a, b: sum(s_spl[y] for y in range(a, b)) / (b - a) out["pole_speed_baselines_km_per_yr"] = {"mean 1600-1699 (gufm1)": round(m(1600, 1700), 3), "mean 1700-1799 (gufm1)": round(m(1700, 1800), 2), "mean 1800-1899 (gufm1)": round(m(1800, 1900), 2), "mean 1900-1989 (IGRF-14)": round(m(1900, 1990), 2), "2000-2001": round(s_spl[2000], 2), "2010-2011": round(s_spl[2010], 2), "2024-2025": round(s_spl[2024], 2), "2029-2030 forecast": round(s_spl[2029], 2), "fastest before 1800 (gufm1)": [max((y for y in range(1590, 1800)), key=lambda y: s_spl[y]), round(max(s_spl[y] for y in range(1590, 1800)), 2)]} ymax = max(range(1900, 2031), key=lambda y: Y[y]["dip_lat"]) out["dip_pole_closest_to_geographic_pole"] = {"year": ymax, "lat": round(Y[ymax]["dip_lat"], 3), "km_from_pole": round((90.0 - Y[ymax]["dip_lat"]) * math.pi / 180 * R_SPEED)} out["dip_pole_lon_2017_2018"] = [round(Y[2017]["dip_lon"], 2), round(Y[2018]["dip_lon"], 2)] fp = {} for y in (1840, 1900, 1950, 2000, 2015, 2025, 2030): g, h = gu.gh(float(y)) if y <= 1899 else ig.gh(float(y)) fp[str(y)] = round(F_at(g, h, Y[y]["dip_lat"], Y[y]["dip_lon"], 14 if y <= 1899 else 13), 0) out["field_at_north_dip_pole_nT"] = fp gq = pole_series(gu.gh, 14, [round(1831.4 + 0.1 * k, 6) for k in range(732)]) ts = sorted(gq) out["gufm1_pole_1831.4_1904.5"] = {"path_km": round(sum(gc_km(*gq[a], *gq[b]) for a, b in zip(ts[:-1], ts[1:]))), "straight_km": round(gc_km(*gq[ts[0]], *gq[ts[-1]])), "lowest_lat": round(min(v[0] for v in gq.values()), 2)} # 9. the note's numbers against ours sm = sum(s_spl[y] for y in range(1800, 1900)) / 100 comp = [ ("Weakest field, 1800 (gufm1), nT", 29215, Y[1800]["min_F"], 0, "Abstract; Claims 1"), ("Weakest field, 1840, nT", 28031, Y[1840]["min_F"], 0, "Claims 1"), ("Weakest field, 1900 (IGRF-14), nT", 25422, Y[1900]["min_F"], 0, "Claims 1"), ("Weakest field, 2000, nT", 22874, Y[2000]["min_F"], 0, "Claims 1"), ("Weakest field, 2025, nT", 22071, Y[2025]["min_F"], 0, "Abstract; Claims 1"), ("Weakest field, 2030 (forecast), nT", 21907, Y[2030]["min_F"], 0, "Claims 1"), ("Deepening since 1840, nT", 5959, Y[1840]["min_F"] - Y[2025]["min_F"], 0, "Claims 1"), ("Deepening since 1800, nT (title: 7,100)", 7100, Y[1800]["min_F"] - Y[2025]["min_F"], -2, "Title"), ("Deepening rate 2000-2025, nT/yr", 32, (Y[2000]["min_F"] - Y[2025]["min_F"]) / 25, 0, "Claims 1"), ("Deepening rate 1840-1900, nT/yr", 43, (Y[1840]["min_F"] - Y[1900]["min_F"]) / 60, 0, "Claims 1"), ("Area below 32,000 nT, 1800, million km2", 19.0, Y[1800]["area_km2"] / 1e6, 1, "Abstract; Claims 2"), ("Area, 1840, million km2", 28.3, Y[1840]["area_km2"] / 1e6, 1, "Claims 2"), ("Area, 1900, million km2", 46.0, Y[1900]["area_km2"] / 1e6, 1, "Claims 2"), ("Area, 2025, million km2", 109.1, Y[2025]["area_km2"] / 1e6, 1, "Abstract; Claims 2"), ("Area, 2030 (forecast), million km2", 112.2, Y[2030]["area_km2"] / 1e6, 1, "Claims 2"), ("Area, 2025, % of Earth", 21.4, Y[2025]["area_pct"], 1, "Abstract; Claims 2"), ("Growth since 1800, times", 5.8, Y[2025]["area_km2"] / Y[1800]["area_km2"], 1, "Abstract; Claims 2"), ("Growth since 1840, times", 3.9, Y[2025]["area_km2"] / Y[1840]["area_km2"], 1, "Claims 2"), ("Minimum 1800, latitude", -19.0, Y[1800]["min_lat"], 1, "Claims 3"), ("Minimum 1800, longitude", -6.3, Y[1800]["min_lon"], 1, "Claims 3"), ("Minimum 2025, latitude", -26.2, Y[2025]["min_lat"], 1, "Claims 3"), ("Minimum 2025, longitude", -60.0, Y[2025]["min_lon"], 1, "Claims 3"), ("Area centre 1800, longitude", -5.9, Y[1800]["centre_lon"], 1, "Claims 3"), ("Area centre 2025, longitude", -48.5, Y[2025]["centre_lon"], 1, "Claims 3"), ("Pole speed, mean 1800-1899, km/yr", 5.5, sm, 1, "Claims 4"), ("Pole speed, fastest 1800-1899, km/yr", 11.8, max(s_spl[y] for y in range(1800, 1900)), 1, "Claims 4"), ("Pole speed, mean 1900-1989, km/yr", 10.0, sum(s_spl[y] for y in range(1900, 1990)) / 90, 1, "Claims 4"), ("Pole speed 2000-2001, km/yr", 55.7, s_spl[2000], 1, "Claims 4"), ("Pole speed 2010-2011 (the note's peak), km/yr", 58.5, s_spl[2010], 1, "Abstract; Claims 4"), ("Pole speed 2015-2016, km/yr", 55.2, s_spl[2015], 1, "Claims 4"), ("Pole speed 2024-2025, km/yr", 36.6, s_spl[2024], 1, "Claims 4"), ("Pole speed 2029-2030 (forecast), km/yr", 29.9, s_spl[2029], 1, "Claims 4"), ("Pole path since 1990, km", 1603, sum(s_spl[y] for y in range(1990, 2025)), 0, "Claims 4"), ("Pole path since 1900, km", 2504, sum(s_spl[y] for y in range(1900, 2025)), 0, "Claims 4"), ("Pole latitude 2018, deg N", 86.59, Y[2018]["dip_lat"], 2, "Claims 4"), ("Pole 2025, deg N", 85.73, Y[2025]["dip_lat"], 2, "Claims 4"), ("Pole 2025, deg E", 138.6, Y[2025]["dip_lon"], 1, "Claims 4"), ("Dipole moment 1840, 1e22 A m2", 8.50, Y[1840]["M"], 2, "Claims 5"), ("Dipole moment 1900, 1e22 A m2", 8.32, Y[1900]["M"], 2, "Claims 5"), ("Dipole moment 2015, 1e22 A m2", 7.72, Y[2015]["M"], 2, "Claims 5"), ("Dipole moment 2025, 1e22 A m2", 7.69, Y[2025]["M"], 2, "Claims 5"), ("Dipole moment fall 1840-2025, %", 9.5, 100 * (Y[1840]["M"] - Y[2025]["M"]) / Y[1840]["M"], 1, "Abstract; Claims 5"), ("|g10| 1840 (gufm1), nT", 32215.25, Y[1840]["absg10"], 2, "Figure 5"), ("|g10| loss 1600-1840, gufm1's convention, nT/yr", 15.20, (abs(gu.gh(1600.0)[0][1][0]) - Y[1840]["absg10"]) / 240, 2, "Figure 5"), ("|g10| loss 1840-1900 (gufm1), nT/yr", 12.05, (Y[1840]["absg10"] - abs(gu.gh(1900.0)[0][1][0])) / 60, 2, "Figure 5"), ("|g10| loss 1900-1950, nT/yr", 19.78, (Y[1900]["absg10"] - Y[1950]["absg10"]) / 50, 2, "Figure 5"), ("|g10| loss 1950-2000, nT/yr", 18.69, (Y[1950]["absg10"] - Y[2000]["absg10"]) / 50, 2, "Figure 5"), ("|g10| loss 2000-2025, nT/yr", 10.78, (Y[2000]["absg10"] - Y[2025]["absg10"]) / 25, 2, "Figure 5"), ("|g10| loss 2015-2020, nT/yr", 7.61, (Y[2015]["absg10"] - Y[2020]["absg10"]) / 5, 2, "Figure 5"), ("|g10| loss 2020-2025, nT/yr", 10.68, (Y[2020]["absg10"] - Y[2025]["absg10"]) / 5, 2, "Figure 5"), ("|g10| fall 1840-2025, %", 8.8941, 100 * (Y[1840]["absg10"] - Y[2025]["absg10"]) / Y[1840]["absg10"], 4, "Figure 5"), ("|g10| gap at 1900, IGRF-14 minus gufm1, nT", 50.51, Y[1900]["absg10"] - abs(gu.gh(1900.0)[0][1][0]), 2, "Figure 5"), ("Gubbins alternative 1800, weakest field, nT", 28759, alt["whole field rescaled, 2.28 nT/yr"]["min_F"], 0, "Abstract; Claims 1"), ("Gubbins alternative 1800, area, million km2", 22.8, alt["whole field rescaled, 2.28 nT/yr"]["area_Mkm2"], 1, "Abstract; Claims 2"), ] if overlap: comp += [("Splice 1900: weakest field, IGRF-14 minus gufm1, nT", 22, Y[1900]["min_F"] - overlap[1900]["min_F"], 0, "Methods: Splice and checks"), ("Splice 1900: area, IGRF-14 against gufm1, %", -2.6, 100 * (Y[1900]["area_km2"] / overlap[1900]["area_km2"] - 1), 1, "Methods: Splice and checks"), ("Splice 1900: pole separation, km", 71, gc_km(Y[1900]["dip_lat"], Y[1900]["dip_lon"], overlap[1900]["dip_lat"], overlap[1900]["dip_lon"]), 0, "Methods: Splice and checks"), ("Splice 1900-1990: mean |weakest-field difference|, nT", 33, sum(abs(Y[y]["min_F"] - overlap[y]["min_F"]) for y in range(1900, 1991)) / 91, 0, "Methods: Splice and checks"), ("Splice 1900-1990: mean pole separation, km", 21, sum(gc_km(Y[y]["dip_lat"], Y[y]["dip_lon"], overlap[y]["dip_lat"], overlap[y]["dip_lon"]) for y in range(1900, 1991)) / 91, 0, "Methods: Splice and checks")] out["note_against_ours"] = [] for what, note, ours, places, loc in comp: q = 10.0 ** (-places) diff = abs(round(ours, places) - note) / q verdict = "reproduces" if diff < 0.5 else ("reproduces (rounding)" if diff < 1.5 and abs((abs(ours) / q) % 1 - 0.5) < 0.1 else ("close" if diff <= 3.5 else "differs")) out["note_against_ours"].append({"what": what, "note": note, "ours": round(ours, max(places, 0) + 2), "result": verdict, "where_in_the_note": loc}) # 10. optional: the note's sphere alternate if sphere: GS, d = Globe(14, sphere=True), [] for y in range(1590, 2031): g, h = gu.gh(float(y)) if y <= 1899 else ig.gh(float(y)) ref = Y[y]["min_F"] if y in Y else anomaly(G14, g, h)["min_F"] d.append(anomaly(GS, g, h)["min_F"] - ref) out["sphere_minus_wgs84_minimum_1590_2030_nT"] = [round(min(d), 1), round(max(d), 1)] # 11. the 0.1-year pole series, for the chart fine = {} if not quick: for name, gh_, nmax, t0, t1 in (("COV-OBS.x2", co.gh, 14, 1840.0, 2020.0), ("CHAOS-8.7", ch.gh, 20, 1999.0, 2026.5), ("IGRF-14", ig.gh, 13, 1960.0, 2030.0), ("IGRF-14, cubic control", ig.gh_cubic, 13, 1960.0, 2030.0)): n = int(round((t1 - t0) / 0.1)) ts = [round(t0 + 0.1 * k, 6) for k in range(n + 1)] p = pole_series(gh_, nmax, ts) fine[name] = [((a + b) / 2, gc_km(*p[a], *p[b]) / (b - a)) for a, b in zip(ts[:-1], ts[1:])] out["fine_maxima"] = {k: [round(max(v, key=lambda x: x[1])[0], 2), round(max(x[1] for x in v), 2)] for k, v in fine.items()} # outputs w = lambda name: open(os.path.join(folder, name), "w", encoding="utf-8", newline="\n") with w("saa_yearly.csv") as f: c = csv.writer(f, lineterminator="\n") c.writerow(["year", "model", "weakest_F_nT", "weakest_lat", "weakest_lon", "area_below_32000_nT_million_km2", "area_pct_of_earth", "area_centre_lon", "dip_pole_lat", "dip_pole_lon", "dipole_moment_1e22_Am2", "absg10_nT", "geomagnetic_pole_lat", "geomagnetic_pole_lon"]) for label, series in (("gufm1 to 1899, IGRF-14 from 1900", yearly), ("gufm1 (overlap)", overlap)): for y in sorted(series): a = series[y] c.writerow([y, ("gufm1" if y <= 1899 else "IGRF-14" + (" forecast" if y > 2025 else "")) if series is yearly else "gufm1", "%.3f" % a["min_F"], "%.4f" % a["min_lat"], "%.4f" % a["min_lon"], "%.4f" % (a["area_km2"] / 1e6), "%.4f" % a["area_pct"], "%.4f" % a["centre_lon"], "%.4f" % a["dip_lat"], "%.4f" % a["dip_lon"], "%.5f" % a["M"], "%.3f" % a["absg10"], "%.3f" % a["gm_lat"], "%.3f" % a["gm_lon"]]) with w("pole_speeds.csv") as f: c = csv.writer(f, lineterminator="\n") keys = ["igrf14", "igrf14_cubic", "covobs", "chaos", "chaos_n13", "noaa", "gufm1"] c.writerow(["segment"] + ["km_per_yr_" + k for k in keys]) for y in range(1590, 2030): c.writerow(["%d-%d" % (y, y + 1)] + ["%.4f" % sp[k][y] if y in sp[k] else "" for k in keys]) if fine: with w("pole_speeds_fine.csv") as f: c = csv.writer(f, lineterminator="\n") c.writerow(["model", "mid_year", "km_per_yr"]) for k, v in fine.items(): for t, s in v: c.writerow([k, "%.2f" % t, "%.4f" % s]) with w("axial_dipole_rates.csv") as f: c = csv.writer(f, lineterminator="\n") c.writerow(["span", "igrf14_absg10_loss_nT_per_yr", "igrf14_dipole_moment_loss_pct_per_century", "covobs_absg10_loss_nT_per_yr", "forecast"]) for r in five: c.writerow([r["span"], r["igrf14_absg10_loss_nT_per_yr"], r["igrf14_M_loss_pct_per_century"], r.get("covobs_absg10_loss_nT_per_yr", ""), r["forecast"]]) out["runtime_s"] = round(time.time() - t_start) with w("saa-pole-numbers.json") as f: json.dump(out, f, indent=1) print("\nThe note's numbers against ours:") for r in out["note_against_ours"]: print(" %-58s note %-9s ours %-12s %s" % (r["what"], r["note"], r["ours"], r["result"])) st = out["step_test"]["igrf14_1900_2029"] print("\nIGRF-14's yearly pole speed: %.1f%% of the squared year-to-year change (%.1f%% of the change itself, against %.1f%% for an " "even spread) falls on its five-year epochs; cubic control %.1f%%; rises of more than 5 km/yr: %d, %d of them at epochs; " "in COV-OBS.x2 and CHAOS-8.7: %d and %d" % ( 100 * st["share_of_sum_of_squares_at_epochs"], 100 * st["share_of_sum_of_abs_changes_at_epochs"], 100 * st["even_spread_share"], 100 * out["step_test"]["igrf14_cubic_control"]["share_of_sum_of_squares_at_epochs"], len(st["rises_over_5_km_per_yr"]["years"]), st["rises_over_5_km_per_yr"]["at_epochs"], len(out["step_test"]["rises_over_5_km_per_yr_covobs"]), len(out["step_test"]["rises_over_5_km_per_yr_chaos"]))) print("Wrote saa-pole-numbers.json, saa_yearly.csv, pole_speeds.csv, axial_dipole_rates.csv%s in %d s" % ( ", pole_speeds_fine.csv" if fine else "", out["runtime_s"])) if __name__ == "__main__": main()