make_contacts#
- make_contacts(pop, age_by_uid, homes_by_uids, students_by_uid_lists=None, teachers_by_uid_lists=None, non_teaching_staff_uid_lists=None, workplace_by_uid_lists=None, facilities_by_uid_lists=None, facilities_staff_uid_lists=None, use_two_group_reduction=False, average_LTCF_degree=20, with_school_types=False, school_mixing_type='random', average_class_size=20, inter_grade_mixing=0.1, average_student_teacher_ratio=20, average_teacher_teacher_degree=3, average_student_all_staff_ratio=15, average_additional_staff_degree=20, school_type_by_age=None, workplaces_by_industry_codes=None, max_contacts=None)[source]#
From microstructure objects (dictionary mapping ID to age, lists of lists in different settings, etc.), create a dictionary of individuals. Each key is the ID of an individual which maps to a dictionary for that individual with attributes such as their age, household ID (hhid), school ID (scid), workplace ID (wpid), workplace industry code (wpindcode) if available, and contacts in different layers.
- Parameters:
age_by_uid (dict) – dictionary mapping id to age for all individuals in the population
homes_by_uids (list) – A list of lists where each sublist is a household and the IDs of the household members.
schools_by_uids (list) – A list of lists, where each sublist represents a school and the ids of the students and teachers within it
teachers_by_uids (list) – A list of lists, where each sublist represents a school and the ids of the teachers within it
workplaces_by_uids (list) – A list of lists, where each sublist represents a workplace and the ids of the workers within it
facilities_by_uids (list) – A list of lists, where each sublist represents a skilled nursing or long term care facility and the ids of the residents living within it
facilities_staff_uids (list) – A list of lists, where each sublist represents a skilled nursing or long term care facility and the ids of the staff working within it
non_teaching_staff_uids (list) – None or a list of lists, where each sublist represents a school and the ids of the non teaching staff within it
use_two_group_reduction (bool) – If True, create long term care facilities with reduced contacts across both groups
average_LTCF_degree (int) – default average degree in long term care facilities
with_school_types (bool) – If True, creates explicit school types.
school_mixing_type (str or dict) – The mixing type for schools, ‘random’, ‘age_clustered’, or ‘age_and_class_clustered’ if string, and a dictionary of these by school type otherwise. ‘random’ means random graphs for each school, ‘age_clustered’ means random graphs but with students mostly mixing within the age/grade (inter_grade_mixing controls mixing between grades), ‘age_and_grade_clustered’ means students cohorted into classes with their own teachers.
average_class_size (float) – The average classroom size.
inter_grade_mixing (float) – The average fraction of mixing between grades in the same school for clustered school mixing types.
average_student_teacher_ratio (float) – The average number of students per teacher.
average_teacher_teacher_degree (float) – The average number of contacts per teacher with other teachers.
average_student_all_staff_ratio (float) – The average number of students per staff members at school (including both teachers and non teachers).
average_additional_staff_degree (float) – The average number of contacts per additional non teaching staff in schools.
school_type_by_age (dict) – A dictionary of probabilities for the school type likely for each age.
workplaces_by_industry_codes (np.ndarray or None) – array with workplace industry code for each workplace
trimmed_size_dic (dict) – If supplied, trim contacts on creation rather than post hoc.
- Returns:
A popdict of people with attributes. Dictionary keys are the IDs of individuals in the population and the values are a dictionary for each individual with their attributes, such as age, household ID (hhid), school ID (scid), workplace ID (wpid), workplace industry code (wpindcode) if available, and the IDs of their contacts in different layers. Different layers available are households (‘H’), schools (‘S’), and workplaces (‘W’), and long term care facilities (‘LTCF’). Contacts in these layers are clustered and thus form a network composed of groups of people interacting with each other. For example, all household members are contacts of each other, and everyone in the same school is considered a contact of each other. If use_two_group_reduction is True, then contracts within ‘LTCF’ are reduced from fully connected.
Notes
Methods to trim large groups of contacts down to better approximate a sense of close contacts (such as classroom sizes or smaller work groups are available via sp.trim_contacts() or sp.create_reduced_contacts_with_group_types(): see these methods for more details).
If with_school_types==False, completely random schools will be generated with respect to the average_class_size, but other parameters such as average_additional_staff_degree will not be used.