emod_api.demographics.demographics_utils module

emod_api.demographics.demographics_utils.set_risk_mod(filename, distribution, par1, par2)[source]

Set the RiskDistributionFlag, RiskDistribution1 and RiskDistribution2 in a demographics file.

Parameters
  • filename – The demographics file location

  • distribution – The selected distribution (need to come from distribution_types)

  • par1 – Parameter 1 of the distribution

  • par2 – Parameter 2 of the distribution (may be unused depending on the selected distribution)

Returns

Nothing

emod_api.demographics.demographics_utils.set_immune_mod(filename, distribution, par1, par2)[source]

Set the ImmunityDistributionFlag, ImmunityDistribution1 and ImmunityDistribution2 in a demographics file.

Parameters
  • filename – The demographics file location

  • distribution – The selected distribution (need to come from distribution_types)

  • par1 – Parameter 1 of the distribution

  • par2 – Parameter 2 of the distribution (may be unused depending on the selected distribution)

Returns

Nothing

emod_api.demographics.demographics_utils.apply_to_defaults_or_nodes(demog, fn, *args)[source]

Apply the fn function either to the Defaults dictionary or to each of the nodes depending if the IndividualAttributes parameter is present in the Defaults or not.

Parameters
  • demog – The demographic file represented as a dictionary

  • fn – The function to apply the Defaults or individual nodes

  • args – Argument list needed by fn

Returns

Nothing

emod_api.demographics.demographics_utils.set_demog_distributions(filename, distributions)[source]

Apply distributions to a given demographics file. The distributions needs to be formatted as a list of (name, distribution, par1, par2) with:

  • name: Immunity, Risk, Age, Prevalence or MigrationHeterogeneity

  • distribution: One distribution contained in distribution_types

  • par1, par2: the values for the distribution parameters

# Set the PrevalenceDistribution to a uniform distribution with 0.1 and 0.2
# and the ImmunityDistributionFlag to a constant distribution with 1
demog = json.load(open("demographics.json","r"))
distributions = list()
distributions.add(("Prevalence","UNIFORM_DISTRIBUTION",0.1,0.2))
distributions.add(("Immunity","CONSTANT_DISTRIBUTION",1,0))
set_demog_distribution(demog, distributions)
Parameters
  • filename – the demographics file as json

  • distributions – the different distributions to set contained in a list

Returns

Nothing

emod_api.demographics.demographics_utils.set_static_demographics(cb, use_existing=False)[source]

Create a static demographics based on the demographics file specified in the config file of the DTKConfigBuilder object passed to the function.

This function takes the current demographics file and adjust the birth rate/death rate to get a static population (the deaths are always compensated by new births).

Parameters
  • cb – The config builder object

  • use_existing – If True will only take the demographics file name and add the .static to it. If False will create a static demographics file based on the specified demographics file.

Returns

Nothing

emod_api.demographics.demographics_utils.set_growing_demographics(cb, use_existing=False)[source]

This function creates a growing population. It works the same way as the set_static_demographics but with a birth rate more important than the death rate which leads to a growing population.

Parameters
  • cb – The DTKConfigBuilder object

  • use_existing – If True will only take the demographics file name and add the .growing to it. If False will create a growing demographics file based on the specified demographics file.

Returns

Nothing