From 68d495ee8e8aeac26a7e523a984002f792719bea Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Fri, 28 Jan 2022 11:18:47 +0100 Subject: [PATCH] Move toronto temperatures into test_monte_carlo_full_models where it is used --- cara/data/__init__.py | 20 ---------------- cara/tests/test_monte_carlo_full_models.py | 27 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/cara/data/__init__.py b/cara/data/__init__.py index 6f1ddb0b..31195ba7 100644 --- a/cara/data/__init__.py +++ b/cara/data/__init__.py @@ -22,10 +22,6 @@ geneva_coordinates = (46.204391, 6.143158) local_hourly_temperatures_celsius_per_hour = get_hourly_temperatures_celsius_per_hour( geneva_coordinates) -# Load the weather data (temperature in kelvin) for Toronto. -toronto_coordinates = (43.667, 79.400) -toronto_hourly_temperatures_celsius_per_hour = get_hourly_temperatures_celsius_per_hour( - toronto_coordinates) # Geneva hourly temperatures as piecewise constant function (in Kelvin). GenevaTemperatures_hourly = { @@ -38,25 +34,9 @@ GenevaTemperatures_hourly = { for month, temperatures in local_hourly_temperatures_celsius_per_hour.items() } -# Toronto hourly temperatures as piecewise constant function (in Kelvin). -TorontoTemperatures_hourly = { - month: models.PiecewiseConstant( - # NOTE: It is important that the time type is float, not np.float, in - # order to allow hashability (for caching). - tuple(float(time) for time in range(25)), - tuple(273.15 + np.array(temperatures)), - ) - for month, temperatures in toronto_hourly_temperatures_celsius_per_hour.items() -} # Same Geneva temperatures on a finer temperature mesh (every 6 minutes). GenevaTemperatures = { month: GenevaTemperatures_hourly[month].refine(refine_factor=10) for month, temperatures in local_hourly_temperatures_celsius_per_hour.items() } - -# Same Toronto temperatures on a finer temperature mesh (every 6 minutes). -TorontoTemperatures = { - month: TorontoTemperatures_hourly[month].refine(refine_factor=10) - for month, temperatures in toronto_hourly_temperatures_celsius_per_hour.items() -} diff --git a/cara/tests/test_monte_carlo_full_models.py b/cara/tests/test_monte_carlo_full_models.py index e5c96b82..407ea37d 100644 --- a/cara/tests/test_monte_carlo_full_models.py +++ b/cara/tests/test_monte_carlo_full_models.py @@ -12,6 +12,31 @@ np.random.seed(2000) SAMPLE_SIZE = 250000 TOLERANCE = 0.05 +# Load the weather data (temperature in kelvin) for Toronto. +toronto_coordinates = (43.667, 79.400) +toronto_hourly_temperatures_celsius_per_hour = data.get_hourly_temperatures_celsius_per_hour( + toronto_coordinates) + + +# Toronto hourly temperatures as piecewise constant function (in Kelvin). +TorontoTemperatures_hourly = { + month: models.PiecewiseConstant( + # NOTE: It is important that the time type is float, not np.float, in + # order to allow hashability (for caching). + tuple(float(time) for time in range(25)), + tuple(273.15 + np.array(temperatures)), + ) + for month, temperatures in toronto_hourly_temperatures_celsius_per_hour.items() +} + + +# Same Toronto temperatures on a finer temperature mesh (every 6 minutes). +TorontoTemperatures = { + month: TorontoTemperatures_hourly[month].refine(refine_factor=10) + for month, temperatures in toronto_hourly_temperatures_celsius_per_hour.items() +} + + # references values for infection_probability and expected new cases # in the following tests, were obtained from the feature/mc branch @@ -69,7 +94,7 @@ def classroom_mc(): models.SlidingWindow( active=models.PeriodicInterval(period=120, duration=120), inside_temp=models.PiecewiseConstant((0., 24.), (293,)), - outside_temp=data.TorontoTemperatures['Dec'], + outside_temp=TorontoTemperatures['Dec'], window_height=1.6, opening_length=0.2, ),