synthpops.schools module¶
This module generates school contacts by class and grade in flexible ways. Contacts can be clustered into classes and also mixed across the grade and across the school.
H. Guclu et. al (2016) shows that mixing across grades is low for public schools in elementary and middle schools. Mixing across grades is however higher in high schools.
Functions in this module are flexible to allow users to specify the inter-grade mixing (for ‘age_clustered’ school_mixing_type), and to choose whether contacts are clustered within a grade. Clustering contacts across different grades is not supported because there is no data to suggest that this happens commonly.
-
class
School
(scid=None, sc_type=None, school_mixing_type=None, student_uids=array([], dtype=int64), teacher_uids=array([], dtype=int64), non_teaching_staff_uids=array([], dtype=int64), **kwargs)[source]¶ Bases:
synthpops.base.LayerGroup
A class for individual schools and methods to operate on each.
Parameters: kwargs (dict) – data dictionary of the school Class constructor for an base empty setting group.
Parameters: - **scid (int) – id of the school
- **sc_type (str) – school type defined by grade/age ranges
- **school_mixing_type (str) – the mixing type of the school, ‘random’, ‘age_clustered’, or ‘age_and_class_clustered’ if str. Else, None. See sp.schools.add_school_edges() for more information.
- **student_uids (np.array) – ids of student members
- **teacher_uids (np.array) – ids of teacher members
- **non_teaching_staff_uids (np.array) – ids of non_teaching_staff members
-
validate
()[source]¶ Check that information supplied to make a school is valid and update to the correct type if necessary.
-
member_uids
¶ students, teachers, and non teaching staff.
Returns: school member ids Return type: np.ndarray Type: Return ids of all school members
-
member_ages
(age_by_uid)[source]¶ Return ages of all school members: students, teachers, and non teaching staff.
Parameters: age_by_uid (np.ndarray) – mapping of age to uid Returns: school member ages Return type: np.ndarray
-
student_ages
(age_by_uid)[source]¶ Return student ages in the school.
Parameters: age_by_uid (np.ndarray) – mapping of age to uid Returns: student ages in school Return type: np.ndarray
-
teacher_ages
(age_by_uid)[source]¶ Return teacher ages in the school.
Parameters: age_by_uid (np.ndarray) – mapping of age to uid Returns: teacher ages in school Return type: np.ndarray
-
class
Classroom
(clid=None, student_uids=array([], dtype=int64), teacher_uids=array([], dtype=int64), **kwargs)[source]¶ Bases:
synthpops.base.LayerGroup
A class for individual classrooms and methods to operate on each.
Parameters: kwargs (dict) – data dictionary of the classroom Class constructor for an base empty setting group.
Parameters: - **clid (int) – id of the classroom
- **student_uids (np.array) – ids of student members
- **teacher_uids (np.array) – ids of teacher members
-
validate
()[source]¶ Check that information supplied to make a school is valid and update to the correct type if necessary.
-
member_uids
¶ students and teachers.
Returns: classroom member ids Return type: np.ndarray Type: Return ids of all classroom members
-
member_ages
(age_by_uid)[source]¶ Return ages of all classroom members: students and teachers.
Parameters: age_by_uid (np.ndarray) – mapping of age to uid Returns: classroom member ages Return type: np.ndarray
-
count_enrollment_by_age
(popdict)[source]¶ Get enrollment count by age for students in the popdict.
Parameters: popdict (dict) – population dictionary Returns: Dictionary of the count of enrolled students by age in popdict. Return type: dict
-
get_enrollment_rates_by_age
(enrollment_count_by_age, age_count)[source]¶ Get enrollment rates by age.
Parameters: - enrollment_count_by_age (dict) – dictionary of the count of enrolled students
- age_count (dict) – dictionary of the age count
Returns: Dictionary of the enrollment rates by age.
Return type: dict
-
count_enrollment_by_school_type
(popdict, **kwargs)[source]¶ Get enrollment sizes by school types in popdict.
Parameters: - popdict (dict) – population dictionary
- **with_school_types (bool) – If True, return enrollment by school types as defined in the popdict. Otherwise, combine all enrollment sizes for a school type of None.
- **keys_to_exclude (list) – school types to exclude
Returns: Dictionary of generated enrollment sizes by school type.
Return type: dict
-
get_generated_school_size_distributions
(enrollment_by_school_type, bins)[source]¶ Get school size distributions by type.
Parameters: - enrollment_by_school_type (dict) – generated enrollment sizes by school types
- bins (list) – school size bins
Returns: Dictionary of generated school size distribution by school type.
Return type: dict