From 98646533784f1a02afc9ecaa4da5135841085e6d Mon Sep 17 00:00:00 2001 From: ettore zanetti Date: Mon, 13 May 2024 20:35:40 -0700 Subject: [PATCH 1/4] Add missing weather variable warning to data_manager --- data/data_manager.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/data/data_manager.py b/data/data_manager.py index cba49c4f0..b8ef6ea5a 100644 --- a/data/data_manager.py +++ b/data/data_manager.py @@ -427,7 +427,8 @@ def load_data_and_jsons(self): # Get zone and boundary data keys allowed zon_keys, bou_keys = self._get_zone_and_boundary_keys() - + weather_keys = list(self.categories['weather'].keys()) + # Initialize test case data frame self.case.data = \ pd.DataFrame(index=index).rename_axis('time') @@ -436,6 +437,13 @@ def load_data_and_jsons(self): for f in files: df = pd.read_csv(z_fmu.open(f)) cols = df.keys() + + # Check if all weather variables are included in weather.csv + if 'weather' in f: + if not set(cols) <= set(weather_keys): + warnings.warn('The file weather.csv is missing '\ + 'the following variables '+str(set(weather_keys).difference(set(cols)))+'.', Warning) + if 'time' in cols: for col in cols.drop('time'): # Check that column has any of the allowed data keys From 45134e8b0c2b27e0c50633e89fa318d912d4e12b Mon Sep 17 00:00:00 2001 From: ettore zanetti Date: Mon, 13 May 2024 20:43:14 -0700 Subject: [PATCH 2/4] Update release notes --- releasenotes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes.md b/releasenotes.md index 524d922df..a9995380f 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -8,7 +8,7 @@ Released on xx/xx/xxxx. - Update pyfmi version from 2.11 to 2.12 and miniconda version from py310_23.1.0-1-Linux-x86_64 to py310_24.3.0-0-Linux-x86_64. This is for [#643](https://github.com/ibpsa/project1-boptest/issues/643). - Remove support and unit testing of example python controllers using Python 2. This is for [#634](https://github.com/ibpsa/project1-boptest/issues/634). - +- Add a warning message in ``data/data_manager.py`` that is displayed if any of the weather variables in ``data/categories.json`` is not in ``wrapped.fmu/resources/weather.csv``. This is for [#500](https://github.com/ibpsa/project1-boptest/issues/500). ## BOPTEST v0.6.0 From 28b2aa71a626bcbf8c1cf7331d0bcd3018b8815d Mon Sep 17 00:00:00 2001 From: Ettore Zanetti Date: Tue, 14 May 2024 08:37:52 -0700 Subject: [PATCH 3/4] Moved warning to _append_csv_data and update release notes --- data/data_manager.py | 16 +++++++++------- releasenotes.md | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/data/data_manager.py b/data/data_manager.py index b8ef6ea5a..3e911648c 100644 --- a/data/data_manager.py +++ b/data/data_manager.py @@ -146,12 +146,20 @@ def _append_csv_data(self): # Get zone and boundary data keys allowed zon_keys, bou_keys = self._get_zone_and_boundary_keys() + weather_keys = list(self.categories['weather'].keys()) # Search for .csv files in the resources folder for f in self.files: if f.endswith('.csv'): df = pd.read_csv(f, comment='#') cols = df.keys() + + # Check if all weather variables are included in weather.csv + if 'weather' in f: + if not set(cols) <= set(weather_keys): + warnings.warn('The file weather.csv is missing '\ + 'the following variables '+str(set(weather_keys).difference(set(cols)))+'.', Warning) + if 'time' in cols: for col in cols.drop('time'): # Raise error if col already appended @@ -427,7 +435,7 @@ def load_data_and_jsons(self): # Get zone and boundary data keys allowed zon_keys, bou_keys = self._get_zone_and_boundary_keys() - weather_keys = list(self.categories['weather'].keys()) + # Initialize test case data frame self.case.data = \ @@ -437,12 +445,6 @@ def load_data_and_jsons(self): for f in files: df = pd.read_csv(z_fmu.open(f)) cols = df.keys() - - # Check if all weather variables are included in weather.csv - if 'weather' in f: - if not set(cols) <= set(weather_keys): - warnings.warn('The file weather.csv is missing '\ - 'the following variables '+str(set(weather_keys).difference(set(cols)))+'.', Warning) if 'time' in cols: for col in cols.drop('time'): diff --git a/releasenotes.md b/releasenotes.md index a9995380f..0820d1055 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -8,7 +8,7 @@ Released on xx/xx/xxxx. - Update pyfmi version from 2.11 to 2.12 and miniconda version from py310_23.1.0-1-Linux-x86_64 to py310_24.3.0-0-Linux-x86_64. This is for [#643](https://github.com/ibpsa/project1-boptest/issues/643). - Remove support and unit testing of example python controllers using Python 2. This is for [#634](https://github.com/ibpsa/project1-boptest/issues/634). -- Add a warning message in ``data/data_manager.py`` that is displayed if any of the weather variables in ``data/categories.json`` is not in ``wrapped.fmu/resources/weather.csv``. This is for [#500](https://github.com/ibpsa/project1-boptest/issues/500). +- Add a warning message upon test case compilation in ``data/data_manager.py`` that is displayed if any of the weather variables in ``data/categories.json`` is not in ``wrapped.fmu/resources/weather.csv``. This is for [#500](https://github.com/ibpsa/project1-boptest/issues/500). ## BOPTEST v0.6.0 From a1a54d4db48884b5de06c5659f7d7b3137ab908e Mon Sep 17 00:00:00 2001 From: Ettore Zanetti Date: Tue, 14 May 2024 08:39:43 -0700 Subject: [PATCH 4/4] Update release notes --- releasenotes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes.md b/releasenotes.md index 0820d1055..8cea7a331 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -8,7 +8,7 @@ Released on xx/xx/xxxx. - Update pyfmi version from 2.11 to 2.12 and miniconda version from py310_23.1.0-1-Linux-x86_64 to py310_24.3.0-0-Linux-x86_64. This is for [#643](https://github.com/ibpsa/project1-boptest/issues/643). - Remove support and unit testing of example python controllers using Python 2. This is for [#634](https://github.com/ibpsa/project1-boptest/issues/634). -- Add a warning message upon test case compilation in ``data/data_manager.py`` that is displayed if any of the weather variables in ``data/categories.json`` is not in ``wrapped.fmu/resources/weather.csv``. This is for [#500](https://github.com/ibpsa/project1-boptest/issues/500). +- Add a warning message upon test case compilation in ``data/data_manager.py`` that is displayed if any of the weather variables in ``data/categories.json`` is not in ``/resources/weather.csv``. This is for [#500](https://github.com/ibpsa/project1-boptest/issues/500). ## BOPTEST v0.6.0