logo Netzschleuder network catalog, repository, and centrifuge

History of sp_malawi_village

The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.

[entries] Add the date when each entry was added, and remove icon_hash by Tiago de Paula Peixoto beff7c9
The dates are those of the commits that first added the entries' files
(2020-08-11 for the entries of the initial commit); renamed entries keep
the date of their first name.

Changed: none
diff --git a/entries/sp_malawi_village/__init__.py b/entries/sp_malawi_village/__init__.py
index d7903b8..e31444a 100644
--- a/entries/sp_malawi_village/__init__.py
+++ b/entries/sp_malawi_village/__init__.py
@@ -32,7 +32,7 @@ Nodes are individuals, and each edge is a contact between two individuals active
 tags = ['Social', 'Offline', 'Temporal', 'Timestamps', 'Multigraph', 'Unweighted']
 url = 'https://sociopatterns.org/datasets/contact-patterns-in-a-village-in-rural-malawi/'
 citation = [('L. Ozella, D. Paolotti, G. Lichand, J. P. Rodríguez, S. Haenni, J. Phuka, O. B. Leal-Neto, C. Cattuto, "Using wearable proximity sensors to characterize social contact patterns in a village of rural Malawi." EPJ Data Science 10, 46 (2021)', 'https://doi.org/10.1140/epjds/s13688-021-00302-w')]
