Results Stratifier
The ResultsStratifier
is a component that registers the common
stratifications shared across public health observers.
It serves as the single place where default grouping dimensions — age, sex,
and time — are defined for the simulation’s results.
Concrete observers such as DiseaseObserver and MortalityObserver may register additional observer-specific stratifications, but the broadly applicable ones live here.
Default Stratifications
ResultsStratifier registers the following stratifications during setup:
Name |
Source Column(s) |
Description |
|---|---|---|
|
|
Bins simulant ages into age-group name strings (e.g.
|
|
|
Maps each time step’s clock time to a calendar-year string (e.g.
|
|
|
Maps the event time to a calendar-year string. The event time is
the end of the current time step (i.e.
|
|
|
Groups simulants by |
Activating Stratifications
Registering a stratification makes it available but does not apply it to
any observation automatically. To activate stratifications for all observations, list them under
the stratification.default key in the
model specification configuration.
The key path is configuration.stratification.default, whose value is a
list of stratification names (e.g. "age_group", "sex",
"current_year").
Individual observers can further customize which defaults they use through
their include and exclude configuration keys (see
Concrete Observers).
Age Bins
Age-group bins are loaded from the population.age_bins artifact key and
trimmed to the simulation’s configured age window
(population.initialization_age_min through population.untracking_age).
Group names are normalized to lowercase with underscores (e.g.
"Early Neonatal" becomes "early_neonatal").
The mapper uses pandas.cut() to assign each simulant’s continuous age to
the appropriate bin.
Mappers
Two mappers are provided:
map_age_groups()— vectorized mapper that bins ages into age-group name strings.map_year()— vectorized mapper that extracts the year from a datetime column and returns it as a string.
Both mappers are vectorized (is_vectorized=True), meaning they operate on
the entire population DataFrame at once rather than row by row.
See Also
Results Management — vivarium’s results management system
Public Health Observer — the base observer class
Concrete Observers — the concrete public health observers