#!/usr/bin/env python3 """Recompute the numbers behind /space-weather-hearing-charter/ from their public sources. python3 charter_numbers.py # prints the results; standard library only It fetches three public files under a plain client name, compares each with the SHA-256 of the copy we used on November 18, 2026, and recomputes: 1. Solar Cycle 25's minimum and maximum in SILSO's 13-month smoothed sunspot number, and its value in July 2025 (the month the charter gives for the maximum). SILSO revises recent months and adds a month each month, so a later download will differ from ours in its hash; the script says so and computes anyway. 2. The highest definitive Kp (GFZ) from February 1 to 6, 2022, the days of the Starlink losses, and its level on NOAA's G-scale. 3. The House Appropriations Committee's FY2027 figures (H. Rept. 119-652) for NWS and NESDIS, each account, and the Heliophysics and NSF lines the charter quotes. Credits: SILSO, Royal Observatory of Belgium, Brussels (CC BY-NC 4.0); GFZ German Research Centre for Geosciences, Kp index (CC BY 4.0); the House report is a U.S. government work. """ import hashlib import html import json import re import sys import urllib.request UA = "factchecked-research/1.0" SOURCES = { "silso": ("https://www.sidc.be/SILSO/DATA/SN_ms_tot_V2.0.csv", "6556ec0b65f608a27d7c559feb0177c91c6340ca4b7b31d016dacbbeaca176e3"), "kp": ("https://kp.gfz.de/app/json/?start=2022-02-01T00:00:00Z&end=2022-02-06T23:59:59Z&index=Kp&status=def", "984cf5da960e13da622f77c51e7ab183794cd54e6bbc9982db1606cd9733ae0c"), "house": ("https://www.govinfo.gov/content/pkg/CRPT-119hrpt652/html/CRPT-119hrpt652.htm", "efaff532b8b3fab0635566b5c59dc47eba17bbce47247f244dac3bbbcb709da6"), } def fetch(url): req = urllib.request.Request(url, headers={"User-Agent": UA}) with urllib.request.urlopen(req, timeout=120) as r: return r.read() def check(name, data): want = SOURCES[name][1] got = hashlib.sha256(data).hexdigest() same = "matches" if got == want else "differs from" print(f"[{name}] {len(data)} bytes, SHA-256 {got[:16]}… {same} our copy of 2026-11-18 ({want[:16]}…)") def silso(data): rows = [] for line in data.decode("utf-8").splitlines(): f = [x.strip() for x in line.split(";")] if len(f) < 4: continue y, m, v = int(f[0]), int(f[1]), float(f[3]) if v >= 0: rows.append((y, m, v)) c25 = [r for r in rows if (r[0], r[1]) >= (2019, 1)] mn = min((r for r in c25 if r[0] <= 2020), key=lambda r: r[2]) mx = max(c25, key=lambda r: r[2]) jul = [r for r in c25 if (r[0], r[1]) == (2025, 7)] last = c25[-1] print(f" Cycle 25 smoothed minimum: {mn[2]:.1f} in {mn[0]}-{mn[1]:02d}") print(f" Cycle 25 smoothed maximum: {mx[2]:.1f} in {mx[0]}-{mx[1]:02d}") if jul: print(f" July 2025: {jul[0][2]:.1f} ({jul[0][2] / mx[2]:.0%} of the maximum)") print(f" Latest smoothed value in the file: {last[2]:.1f} in {last[0]}-{last[1]:02d}") def kp(data): d = json.loads(data) vals = list(zip(d["datetime"], d["Kp"], d.get("status", ["?"] * len(d["Kp"])))) top = max(v[1] for v in vals) when = [v[0] for v in vals if v[1] == top] whole, third = divmod(round(top * 3), 3) # Kp comes in thirds: 5.333 is 5+, 5.667 is 6- label = f"{whole}o" if third == 0 else f"{whole}+" if third == 1 else f"{whole + 1}-" # NOAA's G-scale: G1 at Kp 5 (5- to 5+), G2 at 6, G3 at 7, G4 at 8 (with 9-), G5 at 9 levels = [(4.6, "below G1"), (5.6, "G1 (Minor)"), (6.6, "G2 (Moderate)"), (7.6, "G3 (Strong)"), (8.8, "G4 (Severe)"), (99, "G5 (Extreme)")] g = next(name for limit, name in levels if top < limit) print(f" Highest definitive Kp, Feb 1-6, 2022: {top:.3f} ({label}) at {', '.join(when)}; NOAA scale: {g}") print(f" All values definitive: {all(v[2] == 'def' for v in vals)}") def house(data): t = html.unescape(re.sub(r"<[^>]+>", " ", data.decode("utf-8", "replace"))) t = re.sub(r"\s+", " ", t) def num(pattern): m = re.search(pattern, t) return int(m.group(1).replace(",", "")) if m else None nws_orf = num(r"Total, National Weather Service, Operations, ([\d,]+) Research, and Facilities") nws_pac = num(r"Total, NWS--PAC\.* ([\d,]+)") nes_orf = num(r"Total, National Environmental Satellite, Data ([\d,]+) and Information Service, Operations") nes_pac = num(r"Total, NESDIS--PAC\.* ([\d,]+)") helio = num(r"Heliophysics\.--The recommendation includes \$([\d,]+) for Heliophysics") nsf = num(r"The Committee recommends \$([\d,]+) for the National Science Foundation") print(f" NWS: operations (ORF) ${nws_orf:,} thousand + procurement (PAC) ${nws_pac:,} thousand" f" = ${(nws_orf + nws_pac) / 1000:,.1f} million") print(f" NESDIS: ORF ${nes_orf:,} thousand + PAC ${nes_pac:,} thousand = ${(nes_orf + nes_pac) / 1000:,.1f} million;" f" ORF is {nes_orf / (nes_orf + nes_pac):.1%} of it") print(f" NASA Heliophysics: ${helio:,}; NSF: ${nsf:,}") def main(): for name, fn in (("silso", silso), ("kp", kp), ("house", house)): try: data = fetch(SOURCES[name][0]) except Exception as e: # report and go on print(f"[{name}] could not fetch {SOURCES[name][0]}: {e}") continue check(name, data) fn(data) if __name__ == "__main__": sys.stdout.reconfigure(encoding="utf-8") main()