-icon_hash = None
+date_added = '2026-10-25'
 upstream_license = ("Creative Commons Attribution-NonCommercial-ShareAlike",
                     "http://creativecommons.org/licenses/by-nc-sa/3.0/")
 upstream_prefix = 'https://sociopatterns.org/assets/data'
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) by Tiago de Paula Peixoto bc3dbbd
The lists of properties at the end of the descriptions marked edge
properties with "Edge" but left node properties unmarked, or grouped
them in "Nodes: `a`, ...; `b`, ..." items, so the kind of a property
was often unclear. Every item now starts with (Node), (Edge) or (Graph),
followed by the property names, a colon and the explanation, one item
per property or group of properties; qualifications (kinds of nodes,
networks) follow the names in parentheses. Properties that were only
named got a short explanation, and a few items that named the wrong
kind of property were corrected.
diff --git a/entries/sp_malawi_village/__init__.py b/entries/sp_malawi_village/__init__.py
index a971596..d7903b8 100644
--- a/entries/sp_malawi_village/__init__.py
+++ b/entries/sp_malawi_village/__init__.py
@@ -26,9 +26,9 @@ description = r"""Temporal network of close-range proximity contacts among 86 in
 
 Nodes are individuals, and each edge is a contact between two individuals active during one 20-second interval, so that two individuals are connected by as many edges as the number of intervals in which they were in contact. The network has the following properties:
 
-- `id`: the anonymous identifier of the individual (1 to 86).
-- `time`: the end of the 20-second interval in which the contact was active, in seconds. The origin of the times is the first recorded contact, on 22 December 2019 (its time of day is not stated in the source).
-- `date`: the date of the contact (`YYYY-MM-DD`). The source gives only the day of the month; the month and year were inferred from the study period."""
+- (Node) `id`: the anonymous identifier of the individual (1 to 86).
+- (Edge) `time`: the end of the 20-second interval in which the contact was active, in seconds. The origin of the times is the first recorded contact, on 22 December 2019 (its time of day is not stated in the source).
+- (Edge) `date`: the date of the contact (`YYYY-MM-DD`). The source gives only the day of the month; the month and year were inferred from the study period."""
 tags = ['Social', 'Offline', 'Temporal', 'Timestamps', 'Multigraph', 'Unweighted']
 url = 'https://sociopatterns.org/datasets/contact-patterns-in-a-village-in-rural-malawi/'
 citation = [('L. Ozella, D. Paolotti, G. Lichand, J. P. Rodríguez, S. Haenni, J. Phuka, O. B. Leal-Neto, C. Cattuto, "Using wearable proximity sensors to characterize social contact patterns in a village of rural Malawi." EPJ Data Science 10, 46 (2021)', 'https://doi.org/10.1140/epjds/s13688-021-00302-w')]
[entries] Remove unneeded code from the entries by Tiago de Paula Peixoto 2c69f19
Unneeded "global files" statements, unused imports and variables,
f-strings without placeholders, duplicate keys in foodweb_little_rock
(keeping the order and the values used), and the second definition of
get_lines() in twitter_higgs. Nothing changes in the networks or
descriptions.

Changed: none
diff --git a/entries/sp_malawi_village/__init__.py b/entries/sp_malawi_village/__init__.py
index 0cbccda..a971596 100644
--- a/entries/sp_malawi_village/__init__.py
+++ b/entries/sp_malawi_village/__init__.py
@@ -54,7 +54,6 @@ def _date(day):
 @coerce_props()
 @annotate()
 def parse(alts=None):
-    global files
     name = __name__.split(".")[-1]
     for fnames, alt, fmt in files:
         if alts is not None and alt not in alts:
[entries] New entry: sp_malawi_village by Tiago de Paula Peixoto 3b2f47f
diff --git a/entries/sp_malawi_village/__init__.py b/entries/sp_malawi_village/__init__.py
new file mode 100644
index 0000000..0cbccda
--- /dev/null
+++ b/entries/sp_malawi_village/__init__.py
@@ -0,0 +1,81 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020-2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from .. import *
+
+import csv
+import datetime
+
+title = "Rural Malawi village contacts (2019-2020)"
+description = r"""Temporal network of close-range proximity contacts among 86 inhabitants of Mdoliro, a village in the Dowa district (Central Region) of Malawi, measured with wearable proximity sensors by the SocioPatterns collaboration, as part of a Child and Youth Development Study funded by UNICEF Malawi. The study ran from 16 December 2019 to 10 January 2020; children, adolescents and adult caregivers of 28 households wore a sensor pinned to the front of their clothing, and sensors exchanged low-power radio packets that are only received at distances of about 1-1.5 m (attenuation threshold of -75 dBm). Two individuals are in contact during a 20-second interval if their sensors exchanged at least one packet during it. Participants were asked to remove the sensors overnight; night-time contacts and periods during which a sensor did not move (according to its accelerometer) were removed from the data. The released data cover the 14 days from 22 December 2019 to 4 January 2020, and include both contacts within and between households. The demographic metadata (age, gender, household) described in the paper are not released.
+
+Nodes are individuals, and each edge is a contact between two individuals active during one 20-second interval, so that two individuals are connected by as many edges as the number of intervals in which they were in contact. The network has the following properties:
+
+- `id`: the anonymous identifier of the individual (1 to 86).
+- `time`: the end of the 20-second interval in which the contact was active, in seconds. The origin of the times is the first recorded contact, on 22 December 2019 (its time of day is not stated in the source).
+- `date`: the date of the contact (`YYYY-MM-DD`). The source gives only the day of the month; the month and year were inferred from the study period."""
+tags = ['Social', 'Offline', 'Temporal', 'Timestamps', 'Multigraph', 'Unweighted']
+url = 'https://sociopatterns.org/datasets/contact-patterns-in-a-village-in-rural-malawi/'
+citation = [('L. Ozella, D. Paolotti, G. Lichand, J. P. Rodríguez, S. Haenni, J. Phuka, O. B. Leal-Neto, C. Cattuto, "Using wearable proximity sensors to characterize social contact patterns in a village of rural Malawi." EPJ Data Science 10, 46 (2021)', 'https://doi.org/10.1140/epjds/s13688-021-00302-w')]
+icon_hash = None
+upstream_license = ("Creative Commons Attribution-NonCommercial-ShareAlike",
+                    "http://creativecommons.org/licenses/by-nc-sa/3.0/")
+upstream_prefix = 'https://sociopatterns.org/assets/data'
+files = [('tnet_malawi_pilot.csv.gz', None, None)]
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+def _date(day):
+    # The data cover 22 December 2019 to 4 January 2020; only the day of the
+    # month is given.
+    day = int(day)
+    if day >= 16:
+        return datetime.date(2019, 12, day).isoformat()
+    return datetime.date(2020, 1, day).isoformat()
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    global files
+    name = __name__.split(".")[-1]
+    for fnames, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        if isinstance(fnames, str):
+            fnames = [fnames]
+        with ExitStack() as stack:
+            fs = [stack.enter_context(open_upstream_file(name, fn, "r")) for fn in fnames]
+
+            # Columns: (row index), contact_time, day, id1, id2
+            reader = csv.reader(fs[0])
+            next(reader)
+            def get_edges():
+                for row in reader:
+                    _, t, day, u, v = row
+                    yield int(u), int(v), int(t), _date(day)
+            g = Graph(directed=False)
+            g.ep.time = g.new_ep("int")
+            g.ep.date = g.new_ep("string")
+            g.vp.id = g.add_edge_list(get_edges(), hashed=True,
+                                      hash_type="int",
+                                      eprops=[g.ep.time, g.ep.date])
+            g = Graph(g, vorder=g.vp.id)
+        yield alt, g