laser_measles.biweekly package#
- BaseScenario#
- alias of - BaseBiweeklyScenario
- class BiweeklyModel(scenario, params, name='biweekly')[source]#
- Bases: - BaseLaserModel- A class to represent the biweekly model. - Parameters:
- 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 - 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. 
 - infect(indices, num_infected)[source]#
- Infects the given nodes with the given number of infected individuals. - Parameters:
- indices (int | np.ndarray) – The indices of the nodes to infect. 
- num_infected (int | np.ndarray) – The number of infected individuals to infect. 
 
- Return type:
- None
 
 - recover(indices, num_recovered)[source]#
- Recovers the given nodes with the given number of recovered individuals. Moves individuals from Infected to Recovered compartment. - Parameters:
- indices (int | np.ndarray) – The indices of the nodes to recover. 
- num_recovered (int | np.ndarray) – The number of recovered individuals. 
 
- Return type:
- None
 
 - scenario_wrapper_class#
- alias of - BaseBiweeklyScenario
 - 
patches: PatchLaserFrame#
 
- pydantic model BiweeklyParams[source]#
- Bases: - BaseModelParams- Parameters for the biweekly model. - Show JSON schema- { "title": "BiweeklyParams", "description": "Parameters for the biweekly model.", "type": "object", "properties": { "seed": { "default": 20250314, "description": "Random seed", "title": "Seed", "type": "integer" }, "start_time": { "default": "2000-01", "description": "Initial start time of simulation in YYYY-MM format", "title": "Start Time", "type": "string" }, "num_ticks": { "default": 365, "description": "Number of time steps", "title": "Num Ticks", "type": "integer" }, "verbose": { "default": false, "description": "Whether to print verbose output", "title": "Verbose", "type": "boolean" }, "show_progress": { "default": true, "description": "Whether to show progress bar during simulation", "title": "Show Progress", "type": "boolean" }, "use_numba": { "default": true, "description": "Whether to use numba acceleration when available", "title": "Use Numba", "type": "boolean" } }, "additionalProperties": false } - Config:
- extra: str = forbid 
 
- Fields:
 - property states: list[str]#
 - property time_step_days: int#
 
- Model#
- alias of - BiweeklyModel
- Params#
- alias of - BiweeklyParams
Subpackages#
Submodules#
laser_measles.biweekly.base module#
Basic classes for biweekly model.
- pydantic model BaseScenarioSchema[source]#
- Bases: - Model- Schema for the scenario data. - Show JSON schema- { "title": "BaseScenarioSchema", "description": "Schema for the scenario data.", "type": "object", "properties": { "pop": { "title": "Pop", "type": "integer" }, "lat": { "title": "Lat", "type": "number" }, "lon": { "title": "Lon", "type": "number" }, "id": { "title": "Id", "type": "string" }, "mcv1": { "title": "Mcv1", "type": "number" } }, "required": [ "pop", "lat", "lon", "id", "mcv1" ] } - 
field id: str[Required]#
 - 
field lat: float[Required]#
 - 
field lon: float[Required]#
 - 
field mcv1: float[Required]#
 - 
field pop: int[Required]#
 - DataFrame#
- alias of - BaseScenarioSchemaDataFrame
 - LazyFrame#
- alias of - BaseScenarioSchemaLazyFrame
 
- 
field id: 
- BaseScenario#
- alias of - BaseBiweeklyScenario
laser_measles.biweekly.mixing module#
- pairwise_haversine(df)[source]#
- Pairwise distances for all (lon, lat) points using the Haversine formula. - Parameters:
- df (pl.DataFrame) – Polars DataFrame with ‘lon’ and ‘lat’ columns 
- Returns:
- Pairwise distances in kilometers 
 
- pairwise_haversine_(lon, lat)[source]#
- Calculate pairwise distances for all (lon, lat) points using the Haversine formula. - Parameters:
- lon ( - ndarray) – Array of longitude values in degrees
- lat ( - ndarray) – Array of latitude values in degrees
 
- Return type:
- ndarray
- Returns:
- Compressed matrix of pairwise distances in kilometers, where only the upper triangle (excluding diagonal) is stored. The full matrix can be reconstructed using: full_matrix = np.zeros((n, n)) full_matrix[np.triu_indices(n, k=1)] = compressed_matrix full_matrix = full_matrix + full_matrix.T 
 
- init_gravity_diffusion_(df, scale, dist_exp)[source]#
- Initialize a gravity diffusion matrix for population mixing. - Parameters:
- df ( - DataFrame|- tuple[- ndarray,- ndarray]) – Either a DataFrame with ‘population’, ‘lat’, and ‘lon’ columns, or a tuple of (lon, lat) arrays
- scale ( - float) – Scaling factor for the diffusion matrix
- dist_exp ( - float) – Distance exponent for the gravity model
 
- Return type:
- ndarray
- Returns:
- Normalized diffusion matrix where each row sums to 1 
 
laser_measles.biweekly.model module#
A class to represent the biweekly model.
- class BiweeklyModel(scenario, params, name='biweekly')[source]#
- Bases: - BaseLaserModel- A class to represent the biweekly model. - Parameters:
- 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 - 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. 
 - scenario_wrapper_class#
- alias of - BaseBiweeklyScenario
 - 
patches: PatchLaserFrame#
 - infect(indices, num_infected)[source]#
- Infects the given nodes with the given number of infected individuals. - Parameters:
- indices (int | np.ndarray) – The indices of the nodes to infect. 
- num_infected (int | np.ndarray) – The number of infected individuals to infect. 
 
- Return type:
- None
 
 - recover(indices, num_recovered)[source]#
- Recovers the given nodes with the given number of recovered individuals. Moves individuals from Infected to Recovered compartment. - Parameters:
- indices (int | np.ndarray) – The indices of the nodes to recover. 
- num_recovered (int | np.ndarray) – The number of recovered individuals. 
 
- Return type:
- None
 
 - scenario: BaseScenario#
 - params: BaseModelParams#
 - instances: list#
 - phases: list#
 - metrics: list#
 
- Model#
- alias of - BiweeklyModel
laser_measles.biweekly.params module#
- pydantic model BiweeklyParams[source]#
- Bases: - BaseModelParams- Parameters for the biweekly model. - Show JSON schema- { "title": "BiweeklyParams", "description": "Parameters for the biweekly model.", "type": "object", "properties": { "seed": { "default": 20250314, "description": "Random seed", "title": "Seed", "type": "integer" }, "start_time": { "default": "2000-01", "description": "Initial start time of simulation in YYYY-MM format", "title": "Start Time", "type": "string" }, "num_ticks": { "default": 365, "description": "Number of time steps", "title": "Num Ticks", "type": "integer" }, "verbose": { "default": false, "description": "Whether to print verbose output", "title": "Verbose", "type": "boolean" }, "show_progress": { "default": true, "description": "Whether to show progress bar during simulation", "title": "Show Progress", "type": "boolean" }, "use_numba": { "default": true, "description": "Whether to use numba acceleration when available", "title": "Use Numba", "type": "boolean" } }, "additionalProperties": false } - Config:
- extra: str = forbid 
 
- Fields:
 - property states: list[str]#
 - property time_step_days: int#
 
- Params#
- alias of - BiweeklyParams
