june.demography.demography

exception june.demography.demography.DemographyError
__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
class june.demography.demography.AgeSexGenerator(age_counts: list, sex_bins: list, female_fractions: list, ethnicity_age_bins: list = None, ethnicity_groups: list = None, ethnicity_structure: list = None, socioecon_index_value: int = None, max_age=99)

age_counts is an array where the index in the array indicates the age, and the value indicates the number of counts in that age. sex_bins are the lower edges of each sex bin where we have a fraction of females from census data, and female_fractions are those fractions. ethnicity_age_bins are the lower edges of the age bins that ethnicity data is in ethnicity_groups are the labels of the ethnicities which we have data for. ethnicity_structure are (integer) ratios of the ethnicities, for each age bin. the sum of this strucutre need NOT be the total number of people returned by the generator. Example:

age_counts = [1, 2, 3] means 1 person of age 0, 2 people of age 1 and 3 people of age 2. sex_bins = [1, 3] defines two bins: (0,1) and (3, infinity) female_fractions = [0.3, 0.5] means that between the ages 0 and 1 there are 30% females,

and there are 50% females in the bin 3+ years

ethnicity_age_bins - see sex_bins ethnicity_groups = [‘A’,’B’,’C’] - there are three types of ethnicities that we are

assigning here.

ethnicity_structure = [[0,5,3],[2,3,0],…] in the first age bin, we assign people

ethnicities A:B:C with probability 0:5:3, and so on.

socioecon_index = 6 means this area belongs to the 6th decile in the index

of multiple deprivation.

Given this information we initialize two generators for age and sex, that can be accessed through gen = AgeSexGenerator().age() and AgeSexGenerator().sex().

age_counts

A list or array with the counts for each age.

female_fractions

A dictionary where keys are age intervals like “int-int” and the values are the fraction of females inside each age bin.

__init__(age_counts: list, sex_bins: list, female_fractions: list, ethnicity_age_bins: list = None, ethnicity_groups: list = None, ethnicity_structure: list = None, socioecon_index_value: int = None, max_age=99)

age_counts is an array where the index in the array indicates the age, and the value indicates the number of counts in that age. sex_bins are the lower edges of each sex bin where we have a fraction of females from census data, and female_fractions are those fractions. ethnicity_age_bins are the lower edges of the age bins that ethnicity data is in ethnicity_groups are the labels of the ethnicities which we have data for. ethnicity_structure are (integer) ratios of the ethnicities, for each age bin. the sum of this strucutre need NOT be the total number of people returned by the generator. Example:

age_counts = [1, 2, 3] means 1 person of age 0, 2 people of age 1 and 3 people of age 2. sex_bins = [1, 3] defines two bins: (0,1) and (3, infinity) female_fractions = [0.3, 0.5] means that between the ages 0 and 1 there are 30% females,

and there are 50% females in the bin 3+ years

ethnicity_age_bins - see sex_bins ethnicity_groups = [‘A’,’B’,’C’] - there are three types of ethnicities that we are

assigning here.

ethnicity_structure = [[0,5,3],[2,3,0],…] in the first age bin, we assign people

ethnicities A:B:C with probability 0:5:3, and so on.

socioecon_index = 6 means this area belongs to the 6th decile in the index

of multiple deprivation.

Given this information we initialize two generators for age and sex, that can be accessed through gen = AgeSexGenerator().age() and AgeSexGenerator().sex().

age_counts

A list or array with the counts for each age.

female_fractions

A dictionary where keys are age intervals like “int-int” and the values are the fraction of females inside each age bin.

age() → int
ethnicity() → str
classmethod from_age_sex_bins(men_age_dict: dict, women_age_dict: dict, exponential_decay: int = 2)

Initializes age and sex generator (no ethnicity and socioecon_index for now) from a dictionary containing age bins and counts for man and woman. An example of the input is men_age_dict = {“0-2” : 10, “2-99”: 50}. If the bin contains the 99 value at the end, the age will be sampled with an exponential decay of the form e^(-x/exponential_decay).

