synthpops.read_write module

This module contains reading and writing functions for contact networks and populations

synthpops.read_write.write_age_by_uid_dic(datadir, location, state_location, country_location, folder_name, age_by_uid_dic)

Write the dictionary of ID mapping to age for each individual in the population.

Parameters
  • datadir (string) – The file path to the data directory.

  • location (string) – The name of the location.

  • state_location (string) – The name of the state the location is in.

  • country_location (string) – The name of the country the location is in.

  • folder_name (string) – The name of the folder the location is in, e.g. ‘contact_networks’

  • age_by_uid_dic (dict) – A dictionary mapping ID to age for each individual in the population.

Returns

None

synthpops.read_write.read_in_age_by_uid(datadir, location, state_location, country_location, folder_name, n)

Read dictionary of ID mapping to ages for all individuals from file.

Parameters
  • datadir (string) – The file path to the data directory.

  • location (string) – The name of the location.

  • state_location (string) – The name of the state the location is in.

  • country_location (string) – The name of the country the location is in.

  • folder_name (string) – The name of the folder the location is in, e.g. ‘contact_networks’

  • n (int) – The number of people in the population.

Returns

A dictionary mapping ID to age for all individuals in the population.

synthpops.read_write.write_groups_by_age_and_uid(datadir, location, state_location, country_location, folder_name, age_by_uid_dic, group_type, groups_by_uids)

Write groups to file with both ID and their ages.

Parameters
  • datadir (string) – The file path to the data directory.

  • location (string) – The name of the location.

  • state_location (string) – The name of the state of the location is in.

  • country_location (string) – The name of the country the location is in.

  • folder_name (string) – The name of the folder the location is in, e.g. ‘contact_networks’

  • age_by_uid_dic (dict) – A dictionary mapping ID to age for each individual in the population.

  • group_type (string) – The name of the group type.

  • groups_by_uids (list) – The list of lists, where each sublist represents a household and the IDs of the household members.

Returns

None

synthpops.read_write.read_setting_groups(datadir, location, state_location, country_location, folder_name, group_type, n, with_ages=False)

Read in groups of people interacting in different social settings from file.

Parameters
  • datadir (string) – The file path to the data directory.

  • location (string) – The name of the location.

  • state_location (string) – The name of the state the location is in.

  • country_location (string) – The name of the country the location is in.

  • folder_name (string) – The name of the folder the location is in, e.g. ‘contact_networks’

  • group_type (string) – The name of the group type.

  • n (int) – The number of people in the population.

  • with_ages (bool) – If True, read in the ages of each individual in the group; otherwise, read in their IDs.

Returns

A list of lists where each sublist represents of group of individuals in the same group and thus are contacts of each other.