#!/usr/bin/env python3 """Smaller numbers on the page that are ours (exploratory, not part of the frozen test). python3 -I extras.py [] Standard library only. (1) Chance, from the same 1976 to May 2022 reference catalogue and the same method as score_forecasts.py, that windows like SSGEOS's 2015 forecasts and its forecast of 10-19 November 2026 hold an earthquake of a given size. (2) How many geometric events SSGEOS's own report on the M 8.8 Kamchatka earthquake of 29 July 2025 lists, and how many involve the Moon. (3) Jupiter's dipole field at its closest to Earth, from NASA's fact sheet, against Earth's own field (NOAA). (4) The distance from the M 4.2 of 3 February 2023 to the M 7.8's epicentre (USGS coordinates), the time encoded in the post's ID, and how much of a month SSGEOS's lunar windows cover. (5) From the results file, the 2025-2026 tables on their own. (6) From the results file, the primary scoring without the largest rows, with the same month bootstrap as the frozen test. (7) The planets' tidal stress on faults, scaled roughly from the Moon's and Sun's stresses in Cochran et al. (2004), added after publication. """ import bisect import csv import datetime as dt import glob import json import math import os import re import sys from decimal import Decimal, ROUND_HALF_UP UTC = dt.timezone.utc REF_START, REF_END = dt.datetime(1976, 1, 1, tzinfo=UTC), dt.datetime(2022, 6, 1, tzinfo=UTC) GRID = dt.timedelta(hours=6) def load(folder): seen, out = set(), [] for path in sorted(glob.glob(os.path.join(folder, "*.csv"))): with open(path, encoding="utf-8", newline="") as fh: for row in csv.DictReader(fh): if row.get("type") != "earthquake" or not row.get("mag") or row["id"] in seen: continue seen.add(row["id"]) m = float(Decimal(row["mag"]).quantize(Decimal("0.1"), rounding=ROUND_HALF_UP)) out.append((dt.datetime.fromisoformat(row["time"].replace("Z", "+00:00")), m)) out.sort() return out def chance(events, lo, hi, days, ref_end=REF_END): times = [t for t, m in events if REF_START <= t < ref_end and m >= lo - 1e-9 and (hi is None or m <= hi + 1e-9)] h = dt.timedelta(days=days) t, n, k = REF_START, 0, 0 while t <= ref_end - h: i = bisect.bisect_left(times, t) n += 1 k += 1 if i < len(times) and times[i] < t + h else 0 t += GRID return k / n def main(): events = load(sys.argv[1]) before_2015 = dt.datetime(2015, 4, 20, tzinfo=UTC) res = {"chance": { "2015-04-22..27 (6 days), M>=7.5, 1976 to 19 April 2015": round(chance(events, 7.5, None, 6, before_2015), 4), "2015-04-22..27 (6 days), M>=7.8, 1976 to 19 April 2015": round(chance(events, 7.8, None, 6, before_2015), 4), "2015-04-22..27 (6 days), M>=7.0, 1976 to 19 April 2015": round(chance(events, 7.0, None, 6, before_2015), 4), "2015-05-28..29 (2 days), M>=7.5, 1976 to 19 April 2015": round(chance(events, 7.5, None, 2, before_2015), 4), "2015-05-28..30 (3 days), M>=7.5, 1976 to 19 April 2015": round(chance(events, 7.5, None, 3, before_2015), 4), "10 days, M 7.5-8.4, 1976 to May 2022": round(chance(events, 7.5, 8.4, 10), 4), "10 days, M>=8.5, 1976 to May 2022": round(chance(events, 8.5, None, 10), 4), "10 days, M 7.0-7.4, 1976 to May 2022": round(chance(events, 7.0, 7.4, 10), 4), "10 days, M 6.5-6.9, 1976 to May 2022": round(chance(events, 6.5, 6.9, 10), 4), "10 days, M 5.5-6.4, 1976 to May 2022": round(chance(events, 5.5, 6.4, 10), 4), "3 days (4-6 Feb 2023 forecast), M>=6.5, 1976 to May 2022": round(chance(events, 6.5, None, 3), 4), "3 days (4-6 Feb 2023 forecast), M>=7.0, 1976 to May 2022": round(chance(events, 7.0, None, 3), 4), "3 days (4-6 Feb 2023 forecast), M>=7.5, 1976 to May 2022": round(chance(events, 7.5, None, 3), 4), "3 days (4-6 Feb 2023 forecast), M>=7.8, 1976 to May 2022": round(chance(events, 7.8, None, 3), 4), "2015-05-28..31 (4 days), M>=7.5, 1976 to 19 April 2015": round(chance(events, 7.5, None, 4, before_2015), 4), "2015-05-28..31 (4 days), M>=7.8, 1976 to 19 April 2015": round(chance(events, 7.8, None, 4, before_2015), 4), }} # M >= 8.5 earthquakes in the whole catalogue res["m85_events_1976_2026"] = [(t.isoformat(), m) for t, m in events if m >= 8.5] # SSGEOS's Kamchatka report: geometric events listed raw = open(sys.argv[2], encoding="utf-8", errors="replace").read() lines = re.findall(r"([A-Z][a-z]+):([A-Z][a-z]+)-([A-Z][a-z]+)\s+(\d{4}-\d{2}-\d{2}),\s+(\d{2}:\d{2}:\d{2})\s+(\d+)°", raw) res["kamchatka_report"] = {"listed": len(lines), "involving_moon": sum(1 for x in lines if "Moon" in x[:3]), "first_day": min(x[3] for x in lines) if lines else None, "last_day": max(x[3] for x in lines) if lines else None, "by_angle": {a: sum(1 for x in lines if x[5] == a) for a in sorted({x[5] for x in lines})}} # Jupiter's dipole field at its closest to Earth (NASA fact sheet: 4.30 gauss Rj^3, Rj = 71,398 km, # minimum distance from Earth 588.5 million km); Earth's field 25,000-65,000 nT (NOAA NCEI) b_gauss = 4.30 * (71398.0 / 588.5e6) ** 3 b_nt = b_gauss * 1e5 res["jupiter_dipole_at_earth"] = {"gauss": b_gauss, "nT": b_nt, "fraction_of_25000_nT": b_nt / 25000, "fraction_of_65000_nT": b_nt / 65000} # (4) USGS coordinates: M 4.2 of 2023-02-03 11:05:09 UTC (37.2003 N, 36.4998 E); M 7.8 us6000jllz (37.2256 N, # 37.0143 E); M 7.5 us6000jlqa (38.0106 N, 37.1962 E). Haversine on a 6,371 km sphere. def hav(a, b, c, d): p1, p2, dl = math.radians(a), math.radians(c), math.radians(d - b) h = math.sin((p2 - p1) / 2) ** 2 + math.cos(p1) * math.cos(p2) * math.sin(dl / 2) ** 2 return 2 * 6371.0 * math.asin(math.sqrt(h)) # (7) Tidal stress on faults. Cochran et al. (2004, Science 306, p. 1164): from the Moon and Sun together, solid-Earth # tides stress faults by up to 5 x 10^3 Pa and, in ocean basins, ocean loading by up to nearly 5 x 10^4 Pa. Scaled, # roughly, by the planets' combined maximum tide (7.0 x 10^-5 of the Moon's at its average distance) over the # Moon-and-Sun maximum (Moon at perigee 1.25 plus Sun at perihelion 0.48, same unit), both from # /planet-alignments-earthquakes/ section 6; tidal stress scales with the tide-raising acceleration. Both are maxima, # so this divisor fits Cochran's "up to"; it also gives the smallest planetary stress of the obvious choices (the # Moon's average tide alone, 1.0, would give 0.35 Pa and 3.5 Pa, about 1,100 times below 0.004 MPa). Compared with # 0.004 MPa, below which the global thrust events in Cochran et al.'s Table 2 (p. 1166) show no clear excess # (1.2 +/- 1.17%; the California strike-slip events below it: 0.60 +/- 0.30%). share = 7.0e-5 / (1.25 + 0.48) res["planet_tidal_stress"] = {"planets_share_of_moon_and_sun_max": round(share, 7), "solid_earth_Pa": round(5e3 * share, 3), "ocean_loading_Pa": round(5e4 * share, 2), "times_below_0.004_MPa": round(4000 / (5e4 * share))} tweet_id = 1621479563720118273 posted = dt.datetime.fromtimestamp(((tweet_id >> 22) + 1288834974657) / 1000, UTC) res["turkey"] = {"km_m42_to_m78_epicentre": round(hav(37.2003, 36.4998, 37.2256, 37.0143), 1), "km_m42_to_m75_epicentre": round(hav(37.2003, 36.4998, 38.0106, 37.1962), 1), "post_time_from_id": posted.isoformat(), "minutes_m78_to_first_archive": round((dt.datetime(2023, 2, 6, 2, 45, 38, tzinfo=UTC) - dt.datetime(2023, 2, 6, 1, 17, 34, tzinfo=UTC)).total_seconds() / 60, 1)} res["lunar_windows_share_of_month"] = round(4 * 2 * 2.95 / 29.530589, 4) # (5) the 2025-2026 tables (exploratory; the frozen test pools all years) if len(sys.argv) > 4: pairs = json.load(open(sys.argv[4], encoding="utf-8"))["analysis1"]["primary"]["pairs"] recent = [p for p in pairs if p["start"] >= "2025-01-01"] rows = {} for p in recent: r = rows.setdefault(f"{p['bin'][0]}-{p['bin'][1]}", {"n": 0, "ssgeos_expected": 0.0, "observed": 0, "base_expected": 0.0}) r["n"] += 1 r["ssgeos_expected"] += p["p"] r["observed"] += p["o"] r["base_expected"] += p["q"] bs = sum((p["p"] - p["o"]) ** 2 for p in recent) / len(recent) bb = sum((p["q"] - p["o"]) ** 2 for p in recent) / len(recent) res["tables_2025_2026"] = {"tables": len({p["id"] for p in recent}), "first": min(p["start"] for p in recent), "last": max(p["start"] for p in recent), "rows": {k: {kk: round(vv, 2) for kk, vv in v.items()} for k, v in rows.items()}, "brier_ssgeos": round(bs, 3), "brier_base": round(bb, 3), "bss": round(1 - bs / bb, 2)} # (6) the primary scoring without the largest rows, with the same month bootstrap as the frozen test # (exploratory: suggested by the fresh review, since the rarity of M 8.5+ was known in advance) import random def bss_ci(sel): def bss(rs): s = sum((r["p"] - r["o"]) ** 2 for r in rs) b = sum((r["q"] - r["o"]) ** 2 for r in rs) return 1 - s / b months = sorted({r["start"][:7] for r in sel}) by = {m: [r for r in sel if r["start"][:7] == m] for m in months} rng = random.Random(20261112) vals = sorted(bss([r for m in rng.choices(months, k=len(months)) for r in by[m]]) for _ in range(10000)) return {"pairs": len(sel), "brier_ssgeos": round(sum((r["p"] - r["o"]) ** 2 for r in sel) / len(sel), 3), "brier_base": round(sum((r["q"] - r["o"]) ** 2 for r in sel) / len(sel), 3), "bss": round(bss(sel), 2), "bss_95": [round(vals[249], 2), round(vals[9749], 2)]} res["without_largest_rows"] = { "without 7.5-8.4 and 8.5+": bss_ci([p for p in pairs if p["bin"][0] < 7.5]), "rows below magnitude 7 only": bss_ci([p for p in pairs if p["bin"][1] is not None and p["bin"][1] < 7.0]), } with open(sys.argv[3], "w", encoding="utf-8", newline="\n") as fh: json.dump(res, fh, ensure_ascii=False, indent=1) sys.stdout.reconfigure(encoding="utf-8") print(json.dumps(res, ensure_ascii=False, indent=1)) if __name__ == "__main__": main()