Write the outbreak nowcasting program of a regional public-health unit (onset-date nowcast, time-varying reproduction number and growth rate from daily line-list extracts with reporting delays); it is run on further outbreak data packs with known eventual counts and reproduction numbers.
harbor run -t reactive-labs/outbreak-nowcastharbor download reactive-labs/outbreak-nowcastYou are Tamsin Rook, epidemiologist in the Health Protection Surveillance Unit (HPU-ALD) of the Aldermoor Regional Public Health Laboratory. Today is Tuesday 1 December 2026. Dr Idris Penhallow, Consultant in Health Protection and chair of the Outbreak Control Team (OCT), wrote this morning:
As agreed on Friday: one program that takes a pack folder as it lands each morning and gives the bulletin figures under SOP-14 rev 3, and the results for the four packs on the share (the live one and the three from the spring review). Gareth's script is in legacy/ with his notes; use what is useful, but the last two bulletins came out of it and I am not confident in them. Everything the program needs to know about our labs, the calendar and the serial interval it has to carry with it: Priya's validation runs it on her machine with nothing but the pack.
In /app/inputs:
packs/: four outbreak data packs: the live outbreak ALD-2026-FLU-07 (its latest extract ran at 06:00
today) and the archived packs ALD-2025-FLU-02, ALD-2025-FLU-11 and ALD-2026-FLU-03, each as it stood on
its bulletin morning. A pack holds pack.json, extracts/ (the NotifyHub daily notification extracts since the
outbreak was declared, one gzip CSV per extract run) and lab_events.csv (the laboratory events log entries for
the period).backtest/: two archived packs from 2024 and 2025 with their final epidemic curves.docs/: HPU-SOP-14 rev 3 (the procedure), the influenza case definition CD-FLU v3, the NotifyHub extract
interface specification ISP-NH-12 rev D, the laboratories' service note LAB-OPS-RESP-03, the extract calendar
2023-2026, OCT minutes, the household transmission study HTS-2025 (pair list and preliminary report) and the
mails from Idris and from Priya Venn (modelling cell).legacy/: the previous epidemiologist's script and his handover note./app/output/nowcast.py, run as
python3 /app/output/nowcast.py <pack_dir> <out.json>
It reads one pack in the format of the four in hand and writes one JSON object. D below is the nowcast date, the run date of the latest extract in the pack.
{"pack_id": "ALD-2026-FLU-07", "nowcast_date": "2026-12-01",
"nowcast": {"2026-11-21": 231.4, "...": 0.0},
"rt": {"2026-11-10": 1.12, "...": 0.0},
"growth_rate": 0.031}
| Key | Content |
|---|---|
pack_id |
pack_id from pack.json (not scored) |
nowcast_date |
D as YYYY-MM-DD (not scored) |
nowcast |
object keyed by onset date YYYY-MM-DD: the expected eventual number of confirmed influenza A cases, counted as the bulletin counts them under HPU-SOP-14, with symptom onset on that date; at least every date from D-14 to D-3 |
rt |
object keyed by date t: the instantaneous reproduction number by date of onset for the 7-day window t-6 to t; every t from D-21 to D-4 |
growth_rate |
daily exponential growth rate of the eventual counts, per day: the least-squares slope of their natural logarithm over the onset dates D-20 to D-7 |
The program runs with Python 3.12, numpy, scipy and pandas, on one CPU core with 3 GB of memory and no
network, and must finish a pack within 90 seconds. It is run as another user from a copy of /app/output: it
may load helper files that you put in /app/output (found relative to __file__), but /app/inputs is not
there when it runs.
/app/output/results/<pack_id>.json for each of the four packs in /app/inputs/packs (for example
/app/output/results/ALD-2026-FLU-07.json): the program's output for that pack.
Priya runs your program on the validation set: 30 further packs from the modelling cell's outbreak simulator (renewal-equation epidemics with a known reproduction number, passed through an emulation of the notification chain from swab to NotifyHub extract), in exactly the pack format above, with nowcast dates between January 2024 and November 2026. For each pack the eventual counts and the true reproduction number are known. Your four result files are compared with reference values in the same way.
Per pack, with N the eventual count of an onset day:
| Quantity | What is scored | Full credit within T |
|---|---|---|
| Nowcast | each onset date from D-14 to D-3 on which at least 20 % of N is already in the pack's extracts | T = the largest of 5 % of N, 3 cases, and 2.25 x sqrt(N (1 - p) / p + m / 2), where p is the share of N already in the extracts and m is the number of those cases whose own onset date is not in the extracts |
| Rt | each window end t from D-21 to D-4, against the mean of the true instantaneous reproduction number over t-6 to t | T = the larger of 0.04 and 1.5 x R / sqrt(n), where n is the eventual count of the seven onset days |
| Growth rate | the value against the slope of the eventual counts | T = the larger of 0.02 per day and 0.2 / sqrt(c), where c is the mean eventual count per day over D-20 to D-7 |
Credit is 1 within T and falls linearly to 0 at 2 T. The count fraction is the mean credit over all scored nowcast dates, the nowcast fraction the mean credit over the six scored dates with the smallest p (all of them if there are fewer), and the Rt fraction the mean credit over the Rt dates; each is divided by 0.75 and capped at 1. Pack score = count fraction x nowcast fraction x (0.50 + 0.35 x Rt fraction + 0.15 x growth credit). Values that are missing, not numbers or not finite earn nothing; a pack on which the program fails, runs out of time or writes no readable JSON scores zero. The final score is 80 % the mean over the 30 validation packs and 20 % the mean over the four result files.