Data I/O module

This module provides routines to load and write temporal networks to the taco-fileformat.

tacoma.data_io.download_and_convert_sociopatterns_high_school_2013(url='http://www.sociopatterns.org/wp-content/uploads/2015/07/High-School_data_2013.csv.gz', filename='~/.tacoma/hs13.taco')[source]

Download the SocioPatterns ‘High school 2013 dynamic contact network’ data, extract it and save it as taco. This data is actually binned in intervals of [t-20s, t].

Parameters:
  • url (str, optional) – The url from which the tsv-data should be retrieved
  • filename (str, optional) – this is the path where the taco will be saved to. default : “~/.tacoma/hs13.taco”
Returns:

edge_lists – The temporal network of the ‘High school 2013 dynamic contact network’.

Return type:

edge_lists

Notes

If you use this data, please cite

:: [HS13]
R. Mastrandrea, J. Fournet, A. Barrat, Contact patterns in a high school: a comparison between data collected using wearable sensors, contact diaries and friendship surveys. PLoS ONE 10(9): e0136497 (2015)
tacoma.data_io.download_and_convert_sociopatterns_hypertext_2009(url='http://www.sociopatterns.org/files/datasets/003/ht09_contact_list.dat.gz', filename='~/.tacoma/ht09.taco')[source]

Download the SocioPatterns ‘Hypertext 2009 dynamic contact network’ data, extract it and save it as taco. This data is actually binned in intervals of [t-20s, t].

Parameters:
  • url (str, optional) – The url from which the tsv-data should be retrieved
  • filename (str, optional) – this is the path where the taco will be saved to. default : “~/.tacoma/ht09.taco”
Returns:

edge_lists – The temporal network of the ‘Hypertext 2009 dynamic contact network’.

Return type:

edge_lists

Notes

If you use this data, please cite

::
L. Isella et al., What’s in a crowd? Analysis of face-to-face behavioral networks, Journal of Theoretical Biology 271, 166 (2011).
tacoma.data_io.load_fwP_args(filename)[source]

Load Flockwork-P arguments from a json-file

tacoma.data_io.load_json_dict(fn)[source]

Load a dictionary from a JSON-file

tacoma.data_io.load_json_taco(fp)[source]

Loads a temporal network from a .taco-file (which is actually in json format).

Parameters:fp (file-like or str) – read from this file
Returns:type as given in the .taco-file
Return type:temporal network
tacoma.data_io.load_sociopatterns_high_school_2013(filename='~/.tacoma/hs13.taco')[source]

Once tacoma.data_io.download_sociopatterns_high_school_2013() was called, use this function to retrieve an edge_lists instance of the conference data set ‘High school 2013 dynamic contact network’ (from the SocioPatterns project).

Parameters:filename (str, optional) – this is the path where the taco was saved to. default : “~/.tacoma/hs13.taco”
Returns:edge_lists – The temporal network of the ‘High school 2013 dynamic contact network’.
Return type:edge_lists

Notes

If you use this data, please cite

::
R. Mastrandrea, J. Fournet, A. Barrat, Contact patterns in a high school: a comparison between data collected using wearable sensors, contact diaries and friendship surveys. PLoS ONE 10(9): e0136497 (2015)
tacoma.data_io.load_sociopatterns_hypertext_2009(filename='~/.tacoma/ht09.taco')[source]

Once tacoma.data_io.download_sociopatterns_hypertext_2009() was called, use this function to retrieve an edge_lists instance of the conference data set ‘Hypertext 2009 dynamic contact network’ (from the SocioPatterns project).

Parameters:filename (str, optional) – this is the path where the taco was saved to. default : “~/.tacoma/ht09.taco”
Returns:
  • edge_lists (edge_lists) – The temporal network of the ‘Hypertext 2009 dynamic contact network’.
  • If you use this data, please cite
  • ::

    L. Isella et al., What’s in a crowd? Analysis of face-to-face behavioral networks, Journal of Theoretical Biology 271, 166 (2011).

tacoma.data_io.mkdirp_customdir(directory='~/.tacoma/')[source]

simulate mkdir -p functionality

tacoma.data_io.read_json_taco(fp)[source]

Loads a temporal network from a .taco-file (which is actually in json format) by simply calling load_json_taco because I’m too stupid to remember if it’s actually ‘read’ or ‘load’ smh.

Parameters:fp (file-like or str) – read from this file
Returns:temporal_network – type as given in the .taco-file
Return type:edge_lists or edge_changes
tacoma.data_io.reset_web_directory()[source]

Reset the internal system directory ~/.tacoma/

tacoma.data_io.write_edge_trajectory_coordinates(temporal_network, filename, filter_for_duration=0.0)[source]

Write the coordinates of the edge activation periods to a json-file such that each entry corresponds to a line to be drawn.

Parameters:
  • temporal_network (edge_changes, edge_lists, edge_changes_with_histograms, or edge_lists_with_histograms) – An instance of a temporal network.
  • filename (str) – Write to this file.
tacoma.data_io.write_fwP_args(args, filename)[source]

Dump Flockwork-P arguments to a json-file

tacoma.data_io.write_json_taco(temporal_network, fp)[source]

Writes a temporal network to a .taco-file (which is actually in json format).

Parameters:
  • temporal_network (edge_changes, edge_lists, edge_changes_with_histograms, or edge_lists_with_histograms) – An instance of a temporal network.
  • fp (file-like or str) – write to this file