API reference#

This page lists laser-measles’s API.

Base Components#

Components (e.g., infection, aging, vital dynamics, etc.) setup and affect the model, its structure and dynamics. Shared base classes that provide common interfaces and functionality across all model types. Model-specific implementations inherit from these base classes.

Component Architecture#

The laser-measles framework follows a hierarchical component architecture:

  1. Base Components (laser_measles.components) define abstract interfaces and common functionality

  2. Model-Specific Implementations (laser_measles.{model}.components) inherit from base classes and implement model-specific behavior

  3. Parameter Classes use Pydantic for validation and are paired with their respective component classes

  4. Numpy/Numba Pattern - Components can provide both numpy and numba implementations for performance optimization

Inheritance Pattern Example:

# Base class in laser_measles.components
class BaseInitializeEquilibriumStatesProcess(BasePhase):
    # Common interface and default behavior
    pass

# Model-specific implementation in laser_measles.abm.components
class InitializeEquilibriumStatesProcess(BaseInitializeEquilibriumStatesProcess):
    # ABM-specific implementation
    pass

Process Base Classes#

Abstract base classes for components that modify population states and drive model dynamics:

BaseInitializeEquilibriumStatesProcess

Initialize S, R states of the population in each of the model states by rough equilibrium of R0.

BaseVitalDynamicsProcess

Phase for simulating the vital dynamics in the model with MCV1.

BaseConstantPopProcess

A component to handle the birth events in a model with constant population - that is, births == deaths.

BaseInfectionProcess

Base class for infection (transmission and disease progression).

Note that each component has a corresponding parameter class that is used to configure the component. For example, the BaseInfectionProcess has a corresponding BaseInfectionParams class. The parameter class is used to configure the component and defaults can be overridden using the create_component function.

Tracker Base Classes#

Abstract base classes for components that monitor and record model state for analysis:

BaseStateTracker

Component for tracking the number in each SEIR state for each time tick.

BaseCaseSurveillanceTracker

Component for tracking detected cases in the model.

BasePopulationTracker

Tracks the population size of each patch at each time tick.

BaseFadeOutTracker

A phase that tracks and records the number of nodes experiencing fade-outs over time.

Utilities#

Component creation and management utilities:

component

Decorator for creating components with default parameters.

create_component

Helper function to create a component instance with parameters.


ABM Model#

Core Model#

Agent based model:

model

A class to represent the agent-based model.

params

Parameters for the ABM model.

base

Basic classes

utils

This module provides utility functions for the laser-measles project.

Process Components#

Components that modify population states and drive model dynamics. Most inherit from base classes in laser_measles.components:

components.InitializeEquilibriumStatesProcess

Initialize S, R states of the population in each of the model states by rough equilibrium of R0.

components.VitalDynamicsProcess

Process for simulating vital dynamics in the ABM model with MCV1 and constant birth and mortality rates (not age-structured).

components.ConstantPopProcess

A component to handle the birth events in a model with constant population - that is, births == deaths.

components.InfectionProcess

Combined infection process that orchestrates transmission and disease progression.

components.InfectionSeedingProcess

Component for seeding initial infections in the compartmental model.

components.ImportationPressureProcess

Component for simulating the importation pressure in the model.

components.SIACalendarProcess

Phase for implementing Supplementary Immunization Activities (SIAs) based on a calendar schedule.

ABM-Specific Process Components#

Components unique to the ABM model:

components.NoBirthsProcess

Component for setting the population of the patches to not have births.

components.TransmissionProcess

A component to model the transmission of disease in a population.

components.DiseaseProcess

This component provides disease progression (E->I->R) It is used to update the infectious timers and the exposed timers.

Tracker Components#

Components that monitor and record model state for analysis. All inherit from base classes in laser_measles.components:

components.StateTracker

ABM state tracking component.

components.CaseSurveillanceTracker

components.PopulationTracker

Tracks the population size of each patch at each time tick.

components.FadeOutTracker

A component that tracks the number of nodes experiencing fade-outs over time.


Compartmental Model#

Core Model#

Compartmental model with daily timesteps:

model

This module defines the CompartmentalModel class for SEIR simulation with daily timesteps

