"""Post hoc, descriptive: U.S. weekly influenza-and-pneumonia deaths in 2015 (and 2018) against the other years, under RULES_posthoc_flu_deaths.txt. Fact-Checked Science ("Our analysis"), 20 November 2026, for the check of Marschollek, M., AGU26 abstract GH11D-VR9816 (not peer reviewed). This describes national deaths; it is not a test and decides no verdict. Input: CDC/NCHS, "Weekly Counts of Deaths by State and Select Causes, 2014-2019" (data.cdc.gov dataset 3yf8-kanr; public domain), either - the CSV export that fetch_inputs.py saves as cdc-nchs/rows_3yf8-kanr.csv, or - the United States rows through the SODA API, https://data.cdc.gov/resource/3yf8-kanr.json?jurisdiction_of_occurrence=United%20States&$limit=1000 The script reads the United States rows only and checks the SHA-256 of their year, week, influenza-and-pneumonia and heart-disease counts, written "year,week,ip,heart" one row per line (LF), against the copies we used: both gave the same 313 weeks and the same hash. Run: python3 -I posthoc_flu_deaths.py Standard library only (Python 3.9+). Writes LF line endings. """ import csv import hashlib import json import sys YEARS = [2014, 2015, 2016, 2017, 2018, 2019] US_ROWS_SHA256 = "18cb03a27821bef5e25ec4c03586fc66b214436a8249e0b064420cef9d6a16ac" def read_rows(path): """Return {(year, week): (influenza_and_pneumonia, heart, week_ending)} for the United States.""" data = {} if path.lower().endswith(".json"): for r in json.load(open(path, encoding="utf-8")): if r.get("jurisdiction_of_occurrence") != "United States": continue data[(int(r["mmwryear"]), int(r["mmwrweek"]))] = ( int(r["influenza_and_pneumonia_j10"]), int(r["diseases_of_heart_i00_i09"]), r["weekendingdate"][:10]) else: with open(path, encoding="utf-8", newline="") as f: rd = csv.DictReader(f) ip_col = next(c for c in rd.fieldnames if c.startswith("Influenza and pneumonia")) heart_col = next(c for c in rd.fieldnames if c.startswith("Diseases of heart")) for r in rd: if r["Jurisdiction of Occurrence"] != "United States": continue m, d, y = r["Week Ending Date"].split("/") data[(int(r["MMWR Year"]), int(r["MMWR Week"]))] = ( int(r[ip_col]), int(r[heart_col]), "%s-%s-%s" % (y, m.zfill(2), d.zfill(2))) return data def canonical_sha(data): lines = ["%d,%d,%d,%d" % (y, w, v[0], v[1]) for (y, w), v in sorted(data.items())] return hashlib.sha256(("\n".join(lines) + "\n").encode()).hexdigest() def main(src, out): data = read_rows(src) sha = canonical_sha(data) lines = ["United States weeks read: %d; SHA-256 of the rows: %s (%s)" % ( len(data), sha, "matches our copy" if sha == US_ROWS_SHA256 else "DIFFERS from our copy, " + US_ROWS_SHA256)] lines.append("") for target in (2015, 2018): others = [y for y in YEARS if y != target] ratios = {} lines.append("== %d (baseline: mean of the same MMWR week in %s)" % (target, ", ".join(map(str, others)))) lines.append("week\tweek_ending\tIP_deaths\tIP_baseline\tIP_ratio\theart_deaths") for w in range(1, 21): obs, heart, end = data[(target, w)] base = sum(data[(y, w)][0] for y in others) / len(others) ratios[w] = obs / base lines.append("%d\t%s\t%d\t%.1f\t%.3f\t%d" % (w, end, obs, base, obs / base, heart)) mean = lambda ws: sum(ratios[w] for w in ws) / len(ws) lines.append("mean ratio weeks 1-10: %.3f; weeks 11-12: %.3f; weeks 13-14: %.3f" % ( mean(range(1, 11)), mean([11, 12]), mean([13, 14]))) first_below = next((w for w in range(1, 21) if ratios[w] < 1.10), None) lines.append("first week with ratio below 1.10: %s" % first_below) peak_w = max(range(1, 21), key=lambda w: data[(target, w)][0]) lines.append("peak I&P week (weeks 1-20): %d (ending %s), %d deaths" % ( peak_w, data[(target, peak_w)][2], data[(target, peak_w)][0])) lines.append("") lines.append("2014 weeks 48-53 I&P deaths: " + ", ".join( "w%d %d" % (w, data[(2014, w)][0]) for w in range(48, 54) if (2014, w) in data)) with open(out, "w", encoding="utf-8", newline="\n") as f: f.write("\n".join(lines) + "\n") if __name__ == "__main__": main(sys.argv[1], sys.argv[2])