sex() → str
socioecon_index() → int
class june.demography.demography.ComorbidityGenerator(comorbidity_data)
__init__(comorbidity_data)

Initialize self. See help(type(self)) for accurate signature.

_get_age_index(person)
get_comorbidity(person)
class june.demography.demography.Demography(area_names, age_sex_generators: Dict[str, june.demography.demography.AgeSexGenerator], comorbidity_data=None)

Tool to generate population for a certain geographical regin.

age_sex_generators

A dictionary mapping area identifiers to functions that generate age and sex for individuals.

__init__(area_names, age_sex_generators: Dict[str, june.demography.demography.AgeSexGenerator], comorbidity_data=None)

Tool to generate population for a certain geographical regin.

age_sex_generators

A dictionary mapping area identifiers to functions that generate age and sex for individuals.

classmethod for_areas(area_names: List[str], data_path: str = PosixPath('/home/sadie/JUNE/data/input/demography'), config: Optional[dict] = None, config_path: str = PosixPath('/home/sadie/JUNE/configs'))june.demography.demography.Demography

Load data from files and construct classes capable of generating demographic data for individuals in the population.

area_names

List of areas for which to create a demographic generator.

data_path

The path to the data directory

config

Optional configuration. At the moment this just gives an asymptomatic ratio.

A demography representing the super area

classmethod for_geography(geography: june.geography.geography.Geography, data_path: str = PosixPath('/home/sadie/JUNE/data/input/demography'), config: Optional[dict] = None)june.demography.demography.Demography

Initializes demography from an existing geography.

geography

an instance of the geography class

classmethod for_zone(filter_key: Dict[str, list], data_path: str = PosixPath('/home/sadie/JUNE/data/input/demography'), areas_maps_path: str = PosixPath('/home/sadie/JUNE/data/input/geography/area_super_area_region.csv'), config: Optional[dict] = None)june.demography.demography.Demography

Initializes a geography for a specific list of zones. The zones are specified by the filter_dict dictionary where the key denotes the kind of zone, and the value is a list with the different zone names.

filter_key = {“region” : “North East”} filter_key = {“super_area” : [“EXXXX”, “EYYYY”]}

populate(area_name: str, ethnicity=True, socioecon_index=True, comorbidity=True)june.demography.demography.Population

Generate a population for a given area. Age, sex and number of residents are all based on census data for that area.

area_name

The name of an area a population should be generated for

A population of people

class june.demography.demography.Population(people: Optional[List[june.demography.person.Person]] = None)

A population of people.

Behaves mostly like a list but also has the name of the area attached.

people

A list of people generated to match census data for that area

__init__(people: Optional[List[june.demography.person.Person]] = None)

A population of people.

Behaves mostly like a list but also has the name of the area attached.

people

A list of people generated to match census data for that area

add(person)
extend(people)
get_from_id(id)
property dead
property infected
property members
property people_ids
property recovered
property susceptible
property total_people
june.demography.demography._load_age_and_sex_generators(age_structure_path: str, female_ratios_path: str, ethnicity_structure_path: str, socioecon_structure_path: str, area_names: List[str]) → Dict[str, june.demography.demography.AgeSexGenerator]

A dictionary mapping area identifiers to a generator of age, sex, ethnicity, and socio-economic index.

ethnicity_structure_path

File containing ethnicity nr. per Area. This approach chosen based on: Davis, J. A., & Smith, T. W. (1999); Chicago: National Opinion Research Center

june.demography.demography.load_age_and_sex_generators_for_bins(age_sex_bins_filename: str, by='super_area') → Dict[str, june.demography.demography.AgeSexGenerator]
june.demography.demography.load_comorbidity_data(m_comorbidity_path=None, f_comorbidity_path=None)
june.demography.demography.parse_age_bin(age_bin: str)