Skip to content

laser.measles.biweekly

laser.measles.biweekly

laser.measles.biweekly.BaseScenario = BaseBiweeklyScenario module-attribute

Base class for scenario data wrappers.

Provides a wrapper around polars DataFrames with additional validation and convenience methods.

laser.measles.biweekly.BiweeklyModel(scenario, params, name='biweekly')

Bases: BaseLaserModel

A class to represent the biweekly model.

Args:

1
2
3
scenario (BaseScenario): A scenario containing the scenario data, including population, latitude, and longitude.
params (BiweeklyParams): A set of parameters for the model.
name (str, optional): The name of the model. Defaults to "biweekly".

Notes:

1
2
3
4
5
6
7
This class initializes the model with the given scenario and parameters. The scenario must include the following columns:

    - `id` (string): The name of the patch or location.
    - `pop` (integer): The population count for the patch.
    - `lat` (float degrees): The latitude of the patches (e.g., from geographic or population centroid).
    - `lon` (float degrees): The longitude of the patches (e.g., from geographic or population centroid).
    - `mcv1` (float): The MCV1 coverage for the patches.

Initialize the disease model with the given scenario and parameters.

Args:

1
2
3
scenario (BaseScenario): A scenario containing the scenario data, including population, latitude, and longitude.
params (BiweeklyParams): A set of parameters for the model, including seed, nticks, k, a, b, c, max_frac, cbr, verbose, and pyramid_file.
name (str, optional): The name of the model. Defaults to "biweekly".

Returns:

1
None

laser.measles.biweekly.BiweeklyModel.__call__(model, tick)

Updates the model for the next tick.

Args:

1
2
model: The model containing the patches and their populations.
tick (int): The current time step or tick.

Returns:

1
None

laser.measles.biweekly.BiweeklyModel.infect(indices, num_infected)

Infects the given nodes with the given number of infected individuals.

Parameters:

Name Type Description Default
indices int | ndarray

The indices of the nodes to infect.

required
num_infected int | ndarray

The number of infected individuals to infect.

required

laser.measles.biweekly.BiweeklyModel.recover(indices, num_recovered)

Recovers the given nodes with the given number of recovered individuals. Moves individuals from Infected to Recovered compartment.

Parameters:

Name Type Description Default
indices int | ndarray

The indices of the nodes to recover.

required
num_recovered int | ndarray

The number of recovered individuals.

required

laser.measles.biweekly.BiweeklyParams

Bases: BaseModelParams

Parameters for the biweekly compartmental measles model (14-day timesteps).

All fields are inherited from :class:BaseModelParams. Key fields:

Attributes:

Name Type Description
num_ticks int

Number of biweekly (14-day) simulation steps (e.g., 26 = 1 year, 130 = 5 years).

seed int

Random seed for reproducibility. Default: 20250314.

start_time str

Simulation start in "YYYY-MM" format. Default: "2000-01".

verbose bool

Print detailed logging. Default: False.

Example::

1
2
3
params = BiweeklyParams(num_ticks=26, seed=42)           # 1 year
params = BiweeklyParams(num_ticks=130, seed=0)           # 5 years
params = BiweeklyParams(num_ticks=260, start_time="2005-01")  # 10 years

laser.measles.biweekly.create_component(component_class, params=None)

Helper function to create a component instance with parameters.

This function creates a callable object that will instantiate the component with the given parameters when called by the model.

Parameters

component_class : Type[BaseComponent] The component class to instantiate **kwargs Parameters to pass to the component constructor

Returns

Callable[[Any, Any], BaseComponent] A function that creates the component instance when called by the model

Examples

model.components = [ ... create_component(MyComponent, params=MyComponentParams), ... AnotherComponent, ... ]