Skip to content

laser.measles.components.base_transmission

laser.measles.components.base_transmission

Base transmission component for laser.measles models.

This module defines the common interface and parameters for transmission components across different model types (ABM, biweekly, compartmental).

laser.measles.components.base_transmission.BaseTransmission(model, verbose=False, params=None)

Bases: BasePhase, ABC

Abstract base for transmission components.

Defines the shared interface for all transmission implementations (agent-based, compartmental, biweekly). Subclasses must implement __call__ to execute transmission dynamics each tick. This component belongs to the per-timestep stage and should appear in the component list after any vital-dynamics component.

Provides helper methods for seasonality, spatial mixing, and effective β calculation that subclasses can call from their __call__ implementations.

Parameters:

Name Type Description Default
model

The simulation model this component is attached to.

required
verbose bool

Enable verbose logging.

False
params BaseTransmissionParams | None

Transmission parameters. Uses BaseTransmissionParams defaults if None.

None

Example:

1
2
3
4
5
```python
# Transmission components are typically added via the model's component list:
from laser.measles.compartmental.components import InfectionProcess
model.add_component(InfectionProcess)
```

laser.measles.components.base_transmission.BaseTransmission.__call__(model, tick) abstractmethod

Execute transmission dynamics for one time step.

This method must be implemented by each model type to define how transmission occurs in that specific mathematical framework.

Parameters:

Name Type Description Default
model

The model instance

required
tick int

Current time step

required

laser.measles.components.base_transmission.BaseTransmission.apply_spatial_mixing(local_infections)

Apply spatial mixing to infection rates.

Parameters:

Name Type Description Default
local_infections ndarray

Local infection rates per patch

required

Returns:

Type Description
ndarray

Mixed infection rates accounting for spatial coupling

laser.measles.components.base_transmission.BaseTransmission.get_effective_beta(tick, time_scale='daily')

Get effective transmission rate accounting for seasonality.

Parameters:

Name Type Description Default
tick int

Current time step

required
time_scale str

Time scale of the model

'daily'

Returns:

Type Description
float

Effective transmission rate

laser.measles.components.base_transmission.BaseTransmission.get_force_of_infection(model, tick)

Calculate force of infection for each patch.

This method provides a common interface for calculating the force of infection, which can be overridden by model-specific implementations.

Parameters:

Name Type Description Default
model

The model instance

required
tick int

Current time step

required

Returns:

Type Description
ndarray

Array of force of infection values per patch

laser.measles.components.base_transmission.BaseTransmission.get_seasonal_multiplier(tick, time_scale='daily')

Calculate seasonal transmission multiplier.

Parameters:

Name Type Description Default
tick int

Current time step

required
time_scale str

Time scale of the model ('daily', 'biweekly')

'daily'

Returns:

Type Description
float

Seasonal multiplier (1.0 = no seasonal effect)

laser.measles.components.base_transmission.BaseTransmissionParams

Bases: BaseModel

Common parameters for all transmission components.

Example:

1
2
3
4
5
```python
from laser.measles.abm.components.process_transmission import TransmissionParams

params = TransmissionParams(beta=0.3)
```

laser.measles.components.base_transmission.BaseTransmissionParams.Config

Pydantic config allowing numpy array fields.