emod_api.demographics.DemographicsTemplates module#
- class emod_api.demographics.DemographicsTemplates.DemographicsTemplatesConstants[source]#
Bases:
object
Mortality_Rates_Mod30_5yrs_Xval: Mod 30 values closest to the 5 yr age boundaries based on when EMOD actually updates individual mortality rates. The distribution is constant for about 5 years (e.g. values at 0.6 days and 1829.5 days) and linearly interpolated between the 5 yr boundaries.
- Mortality_Rates_Mod30_5yrs_Xval = [0.6, 1829.5, 1829.6, 3659.5, 3659.6, 5489.5, 5489.6, 7289.5, 7289.6, 9119.5, 9119.6, 10949.5, 10949.6, 12779.5, 12779.6, 14609.5, 14609.6, 16439.5, 16439.6, 18239.5, 18239.6, 20069.5, 20069.6, 21899.5, 21899.6, 23729.5, 23729.6, 25559.5, 25559.6, 27389.5, 27389.6, 29189.5, 29189.6, 31019.5, 31019.6, 32849.5, 32849.6, 34679.5, 34679.6, 36509.5, 36509.6, 38339.5]#
- emod_api.demographics.DemographicsTemplates.FullRisk(demog, description='')[source]#
FullRisk puts everyone at 100% risk.
- emod_api.demographics.DemographicsTemplates.InitRiskUniform(demog, min_lim=0, max_lim=1, description='')[source]#
InitRiskUniform puts everyone at somewhere between 0% risk and 100% risk, drawn uniformly.
- Parameters:
- Returns:
json object aka python dict that can be directly passed to Demographics::SetDefaultFromTemplate
- Raises:
None –
- emod_api.demographics.DemographicsTemplates.InitRiskLogNormal(demog, mean=0.0, sigma=1.0)[source]#
InitRiskLogNormal puts everyone at somewhere between 0% risk and 100% risk, drawn from LogNormal.
- emod_api.demographics.DemographicsTemplates.InitRiskExponential(demog, mean=1.0)[source]#
InitRiskExponential puts everyone at somewhere between 0% risk and 100% risk, drawn from Exponential.
- Parameters:
mean (float) – Mean of exponential distribution.
- Returns:
json object aka python dict that can be directly passed to Demographics::SetDefaultFromTemplate
- Raises:
None –
- emod_api.demographics.DemographicsTemplates.NoInitialPrevalence(demog)[source]#
NoInitialPrevalence disables initial prevalence; outbreak seeding must be done from an Outbreak intervention (or serialized population).
- Parameters:
demog – emod-api.demographics.Demographics instance.
- Returns:
None
- Raises:
None –
- emod_api.demographics.DemographicsTemplates.InitPrevUniform(demog, low_prev, high_prev, description='')[source]#
- emod_api.demographics.DemographicsTemplates.EveryoneInitiallySusceptible(demog, setting=1.0)[source]#
- emod_api.demographics.DemographicsTemplates.StepFunctionSusceptibility(demog, protected_setting=0.0, threshold_age=1825.0)[source]#
- emod_api.demographics.DemographicsTemplates.SimpleSusceptibilityDistribution(demog, meanAgeAtInfection=2.5)[source]#
Rough initialization to reduce burn-in and prevent huge outbreaks at sim start. For ages 0 through 99 the susceptibility distribution is set to an exponential distribution with an average age at infection. The minimum susceptibility is 2.5% at old ages.
- Parameters:
demog (
Demographics
) – Demographics object to updatemeanAgeAtInfection (float, optional) – Rough average age at infection in years.
Note: Requires that
config.parameters.Susceptibility_Initialization_Distribution_Type=DISTRIBUTION_COMPLEX
- emod_api.demographics.DemographicsTemplates.MortalityRateByAge(demog, age_bins, mort_rates)[source]#
Set (non-disease) mortality rates by age bins. No checks are done on input arrays.
- Parameters:
age_bins – list of age bins, with ages in years.
mort_rates – list of mortality rates, where mortality rate is daily probability of dying..
- Returns:
N/A.
- emod_api.demographics.DemographicsTemplates.get_fert_dist_from_rates(rates)[source]#
Create dictionary with DTK-compatible distributions from input vectors of fertility (crude) rates.
- Parameters:
rates – Array/vector of crude rates for whole population, for a range of years.
- emod_api.demographics.DemographicsTemplates.get_fert_dist(path_to_csv, verbose=False)[source]#
This function takes a fertility csv file (by year and age bin) and populates a DTK demographics.json file, and the corresponding config file to do individual pregnancies by age and year from data.
- Parameters:
demog – emod_api.demographics.Demographics instance.
path_to_csv – absolute path to csv input file. The file should have columns for 5-year age bins
"1950-1955". (labelled "15-19", etc. up to "45-49", and a column named "Years" with values like) –
anywhere. (There can be extra columns and the columns can be) –
- Returns:
(complex) dictionary. fertility distribution, ready to be added to demographics file.
- emod_api.demographics.DemographicsTemplates.birthrate_multiplier(pop_dat_file: Path, base_year: int, start_year: int, max_daily_mort: float = 0.01)[source]#
Create a birth rate multiplier from UN World Population data file. :param pop_dat_file: path to UN World Population data file :param base_year: Base year/Reference year :param start_year: Read in the pop_dat_file starting with year ‘start_year’ :param max_daily_mort: Maximum daily mortality rate
- Returns:
bith_rate_multiplier_x, birth_rate_multiplier_y
- emod_api.demographics.DemographicsTemplates.demographicsBuilder(pop_dat_file: Path, base_year: int, start_year: int = 1950, max_daily_mort: float = 0.01, mortality_rate_x_values: list = [0.6, 1829.5, 1829.6, 3659.5, 3659.6, 5489.5, 5489.6, 7289.5, 7289.6, 9119.5, 9119.6, 10949.5, 10949.6, 12779.5, 12779.6, 14609.5, 14609.6, 16439.5, 16439.6, 18239.5, 18239.6, 20069.5, 20069.6, 21899.5, 21899.6, 23729.5, 23729.6, 25559.5, 25559.6, 27389.5, 27389.6, 29189.5, 29189.6, 31019.5, 31019.6, 32849.5, 32849.6, 34679.5, 34679.6, 36509.5, 36509.6, 38339.5], years_per_age_bin: int = 5)[source]#
Build demographics from UN World Population data. :param pop_dat_file: path to UN World Population data file :param base_year: Base year/Reference year :param start_year: Read in the pop_dat_file starting with year ‘start_year’ :param years_per_age_bin: The number of years in one age bin, i.e. in one row of the UN World Population data file :param max_daily_mort: Maximum daily mortality rate :param mortality_rate_x_values: The distribution of non-disease mortality for a population.
- Returns:
IndividualAttributes, NodeAttributes