History of haslemere
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] New entry: haslemere 8949e13
diff --git a/entries/haslemere/__init__.py b/entries/haslemere/__init__.py
new file mode 100644
index 0000000..78a79b4
--- /dev/null
+++ b/entries/haslemere/__init__.py
@@ -0,0 +1,79 @@
+#! /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 = "BBC Pandemic Haslemere proximity (2017)"
+description = r"""Temporal network of physical proximity among residents of the town of Haslemere (Surrey, England), collected with the "BBC Pandemic" mobile phone app for the BBC Four documentary "Contagion! The BBC Four Pandemic" (2018). Volunteers installed the app, which recorded their GPS location about every five minutes during three days, from Thursday 12 to Saturday 14 October 2017. Kissler et al. kept the 469 users who logged a location in Haslemere in at least six different hours, aggregated each user's locations into five-minute time bins (filling the bins without data with the last recorded location, or with the user's home location at the start), and computed the distances between all pairs of users in each bin. To protect the users' privacy, only the bins between 07:00 and 22:55 (British Summer Time) of each day were released (576 bins), without the locations.
+
+Nodes are users of the app, and each edge is an encounter, i.e. two users within 50 m of each other during one five-minute time bin, so that two users are connected by as many edges as the number of time bins in which they were close. The network has the following properties:
+
+- `id`: the anonymous identifier of the user (from 1 to 469).
+- `time` (edges): the start of the five-minute time bin, in Unix time.
+- `distance` (edges): the distance between the two users in that time bin, rounded to the meter."""
+tags = ['Social', 'Offline', 'Temporal', 'Timestamps', 'Multigraph', 'Unweighted', 'Metadata']
+url = 'https://github.com/skissler/haslemere'
+citation = [('S. M. Kissler, P. Klepac, M. Tang, A. J. K. Conlan, J. R. Gog, "Sparking \'The BBC Four Pandemic\': Leveraging citizen science and mobile phones to model the spread of disease." bioRxiv 479154 (2018)', 'https://doi.org/10.1101/479154'),
+ ('P. Klepac, S. Kissler, J. Gog, "Contagion! The BBC Four Pandemic - The model behind the documentary." Epidemics 24, 49-59 (2018)', 'https://doi.org/10.1016/j.epidem.2018.03.003')]
+icon_hash = None
+upstream_license = None
+upstream_prefix = 'https://raw.githubusercontent.com/skissler/haslemere/dc49e83406bbd4788d0a5baeca6ceeba53241d7e'
+files = [(('Kissler_DataS1.csv', 'Kissler_DataS2.csv'), None, None)]
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
+ "Oct", "Nov", "Dec"]
+
+# British Summer Time
+bst = datetime.timezone(datetime.timedelta(hours=1))
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+ name = __name__.split(".")[-1]
+ for (fdata, ftimes), alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ times = {}
+ with open_upstream_file(name, ftimes, "r") as f:
+ for row in csv.reader(f):
+ # e.g. "Thu 12 Oct 2017 07:00:00" (parsed without the
+ # locale-dependent strptime)
+ wd, day, mon, year, hms = row[1].split()
+ h, m, sec = [int(x) for x in hms.split(":")]
+ t = datetime.datetime(int(year), months.index(mon) + 1, int(day),
+ h, m, sec)
+ times[int(row[0])] = int(t.replace(tzinfo=bst).timestamp())
+ g = Graph(directed=False)
+ g.add_vertex(469)
+ g.vp.id = g.new_vp("int", vals=range(1, 470))
+ edges = []
+ with open_upstream_file(name, fdata, "r") as f:
+ for row in csv.reader(f):
+ t, i, j, d = [int(x) for x in row]
+ edges.append((i - 1, j - 1, times[t], d))
+ g.ep.time = g.new_ep("int64_t")
+ g.ep.distance = g.new_ep("int")
+ g.add_edge_list(edges, eprops=[g.ep.time, g.ep.distance])
+ yield alt, g