"""Context numbers (descriptive, not tests): dipole geomagnetic latitude of the four places (IGRF-14 at 2026.84), and GFZ's daily max Kp and Ap for the Halloween storms of 2003 and for October 31 - November 1, 2026. Reads downloads as data. usage: python3 -I context_numbers.py Version 2 (after the fresh review): the part that read Kyoto's Dst pages is removed. Kyoto's rules ask users of its real-time values to contact its staff before publication, so the page doesn't use them; version 1's output is kept in our working folder as a record.""" import sys, os, math sys.stdout.reconfigure(encoding="utf-8") D, OUT = sys.argv[1], sys.argv[2] lines = [] def p(*a): s = " ".join(str(x) for x in a); lines.append(s); print(s) # IGRF-14 dipole terms: 2025.0 IGRF plus SV coef = {} for ln in open(os.path.join(D, "igrf", "igrf14coeffs.txt"), "rb").read().decode("utf-8").splitlines(): f = ln.split() if len(f) > 4 and f[0] in ("g", "h") and f[1] == "1": coef[(f[0], int(f[2]))] = (float(f[-2]), float(f[-1])) # 2025.0 value, SV nT/yr t = 2026.84 - 2025.0 g10 = coef[("g", 0)][0] + t * coef[("g", 0)][1] g11 = coef[("g", 1)][0] + t * coef[("g", 1)][1] h11 = coef[("h", 1)][0] + t * coef[("h", 1)][1] B0 = math.sqrt(g10 ** 2 + g11 ** 2 + h11 ** 2) lat0 = 90 - math.degrees(math.acos(-g10 / B0)) lon0 = math.degrees(math.atan2(-h11, -g11)) p("IGRF-14 dipole at 2026.84: g10 %.1f g11 %.1f h11 %.1f nT; north geomagnetic pole %.2f N, %.2f E" % (g10, g11, h11, lat0, lon0)) places = [("El Espinal, Margarita Island (approx.)", 10.98, -63.98), ("El Vedado, Havana (J and 9th, approx.)", 23.14, -82.39), ("Usia, Dildarnagar, Ghazipur (approx.)", 25.45, 83.67), ("Jhunjhunu district (Udaipurwati, approx.)", 27.73, 75.48), ("for scale: Quebec City", 46.81, -71.21), ("for scale: Malmo", 55.60, 13.00)] for name, la, lo in places: s = math.sin(math.radians(la)) * math.sin(math.radians(lat0)) + math.cos(math.radians(la)) * math.cos(math.radians(lat0)) * math.cos(math.radians(lo - lon0)) p("%-44s %6.2f, %7.2f -> dipole geomagnetic latitude %5.1f" % (name, la, lo, math.degrees(math.asin(s)))) # GFZ Kp, Halloween 2003 and 2026 for ln in open(os.path.join(D, "gfz", "Kp_ap_Ap_SN_F107_since_1932.txt"), "rb").read().decode("utf-8").splitlines(): if ln.startswith("2003 10 2") or ln.startswith("2003 10 3") or ln.startswith("2026 10 31") or ln.startswith("2026 11 01"): f = ln.split() if f[0] == "2003" and int(f[2]) < 28: continue ks = [float(x) for x in f[7:15]] p("GFZ %s-%s-%s daily max Kp %.3f, Ap %s" % (f[0], f[1], f[2], max(ks), f[23])) open(OUT, "w", encoding="utf-8", newline="\n").write("\n".join(lines) + "\n")