laser.measles.demographics.raster_patch
laser.measles.demographics.raster_patch
Raster patch generator for demographic data. You can use this to generate initial conditions (e.g, population, MCV1 coverage) for a laser-measles scenario.
laser.measles.demographics.raster_patch.RasterPatchGenerator(config, verbose=True)
Generate a scenario DataFrame by clipping raster data to shapefile boundaries.
This is the primary tool for the prepare scenario stage. Given
population and vaccination-coverage rasters plus an admin-boundary
shapefile, it produces a Polars DataFrame with one row per patch
containing id, pop, lat, lon, mcv1, and optionally
mcv2 columns — ready to pass to any model constructor.
Results are cached on disk; subsequent calls with the same configuration skip the raster-clipping step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
RasterPatchParams
|
A |
required |
verbose
|
bool
|
Print progress messages. |
True
|
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
laser.measles.demographics.raster_patch.RasterPatchGenerator.clear_cache()
Remove all cached entries for this configuration's ID.
laser.measles.demographics.raster_patch.RasterPatchGenerator.generate_birth_rates()
Generate birth-rate data (not yet implemented).
laser.measles.demographics.raster_patch.RasterPatchGenerator.generate_demographics()
Run the full demographic extraction pipeline.
Clips population (and optionally MCV1) rasters to the shapefile
boundaries and stores results in self.population and self.mcv1.
laser.measles.demographics.raster_patch.RasterPatchGenerator.generate_mcv1()
MCV1 coverage, population weighted
laser.measles.demographics.raster_patch.RasterPatchGenerator.generate_mortality_rates()
Generate mortality-rate data (not yet implemented).
laser.measles.demographics.raster_patch.RasterPatchGenerator.generate_population()
Population, counts
laser.measles.demographics.raster_patch.RasterPatchGenerator.get_cache_key(key)
Build a namespaced cache key for this configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
One of |
required |
Returns:
| Type | Description |
|---|---|
str
|
Cache key string in the form |
laser.measles.demographics.raster_patch.RasterPatchParams
Bases: BaseModel
Configuration for raster-based demographic data extraction.
Specifies the geographic region, shapefile boundaries, and raster
data sources used by
RasterPatchGenerator
to build a scenario DataFrame during the prepare scenario stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
Unique identifier for this scenario configuration. |
required | |
region
|
ISO-3166 alpha-3 country code (e.g. |
required | |
shapefile
|
Path to the admin-boundary shapefile ( |
required | |
population_raster
|
Path to a population-count raster (GeoTIFF). |
required | |
mcv1_raster
|
Path to a MCV1 coverage raster (GeoTIFF). |
required | |
mcv2_raster
|
Path to a MCV2 coverage raster (GeoTIFF). |
required |
Example:
1 2 3 4 5 | |
laser.measles.demographics.raster_patch.RasterPatchParams.shapefile_exists(v, info)
Verify the shapefile path exists on disk.