Core¶
Core provides the basic class framework to build a population
Overview:
- class pyEpiabm.Cell(loc: Tuple[float, float] = (0, 0))[source]¶
Class representing a Cell (Subset of Population). Collection of
Microcells andPersons.- add_microcells(n)[source]¶
Add n empty
Microcells to Cell.- Parameters:
n (int) – Number of empty
Microcells to add
- enqueue_LFT_testing(person: Person)[source]¶
- Add person to LFT testing queue for processing in testing
sweep.
Detailed description of the implementation can be found in github wiki: https://github.com/SABS-R3-Epidemiology/epiabm/wiki/Interventions#testing
- Parameters:
person (Person) – Person to enqueue.
- enqueue_PCR_testing(person: Person)[source]¶
- Add person to PCR testing queue for processing in testing
sweep.
Detailed description of the implementation can be found in github wiki: https://github.com/SABS-R3-Epidemiology/epiabm/wiki/Interventions#testing
- Parameters:
person (Person) – Person to enqueue.
- enqueue_person(person: Person)[source]¶
Add person to queue for processing at end of iteration, provided they are not already recovered (and so may be infected).
- Parameters:
person (Person) – Person to enqueue
- find_nearby_cells(other_cells)[source]¶
Helper function which takes in a given cell and the list of all cells and generates a list of nearby cells which are closer than the cutoff for cross-cell infection.
Populates: self.find_nearby_cells Dictionary of all cells with distance below cutoff. Dictionary stores cell.id and distance between the 2 cells These are stored in the form: cell.id: distance
- Parameters:
other_cells (List[Cell]) – List of all cells except cell
- notify_person_status_change(old_status: InfectionStatus, new_status: InfectionStatus, age_group) None[source]¶
Notify Cell that a person’s status has changed.
- Parameters:
old_status (InfectionStatus) – Person’s old infection status
new_status (InfectionStatus) – Person’s new infection status
age_group (Age group index) – Person’s associated age group
- number_infectious()[source]¶
- Returns the total number of infectious people in each
cell, all ages combined.
- Returns:
Total infectors in cell
- Return type:
int
- class pyEpiabm._CompartmentCounter(identifier: str)[source]¶
Class Component which maintains count of people in each compartment, according to their age group.
- property identifier¶
Get identifier.
- report(old_status: InfectionStatus, new_status: InfectionStatus, age_group=0) None[source]¶
Report Person has changed state. Update internal compartments state.
- Parameters:
old_status (InfectionStatus) – Person’s previous infection state
new_status (InfectionStatus) – Person’s new infection state
age_group (Age group index) – Person’s associated age group, defaults to 0 if age not implemented
- retrieve() Dict[InfectionStatus, array][source]¶
Get Compartment Counts. Returns dictionary of compartment counts, in which each entry is an array containing the number of people by age group. If age is not used then there is only one age group and the array length is 1.
- Returns:
Dictionary of compartments
- Return type:
dict
- class pyEpiabm.Household(microcell, loc: Tuple[float, float], susceptibility=0, infectiousness=0)[source]¶
Class representing a household, a group of people (family or otherwise) who live together and share living spaces. This group will have a combined susceptibility and infectiousness different to that of the individuals.
- add_person(person)[source]¶
Adds a person to this household.
- Parameters:
person (Person) – Person to be added
- add_susceptible_person(susceptible_person)[source]¶
Adds a person to the list of susceptible people in the household.
- Parameters:
susceptible_person (Person) – Person to be added
- remove_household()[source]¶
Method to remove Household object from population. Used to remove household in which a traveller was hotel isolating.
- class pyEpiabm.Microcell(cell)[source]¶
Class representing a Microcell (Group of people and places). Collection of
Persons.- add_household(people: list, update_person_id: bool = True)[source]¶
Adds a default
Householdto Microcell and fills it with a number ofPersons.- Parameters:
people (list) – List of
Peopleto add to householdupdate_person_id (bool) – Boolean representing whether we wish to update the id of the people of the household when the function is called or not
- add_people(n, status=InfectionStatus.Susceptible, age_group=None)[source]¶
Adds n default
Personof given status to Microcell.- Parameters:
n (int) – Number of default
Persons to addstatus (InfectionStatus) – Status of persons to add to cell
age_group (Age group index) – Person’s associated age group
- add_person(person)[source]¶
Adds
Personwith givenInfectionStatusand given age group to Microcell.- Parameters:
person (Person) – Newly instantiated person with InfectionStatus and associated age group
- add_place(n: int, loc: Tuple[float, float], place_type)[source]¶
Adds n default
Placeto Microcell.- Parameters:
n (int) – Number of default
Places to add
- notify_person_status_change(old_status: InfectionStatus, new_status: InfectionStatus, age_group) None[source]¶
Notify Microcell that a person’s status has changed.
- Parameters:
old_status (InfectionStatus) – Person’s old infection status
new_status (InfectionStatus) – Person’s new infection status
age_group (Age group index) – Person’s associated age group
- class pyEpiabm.Parameters[source]¶
Class for global parameters.
Following a singleton Pattern.
- class pyEpiabm.Person(microcell, age_group=None)[source]¶
Class to represent each person in a population.
- Parameters:
- Variables:
infection_status (InfectionStatus) – Person’s current infection status
next_infection_status (InfectionStatus) – Person’s next infection status after current one
time_of_status_change (int) – Time when person’s infection status is updated
- add_place(place, person_group: int = 0)[source]¶
Method adds a place to the place list if the person visits or is associated with this place. Places are saved as a tuple with the place as the first entry and the group the person is associated with as the second.
- Parameters:
place (Place) – Place person should be added to
person_group (int) – Key for the person group dictionary
- increment_num_times_infected()[source]¶
Increments the number of times the person has been Infected as a useful parameter to keep track of.
- increment_secondary_infections()[source]¶
Increments the number of secondary infections the given person has for this specific infection period (i.e. if the given person has been infected multiple times, then we only increment the current secondary infection count).
- is_infectious()[source]¶
Query if the person is currently infectious.
- Returns:
Whether person is currently infectious
- Return type:
bool
- is_place_closed(closure_place_type)[source]¶
Method to check if any of the place in the person’s place list will be closed based on the place type, to be used when place closure intervention is active.
- Parameters:
closure_place_type (a list of PlaceType) – PlaceType should be closed if in place closure intervention
- is_susceptible()[source]¶
Query if the person is currently susceptible.
- Returns:
Whether person is currently susceptible
- Return type:
bool
- is_symptomatic()[source]¶
Query if the person is currently symptomatic.
- Returns:
Whether person is currently symptomatic
- Return type:
bool
- remove_person()[source]¶
Method to remove Person object from population. Used to remove travellers from the population.
- remove_place(place)[source]¶
Method to remove person for each associated place, to be used when updating places.
- Parameters:
place (Place) – Place person should be removed from
- set_exposure_period(exposure_period: float)[source]¶
Sets the exposure period (we define here as the time between a primary case infection and a secondary case exposure, with the current Person being the secondary case). We store this to be added to the latent period of the infection to give a serial interval.
- Parameters:
exposure_period (float) – The time between the infector’s time of infection and the time of exposure to the current Person
- set_id(id: str)[source]¶
Updates id of current person (i.e. for input from file). id format: 4.3.2.1 represents cell 4, microcell 3 within this cell, household 2 within this microcell, and person 1 within this household. The id will only be changed if it is of the correct format.
- Parameters:
id (str) – Identity of person
- set_infector_latent_period(latent_period: float)[source]¶
Sets the latent period of the primary infector of this Person. We store this in order to calculate the generation_time of the interaction between infector and infectee.
- Parameters:
latent_period (float) – The latency period of the primary infector (the individual who infected the current Person).
- set_latent_period(latent_period: float)[source]¶
Sets the latent period of the current Person.
- Parameters:
latent_period (float) – The time between the exposure and infection onset of the current Person.
- set_random_age(age_group=None)[source]¶
Set random age of person, and save index of their age group. Note that the max age in the 80+ group is 84 here, however the precise age of 80+ people is never used (exact ages are only used to assign school/workplaces) so this does not cause any issues.
- set_time_of_recovery(time: float)[source]¶
Records the time at which a person enters the Recovered compartment.
- Parameters:
time (float) – Current simulation time
- store_generation_time()[source]¶
Adds the infector_latent_period to the current exposure_period to give a generation_time, which will be stored in the generation_time_dict. The generation time is the time between a primary case exposure and a secondary case exposure. This method is called immediately after the infectee becomes exposed.
- store_serial_interval()[source]¶
Adds the latent_period to the current exposure_period to give a serial_interval, which will be stored in the serial_interval_dict. The serial interval is the time between a primary case infection and a secondary case infection. This method is called immediately after a person becomes exposed.
- update_age_group()[source]¶
Update the age_group attribute based on the current age value. This should be called after the age is set directly (e.g., in household age assignment) to ensure the age_group is consistent with the age.
- update_status(new_status: InfectionStatus) None[source]¶
Update Person’s Infection Status.
- Parameters:
new_status (InfectionStatus) – Person’s new status
- class pyEpiabm.Place(loc: Tuple[float, float], place_type: PlaceType, cell, microcell)[source]¶
Creates a place class which represents spaces such as cafes, restaurants and hotels where people may come into contact with others outside their household. People can be stratified in this place into different groups which may interact differently (ie workers and visitors).
- add_person(person: Person, person_group: int = 0)[source]¶
Add a person into the place.
- Parameters:
person (Person) – Person to add
person_group (int) – Key for the person group dictionary
- empty_place(groups_to_empty: list = [])[source]¶
Remove all people from place who are in a specific person group. For example a restaurant or park might regularly change all occupants each timestep, but workers at the restaurant will be present each timestep. Defaults to emptying the whole place.
- Parameters:
person_groups (list) – List of person_group indicies to be removed
- get_group_index(person)[source]¶
Get the group of a person in the place.
- Parameters:
person (Person) – Person associated with group
- remove_person(person: Person)[source]¶
Remove a person from place.
- Parameters:
person (Person) – Person to remove from place
- class pyEpiabm.Population[source]¶
Class representing a Population. Collection of
Cells.- add_cells(n)[source]¶
Adds n default
Cells to the population.- Parameters:
n (int) – Number of empty
Cells to add
- enqueue_vaccine(priority, counter, person: Person)[source]¶
Add person to queue for processing when mass vaccination begins.
- Parameters:
priority (int) – Priority level of 1, 2, 3, or 4 to prioritise by age and whether carehome resident. 1 being highest priority and 4 being lowest.
counter (int) – Counter to prioritise by order of addition within each priority group. Generated successively on addition of individuals to the queue.
person (Person) – Person to enqueue