params

Parameters for the compartmental SEIR model with daily timesteps.

base

Basic classes for compartmental model.

Process Components#

Components that modify population states and drive model dynamics. All inherit from base classes in laser_measles.components:

components.InitializeEquilibriumStatesProcess

Initialize S, R states of the population in each of the model states by rough equilibrium of R0.

components.InfectionSeedingProcess

Process infection seeding.

components.InfectionProcess

Component for simulating SEIR disease progression with daily timesteps.

components.ImportationPressureProcess

Component for simulating the importation pressure in the model.

components.VitalDynamicsProcess

Phase for simulating the vital dynamics in the model with MCV1.

components.ConstantPopProcess

A component to handle the birth events in a model with constant population - that is, births == deaths.

components.SIACalendarProcess

Phase for implementing Supplementary Immunization Activities (SIAs) based on a calendar schedule.

Tracker Components#

Components that monitor and record model state for analysis. All inherit from base classes in laser_measles.components:

components.StateTracker

Atate tracking component.

components.CaseSurveillanceTracker

Tracks detected cases in the model.

components.PopulationTracker

Tracks the population size of each patch.

components.FadeOutTracker

A component that tracks the number of nodes experiencing fade-outs over time.


Biweekly Model#

Core Model#

Compartmental model with 2-week timesteps

model

A class to represent the biweekly model.

params

Parameters for the biweekly model.

base

Basic classes for biweekly model.

Process Components#

Components that modify population states and drive model dynamics. All inherit from base classes in laser_measles.components:

components.InitializeEquilibriumStatesProcess

Initialize S, R states of the population in each of the model states by rough equilibrium of R0.

components.InfectionSeedingProcess

Process infection seeding.

components.InfectionProcess

Component for simulating the spread of infection in the model.

components.VitalDynamicsProcess

Phase for simulating the vital dynamics in the model with MCV1.

components.ImportationPressureProcess

Component for simulating the importation pressure in the model.

components.ConstantPopProcess

A component to handle the birth events in a model with constant population - that is, births == deaths.

components.SIACalendarProcess

Phase for implementing Supplementary Immunization Activities (SIAs) based on a calendar schedule.

Tracker Components#

Components that monitor and record model state for analysis. Most inherit from base classes in laser_measles.components:

components.StateTracker

Atate tracking component.

components.CaseSurveillanceTracker

Tracks detected cases in the model.

components.PopulationTracker

Tracks the population size of each patch.

components.FadeOutTracker

A component that tracks the number of nodes experiencing fade-outs over time.

Biweekly-Specific Tracker Components#

Components unique to the Biweekly model:

components.FadeOutTracker

A component that tracks the number of nodes experiencing fade-outs over time.

Utilities#

Core Framework#

Base Classes#

Foundation classes that provide the component architecture:

base.BaseComponent

Base class for all laser-measles components.

base.BaseLaserModel

Base class for laser-measles simulation models.

Utilities#

Core utilities and computation functions:

create_component

Helper function to create a component instance with parameters.


Demographics Package#

Geographic data handling for spatial epidemiological modeling:

Shapefile Utilities#

Functions for processing and visualizing geographic shapefiles:

get_shapefile_dataframe

Get a DataFrame containing the shapefile data with DOTNAME and shape columns.

plot_shapefile_dataframe

GADMShapefile

Raster Processing#

Tools for handling raster data and patch generation:


Mixing Models#

Spatial mixing models for population movement and disease transmission between geographic patches (see laser-core for more details):

Base Classes#

Abstract base class that defines the interface for all mixing models:

base.BaseMixing

Base class for migration models.

Mixing Implementations#

Specific mixing model implementations for different types of population movement:

gravity.GravityMixing

Gravity migration model.

stouffer.StoufferMixing

Stouffer migration model where long distance travel is impacted by intervening opportunities.

radiation.RadiationMixing

Radiation migration model where outbound migration flux from origin to destination is enhanced by destination population and absorbed by the density of nearer destinations.

competing_destinations.CompetingDestinationsMixing

Competing destinations mixing model that accounts for the effects of nearby destinations.