emod_api.demographics.Demographics module

emod_api.demographics.Demographics.from_template_node(lat=0, lon=0, pop=1000000.0, name='Erewhon', forced_id=1)

Create a single-node Demographics instance from a few params.

emod_api.demographics.Demographics.from_file(base_file)

Create a Demographics instance from an existing demographics file.

emod_api.demographics.Demographics.get_node_ids_from_file(demographics_file)

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)

Get a list of node populations from the params used to create a sparsely parameterized multi-node Demographics instance.

emod_api.demographics.Demographics.from_params(tot_pop=1000000.0, num_nodes=100, frac_rural=0.3, id_ref='from_params')

Create an EMOD-compatible Demographics object with the population and number of nodes specified, distributing per a ‘spread’ parameter.

emod_api.demographics.Demographics.from_csv(input_file, res=0.008333333333333333)

Create an EMOD-compatible Demographics instance from a csv population-by-node file.

emod_api.demographics.Demographics.from_pop_csv(pop_filename_in, pop_filename_out='spatial_gridded_pop_dir', site='No_Site')
class emod_api.demographics.Demographics.Demographics(nodes, idref='Gridded world grump2.5arcmin', base_file=None)

Bases: emod_api.demographics.BaseInputFile.BaseInputFile

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.

generate_file(name='demographics.json')

Write the contents of the instance to an EMOD-compatible (JSON) file.

property node_ids

Return the list of (geographic) node ids.

property node_count

Return the number of (geographic) nodes.

get_node(nodeid)

Return the node idendified by nodeid. Search either name or actual id :param nodeid: :return:

SetIndividualAttributesWithFertMort(CrudeBirthRate=0.04, CrudeMortRate=0.02)
AddIndividualPropertyAndHINT(Property, Values, InitialDistribution=None, TransmissionMatrix=None)

Add Individual Properties, including an optional HINT configuration matrix. :param Property: :param Values: :param InitialDistribution: :param TransmissionMatrix:

Returns

N/A/

AddAgeDependentTransmission(Age_Bin_Edges_In_Years=[0, 1, 2, - 1], TransmissionMatrix=[[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]])
SetDefaultIndividualAttributes()

NOTE: This is very Measles-ish. We might want to move into MeaslesDemographics

SetMinimalNodeAttributes()
SetBirthRate(birth_rate)

Set Default birth rate to birth_rate. Turn on Vital Dynamics and Births implicitly.

SetMortalityRate(mort_rate)

Set constant mortality rate to mort_rate. Turn on Enable_Natural_Mortality implicitly.

SetDefaultNodeAttributes(birth=True)

Set the default NodeAttributes (Altitude, Airport, Region, Seaport), optionally including birth, which is most important actually.

SetDefaultIndividualProperties()

Initialize Individual Properties to empty.

SetDefaultProperties()

Set a bunch of defaults (age structure, initial susceptibility and initial prevalencec) to sensible values.

SetDefaultPropertiesFertMort(CrudeBirthRate=0.04, CrudeMortRate=0.02)

Set a bunch of defaults (birth rates, death rates, age structure, initial susceptibility and initial prevalencec) to sensible values.

SetDefaultFromTemplate(template, setter_fn=None)

Add to the default IndividualAttributes using the input template (raw json) and set corresponding config values per the setter_fn. The template should always be constructed by a function in DemographicsTemplates. Eventually this function will be hidden and only accessed via separate application-specific API functions such as the ones below.

SetNodeDefaultFromTemplate(template, setter_fn)

Add to the default NodeAttributes using the input template (raw json) and set corresponding config values per the setter_fn. The template should always be constructed by a function in DemographicsTemplates. Eventually this function will be hidden and only accessed via separate application-specific API functions such as the ones below.

SetEquilibriumAgeDistFromBirthAndMortRates(CrudeBirthRate=0.04, CrudeMortRate=0.02)

Set the inital ages of the population to a sensible equilibrium profile based on the specified input birth and death rates. Note this does not set the fertility and mortality rates.

SetOverdispersion(new_overdispersion_value, nodes=[])

Set the overdispersion value for the specified nodes (all if empty).

SetConstantSusceptibility()

Set the initial susceptibilty for each new individual to a constant value of 1.0.

SetHeteroRiskUniformDist(min_risk=0, max_risk=1)

Set the initial risk for each new individual to a value drawn from a uniform distribution.

SetHeteroRiskLognormalDist(mean=1.0, sigma=0)

Set the initial risk for each new individual to a value drawn from a log-normal distribution.

SetHeteroRiskExponDist(mean=1.0)

Set the initial risk for each new individual to a value drawn from an exponential distribution.