From 66dc896988fca33616d560607ec4dfb047f1f9be Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Mon, 27 Sep 2021 14:31:09 +0200 Subject: [PATCH 1/5] Updated temperatures for Geneva --- cara/data/__init__.py | 50 +++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/cara/data/__init__.py b/cara/data/__init__.py index 353992e6..21e2ccb3 100644 --- a/cara/data/__init__.py +++ b/cara/data/__init__.py @@ -5,31 +5,31 @@ from cara import models # average temperature of each month, hour per hour (from midnight to 11 pm) Geneva_hourly_temperatures_celsius_per_hour = { - 'Jan': [0.2, -0.3, -0.5, -0.9, -1.1, -1.4, -1.5, -1.5, -1.1, 0.1, 1.5, - 2.8, 3.8, 4.4, 4.5, 4.4, 4.4, 3.9, 3.1, 2.7, 2.2, 1.7, 1.5, 1.1], - 'Feb': [0.9, 0.3, 0.0, -0.5, -0.7, -1.1, -1.2, -1.1, -0.7, 0.8, 2.5, - 4.2, 5.4, 6.2, 6.3, 6.2, 6.1, 5.5, 4.5, 4.1, 3.5, 2.8, 2.5, 2.0], - 'Mar': [4.2, 3.5, 3.1, 2.5, 2.1, 1.6, 1.5, 1.6, 2.2, 4.0, 6.3, 8.4, - 10.0, 11.1, 11.2, 11.1, 11.0, 10.2, 8.9, 8.3, 7.5, 6.7, 6.3, 5.6], - 'Apr': [7.4, 6.7, 6.2, 5.5, 5.2, 4.7, 4.5, 4.6, 5.3, 7.2, 9.6, 11.9, - 13.7, 14.8, 14.9, 14.8, 14.7, 13.8, 12.4, 11.8, 10.9, 10.1, 9.6, 8.9], - 'May': [11.8, 11.1, 10.6, 9.9, 9.5, 8.9, 8.8, 8.9, 9.6, 11.6, 14.2, 16.6, - 18.4, 19.6, 19.7, 19.6, 19.4, 18.6, 17.1, 16.5, 15.6, 14.6, 14.2, 13.4], - 'Jun': [15.2, 14.4, 13.9, 13.2, 12.7, 12.2, 12.0, 12.1, 12.8, 15.0, 17.7, - 20.2, 22.1, 23.3, 23.5, 23.4, 23.2, 22.3, 20.8, 20.1, 19.1, 18.2, 17.7, 16.9], - 'Jul': [17.6, 16.7, 16.1, 15.3, 14.9, 14.3, 14.1, 14.2, 15.0, 17.3, 20.2, - 23.0, 25.0, 26.3, 26.5, 26.4, 26.2, 25.2, 23.6, 22.8, 21.8, 20.8, 20.2, 19.4], - 'Aug': [17.1, 16.2, 15.7, 14.9, 14.5, 13.9, 13.7, 13.8, 14.6, 16.9, 19.7, - 22.4, 24.4, 25.6, 25.8, 25.7, 25.5, 24.5, 22.9, 22.2, 21.2, 20.2, 19.7, 18.9], - 'Sep': [13.4, 12.7, 12.2, 11.5, 11.2, 10.7, 10.5, 10.6, 11.3, 13.2, 15.6, - 17.9, 19.6, 20.8, 20.9, 20.8, 20.7, 19.8, 18.4, 17.8, 16.9, 16.1, 15.6, 14.9], - 'Oct': [9.4, 8.8, 8.5, 7.9, 7.6, 7.2, 7.1, 7.2, 7.7, 9.3, 11.2, 13.0, - 14.4, 15.3, 15.4, 15.3, 15.2, 14.5, 13.4, 12.9, 12.2, 11.6, 11.2, 10.6], - 'Nov': [4.0, 3.6, 3.3, 2.9, 2.6, 2.3, 2.2, 2.2, 2.7, 3.9, 5.5, 6.9, 8.0, - 8.7, 8.8, 8.7, 8.7, 8.1, 7.2, 6.8, 6.3, 5.7, 5.5, 5.0], - 'Dec': [1.4, 1.0, 0.8, 0.4, 0.2, -0.0, -0.1, -0.1, 0.3, 1.3, 2.6, 3.8, - 4.7, 5.2, 5.3, 5.2, 5.2, 4.7, 4.0, 3.7, 3.2, 2.8, 2.6, 2.2] - } + 'Jan': [1.3, 1.1, 1.0, 1.0, 0.8, 0.8, 0.9, 0.9, 1.1, 1.8, 2.6, + 3.3, 3.8, 4.2, 4.4, 4.4, 3.9, 3.2, 2.8, 2.4, 2.1, 1.9, 1.6, 1.4], + 'Feb': [1.6, 1.3, 1.1, 1.0, 0.8, 0.7, 0.9, 0.8, 1.5, 2.8, 3.8, + 4.7, 5.4, 6.0, 6.3, 6.4, 6.0, 5.1, 4.3, 3.6, 3.1, 2.8, 2.3, 1.9], + 'Mar': [4.8, 4.3, 3.9, 3.7, 3.4, 3.2, 3.3, 3.9, 5.6, 6.9, 8.1, 9.0, + 9.9, 10.6, 11.0, 11.1, 10.8, 10.1, 8.9, 7.8, 7.0, 6.5, 5.8, 5.2], + 'Apr': [8.0, 7.4, 6.9, 6.8, 6.3, 6.1, 6.9, 8.4, 9.8, 10.9, 12.0, 12.9, + 13.7, 14.3, 14.7, 14.8, 14.6, 14.0, 13.0, 11.6, 10.7, 10.0, 9.2, 8.5], + 'May': [11.9, 11.3, 10.8, 10.6, 10.2, 10.4, 11.9, 13.2, 14.3, 15.4, 16.4, + 17.3, 18.1, 18.6, 18.9, 19.0, 18.7, 18.2, 17.3, 15.9, 14.7, 13.9, 13.1, 12.4], + 'Jun': [15.4, 14.7, 14.3, 14.1, 13.6, 14.1, 15.7, 17.0, 18.2, 19.2, 20.2, + 21.2, 22.0, 22.6, 22.9, 23.0, 22.7, 22.2, 21.5, 20.0, 18.6, 17.7, 16.8, 16.0], + 'Jul': [17.4, 16.8, 16.3, 16.1, 15.5, 15.8, 17.5, 18.9, 20.2, 21.3, 22.4, + 23.4, 24.4, 24.9, 25.3, 25.5, 25.2, 24.7, 23.9, 22.3, 20.8, 19.8, 18.8, 18.0], + 'Aug': [17.1, 16.4, 15.9, 15.7, 15.2, 15.1, 16.3, 18.1, 19.6, 20.8, 22.0, + 23.0, 23.9, 24.5, 25.0, 25.2, 24.9, 24.2, 23.1, 21.2, 20.0, 19.1, 18.2, 17.5], + 'Sep': [13.4, 12.9, 12.5, 12.4, 12.0, 11.9, 12.3, 13.6, 15.1, 16.3, 17.4, + 18.4, 19.2, 19.8, 20.2, 20.2, 19.9, 19.0, 17.5, 16.2, 15.5, 14.9, 14.1, 13.6], + 'Oct': [9.7, 9.4, 9.2, 9.2, 8.9, 8.9, 9.1, 9.4, 10.6, 11.7, 12.6, 13.5, + 14.2, 14.6, 14.9, 14.8, 14.1, 13.0, 12.1, 11.4, 10.9, 10.6, 10.1, 9.7], + 'Nov': [5.1, 4.8, 4.7, 4.8, 4.5, 4.6, 4.7, 4.7, 5.3, 6.3, 7.0, + 7.7, 8.3, 8.6, 8.7, 8.5, 7.7, 7.0, 6.6, 6.1, 5.8, 5.6, 5.3, 5.0], + 'Dec': [2.2, 2.0, 1.9, 1.9, 1.7, 1.7, 1.8, 1.7, 1.9, 2.6, 3.3, + 4.0, 4.5, 4.8, 4.9, 4.7, 4.1, 3.6, 3.3, 3.0, 2.8, 2.7, 2.4, 2.2] + } # Geneva hourly temperatures as piecewise constant function (in Kelvin). From 1934f41d2c4365b746b732a47e95c2d54dac05ee Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Mon, 27 Sep 2021 15:07:21 +0200 Subject: [PATCH 2/5] updated temperature tests --- cara/tests/test_known_quantities.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cara/tests/test_known_quantities.py b/cara/tests/test_known_quantities.py index d1db42c2..907feead 100644 --- a/cara/tests/test_known_quantities.py +++ b/cara/tests/test_known_quantities.py @@ -378,8 +378,8 @@ def build_exposure_model(concentration_model): @pytest.mark.parametrize( "month, expected_exposure", [ - ['Jan', 496.5427], - ['Jun', 1898.1354], + ['Jan', 503.254087759], + ['Jun', 2294.71115639], ], ) def test_exposure_hourly_dep(month,expected_exposure): @@ -399,8 +399,8 @@ def test_exposure_hourly_dep(month,expected_exposure): @pytest.mark.parametrize( "month, expected_exposure", [ - ['Jan', 499.6921], - ['Jun', 2007.59925], + ['Jan', 511.118941481], + ['Jun', 2398.90129579], ], ) def test_exposure_hourly_dep_refined(month,expected_exposure): From 5b764ceb16dd8c79b201e453db0ca383c483b436 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Wed, 6 Oct 2021 14:38:31 +0200 Subject: [PATCH 3/5] Fetch Geneva data from LFS --- cara/data/__init__.py | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/cara/data/__init__.py b/cara/data/__init__.py index 21e2ccb3..6e7ac9c9 100644 --- a/cara/data/__init__.py +++ b/cara/data/__init__.py @@ -1,37 +1,20 @@ import numpy as np from cara import models +from cara.data.weather import wx_data, nearest_wx_station -# TODO: The values in this module to be removed and instead use the cara.data.weather functionality. +MONTH_NAMES = [ + 'January', 'February', 'March', 'April', 'May', 'June', 'July', + 'August', 'September', 'October', 'November', 'December', +] +# Load the weather data (temperature in kelvin) for Geneva. +coordinates = (46.204391, 6.143158) +wx_station_id = nearest_wx_station(longitude=coordinates[1], latitude=coordinates[0])[0] # average temperature of each month, hour per hour (from midnight to 11 pm) -Geneva_hourly_temperatures_celsius_per_hour = { - 'Jan': [1.3, 1.1, 1.0, 1.0, 0.8, 0.8, 0.9, 0.9, 1.1, 1.8, 2.6, - 3.3, 3.8, 4.2, 4.4, 4.4, 3.9, 3.2, 2.8, 2.4, 2.1, 1.9, 1.6, 1.4], - 'Feb': [1.6, 1.3, 1.1, 1.0, 0.8, 0.7, 0.9, 0.8, 1.5, 2.8, 3.8, - 4.7, 5.4, 6.0, 6.3, 6.4, 6.0, 5.1, 4.3, 3.6, 3.1, 2.8, 2.3, 1.9], - 'Mar': [4.8, 4.3, 3.9, 3.7, 3.4, 3.2, 3.3, 3.9, 5.6, 6.9, 8.1, 9.0, - 9.9, 10.6, 11.0, 11.1, 10.8, 10.1, 8.9, 7.8, 7.0, 6.5, 5.8, 5.2], - 'Apr': [8.0, 7.4, 6.9, 6.8, 6.3, 6.1, 6.9, 8.4, 9.8, 10.9, 12.0, 12.9, - 13.7, 14.3, 14.7, 14.8, 14.6, 14.0, 13.0, 11.6, 10.7, 10.0, 9.2, 8.5], - 'May': [11.9, 11.3, 10.8, 10.6, 10.2, 10.4, 11.9, 13.2, 14.3, 15.4, 16.4, - 17.3, 18.1, 18.6, 18.9, 19.0, 18.7, 18.2, 17.3, 15.9, 14.7, 13.9, 13.1, 12.4], - 'Jun': [15.4, 14.7, 14.3, 14.1, 13.6, 14.1, 15.7, 17.0, 18.2, 19.2, 20.2, - 21.2, 22.0, 22.6, 22.9, 23.0, 22.7, 22.2, 21.5, 20.0, 18.6, 17.7, 16.8, 16.0], - 'Jul': [17.4, 16.8, 16.3, 16.1, 15.5, 15.8, 17.5, 18.9, 20.2, 21.3, 22.4, - 23.4, 24.4, 24.9, 25.3, 25.5, 25.2, 24.7, 23.9, 22.3, 20.8, 19.8, 18.8, 18.0], - 'Aug': [17.1, 16.4, 15.9, 15.7, 15.2, 15.1, 16.3, 18.1, 19.6, 20.8, 22.0, - 23.0, 23.9, 24.5, 25.0, 25.2, 24.9, 24.2, 23.1, 21.2, 20.0, 19.1, 18.2, 17.5], - 'Sep': [13.4, 12.9, 12.5, 12.4, 12.0, 11.9, 12.3, 13.6, 15.1, 16.3, 17.4, - 18.4, 19.2, 19.8, 20.2, 20.2, 19.9, 19.0, 17.5, 16.2, 15.5, 14.9, 14.1, 13.6], - 'Oct': [9.7, 9.4, 9.2, 9.2, 8.9, 8.9, 9.1, 9.4, 10.6, 11.7, 12.6, 13.5, - 14.2, 14.6, 14.9, 14.8, 14.1, 13.0, 12.1, 11.4, 10.9, 10.6, 10.1, 9.7], - 'Nov': [5.1, 4.8, 4.7, 4.8, 4.5, 4.6, 4.7, 4.7, 5.3, 6.3, 7.0, - 7.7, 8.3, 8.6, 8.7, 8.5, 7.7, 7.0, 6.6, 6.1, 5.8, 5.6, 5.3, 5.0], - 'Dec': [2.2, 2.0, 1.9, 1.9, 1.7, 1.7, 1.8, 1.7, 1.9, 2.6, 3.3, - 4.0, 4.5, 4.8, 4.9, 4.7, 4.1, 3.6, 3.3, 3.0, 2.8, 2.7, 2.4, 2.2] - } - - +Geneva_hourly_temperatures_celsius_per_hour = {month.replace(month, MONTH_NAMES[i][:3]): + [t - 273.15 for t in temp] for i, (month, temp) + in enumerate(wx_data()[wx_station_id].items())} + # Geneva hourly temperatures as piecewise constant function (in Kelvin). GenevaTemperatures_hourly = { month: models.PiecewiseConstant( From 55d2d6fb34c5a1e781ed0b90d9f256d47f553522 Mon Sep 17 00:00:00 2001 From: James Devine Date: Wed, 13 Oct 2021 15:56:50 +0200 Subject: [PATCH 4/5] Update README.md, fixed capitalisation on headings --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7853027d..d6d770f9 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Andre Henriques1, Luis Aleixo1, Marco Andreini1 5Information Technology Department, Collaboration, Devices & Applications Group, CERN
6Norwegian University of Science and Technology (NTNU)
-### citation +### Citation A. Henriques, M. Andreini, G. Azzopardi, J. Devine, P. Elson, N. Mounet, M. Kongstein, N. Tarocco. CARA - COVID Airborne Risk Assessment tools. CERN (2021). From 95a54de9ba62158861eca4e04db9bd6352d945e3 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Wed, 27 Oct 2021 14:46:59 +0200 Subject: [PATCH 5/5] Replaced Geneva temperature variable name --- cara/data/__init__.py | 6 +++--- cara/tests/test_known_quantities.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cara/data/__init__.py b/cara/data/__init__.py index 6e7ac9c9..555a5d33 100644 --- a/cara/data/__init__.py +++ b/cara/data/__init__.py @@ -11,7 +11,7 @@ MONTH_NAMES = [ coordinates = (46.204391, 6.143158) wx_station_id = nearest_wx_station(longitude=coordinates[1], latitude=coordinates[0])[0] # average temperature of each month, hour per hour (from midnight to 11 pm) -Geneva_hourly_temperatures_celsius_per_hour = {month.replace(month, MONTH_NAMES[i][:3]): +local_hourly_temperatures_celsius_per_hour = {month.replace(month, MONTH_NAMES[i][:3]): [t - 273.15 for t in temp] for i, (month, temp) in enumerate(wx_data()[wx_station_id].items())} @@ -23,12 +23,12 @@ GenevaTemperatures_hourly = { tuple(float(time) for time in range(25)), tuple(273.15 + np.array(temperatures)), ) - for month, temperatures in Geneva_hourly_temperatures_celsius_per_hour.items() + for month, temperatures in local_hourly_temperatures_celsius_per_hour.items() } # Same temperatures on a finer temperature mesh (every 6 minutes). GenevaTemperatures = { month: GenevaTemperatures_hourly[month].refine(refine_factor=10) - for month, temperatures in Geneva_hourly_temperatures_celsius_per_hour.items() + for month, temperatures in local_hourly_temperatures_celsius_per_hour.items() } diff --git a/cara/tests/test_known_quantities.py b/cara/tests/test_known_quantities.py index 907feead..3fbb456e 100644 --- a/cara/tests/test_known_quantities.py +++ b/cara/tests/test_known_quantities.py @@ -291,7 +291,7 @@ def build_hourly_dependent_model_multipleventilation(month, intervals_open=((7.5 @pytest.mark.parametrize( "month, temperatures", - data.Geneva_hourly_temperatures_celsius_per_hour.items(), + data.local_hourly_temperatures_celsius_per_hour.items(), ) @pytest.mark.parametrize( "time", @@ -306,7 +306,7 @@ def test_concentrations_hourly_dep_temp_vs_constant(month, temperatures, time): @pytest.mark.parametrize( "month, temperatures", - data.Geneva_hourly_temperatures_celsius_per_hour.items(), + data.local_hourly_temperatures_celsius_per_hour.items(), ) @pytest.mark.parametrize( "time", @@ -330,7 +330,7 @@ def test_concentrations_hourly_dep_multipleventilation(): @pytest.mark.parametrize( "month_temp_item", - data.Geneva_hourly_temperatures_celsius_per_hour.items(), + data.local_hourly_temperatures_celsius_per_hour.items(), ) @pytest.mark.parametrize( "time",