logo Netzschleuder network catalog, repository, and centrifuge

History of utah_schools

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/utah_schools/__init__.py b/entries/utah_schools/__init__.py
index 892a84f..3a21531 100644
--- a/entries/utah_schools/__init__.py
+++ b/entries/utah_schools/__init__.py
@@ -37,7 +37,7 @@ Every network contains all the students of the respective school, including the
 tags = ['Social', 'Offline', 'Temporal', 'Timestamps', 'Multigraph', 'Weighted', 'Metadata']
 url = 'https://doi.org/10.1098/rsif.2015.0279'
 citation = [('D. J. A. Toth, M. Leecaster, W. B. P. Pettey, A. V. Gundlapalli, H. Gao, J. J. Rainey, A. Uzicanin, M. H. Samore, "The role of heterogeneity in contact timing and duration in network models of influenza spread in schools." Journal of The Royal Society Interface 12(108), 20150279 (2015)', 'https://doi.org/10.1098/rsif.2015.0279')]
-icon_hash = None
+date_added = '2026-10-25'
 upstream_license = ("CC BY 4.0", "https://creativecommons.org/licenses/by/4.0/")
 # Europe PMC serves the supplementary material of the article as a zip file
 # at the URL ".../supplementaryFiles" (without extension)
[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/utah_schools/__init__.py b/entries/utah_schools/__init__.py
index 397bbe2..892a84f 100644
--- a/entries/utah_schools/__init__.py
+++ b/entries/utah_schools/__init__.py
@@ -28,12 +28,12 @@ description = """Temporal networks of close-proximity contacts between students
 
 Every network contains all the students of the respective school, including the ones without any recorded contact on that day (one in `mid1_day1_1m` and `mid1_day2_1m`). The networks have the following properties:
 
-- `id`: the anonymous identifier of the student in the source data (the same across the two days of a school).
-- `grade`: the school grade of the student (0 = kindergarten, 1 to 8 = 1st to 8th grade, -1 = unknown).
-- `class`: the class of the student, numbered 0 to 20 (`elem1_*` only).
-- `gender`: the gender of the student (0 = male, 1 = female, -1 = unknown).
-- `time`: the time of day at which the contact started, in seconds since midnight (local time), i.e. the start of its first time bin. The source gives it in units of 19.53125 seconds, so it is a multiple of this value.
-- `duration`: the duration of the contact, in seconds (the number of consecutive time bins times 19.53125 seconds)."""
+- (Node) `id`: the anonymous identifier of the student in the source data (the same across the two days of a school).
+- (Node) `grade`: the school grade of the student (0 = kindergarten, 1 to 8 = 1st to 8th grade, -1 = unknown).
+- (Node) `class`: the class of the student, numbered 0 to 20 (`elem1_*` only).
+- (Node) `gender`: the gender of the student (0 = male, 1 = female, -1 = unknown).
+- (Edge) `time`: the time of day at which the contact started, in seconds since midnight (local time), i.e. the start of its first time bin. The source gives it in units of 19.53125 seconds, so it is a multiple of this value.
+- (Edge) `duration`: the duration of the contact, in seconds (the number of consecutive time bins times 19.53125 seconds)."""
 tags = ['Social', 'Offline', 'Temporal', 'Timestamps', 'Multigraph', 'Weighted', 'Metadata']
 url = 'https://doi.org/10.1098/rsif.2015.0279'
 citation = [('D. J. A. Toth, M. Leecaster, W. B. P. Pettey, A. V. Gundlapalli, H. Gao, J. J. Rainey, A. Uzicanin, M. H. Samore, "The role of heterogeneity in contact timing and duration in network models of influenza spread in schools." Journal of The Royal Society Interface 12(108), 20150279 (2015)', 'https://doi.org/10.1098/rsif.2015.0279')]
[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/utah_schools/__init__.py b/entries/utah_schools/__init__.py
index 0fdf908..397bbe2 100644
--- a/entries/utah_schools/__init__.py
+++ b/entries/utah_schools/__init__.py
@@ -61,7 +61,6 @@ def fetch_upstream(force=False):
 @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:
@@ -85,7 +84,6 @@ def parse(alts=None):
             assert numpy.isin(c[:, :2], meta[:, 0]).all()
 
             ids = numpy.sort(meta[:, 0])
-            idx = {int(i): v for v, i in enumerate(ids)}
             g = Graph(directed=False)
             g.add_vertex(len(ids))
             g.vp.id = g.new_vp("int", vals=ids)
[entries] New entry: utah_schools by Tiago de Paula Peixoto ba69ad8
diff --git a/entries/utah_schools/__init__.py b/entries/utah_schools/__init__.py
new file mode 100644
index 0000000..0fdf908
--- /dev/null
+++ b/entries/utah_schools/__init__.py
@@ -0,0 +1,103 @@
+#! /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 *
+
+title = "Utah school contacts (2012-2013)"
+description = """Temporal networks of close-proximity contacts between students of two schools in Utah, USA, recorded with wearable wireless sensors by the Contacts among Utah's School-age Population (CUSP) study. The sensors were deployed at an urban middle school ("Mid1", 7th and 8th grade, 591 students) on November 28 and 29, 2012, and at a suburban elementary school ("Elem1", kindergarten to 6th grade in 21 classes, 339 students) on January 31 and February 1, 2013, and the data cover the school hours of each day. The students wore Wireless Ranging Enabled Nodes (WRENs), which broadcast a packet every 20,000 binary milliseconds (19.53125 seconds) and recorded the packets received from other nodes, together with their signal strength. Packets with a signal strength below -77 dBm were discarded, which was intended to retain contacts at a distance of less than about 2 meters; the authors note that some contacts at larger distances may have been retained and some closer ones discarded. After correcting clock drifts and removing data from nodes that were not being worn, time was divided into bins of 19.53125 seconds, and a contact between two students is a maximal run of consecutive bins in which at least one of them recorded the other. Each contact is an edge, so two students can be connected by several edges. In addition to these data (the main data of the study), the authors released alternative versions obtained with a stricter signal strength threshold, intended to correspond to a distance of less than about 1 meter, which they used for a sensitivity analysis.
+
+- `mid1_day1`, `mid1_day2`: contacts at the middle school, on the first and second day.
+- `elem1_day1`, `elem1_day2`: contacts at the elementary school, on the first and second day.
+- `mid1_day1_1m`, `mid1_day2_1m`, `elem1_day1_1m`, `elem1_day2_1m`: the same, with the stricter (<1 meter) criterion.
+
+Every network contains all the students of the respective school, including the ones without any recorded contact on that day (one in `mid1_day1_1m` and `mid1_day2_1m`). The networks have the following properties:
+
+- `id`: the anonymous identifier of the student in the source data (the same across the two days of a school).
+- `grade`: the school grade of the student (0 = kindergarten, 1 to 8 = 1st to 8th grade, -1 = unknown).
+- `class`: the class of the student, numbered 0 to 20 (`elem1_*` only).
+- `gender`: the gender of the student (0 = male, 1 = female, -1 = unknown).
+- `time`: the time of day at which the contact started, in seconds since midnight (local time), i.e. the start of its first time bin. The source gives it in units of 19.53125 seconds, so it is a multiple of this value.
+- `duration`: the duration of the contact, in seconds (the number of consecutive time bins times 19.53125 seconds)."""
+tags = ['Social', 'Offline', 'Temporal', 'Timestamps', 'Multigraph', 'Weighted', 'Metadata']
+url = 'https://doi.org/10.1098/rsif.2015.0279'
+citation = [('D. J. A. Toth, M. Leecaster, W. B. P. Pettey, A. V. Gundlapalli, H. Gao, J. J. Rainey, A. Uzicanin, M. H. Samore, "The role of heterogeneity in contact timing and duration in network models of influenza spread in schools." Journal of The Royal Society Interface 12(108), 20150279 (2015)', 'https://doi.org/10.1098/rsif.2015.0279')]
+icon_hash = None
+upstream_license = ("CC BY 4.0", "https://creativecommons.org/licenses/by/4.0/")
+# Europe PMC serves the supplementary material of the article as a zip file
+# at the URL ".../supplementaryFiles" (without extension)
+upstream_prefix = 'https://www.ebi.ac.uk/europepmc/webservices/rest/PMC4528592'
+_z = 'supplementaryFiles:zip:rsif20150279supp'
+_meta = {"mid1": _z + '6.txt', "elem1": _z + '7.txt'}
+files = []
+for _crit, _supp in [("", (2, 3, 4, 5)), ("_1m", (8, 9, 10, 11))]:
+    for _i, (_school, _day) in enumerate([("mid1", 1), ("mid1", 2),
+                                         ("elem1", 1), ("elem1", 2)]):
+        files.append(((f'{_z}{_supp[_i]}.txt', _meta[_school]),
+                      f'{_school}_day{_day}{_crit}', None))
+
+BIN = 19.53125  # seconds
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+@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]
+
+            # Contacts: "id1 id2 startTime duration", with a header line in
+            # the <2 m files only; times in units of 19.53125 s
+            lines = fs[0].read().split("\n")
+            if lines[0].startswith("id1"):
+                lines = lines[1:]
+            c = numpy.array(" ".join(lines).split(), dtype=numpy.int64).reshape(-1, 4)
+
+            # Metadata: "id grade gender" (Mid1) or "id grade class gender" (Elem1)
+            header = next(fs[1]).split()
+            meta = numpy.array(fs[1].read().split(),
+                               dtype=numpy.int64).reshape(-1, len(header))
+            assert numpy.isin(c[:, :2], meta[:, 0]).all()
+
+            ids = numpy.sort(meta[:, 0])
+            idx = {int(i): v for v, i in enumerate(ids)}
+            g = Graph(directed=False)
+            g.add_vertex(len(ids))
+            g.vp.id = g.new_vp("int", vals=ids)
+            mpos = numpy.searchsorted(ids, meta[:, 0])
+            for k, col in zip(header[1:], meta[:, 1:].T):
+                g.vp[k] = g.new_vp("int")
+                g.vp[k].a[mpos] = col
+
+            g.ep.time = g.new_ep("double")
+            g.ep.duration = g.new_ep("double")
+            u = numpy.searchsorted(ids, c[:, 0])
+            v = numpy.searchsorted(ids, c[:, 1])
+            g.add_edge_list(numpy.column_stack((u, v, c[:, 2] * BIN, c[:, 3] * BIN)),
+                            eprops=[g.ep.time, g.ep.duration])
+        yield alt, g