From fe45bbc5b2b0e873bfa2b676fcb943a1f7252b2a Mon Sep 17 00:00:00 2001 From: Alejandro Campoy Nieves Date: Fri, 27 Sep 2024 15:41:56 +0200 Subject: [PATCH] (v3.6.2) - EPW processing: Replace opyplus module by epw (#450) * Poetry: opyplus dependency replaced by epw module * Common: deleted commented opyplus import and function * Modeling: Replace opyplus functionality by epw module * Update environemts configuration weather variable names (in mock test too) * Update Sinergym version from 3.6.1 to 3.6.2 * Fix tests * Documentation: Update epw variable names list * Updating comment in modeling --- docs/source/pages/environments.rst | 26 ++++++- poetry.lock | 69 ++++--------------- pyproject.toml | 4 +- sinergym/config/modeling.py | 23 +++---- .../1ZoneDataCenterCRAC_wApproachTemp.json | 2 +- .../2ZoneDataCenterHVAC_wEconomizer.json | 2 +- .../default_configuration/5ZoneAutoDXVAV.json | 2 +- ...ASHRAE901_OfficeMedium_STD2019_Denver.json | 2 +- .../ASHRAE901_Warehouse_STD2019_Denver.json | 2 +- .../LrgOff_GridStorageScheduled.json | 2 +- .../ShopWithPVandBattery.json | 2 +- .../radiant_residential_building.json | 2 +- sinergym/utils/common.py | 15 ---- sinergym/version.txt | 2 +- tests/conftest.py | 22 ++++-- .../5ZoneAutoDXVAV.json | 2 +- .../5ZoneAutoDXVAV_exception1.json | 2 +- .../5ZoneAutoDXVAV_exception2.json | 2 +- .../5ZoneAutoDXVAV_exception3.json | 2 +- .../5ZoneAutoDXVAV_exception4.json | 2 +- .../5ZoneAutoDXVAV_exception5.json | 2 +- .../5ZoneAutoDXVAV_exception6.json | 4 +- tests/test_env.py | 5 +- tests/test_modeling.py | 25 ++++--- 24 files changed, 98 insertions(+), 125 deletions(-) diff --git a/docs/source/pages/environments.rst b/docs/source/pages/environments.rst index b1ec9f548c..94ce15b31c 100644 --- a/docs/source/pages/environments.rst +++ b/docs/source/pages/environments.rst @@ -95,9 +95,29 @@ to introduce **noise** to the weather data episode to episode. Then, the paramet established is a Python dictionary with the EPW column name as key and tuple of three variables (*sigma*, *mu*, and *tau*) whose as value, defining the nature of that noise. This allows to apply different noise in several aspects of the weather data. -.. note:: The weather data columns or variables names is generated with opyplus WeatherData class, - for more information about the available variables in an EPW file, visit - `Opyplus documentation `__. +Since Sinergym v3.6.2, the weather data columns or variables names is generated with +`epw module Weather class `__, the list of the +available variable names is the next: + +- ``Year``, ``Month``, ``Day``, ``Hour``, ``Minute``, + ``Data Source and Uncertainty Flags``, ``Dry Bulb Temperature``, + ``Dew Point Temperature``, ``Relative Humidity``, + ``Atmospheric Station Pressure``, ``Extraterrestrial Horizontal Radiation``, + ``Extraterrestrial Direct Normal Radiation``, + ``Horizontal Infrared Radiation Intensity``, + ``Global Horizontal Radiation``, ``Direct Normal Radiation``, + ``Diffuse Horizontal Radiation``, ``Global Horizontal Illuminance``, + ``Direct Normal Illuminance``, ``Diffuse Horizontal Illuminance``, + ``Zenith Luminance``, ``Wind Direction``, ``Wind Speed``, ``Total Sky Cover``, + ``Opaque Sky Cover (used if Horizontal IR Intensity missing)``, + ``Visibility``, ``Ceiling Height``, ``Present Weather Observation``, + ``Present Weather Codes``, ``Precipitable Water``, ``Aerosol Optical Depth``, + ``Snow Depth``, ``Days Since Last Snowfall``, ``Albedo``, + ``Liquid Precipitation Depth``, ``Liquid Precipitation Quantity`` + +If you are using an older version of Sinergym, the weather data columns or variables names is generated with +*opyplus WeatherData class*, for more information about the available variable names with opyplus, visit +`Opyplus documentation `__. .. image:: /_static/ornstein_noise.png :scale: 80 % diff --git a/poetry.lock b/poetry.lock index df05246a9c..2df15a7dbb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -604,6 +604,17 @@ tinynumpy = ">=1.2.1" [package.extras] testing = ["pytest"] +[[package]] +name = "epw" +version = "1.2.dev2" +description = "EnergyPlus wrapper for Python" +optional = false +python-versions = "*" +files = [ + {file = "epw-1.2.dev2-py3-none-any.whl", hash = "sha256:bab66221fb46ea6cbc39b6cd8339e7193fe6fe336a60fbd5205c59f06a47ef5d"}, + {file = "epw-1.2.dev2.tar.gz", hash = "sha256:a7a25fc6d565843e4b8d7a83e7998645a8adf5c512ed445493bb6d3642983966"}, +] + [[package]] name = "execnet" version = "2.1.1" @@ -2243,23 +2254,6 @@ pyasn1-modules = ">=0.0.5" rsa = ">=3.1.4" six = ">=1.6.1" -[[package]] -name = "opyplus" -version = "2.0.7" -description = "Python package to work with Energyplus input and output" -optional = false -python-versions = "*" -files = [ - {file = "opyplus-2.0.7-py3-none-any.whl", hash = "sha256:e2d56a63e4ab5b0cc7aff2efc2a41cd8a5b5a8650eb43502de3fdb8a99c18d00"}, - {file = "opyplus-2.0.7.tar.gz", hash = "sha256:989fad25effa25aefdd9ed8ea1f8327e7801a5f316116721caca68b7f0e362e0"}, -] - -[package.dependencies] -charset-normalizer = ">=3.2.0,<4.0" -pandas = ">=1.5.0,<3.0.0" -python-slugify = ">=3.0.2,<6.0" -unidecode = ">=1.0.22,<2.0" - [[package]] name = "packaging" version = "24.1" @@ -2860,23 +2854,6 @@ files = [ [package.dependencies] six = ">=1.5" -[[package]] -name = "python-slugify" -version = "5.0.2" -description = "A Python Slugify application that handles Unicode" -optional = false -python-versions = ">=3.6" -files = [ - {file = "python-slugify-5.0.2.tar.gz", hash = "sha256:f13383a0b9fcbe649a1892b9c8eb4f8eab1d6d84b84bb7a624317afa98159cab"}, - {file = "python_slugify-5.0.2-py2.py3-none-any.whl", hash = "sha256:6d8c5df75cd4a7c3a2d21e257633de53f52ab0265cd2d1dc62a730e8194a7380"}, -] - -[package.dependencies] -text-unidecode = ">=1.3" - -[package.extras] -unidecode = ["Unidecode (>=1.1.1)"] - [[package]] name = "pytype" version = "2024.9.13" @@ -3798,17 +3775,6 @@ files = [ [package.extras] widechars = ["wcwidth"] -[[package]] -name = "text-unidecode" -version = "1.3" -description = "The most basic Text::Unidecode port" -optional = false -python-versions = "*" -files = [ - {file = "text-unidecode-1.3.tar.gz", hash = "sha256:bad6603bb14d279193107714b288be206cac565dfa49aa5b105294dd5c4aab93"}, - {file = "text_unidecode-1.3-py2.py3-none-any.whl", hash = "sha256:1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8"}, -] - [[package]] name = "tinycss2" version = "1.3.0" @@ -4001,17 +3967,6 @@ files = [ {file = "tzdata-2024.2.tar.gz", hash = "sha256:7d85cc416e9382e69095b7bdf4afd9e3880418a2413feec7069d533d6b4e31cc"}, ] -[[package]] -name = "unidecode" -version = "1.3.8" -description = "ASCII transliterations of Unicode text" -optional = false -python-versions = ">=3.5" -files = [ - {file = "Unidecode-1.3.8-py3-none-any.whl", hash = "sha256:d130a61ce6696f8148a3bd8fe779c99adeb4b870584eeb9526584e9aa091fd39"}, - {file = "Unidecode-1.3.8.tar.gz", hash = "sha256:cfdb349d46ed3873ece4586b96aa75258726e2fa8ec21d6f00a591d98806c2f4"}, -] - [[package]] name = "uritemplate" version = "4.1.1" @@ -4126,4 +4081,4 @@ test = ["coverage", "pytest", "pytest-cov", "pytest-xdist", "wandb"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "d18d12e759f463390fd5cea3aec52d53831188c574d2c94adfaa09376696455c" +content-hash = "2bc2cd32a5788aa4329d654956e469a383b43f249ffa6d6514e0c21d148ffac0" diff --git a/pyproject.toml b/pyproject.toml index 9f7b771535..e704c26037 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ package-mode = true name = "sinergym" -version = "3.6.1" +version = "3.6.2" description = "The goal of sinergym is to create an environment following OpenAI Gym interface for wrapping simulation engines for building control using deep reinforcement learning." license = "MIT" @@ -62,7 +62,7 @@ pandas = "^2.2.2" eppy = "^0.5.63" tqdm = "^4.66.5" xlsxwriter = "^3.2.0" -opyplus = "^2.0.7" +epw = "^1.2.dev2" # Extra dependencies (optional) pytest = { version = "^8.3.3", optional = true } diff --git a/sinergym/config/modeling.py b/sinergym/config/modeling.py index 1c7ddfa556..e6e5370869 100644 --- a/sinergym/config/modeling.py +++ b/sinergym/config/modeling.py @@ -9,7 +9,7 @@ import numpy as np from eppy.modeleditor import IDF -from opyplus import WeatherData +from epw.weather import Weather from sinergym.utils.common import eppy_element_to_dict, get_delta_seconds from sinergym.utils.constants import (CWD, LOG_MODEL_LEVEL, PKG_DATA_PATH, @@ -34,7 +34,7 @@ class ModelJSON(object): :param config: Dict config with extra configuration which is required to modify building model (may be None). :param building: Building model (Dictionary extracted from JSON). :param ddy_model: eppy object with DDY model. - :param weather_data: opyplus WeatherData object with EPW data. + :param weather_data: epw module Weather class instance with EPW data. :param zone_names: List of the zone names available in the building. :param schedulers: Information in Dict format about all building schedulers. :param runperiod: Information in Dict format about runperiod that determine an episode. @@ -99,8 +99,9 @@ def __init__( IDF.setiddname(self._idd) self.ddy_model = IDF(self._ddy_path) - # Weather data (opyplus object) - self.weather_data = WeatherData.from_epw(self._weather_path) + # Weather data (epw.weather object) + self.weather_data = Weather() + self.weather_data.read(self._weather_path) # ----------------------------- Other attributes ----------------------------- # @@ -309,7 +310,7 @@ def update_weather_path(self) -> None: self.pkg_data_path, 'weather', random.choice(self.weather_files)) self._ddy_path = self._weather_path.split('.epw')[0] + '.ddy' self.ddy_model = IDF(self._ddy_path) - self.weather_data = WeatherData.from_epw(self._weather_path) + self.weather_data.read(self._weather_path) self.logger.info( 'Weather file {} used.'.format( self._weather_path.split('/')[-1])) @@ -332,14 +333,11 @@ def apply_weather_variability( # Apply variation to EPW if exists if weather_variability is not None: - # Get dataframe with weather series - df = weather_data_mod.get_weather_series() - T = 1. # Total time. # All the columns are going to have the same num of rows since they are # in the same dataframe # get first column of df - n = df.shape[0] + n = weather_data_mod.dataframe.shape[0] dt = T / n # t = np.linspace(0., T, n) # Vector of times. @@ -359,10 +357,7 @@ def apply_weather_variability( sigma_bis * sqrtdt * np.random.randn() # Add noise - df[variable] += noise - - # Save new weather data - weather_data_mod.set_weather_series(df) + weather_data_mod.dataframe[variable] += noise self.logger.info( 'Weather noise applied in columns: {}'.format( @@ -374,7 +369,7 @@ def apply_weather_variability( filename += '_OU_Noise.epw' episode_weather_path = self.episode_path + '/' + filename - weather_data_mod.to_epw(episode_weather_path) + weather_data_mod.write(episode_weather_path) self.logger.debug( 'Saving episode weather path... [{}]'.format(episode_weather_path)) diff --git a/sinergym/data/default_configuration/1ZoneDataCenterCRAC_wApproachTemp.json b/sinergym/data/default_configuration/1ZoneDataCenterCRAC_wApproachTemp.json index 3c820bc3b9..3d4fb5cd8f 100644 --- a/sinergym/data/default_configuration/1ZoneDataCenterCRAC_wApproachTemp.json +++ b/sinergym/data/default_configuration/1ZoneDataCenterCRAC_wApproachTemp.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/sinergym/data/default_configuration/2ZoneDataCenterHVAC_wEconomizer.json b/sinergym/data/default_configuration/2ZoneDataCenterHVAC_wEconomizer.json index 7516e5b419..051a9a4dac 100644 --- a/sinergym/data/default_configuration/2ZoneDataCenterHVAC_wEconomizer.json +++ b/sinergym/data/default_configuration/2ZoneDataCenterHVAC_wEconomizer.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/sinergym/data/default_configuration/5ZoneAutoDXVAV.json b/sinergym/data/default_configuration/5ZoneAutoDXVAV.json index 47272c2d19..44f4af250d 100644 --- a/sinergym/data/default_configuration/5ZoneAutoDXVAV.json +++ b/sinergym/data/default_configuration/5ZoneAutoDXVAV.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/sinergym/data/default_configuration/ASHRAE901_OfficeMedium_STD2019_Denver.json b/sinergym/data/default_configuration/ASHRAE901_OfficeMedium_STD2019_Denver.json index 42f3a10dc7..90400715ec 100644 --- a/sinergym/data/default_configuration/ASHRAE901_OfficeMedium_STD2019_Denver.json +++ b/sinergym/data/default_configuration/ASHRAE901_OfficeMedium_STD2019_Denver.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/sinergym/data/default_configuration/ASHRAE901_Warehouse_STD2019_Denver.json b/sinergym/data/default_configuration/ASHRAE901_Warehouse_STD2019_Denver.json index 2ae406f5ca..d5ef40f4f9 100644 --- a/sinergym/data/default_configuration/ASHRAE901_Warehouse_STD2019_Denver.json +++ b/sinergym/data/default_configuration/ASHRAE901_Warehouse_STD2019_Denver.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/sinergym/data/default_configuration/LrgOff_GridStorageScheduled.json b/sinergym/data/default_configuration/LrgOff_GridStorageScheduled.json index 1c714520e9..a851710130 100644 --- a/sinergym/data/default_configuration/LrgOff_GridStorageScheduled.json +++ b/sinergym/data/default_configuration/LrgOff_GridStorageScheduled.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/sinergym/data/default_configuration/ShopWithPVandBattery.json b/sinergym/data/default_configuration/ShopWithPVandBattery.json index 1eaec39e3d..2354b2c490 100644 --- a/sinergym/data/default_configuration/ShopWithPVandBattery.json +++ b/sinergym/data/default_configuration/ShopWithPVandBattery.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/sinergym/data/default_configuration/radiant_residential_building.json b/sinergym/data/default_configuration/radiant_residential_building.json index 1fba88728e..96ba94ed65 100644 --- a/sinergym/data/default_configuration/radiant_residential_building.json +++ b/sinergym/data/default_configuration/radiant_residential_building.json @@ -15,7 +15,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/sinergym/utils/common.py b/sinergym/utils/common.py index 5781c40ba3..9c0674536f 100644 --- a/sinergym/utils/common.py +++ b/sinergym/utils/common.py @@ -13,8 +13,6 @@ from sinergym.utils.logger import TerminalLogger from sinergym.utils.rewards import * -# from opyplus.epgm.record import Record - logger = TerminalLogger().getLogger( name='COMMON', level=LOG_COMMON_LEVEL) @@ -413,16 +411,3 @@ def convert_conf_to_env_parameters( # if np.max(data[column]) > result[column][1]: # result[column][1] = np.max(data[column]) # return result - - -# def get_record_keys(record: Record) -> List[str]: -# """Given an opyplus Epm Record (one element from opyplus.epm object) this function returns list of keys (opyplus hasn't got this functionality explicitly) - -# Args: -# record (opyplus.Epm.Record): Element from Epm object. - -# Returns: -# List[str]: Key list from record. -# """ -# return [field.ref for field in -# record._table._dev_descriptor._field_descriptors] diff --git a/sinergym/version.txt b/sinergym/version.txt index d1428a7e96..77a069e39b 100644 --- a/sinergym/version.txt +++ b/sinergym/version.txt @@ -1 +1 @@ -3.6.1 \ No newline at end of file +3.6.2 \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index a04c072a85..ded61023fb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,7 +5,7 @@ import pkg_resources import pytest -from opyplus import WeatherData +from epw.weather import Weather import sinergym from sinergym.config.modeling import ModelJSON @@ -357,7 +357,11 @@ def env_5zone_stochastic( variables=VARIABLES_5ZONE, meters=METERS_5ZONE, actuators=ACTUATORS_5ZONE, - weather_variability={'drybulb': (1.0, 0.0, 0.001)}, + weather_variability={ + 'Dry Bulb Temperature': ( + 1.0, + 0.0, + 0.001)}, reward=LinearReward, reward_kwargs={ 'temperature_variables': ['air_temperature'], @@ -370,9 +374,13 @@ def env_5zone_stochastic( 26.0)}, env_name='TESTGYM', config_params={ - 'runperiod': (1, 1, 1991, 31, 3, 1991) - } - ) + 'runperiod': ( + 1, + 1, + 1991, + 31, + 3, + 1991)}) return env @@ -595,7 +603,9 @@ def building(json_path_5zone): @ pytest.fixture(scope='function') def weather_data(weather_path_pittsburgh): - return WeatherData.from_epw(weather_path_pittsburgh) + weather_data = Weather() + weather_data.read(weather_path_pittsburgh) + return weather_data # ---------------------------------------------------------------------------- # # Rewards # diff --git a/tests/mock/environment_configurations/5ZoneAutoDXVAV.json b/tests/mock/environment_configurations/5ZoneAutoDXVAV.json index cc0d62ce90..117d2075a0 100644 --- a/tests/mock/environment_configurations/5ZoneAutoDXVAV.json +++ b/tests/mock/environment_configurations/5ZoneAutoDXVAV.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception1.json b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception1.json index 5ec0bd23a4..0dbe16afd0 100644 --- a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception1.json +++ b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception1.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception2.json b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception2.json index 32d2f58379..6584970b95 100644 --- a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception2.json +++ b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception2.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception3.json b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception3.json index f782502d98..dd0b9b6334 100644 --- a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception3.json +++ b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception3.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception4.json b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception4.json index 745281f5e4..9d15b3d952 100644 --- a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception4.json +++ b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception4.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception5.json b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception5.json index c02766e344..86a4de8651 100644 --- a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception5.json +++ b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception5.json @@ -14,7 +14,7 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0, 0.001] + "Dry Bulb Temperature": [1.0, 0.0, 0.001] }, "max_ep_data_store_num" : 10, diff --git a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception6.json b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception6.json index 16067246fe..df5da14a0f 100644 --- a/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception6.json +++ b/tests/mock/environment_configurations/5ZoneAutoDXVAV_exception6.json @@ -14,8 +14,8 @@ "config_params" : null, "weather_variability":{ - "drybulb": [1.0, 0.0], - "windspd": [3.0, 0.0, 0.01] + "Dry Bulb Temperature": [1.0, 0.0], + "Wind Speed": [3.0, 0.0, 0.01] }, "max_ep_data_store_num" : 10, diff --git a/tests/test_env.py b/tests/test_env.py index fa232c6212..c71636371d 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -48,7 +48,10 @@ def test_reset_custom_options(env_5zone_stochastic): 'default_options')['weather_variability'], dict) assert len(env_5zone_stochastic.get_wrapper_attr( 'default_options')['weather_variability']) == 1 - custom_options = {'weather_variability': {'drybulb': (1.1, 0.1, 0.002)}} + custom_options = { + 'weather_variability': { + 'Dry Bulb Temperature': ( + 1.1, 0.1, 0.002)}} env_5zone_stochastic.reset(options=custom_options) # Check if epw with new variation is overwriting default options weather_path = env_5zone_stochastic.model._weather_path diff --git a/tests/test_modeling.py b/tests/test_modeling.py index 7bb58c9365..19c4bb280a 100644 --- a/tests/test_modeling.py +++ b/tests/test_modeling.py @@ -2,7 +2,7 @@ import os import pytest -from opyplus import WeatherData +from epw.weather import Weather from sinergym.utils.constants import WEEKDAY_ENCODING @@ -202,8 +202,8 @@ def test_apply_weather_variability(model_5zone): assert original_filename == path_filename # Check with a variation weather_variability = { - 'drybulb': (1.0, 0.0, 0.001), - 'windspd': (3.0, 0.0, 0.01) + 'Dry Bulb Temperature': (1.0, 0.0, 0.001), + 'Wind Speed': (3.0, 0.0, 0.01) } path_result = model_5zone.apply_weather_variability( weather_variability=weather_variability) @@ -215,15 +215,20 @@ def test_apply_weather_variability(model_5zone): # Check that path exists assert os.path.exists(path_result) # Lets load the original weather file and the new one - df_original = WeatherData.from_epw( - model_5zone._weather_path).get_weather_series() - df_noise = WeatherData.from_epw(path_result).get_weather_series() + original = Weather() + original.read(model_5zone._weather_path) + noise = Weather() + noise.read(path_result) # Check that the noise is applied in drybulb and windspd columns and not # in others - assert (df_original['drybulb'] != df_noise['drybulb']).any() - assert (df_original['windspd'] != df_noise['windspd']).any() - assert (df_original['relhum'] == df_noise['relhum']).all() - assert (df_original['winddir'] == df_noise['winddir']).all() + assert (original.dataframe['Dry Bulb Temperature'] + != noise.dataframe['Dry Bulb Temperature']).any() + assert (original.dataframe['Wind Speed'] != + noise.dataframe['Wind Speed']).any() + assert (original.dataframe['Relative Humidity'] + == noise.dataframe['Relative Humidity']).all() + assert (original.dataframe['Wind Direction'] == + noise.dataframe['Wind Direction']).all() # ---------------------------------------------------------------------------- # # Schedulers info extraction #