emod_api.demographics.Demographics module#
- emod_api.demographics.Demographics.from_template_node(lat=0, lon=0, pop=1000000, name='Erewhon', forced_id=1)[source]#
Create a single-node
Demographics
instance from a few parameters.
- emod_api.demographics.Demographics.from_file(base_file)[source]#
Create a
Demographics
instance from an existing demographics file.
- emod_api.demographics.Demographics.get_node_ids_from_file(demographics_file)[source]#
Get a list of node ids from a demographics file.
- emod_api.demographics.Demographics.get_node_pops_from_params(tot_pop, num_nodes, frac_rural)[source]#
Get a list of node populations from the params used to create a sparsely parameterized multi-node
Demographics
instance. The first population in the list is the “urban” population and remaning populations are roughly drawn from a log-uniform distribution.- Parameters:
- Returns:
A list containing the urban node population followed by the rural nodes.
- emod_api.demographics.Demographics.from_params(tot_pop=1000000, num_nodes=100, frac_rural=0.3, id_ref='from_params', random_2d_grid=False)[source]#
Create an EMOD-compatible
Demographics
object with the population and numbe of nodes specified.- Parameters:
tot_pop – The total population.
num_nodes – Number of nodes. Can be defined as a two-dimensional grid of nodes [longitude, latitude]. The distance to the next neighbouring node is 1.
frac_rural – Determines what fraction of the population gets put in the ‘rural’ nodes, which means all nodes besides node 1. Node 1 is the ‘urban’ node.
id_ref – Facility name
random_2d_grid – Create a random distanced grid with num_nodes nodes.
- Returns:
A
Demographics
object
- emod_api.demographics.Demographics.from_csv(input_file, res=0.008333333333333333, id_ref='from_csv')[source]#
Create an EMOD-compatible
Demographics
instance from a csv population-by-node file.
- emod_api.demographics.Demographics.from_pop_raster_csv(pop_filename_in, res=0.008333333333333333, id_ref='from_raster', pop_filename_out='spatial_gridded_pop_dir', site='No_Site')[source]#
Take a csv of a population-counts raster and build a grid for use with EMOD simulations. Grid size is specified by grid resolution in arcs or in kilometers. The population counts from the raster csv are then assigned to their nearest grid center and a new intermediate grid file is generated with latitude, longitude and population. This file is then fed to from_csv to generate a demographics object.
- Parameters:
pop_filename_in (str) – The filename of the population-counts raster in CSV format.
res (float, optional) – The grid resolution in arcs or kilometers. Default is 1/120.
id_ref (str, optional) – Identifier reference for the grid. Default is “from_raster”.
pop_filename_out (str, optional) – The output filename for the intermediate grid file. Default is “spatial_gridded_pop_dir”.
site (str, optional) – The site name or identifier. Default is “No_Site”.
- Returns:
py:class`Demographics` object: The generated demographics object based on the grid file.
- Raises:
N/A –
- emod_api.demographics.Demographics.from_pop_csv(pop_filename_in, res=0.008333333333333333, id_ref='from_raster', pop_filename_out='spatial_gridded_pop_dir', site='No_Site')[source]#
Deprecated. Please use from_pop_raster_csv.
- class emod_api.demographics.Demographics.Demographics(nodes: List[Node], idref: str = 'Gridded world grump2.5arcmin', base_file: str | None = None, default_node: Node | None = None)[source]#
Bases:
DemographicsBase
This class is a container of data necessary to produce a EMOD-valid demographics input file. It can be initialized from an existing valid demographics.joson type file or from an array of valid Nodes.