
Write ensemble trajectory channels to per-location CSV
Source:R/write_trajectory_csv.R
write_trajectory_csv.RdExports the ensemble central daily trajectory of every captured channel (the
artifact's $summary[[channel]]$median field, which is not always a
median; see "What is lost") to a plain-text CSV, one file per location, as
trajectories_<LOC>.csv.
Arguments
- trajectories
A
mosaic_trajectoriesobject, or a path to atrajectories_ensemble.rdsfile.- dir_out
Directory to write into; created if absent.
- channels
Optional character vector selecting channels. Default
NULLwrites every channel present.- digits
Significant figures to round values to. Default 6.
- verbose
Logical; print one message per file written.
Why this exists
run_MOSAIC() reduces the per-member channel arrays into a
mosaic_trajectories object and persists it to
2_calibration/trajectories_ensemble.rds. That file is an R binary, so
the MOSAIC-results promoter classifies it as heavy and records it
store:"pending" — declared in the manifest but never committed. The
consequence is that only reported_cases and reported_deaths
(via the prediction CSVs) reach the archive, while incidence,
new_symptomatic, disease_deaths, the compartments and the
derived channels do not, and are unreadable outside R even when present.
A text CSV is copied into git by the existing promoter with no schema or promoter change.
Format and size
WIDE, not long: one row per (location, date) with one column per
channel. A long table repeats location and date once per
channel, which for 24 channels measured 2.72 MB against 582 KB wide on a
national model (4.7x), and 410 KB against 202 KB after gzip.
Values are rounded to digits significant figures. At the default 6
this measured 582 KB per national model (202 KB packed) against 970 KB
(373 KB packed) at full precision — model output does not carry 15
significant figures of information.
The per-member $lines component is deliberately NOT exported: at 6
significant figures it measured 62.7 MB raw / 7.8 MB packed for a single
national model, which belongs in blob storage rather than git.
Deaths and the population balance
When the run integrated the reported CFR out (MOSAIC >= v0.96.0),
reported_deaths and disease_deaths are the members' deaths
redrawn from the calibrated CFR. The population compartments and N
carry the engine's own fatal draws at the prior mu_jt (the fatal share
p_fatal of symptomatic onsets, a few percent, never enters
Isym), so N balances against those,
not against the redrawn disease_deaths. disease_deaths are true
deaths, i.e. reported deaths / rho_deaths, and rest on the pinned
rho_deaths.
What is lost
The summary carries one central line per channel and no credible intervals. The central line is not the same statistic for every column:
reported_casesandreported_deathsfollow the run's per-channelcentral_method(default weighted median for cases, weighted mean for deaths) over the engine-level member trajectories, matchingpredicted_centralin the prediction CSVs;disease_deathsfollows the deathscentral_method.mass_balanceis a ratio of the compartments' weighted means,CFRa ratio of 28-day rolling sums of the weighted-mean reported deaths and cases, andepidemic_fracthe weighted mean of the reconstructed epidemic flag.I_totalis the sum of theIsymandIasymmedians.Every other channel is the weighted median.
Intervals for these channels require the per-member data. reported_cases and
reported_deaths keep their intervals in the prediction CSVs.