memilio.epidata.getCommuterMobility

getCommuterMobility.py

gets data related to county mobility from “Bundesagentur fuer Arbeit”

Functions

assign_geographical_entities(countykey_list, ...)

Assigns counties to governing regions based on key comparison and creates list of governing regions per state.

commuter_sanity_checks(df)

param df:

get_commuter_data([read_data, file_format, ...])

Computes DataFrame of commuter mobility patterns based on the Federal Agency of Work data.

get_neighbors_mobility(countyid[, ...])

Returns the neighbors of a particular county ID depening on the commuter mobility and given absolute and relative thresholds on the number of commuters.

get_neighbors_mobility_all([direction, ...])

Returns the neighbors of all counties ID depening on the commuter mobility and given absolute and relative thresholds on the number of commuters.

main()

Main program entry.

verify_sorted(countykey_list)

verify that read countykey_list is sorted

memilio.epidata.getCommuterMobility.assign_geographical_entities(
countykey_list,
govkey_list,
run_checks,
)

Assigns counties to governing regions based on key comparison and creates list of governing regions per state.

Only works with sorted key lists.

Keyword arguments:

Parameters:
  • countykey_list – List of county regional keys.

  • govkey_list – List of governing regions regional keys.

  • run_checks

Returns:

countykey2govkey Hash map from county regional keys to governing region regional keys.

memilio.epidata.getCommuterMobility.commuter_sanity_checks(df)
Parameters:

df

memilio.epidata.getCommuterMobility.get_commuter_data(
read_data=False,
file_format='json_timeasstring',
out_folder='/home/docs/checkouts/readthedocs.org/user_builds/memilio/data/',
setup_dict='',
ref_year=2022,
**kwargs,
)

Computes DataFrame of commuter mobility patterns based on the Federal Agency of Work data.

Keyword arguments:

Parameters:
  • read_data – True or False. Defines if data is read from file or downloaded. Only for population data. Commuter data is always downloaded. Default defined in defaultDict. (Default value = dd.defaultDict[‘read_data’])

  • file_format – File format which is used for writing the data. Default defined in defaultDict. (Default value = dd.defaultDict[‘file_format’])

  • out_folder – Folder where data is written to. Default defined in defaultDict. (Default value = dd.defaultDict[‘out_folder’])

  • setup_dict – dictionary with necessary values: ‘path’: String with datapath where mobility files can be found ‘abs_tol’: tolerated undetected people ‘rel_tol’: relative Tolerance to undetected people (Default value = ‘’)

  • ref_year – Year between 2013 and 2022 that specifies where the data should be taken from. Default value is 2022.

  • **kwargs

Returns:

df_commuter_mobility DataFrame of commuter mobility. df_commuter_mobility[i][j]= number of commuters from county with county-id i to county with county-id j

In commuter mobility files is a cumulative value per county for number of commuters from whole Germany given. The printed errors are refering to the absolute and relative errors from included numbers per county in DataFrame and this cumulative values.

memilio.epidata.getCommuterMobility.get_neighbors_mobility(
countyid,
direction='both',
abs_tol=0,
rel_tol=0,
tol_comb='or',
out_folder='/home/docs/checkouts/readthedocs.org/user_builds/memilio/data/',
ref_year=2022,
**kwargs,
)

Returns the neighbors of a particular county ID depening on the commuter mobility and given absolute and relative thresholds on the number of commuters.

The parameters absolute and relative tolerance decide which connections and neighbors are returned. If tol_comb=’or’, only one of this two criteria has to be satisfied to count the edges. If ‘and’ is chosen, both criteria have to be satisfied.

Parameters:
  • countyid – ID of the county where mobility is considered and for which neighbors have to be returned.

  • direction – both’ [Default], ‘in’, or ‘out’. Defines whether ‘both’ or ‘in’ or ‘out’ commuters only are considered.

  • abs_tol – Minimum number of commuters to count the connection. (Default value = 0)

  • rel_tol – Relative tolerance with respect to the strongest connection of the county to count the connections. (Default value = 0)

  • tol_comb – Defines whether absolute and relative thresholds are combined such that only one criterion has to be satisfied (‘or’) or both (‘and’). (Default value = ‘or’)

  • merge_eisenach – Default: True] Defines whether the counties ‘Wartburgkreis’ and ‘Eisenach’ are listed separately or combined as one entity ‘Wartburgkreis’.

  • out_folder – Folder where data is written to. Default defined in defaultDict.

  • ref_year – Year between 2013 and 2022 that specifies where the data should be taken from. Default value is 2022.

  • **kwargs

Returns:

Neighbors of the county with respect to mobility and the number of commuters from and to the neighbors.

memilio.epidata.getCommuterMobility.get_neighbors_mobility_all(
direction='both',
abs_tol=0,
rel_tol=0,
tol_comb='or',
out_folder='/home/docs/checkouts/readthedocs.org/user_builds/memilio/data/',
ref_year=2022,
)

Returns the neighbors of all counties ID depening on the commuter mobility and given absolute and relative thresholds on the number of commuters.

The parameters absolute and relative tolerance decide which connections and neighbors are returned. If tol_comb=’or’, only one of this two criteria has to be satisfied to count the edges. If ‘and’ is chosen, both criteria have to be satisfied.

Parameters:
  • direction – both’ [Default], ‘in’, or ‘out’. Defines whether ‘both’ or ‘in’ or ‘out’ commuters only are considered.

  • abs_tol – Minimum number of commuters to count the connection. (Default value = 0)

  • rel_tol – Relative tolerance with respect to the strongest connection of the county to count the connections. (Default value = 0)

  • tol_comb – Defines whether absolute and relative thresholds are combined such that only one criterion has to be satisfied (‘or’) or both (‘and’) (Default value = ‘or’)

  • ref_year – Year between 2013 and 2022 that specifies where the data should be taken from. Default value is 2022.

  • out_folder – (Default value = dd.defaultDict[‘out_folder’])

Returns:

Neighbors of all counties with respect to mobility.

memilio.epidata.getCommuterMobility.main()

Main program entry.

memilio.epidata.getCommuterMobility.verify_sorted(countykey_list)

verify that read countykey_list is sorted

Parameters:

countykey_list – List of county regional keys