diff --git a/README.md b/README.md index 7b3949b9..7853027d 100644 --- a/README.md +++ b/README.md @@ -58,19 +58,6 @@ CARA has not undergone review, approval or certification by competent authoritie The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. -## Adapting CARA to your location - -The default weather data (average hourly outdoor temperature in Celcius for each month of the year) used in CARA is for Geneva, Switzerland. -In order for the natural ventilation option to work correctly for other geographic locations, the outdoor temperatures must be updated. -There are some scripts to help download and process the temperature data from your nearest weather station in the https://gitlab.cern.ch/cara/climatology-data repository. -Once you have used the scripts, the hourly temperature data for your location should be added to the file `data.py` in place of the default values for Geneva. The temperature values for your locations should be pasted into the `Geneva_hourly_temperatures_celsius_per_hour` variable, **without changing the variable name** in the following format: - - `'1': [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], - '2': [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],...` - -CARA currently supports **only one geographic location for weather data per instance**. ## Running CARA locally diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index 702f4930..0d2f9c6c 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -3,7 +3,6 @@ from dataclasses import dataclass import html import logging import typing -import datetime import numpy as np @@ -312,10 +311,10 @@ class FormData: return models.MultipleVentilation((ventilation, infiltration_ventilation)) def nearest_weather_station(self) -> cara.data.weather.WxStationRecordType: - wx_station = cara.data.weather.nearest_wx_station( + """Return the nearest weather station (which has valid data) for this form""" + return cara.data.weather.nearest_wx_station( longitude=self.location_longitude, latitude=self.location_latitude ) - return wx_station def mask(self) -> models.Mask: # Initializes the mask type if mask wearing is "continuous", otherwise instantiates the mask attribute as @@ -719,5 +718,3 @@ for _field in dataclasses.fields(FormData): elif _field.type is bool: _CAST_RULES_FORM_ARG_TO_NATIVE[_field.name] = lambda v: v == '1' _CAST_RULES_NATIVE_TO_FORM_ARG[_field.name] = int - - diff --git a/cara/data/weather.py b/cara/data/weather.py index 37ecde76..f760ddc9 100644 --- a/cara/data/weather.py +++ b/cara/data/weather.py @@ -9,9 +9,7 @@ from scipy.spatial import cKDTree from cara import models -weather_debug = False - -DATA_LOCATION = Path(__file__).absolute().parent +WX_DATA_LOCATION = Path(__file__).absolute().parent WxStationIdType = str @@ -28,7 +26,7 @@ def wx_data() -> typing.Dict[WxStationIdType, typing.Dict[MonthType, HourlyTempT The data is structured by station location, and for each station location, by month. """ - with (DATA_LOCATION / 'global_weather_set.json').open("r") as json_file: + with (WX_DATA_LOCATION / 'global_weather_set.json').open("r") as json_file: data = json.load(json_file) for station in list(data.keys()): @@ -52,7 +50,7 @@ def wx_station_data() -> typing.Dict[WxStationIdType, WxStationRecordType]: weather_data = wx_data() station_data = {} fixed_delimits = [0, 12, 13, 44, 51, 60, 69, 90, 91] - station_file = DATA_LOCATION / 'hadisd_station_fullinfo_v311_202001p.txt' + station_file = WX_DATA_LOCATION / 'hadisd_station_fullinfo_v311_202001p.txt' for line in station_file.open('rt'): start_end_positions = zip(fixed_delimits[:-1], fixed_delimits[1:]) @@ -86,6 +84,7 @@ def mean_hourly_temperatures(wx_station: str, month: int) -> HourlyTempType: Index 0 of the result corresponds to hour 00:00-01:00, and index 23 (the last) to 23:00-00:00. """ + # Note that the current dataset encodes month number as a string. return wx_data()[wx_station][str(month)]