#!/usr/bin/env python3 """Test 6: the note's Claim 4 and its epoch_mlat column. Rules: RULES_geometry.txt. Fact-Checked Science, verification of florida-aurora-cycle-25. Standard library only; reads the downloads as data. python3 -I geometry.py Writes /geometry.txt and /florida_latitudes.csv. """ import csv import datetime as dt import os import sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) # our own code folder; -I leaves it out import fclib as F # noqa: E402 import fieldmodels as M # noqa: E402 PLACES = { "Key West": (24.56, -81.78), "Fort Jefferson": (24.63, -82.87), "Big Pine Key": (24.67, -81.35), "Jacksonville": (30.33, -81.66), "Chiefland": (29.47, -82.86), "Mims": (28.67, -80.84), "Orlando": (28.54, -81.38), "Pensacola": (30.42, -87.22), "Miami": (25.76, -80.19), "Mobile": (30.69, -88.04), "Havana": (23.11, -82.37), "Mexico City": (19.43, -99.13), "San Antonio": (29.42, -98.49), "Austin": (30.27, -97.74), "Gulf Coast 29.69N, 83.4W": (29.69, -83.4), "Gulf Coast 29.69N, 85.0W": (29.69, -85.0), } # each row of the note's tables: its date field, the place(s) its epoch_mlat names, the note's value(s) ROWS = [ ("1859-08-28/09-02", [("Key West", 35.5)]), ("1872-02-04", [("Jacksonville", 41.3)]), ("1921-05-14/15", [("Key West", 35.7), ("Jacksonville", 41.4)]), # the note: "35.7-41.4 (Florida)" ("1941-09-18/19", [("Jacksonville", 41.5)]), ("1958-02-11", [("Havana", 34.3)]), ("1981-04-12/13", [("Jacksonville", 41.1)]), ("1989-03-13/14", [("Key West", 35.2)]), ("2003-10-29/31", [("Jacksonville", 40.5)]), ("2003-11-20", [("Chiefland", 39.6)]), ("2023-03-23/24", [("Chiefland", 38.6)]), ("2024-05-10/11", [("Key West", 33.7)]), ("2024-10-10/11", [("Key West", 33.6)]), ("2025-11-11/12", [("Mims", 37.8)]), ("2026-01-19/20", [("Gulf Coast 29.69N, 83.4W", 38.5), ("Gulf Coast 29.69N, 85.0W", 38.5), ("Key West", 33.6)]), ] FL = ["Key West", "Miami", "Orlando", "Mims", "Chiefland", "Jacksonville", "Pensacola"] def decimal_year(d): y0 = dt.date(d.year, 1, 1) return d.year + (d - y0).days / ((dt.date(d.year + 1, 1, 1) - y0).days) def main(): dl, outdir = sys.argv[1], sys.argv[2] fm = os.path.join(dl, "field-models") igrf = M.read_igrf(os.path.join(fm, "igrf14coeffs.txt")) gufm = M.SplineModel(os.path.join(fm, "gufm1.txt"), "gufm1") cov = M.SplineModel(os.path.join(fm, "COV-OBS.x2-int"), "covobs") lines = [] out = lines.append def coeffs(t, model=None): if model == "gufm1" or (model is None and t < 1900.0): return gufm.at(t), "gufm1" if model == "covobs": return cov.at(t), "COV-OBS.x2" c = M.igrf_at(igrf, t) nmax = 10 if t < 2000.0 else 13 return {k: v for k, v in c.items() if k[1] <= nmax}, "IGRF-14" def cd(place, t, model=None, geodetic=False): la, lo = PLACES[place] c, _ = coeffs(t, model) d = M.dipole(c) return M.cd_latitude(la if geodetic else M.geocentric(la), lo, d["plat"], d["plon"]) def apex(place, t, model=None): la, lo = PLACES[place] c, _ = coeffs(t, model) return M.apex_latitude(c, M.geocentric(la), lo) out("TEST 6. Geometry: the note's epoch_mlat and Claim 4 (rules: RULES_geometry.txt)") out("") out("The dipole at the dates used (moment in 10^22 A m^2; geomagnetic north pole, degrees north and east)") for t, model in ((1859.67, "gufm1"), (1859.67, "covobs"), (1872.09, "gufm1"), (1872.09, "covobs"), (1900.0, "gufm1"), (1900.0, None), (1921.37, None), (1941.71, "gufm1"), (1941.71, None), (1958.11, "gufm1"), (1958.11, None), (1981.28, "gufm1"), (1981.28, None), (1989.2, "gufm1"), (1989.2, None), (2003.83, None), (2023.22, None), (2024.36, None), (2026.0, None)): c, name = coeffs(t, model) d = M.dipole(c) out(f" {t:.2f} {name:10s} M = {d['M']:.4f} pole {d['plat']:.2f} N, {d['plon']:.2f} E") out("") out("1. Each row's epoch_mlat against our centred-dipole latitude (geocentric conversion; in brackets, without it)") n_ok = n_bad = n_ok_geod = 0 for date, items in ROWS: d0, _ = F.parse_event_dates(date) t = decimal_year(d0) for place, theirs in items: ours, raw = cd(place, t), cd(place, t, geodetic=True) ok = abs(ours - theirs) <= 0.3 n_ok += ok n_bad += not ok n_ok_geod += abs(raw - theirs) <= 0.3 extra = "" if t < 1900: extra = f"; COV-OBS.x2 {cd(place, t, 'covobs'):.2f}; IGRF-14's 1900 dipole {cd(place, 1900.0):.2f} [{cd(place, 1900.0, geodetic=True):.2f}]" elif t <= 1990: extra = f"; gufm1 {cd(place, t, 'gufm1'):.2f}" out(f" {date:17s} {place:26s} note {theirs:5.1f} ours {ours:6.2f} [{raw:6.2f}] difference {theirs - ours:+.2f} [{theirs - raw:+.2f}]" f" {'match' if ok else 'DIFFERS'}{extra}") out(f" within 0.3 degrees: {n_ok} of {n_ok + n_bad} with the geocentric conversion; {n_ok_geod} of {n_ok + n_bad} without it") out("") out("2. Claim 4: change in Florida's centred-dipole latitude (degrees; negative = farther from the pole)") out(" place 1859.67 1941.71 1958.11 1989.20 2003.83 2023.22 2026.00 | 1859 to 2026 | 1958 to 2026 | 1859 to 2023.22 | 1958 to 2023.22") rng = {"1859": [], "1958": [], "1859b": [], "1958b": []} for p in FL: v = {t: cd(p, t) for t in (1859.67, 1941.71, 1958.11, 1989.2, 2003.83, 2023.22, 2026.0)} out(f" {p:13s} " + " ".join(f"{v[t]:8.2f}" for t in sorted(v)) + f" | {v[2026.0] - v[1859.67]:+.2f} | {v[2026.0] - v[1958.11]:+.2f} | " f"{v[2023.22] - v[1859.67]:+.2f} | {v[2023.22] - v[1958.11]:+.2f}") rng["1859"].append(v[2026.0] - v[1859.67]) rng["1958"].append(v[2026.0] - v[1958.11]) rng["1859b"].append(v[2023.22] - v[1859.67]) rng["1958b"].append(v[2023.22] - v[1958.11]) out(f" range, 1859.67 to 2026.0: {min(rng['1859']):+.2f} to {max(rng['1859']):+.2f} (note: 1.8-1.9 lower); 1958.11 to 2026.0: {min(rng['1958']):+.2f} to {max(rng['1958']):+.2f} (note: 2.1-2.2 lower)") out(f" range, to 2023.22 (the first cycle-25 event): from 1859.67 {min(rng['1859b']):+.2f} to {max(rng['1859b']):+.2f}; from 1958.11 {min(rng['1958b']):+.2f} to {max(rng['1958b']):+.2f}") v59 = [cd(p, 2026.0) - cd(p, 1859.67, "covobs") for p in FL] out(f" with COV-OBS.x2 for 1859.67: {min(v59):+.2f} to {max(v59):+.2f}") vg = [cd(p, 2026.0, geodetic=True) - cd(p, 1859.67, geodetic=True) for p in FL] out(f" without the geocentric conversion, 1859.67 to 2026.0: {min(vg):+.2f} to {max(vg):+.2f}; 1958.11 to 2026.0: " f"{min(cd(p, 2026.0, geodetic=True) - cd(p, 1958.11, geodetic=True) for p in FL):+.2f} to {max(cd(p, 2026.0, geodetic=True) - cd(p, 1958.11, geodetic=True) for p in FL):+.2f}") out("") out("3. Apex latitude (the whole field), same places") epochs = [(1859.67, "gufm1"), (1859.67, "covobs"), (1872.09, "gufm1"), (1921.37, None), (1941.71, None), (1958.11, None), (1981.28, None), (1989.2, None), (2003.83, None), (2023.22, None), (2024.36, None), (2025.86, None), (2026.0, None)] out(" place " + " ".join(f"{t:.2f}{'g' if m == 'gufm1' else 'c' if m == 'covobs' else ' '}" for t, m in epochs)) table = {} for p in FL: table[p] = [apex(p, t, m) for t, m in epochs] out(f" {p:13s} " + " ".join(f"{x:8.2f}" for x in table[p])) out(" (g = gufm1, c = COV-OBS.x2, both degree 14; the rest IGRF-14)") out(" change to 2026.0 (degrees):") for j, (t, m) in enumerate(epochs[:-1]): ch = [table[p][-1] - table[p][j] for p in FL] out(f" from {t:.2f}{' (gufm1)' if m == 'gufm1' else ' (COV-OBS.x2)' if m == 'covobs' else ''}: {min(ch):+.2f} to {max(ch):+.2f}") out("") out("4. Each event at its own place and date: centred dipole / apex") for date, items in ROWS: d0, _ = F.parse_event_dates(date) t = decimal_year(d0) for place, theirs in items: ap = apex(place, t) extra = f" (COV-OBS.x2: {apex(place, t, 'covobs'):.2f})" if t < 1900 else "" out(f" {date:17s} {place:26s} {cd(place, t):6.2f} / {ap:6.2f}{extra}") with open(os.path.join(outdir, "florida_latitudes.csv"), "w", encoding="utf-8", newline="\n") as f: f.write("# Our calculation: centred-dipole (cd) and apex latitude, degrees, from gufm1 (before 1900), IGRF-14 (from 1900) and COV-OBS.x2 (1859.67, second model).\n") w = csv.writer(f, lineterminator="\n") w.writerow(["place", "epoch", "model", "cd", "apex"]) for p in FL: for (t, m), a in zip(epochs, table[p]): w.writerow([p, f"{t:.2f}", coeffs(t, m)[1], f"{cd(p, t, m):.2f}", f"{a:.2f}"]) with open(os.path.join(outdir, "geometry.txt"), "w", encoding="utf-8", newline="\n") as f: f.write("\n".join(lines) + "\n") sys.stdout.reconfigure(encoding="utf-8", newline="\n") print("\n".join(lines)) if __name__ == "__main__": main()