Skip to content

Commit fe45bbc

Browse files
authored
(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
1 parent e676657 commit fe45bbc

24 files changed

+98
-125
lines changed

docs/source/pages/environments.rst

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,29 @@ to introduce **noise** to the weather data episode to episode. Then, the paramet
9595
established is a Python dictionary with the EPW column name as key and tuple of three variables (*sigma*, *mu*, and *tau*) whose
9696
as value, defining the nature of that noise. This allows to apply different noise in several aspects of the weather data.
9797

98-
.. note:: The weather data columns or variables names is generated with opyplus WeatherData class,
99-
for more information about the available variables in an EPW file, visit
100-
`Opyplus documentation <https://opyplus.readthedocs.io/en/2.0.7/quickstart/index.html#weather-data-epw-file>`__.
98+
Since Sinergym v3.6.2, the weather data columns or variables names is generated with
99+
`epw module Weather class <https://pypi.org/project/epw/>`__, the list of the
100+
available variable names is the next:
101+
102+
- ``Year``, ``Month``, ``Day``, ``Hour``, ``Minute``,
103+
``Data Source and Uncertainty Flags``, ``Dry Bulb Temperature``,
104+
``Dew Point Temperature``, ``Relative Humidity``,
105+
``Atmospheric Station Pressure``, ``Extraterrestrial Horizontal Radiation``,
106+
``Extraterrestrial Direct Normal Radiation``,
107+
``Horizontal Infrared Radiation Intensity``,
108+
``Global Horizontal Radiation``, ``Direct Normal Radiation``,
109+
``Diffuse Horizontal Radiation``, ``Global Horizontal Illuminance``,
110+
``Direct Normal Illuminance``, ``Diffuse Horizontal Illuminance``,
111+
``Zenith Luminance``, ``Wind Direction``, ``Wind Speed``, ``Total Sky Cover``,
112+
``Opaque Sky Cover (used if Horizontal IR Intensity missing)``,
113+
``Visibility``, ``Ceiling Height``, ``Present Weather Observation``,
114+
``Present Weather Codes``, ``Precipitable Water``, ``Aerosol Optical Depth``,
115+
``Snow Depth``, ``Days Since Last Snowfall``, ``Albedo``,
116+
``Liquid Precipitation Depth``, ``Liquid Precipitation Quantity``
117+
118+
If you are using an older version of Sinergym, the weather data columns or variables names is generated with
119+
*opyplus WeatherData class*, for more information about the available variable names with opyplus, visit
120+
`Opyplus documentation <https://opyplus.readthedocs.io/en/2.0.7/quickstart/index.html#weather-data-epw-file>`__.
101121

102122
.. image:: /_static/ornstein_noise.png
103123
:scale: 80 %

poetry.lock

Lines changed: 12 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package-mode = true
77
name = "sinergym"
88

9-
version = "3.6.1"
9+
version = "3.6.2"
1010
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."
1111
license = "MIT"
1212

@@ -62,7 +62,7 @@ pandas = "^2.2.2"
6262
eppy = "^0.5.63"
6363
tqdm = "^4.66.5"
6464
xlsxwriter = "^3.2.0"
65-
opyplus = "^2.0.7"
65+
epw = "^1.2.dev2"
6666

6767
# Extra dependencies (optional)
6868
pytest = { version = "^8.3.3", optional = true }

sinergym/config/modeling.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import numpy as np
1111
from eppy.modeleditor import IDF
12-
from opyplus import WeatherData
12+
from epw.weather import Weather
1313

1414
from sinergym.utils.common import eppy_element_to_dict, get_delta_seconds
1515
from sinergym.utils.constants import (CWD, LOG_MODEL_LEVEL, PKG_DATA_PATH,
@@ -34,7 +34,7 @@ class ModelJSON(object):
3434
:param config: Dict config with extra configuration which is required to modify building model (may be None).
3535
:param building: Building model (Dictionary extracted from JSON).
3636
:param ddy_model: eppy object with DDY model.
37-
:param weather_data: opyplus WeatherData object with EPW data.
37+
:param weather_data: epw module Weather class instance with EPW data.
3838
:param zone_names: List of the zone names available in the building.
3939
:param schedulers: Information in Dict format about all building schedulers.
4040
:param runperiod: Information in Dict format about runperiod that determine an episode.
@@ -99,8 +99,9 @@ def __init__(
9999
IDF.setiddname(self._idd)
100100
self.ddy_model = IDF(self._ddy_path)
101101

102-
# Weather data (opyplus object)
103-
self.weather_data = WeatherData.from_epw(self._weather_path)
102+
# Weather data (epw.weather object)
103+
self.weather_data = Weather()
104+
self.weather_data.read(self._weather_path)
104105

105106
# ----------------------------- Other attributes ----------------------------- #
106107

@@ -309,7 +310,7 @@ def update_weather_path(self) -> None:
309310
self.pkg_data_path, 'weather', random.choice(self.weather_files))
310311
self._ddy_path = self._weather_path.split('.epw')[0] + '.ddy'
311312
self.ddy_model = IDF(self._ddy_path)
312-
self.weather_data = WeatherData.from_epw(self._weather_path)
313+
self.weather_data.read(self._weather_path)
313314
self.logger.info(
314315
'Weather file {} used.'.format(
315316
self._weather_path.split('/')[-1]))
@@ -332,14 +333,11 @@ def apply_weather_variability(
332333
# Apply variation to EPW if exists
333334
if weather_variability is not None:
334335

335-
# Get dataframe with weather series
336-
df = weather_data_mod.get_weather_series()
337-
338336
T = 1. # Total time.
339337
# All the columns are going to have the same num of rows since they are
340338
# in the same dataframe
341339
# get first column of df
342-
n = df.shape[0]
340+
n = weather_data_mod.dataframe.shape[0]
343341
dt = T / n
344342
# t = np.linspace(0., T, n) # Vector of times.
345343

@@ -359,10 +357,7 @@ def apply_weather_variability(
359357
sigma_bis * sqrtdt * np.random.randn()
360358

361359
# Add noise
362-
df[variable] += noise
363-
364-
# Save new weather data
365-
weather_data_mod.set_weather_series(df)
360+
weather_data_mod.dataframe[variable] += noise
366361

367362
self.logger.info(
368363
'Weather noise applied in columns: {}'.format(
@@ -374,7 +369,7 @@ def apply_weather_variability(
374369
filename += '_OU_Noise.epw'
375370

376371
episode_weather_path = self.episode_path + '/' + filename
377-
weather_data_mod.to_epw(episode_weather_path)
372+
weather_data_mod.write(episode_weather_path)
378373

379374
self.logger.debug(
380375
'Saving episode weather path... [{}]'.format(episode_weather_path))

sinergym/data/default_configuration/1ZoneDataCenterCRAC_wApproachTemp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"config_params" : null,
1515

1616
"weather_variability":{
17-
"drybulb": [1.0, 0.0, 0.001]
17+
"Dry Bulb Temperature": [1.0, 0.0, 0.001]
1818
},
1919

2020
"max_ep_data_store_num" : 10,

sinergym/data/default_configuration/2ZoneDataCenterHVAC_wEconomizer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"config_params" : null,
1515

1616
"weather_variability":{
17-
"drybulb": [1.0, 0.0, 0.001]
17+
"Dry Bulb Temperature": [1.0, 0.0, 0.001]
1818
},
1919

2020
"max_ep_data_store_num" : 10,

sinergym/data/default_configuration/5ZoneAutoDXVAV.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"config_params" : null,
1515

1616
"weather_variability":{
17-
"drybulb": [1.0, 0.0, 0.001]
17+
"Dry Bulb Temperature": [1.0, 0.0, 0.001]
1818
},
1919

2020
"max_ep_data_store_num" : 10,

sinergym/data/default_configuration/ASHRAE901_OfficeMedium_STD2019_Denver.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"config_params" : null,
1515

1616
"weather_variability":{
17-
"drybulb": [1.0, 0.0, 0.001]
17+
"Dry Bulb Temperature": [1.0, 0.0, 0.001]
1818
},
1919

2020
"max_ep_data_store_num" : 10,

sinergym/data/default_configuration/ASHRAE901_Warehouse_STD2019_Denver.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"config_params" : null,
1515

1616
"weather_variability":{
17-
"drybulb": [1.0, 0.0, 0.001]
17+
"Dry Bulb Temperature": [1.0, 0.0, 0.001]
1818
},
1919

2020
"max_ep_data_store_num" : 10,

sinergym/data/default_configuration/LrgOff_GridStorageScheduled.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"config_params" : null,
1515

1616
"weather_variability":{
17-
"drybulb": [1.0, 0.0, 0.001]
17+
"Dry Bulb Temperature": [1.0, 0.0, 0.001]
1818
},
1919

2020
"max_ep_data_store_num" : 10,

sinergym/data/default_configuration/ShopWithPVandBattery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"config_params" : null,
1515

1616
"weather_variability":{
17-
"drybulb": [1.0, 0.0, 0.001]
17+
"Dry Bulb Temperature": [1.0, 0.0, 0.001]
1818
},
1919

2020
"max_ep_data_store_num" : 10,

sinergym/data/default_configuration/radiant_residential_building.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"config_params" : null,
1616

1717
"weather_variability":{
18-
"drybulb": [1.0, 0.0, 0.001]
18+
"Dry Bulb Temperature": [1.0, 0.0, 0.001]
1919
},
2020

2121
"max_ep_data_store_num" : 10,

sinergym/utils/common.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from sinergym.utils.logger import TerminalLogger
1414
from sinergym.utils.rewards import *
1515

16-
# from opyplus.epgm.record import Record
17-
1816
logger = TerminalLogger().getLogger(
1917
name='COMMON',
2018
level=LOG_COMMON_LEVEL)
@@ -413,16 +411,3 @@ def convert_conf_to_env_parameters(
413411
# if np.max(data[column]) > result[column][1]:
414412
# result[column][1] = np.max(data[column])
415413
# return result
416-
417-
418-
# def get_record_keys(record: Record) -> List[str]:
419-
# """Given an opyplus Epm Record (one element from opyplus.epm object) this function returns list of keys (opyplus hasn't got this functionality explicitly)
420-
421-
# Args:
422-
# record (opyplus.Epm.Record): Element from Epm object.
423-
424-
# Returns:
425-
# List[str]: Key list from record.
426-
# """
427-
# return [field.ref for field in
428-
# record._table._dev_descriptor._field_descriptors]

sinergym/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.6.1
1+
3.6.2

tests/conftest.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pkg_resources
77
import pytest
8-
from opyplus import WeatherData
8+
from epw.weather import Weather
99

1010
import sinergym
1111
from sinergym.config.modeling import ModelJSON
@@ -357,7 +357,11 @@ def env_5zone_stochastic(
357357
variables=VARIABLES_5ZONE,
358358
meters=METERS_5ZONE,
359359
actuators=ACTUATORS_5ZONE,
360-
weather_variability={'drybulb': (1.0, 0.0, 0.001)},
360+
weather_variability={
361+
'Dry Bulb Temperature': (
362+
1.0,
363+
0.0,
364+
0.001)},
361365
reward=LinearReward,
362366
reward_kwargs={
363367
'temperature_variables': ['air_temperature'],
@@ -370,9 +374,13 @@ def env_5zone_stochastic(
370374
26.0)},
371375
env_name='TESTGYM',
372376
config_params={
373-
'runperiod': (1, 1, 1991, 31, 3, 1991)
374-
}
375-
)
377+
'runperiod': (
378+
1,
379+
1,
380+
1991,
381+
31,
382+
3,
383+
1991)})
376384
return env
377385

378386

@@ -595,7 +603,9 @@ def building(json_path_5zone):
595603

596604
@ pytest.fixture(scope='function')
597605
def weather_data(weather_path_pittsburgh):
598-
return WeatherData.from_epw(weather_path_pittsburgh)
606+
weather_data = Weather()
607+
weather_data.read(weather_path_pittsburgh)
608+
return weather_data
599609

600610
# ---------------------------------------------------------------------------- #
601611
# Rewards #

tests/mock/environment_configurations/5ZoneAutoDXVAV.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"config_params" : null,
1515

1616
"weather_variability":{
17-
"drybulb": [1.0, 0.0, 0.001]
17+
"Dry Bulb Temperature": [1.0, 0.0, 0.001]
1818
},
1919

2020
"max_ep_data_store_num" : 10,

0 commit comments

Comments
 (0)