emhass 0.8.5__tar.gz → 0.8.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {emhass-0.8.5 → emhass-0.8.6}/CHANGELOG.md +5 -0
- {emhass-0.8.5 → emhass-0.8.6}/PKG-INFO +1 -1
- {emhass-0.8.5 → emhass-0.8.6}/setup.py +1 -1
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/command_line.py +12 -10
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/forecast.py +61 -25
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass.egg-info/PKG-INFO +1 -1
- {emhass-0.8.5 → emhass-0.8.6}/tests/test_forecast.py +35 -22
- {emhass-0.8.5 → emhass-0.8.6}/CODE_OF_CONDUCT.md +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/CONTRIBUTING.md +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/LICENSE +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/MANIFEST.in +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/README.md +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/data_load_cost_forecast.csv +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/data_load_forecast.csv +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/data_prod_price_forecast.csv +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/data_train_load_clustering.pkl +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/data_train_load_forecast.pkl +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/data_weather_forecast.csv +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/opt_res_latest.csv +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/opt_res_perfect_optim_cost.csv +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/opt_res_perfect_optim_profit.csv +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/opt_res_perfect_optim_self-consumption.csv +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/test_df_final.pkl +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/test_response_get_data_get_method.pbz2 +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/test_response_scrapper_get_method.pbz2 +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/test_response_solarforecast_get_method.pbz2 +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/data/test_response_solcast_get_method.pbz2 +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/pyproject.toml +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/setup.cfg +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/__init__.py +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/data/cec_inverters.pbz2 +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/data/cec_modules.pbz2 +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/machine_learning_forecaster.py +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/optimization.py +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/retrieve_hass.py +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/static/advanced.html +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/static/basic.html +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/static/img/emhass_icon.png +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/static/img/emhass_logo_short.svg +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/static/img/feather-sprite.svg +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/static/script.js +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/static/style.css +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/templates/index.html +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/templates/template.html +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/utils.py +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass/web_server.py +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass.egg-info/SOURCES.txt +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass.egg-info/dependency_links.txt +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass.egg-info/entry_points.txt +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass.egg-info/requires.txt +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/src/emhass.egg-info/top_level.txt +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/tests/test_command_line_utils.py +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/tests/test_machine_learning_forecaster.py +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/tests/test_optimization.py +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/tests/test_retrieve_hass.py +0 -0
- {emhass-0.8.5 → emhass-0.8.6}/tests/test_utils.py +0 -0
@@ -19,7 +19,7 @@ long_description = (here / 'README.md').read_text(encoding='utf-8')
|
|
19
19
|
|
20
20
|
setup(
|
21
21
|
name='emhass', # Required
|
22
|
-
version='0.8.
|
22
|
+
version='0.8.6', # Required
|
23
23
|
description='An Energy Management System for Home Assistant', # Optional
|
24
24
|
long_description=long_description, # Optional
|
25
25
|
long_description_content_type='text/markdown', # Optional (see note above)
|
@@ -76,12 +76,12 @@ def set_input_data_dict(config_path: pathlib.Path, base_path: str, costfun: str,
|
|
76
76
|
days_list = utils.get_days_list(retrieve_hass_conf['days_to_retrieve'])
|
77
77
|
var_list = [retrieve_hass_conf['var_load'], retrieve_hass_conf['var_PV']]
|
78
78
|
if not rh.get_data(days_list, var_list,
|
79
|
-
|
79
|
+
minimal_response=False, significant_changes_only=False):
|
80
80
|
return False
|
81
81
|
if not rh.prepare_data(retrieve_hass_conf['var_load'], load_negative = retrieve_hass_conf['load_negative'],
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
set_zero_min = retrieve_hass_conf['set_zero_min'],
|
83
|
+
var_replace_zero = retrieve_hass_conf['var_replace_zero'],
|
84
|
+
var_interp = retrieve_hass_conf['var_interp']):
|
85
85
|
return False
|
86
86
|
df_input_data = rh.df_final.copy()
|
87
87
|
# What we don't need for this type of action
|
@@ -113,12 +113,12 @@ def set_input_data_dict(config_path: pathlib.Path, base_path: str, costfun: str,
|
|
113
113
|
days_list = utils.get_days_list(1)
|
114
114
|
var_list = [retrieve_hass_conf['var_load'], retrieve_hass_conf['var_PV']]
|
115
115
|
if not rh.get_data(days_list, var_list,
|
116
|
-
|
116
|
+
minimal_response=False, significant_changes_only=False):
|
117
117
|
return False
|
118
118
|
if not rh.prepare_data(retrieve_hass_conf['var_load'], load_negative = retrieve_hass_conf['load_negative'],
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
set_zero_min = retrieve_hass_conf['set_zero_min'],
|
120
|
+
var_replace_zero = retrieve_hass_conf['var_replace_zero'],
|
121
|
+
var_interp = retrieve_hass_conf['var_interp']):
|
122
122
|
return False
|
123
123
|
df_input_data = rh.df_final.copy()
|
124
124
|
# Get PV and load forecasts
|
@@ -201,9 +201,11 @@ def perfect_forecast_optim(input_data_dict: dict, logger: logging.Logger,
|
|
201
201
|
# Load cost and prod price forecast
|
202
202
|
df_input_data = input_data_dict['fcst'].get_load_cost_forecast(
|
203
203
|
input_data_dict['df_input_data'],
|
204
|
-
method=input_data_dict['fcst'].optim_conf['load_cost_forecast_method']
|
204
|
+
method=input_data_dict['fcst'].optim_conf['load_cost_forecast_method'],
|
205
|
+
list_and_perfect=True)
|
205
206
|
df_input_data = input_data_dict['fcst'].get_prod_price_forecast(
|
206
|
-
df_input_data, method=input_data_dict['fcst'].optim_conf['prod_price_forecast_method']
|
207
|
+
df_input_data, method=input_data_dict['fcst'].optim_conf['prod_price_forecast_method'],
|
208
|
+
list_and_perfect=True)
|
207
209
|
opt_res = input_data_dict['opt'].perform_perfect_forecast_optim(df_input_data, input_data_dict['days_list'])
|
208
210
|
# Save CSV file for analysis
|
209
211
|
if save_data_to_file:
|
@@ -23,7 +23,7 @@ from pvlib.irradiance import disc
|
|
23
23
|
|
24
24
|
from emhass.retrieve_hass import RetrieveHass
|
25
25
|
from emhass.machine_learning_forecaster import MLForecaster
|
26
|
-
from emhass.utils import get_days_list, get_root
|
26
|
+
from emhass.utils import get_days_list, get_root, set_df_index_freq
|
27
27
|
|
28
28
|
|
29
29
|
class Forecast(object):
|
@@ -487,8 +487,9 @@ class Forecast(object):
|
|
487
487
|
forecast_dates_csv = forecast_dates_csv[0:self.params['passed_data']['prediction_horizon']]
|
488
488
|
return forecast_dates_csv
|
489
489
|
|
490
|
-
def
|
491
|
-
|
490
|
+
def get_forecast_out_from_csv_or_list(self, df_final: pd.DataFrame, forecast_dates_csv: pd.date_range,
|
491
|
+
csv_path: str, data_list: Optional[list] = None,
|
492
|
+
list_and_perfect: Optional[bool] = False) -> pd.DataFrame:
|
492
493
|
r"""
|
493
494
|
Get the forecast data as a DataFrame from a CSV file.
|
494
495
|
|
@@ -506,34 +507,67 @@ class Forecast(object):
|
|
506
507
|
:rtype: pd.DataFrame
|
507
508
|
|
508
509
|
"""
|
509
|
-
days_list = df_final.index.day.unique().tolist()
|
510
510
|
if csv_path is None:
|
511
511
|
data_dict = {'ts':forecast_dates_csv, 'yhat':data_list}
|
512
512
|
df_csv = pd.DataFrame.from_dict(data_dict)
|
513
513
|
df_csv.index = forecast_dates_csv
|
514
514
|
df_csv.drop(['ts'], axis=1, inplace=True)
|
515
|
+
df_csv = set_df_index_freq(df_csv)
|
516
|
+
if list_and_perfect:
|
517
|
+
days_list = df_final.index.day.unique().tolist()
|
518
|
+
else:
|
519
|
+
days_list = df_csv.index.day.unique().tolist()
|
515
520
|
else:
|
516
521
|
load_csv_file_path = self.root + csv_path
|
517
522
|
df_csv = pd.read_csv(load_csv_file_path, header=None, names=['ts', 'yhat'])
|
518
523
|
df_csv.index = forecast_dates_csv
|
519
524
|
df_csv.drop(['ts'], axis=1, inplace=True)
|
525
|
+
df_csv = set_df_index_freq(df_csv)
|
526
|
+
days_list = df_final.index.day.unique().tolist()
|
520
527
|
forecast_out = pd.DataFrame()
|
521
528
|
for day in days_list:
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
+
if csv_path is None:
|
530
|
+
if list_and_perfect:
|
531
|
+
df_tmp = copy.deepcopy(df_final)
|
532
|
+
else:
|
533
|
+
df_tmp = copy.deepcopy(df_csv)
|
534
|
+
else:
|
535
|
+
df_tmp = copy.deepcopy(df_final)
|
536
|
+
first_elm_index = [i for i, x in enumerate(df_tmp.index.day == day) if x][0]
|
537
|
+
last_elm_index = [i for i, x in enumerate(df_tmp.index.day == day) if x][-1]
|
538
|
+
fcst_index = pd.date_range(start=df_tmp.index[first_elm_index],
|
539
|
+
end=df_tmp.index[last_elm_index],
|
540
|
+
freq=df_tmp.index.freq)
|
541
|
+
first_hour = str(df_tmp.index[first_elm_index].hour)+":"+str(df_tmp.index[first_elm_index].minute)
|
542
|
+
last_hour = str(df_tmp.index[last_elm_index].hour)+":"+str(df_tmp.index[last_elm_index].minute)
|
529
543
|
if len(forecast_out) == 0:
|
530
|
-
|
531
|
-
|
532
|
-
|
544
|
+
if csv_path is None:
|
545
|
+
if list_and_perfect:
|
546
|
+
forecast_out = pd.DataFrame(
|
547
|
+
df_csv.between_time(first_hour, last_hour).values,
|
548
|
+
index=fcst_index)
|
549
|
+
else:
|
550
|
+
forecast_out = pd.DataFrame(
|
551
|
+
df_csv.loc[fcst_index,:].between_time(first_hour, last_hour).values,
|
552
|
+
index=fcst_index)
|
553
|
+
else:
|
554
|
+
forecast_out = pd.DataFrame(
|
555
|
+
df_csv.between_time(first_hour, last_hour).values,
|
556
|
+
index=fcst_index)
|
533
557
|
else:
|
534
|
-
|
535
|
-
|
536
|
-
|
558
|
+
if csv_path is None:
|
559
|
+
if list_and_perfect:
|
560
|
+
forecast_tp = pd.DataFrame(
|
561
|
+
df_csv.between_time(first_hour, last_hour).values,
|
562
|
+
index=fcst_index)
|
563
|
+
else:
|
564
|
+
forecast_tp = pd.DataFrame(
|
565
|
+
df_csv.loc[fcst_index,:].between_time(first_hour, last_hour).values,
|
566
|
+
index=fcst_index)
|
567
|
+
else:
|
568
|
+
forecast_tp = pd.DataFrame(
|
569
|
+
df_csv.between_time(first_hour, last_hour).values,
|
570
|
+
index=fcst_index)
|
537
571
|
forecast_out = pd.concat([forecast_out, forecast_tp], axis=0)
|
538
572
|
return forecast_out
|
539
573
|
|
@@ -668,7 +702,8 @@ class Forecast(object):
|
|
668
702
|
return P_Load_forecast
|
669
703
|
|
670
704
|
def get_load_cost_forecast(self, df_final: pd.DataFrame, method: Optional[str] = 'hp_hc_periods',
|
671
|
-
csv_path: Optional[str] = "data_load_cost_forecast.csv"
|
705
|
+
csv_path: Optional[str] = "data_load_cost_forecast.csv",
|
706
|
+
list_and_perfect: Optional[bool] = False) -> pd.DataFrame:
|
672
707
|
r"""
|
673
708
|
Get the unit cost for the load consumption based on multiple tariff \
|
674
709
|
periods. This is the cost of the energy from the utility in a vector \
|
@@ -698,7 +733,7 @@ class Forecast(object):
|
|
698
733
|
df_final.loc[df_hp.index, self.var_load_cost] = self.optim_conf['load_cost_hp']
|
699
734
|
elif method == 'csv':
|
700
735
|
forecast_dates_csv = self.get_forecast_days_csv(timedelta_days=0)
|
701
|
-
forecast_out = self.
|
736
|
+
forecast_out = self.get_forecast_out_from_csv_or_list(
|
702
737
|
df_final, forecast_dates_csv, csv_path)
|
703
738
|
df_final[self.var_load_cost] = forecast_out
|
704
739
|
elif method == 'list': # reading a list of values
|
@@ -712,8 +747,8 @@ class Forecast(object):
|
|
712
747
|
data_list = data_list[0:len(self.forecast_dates)]
|
713
748
|
# Define the correct dates
|
714
749
|
forecast_dates_csv = self.get_forecast_days_csv(timedelta_days=0)
|
715
|
-
forecast_out = self.
|
716
|
-
df_final, forecast_dates_csv, None, data_list=data_list)
|
750
|
+
forecast_out = self.get_forecast_out_from_csv_or_list(
|
751
|
+
df_final, forecast_dates_csv, None, data_list=data_list, list_and_perfect=list_and_perfect)
|
717
752
|
# Fill the final DF
|
718
753
|
df_final[self.var_load_cost] = forecast_out
|
719
754
|
else:
|
@@ -722,7 +757,8 @@ class Forecast(object):
|
|
722
757
|
return df_final
|
723
758
|
|
724
759
|
def get_prod_price_forecast(self, df_final: pd.DataFrame, method: Optional[str] = 'constant',
|
725
|
-
|
760
|
+
csv_path: Optional[str] = "/data/data_prod_price_forecast.csv",
|
761
|
+
list_and_perfect: Optional[bool] = False) -> pd.DataFrame:
|
726
762
|
r"""
|
727
763
|
Get the unit power production price for the energy injected to the grid.\
|
728
764
|
This is the price of the energy injected to the utility in a vector \
|
@@ -747,7 +783,7 @@ class Forecast(object):
|
|
747
783
|
df_final[self.var_prod_price] = self.optim_conf['prod_sell_price']
|
748
784
|
elif method == 'csv':
|
749
785
|
forecast_dates_csv = self.get_forecast_days_csv(timedelta_days=0)
|
750
|
-
forecast_out = self.
|
786
|
+
forecast_out = self.get_forecast_out_from_csv_or_list(df_final,
|
751
787
|
forecast_dates_csv,
|
752
788
|
csv_path)
|
753
789
|
df_final[self.var_prod_price] = forecast_out
|
@@ -762,8 +798,8 @@ class Forecast(object):
|
|
762
798
|
data_list = data_list[0:len(self.forecast_dates)]
|
763
799
|
# Define the correct dates
|
764
800
|
forecast_dates_csv = self.get_forecast_days_csv(timedelta_days=0)
|
765
|
-
forecast_out = self.
|
766
|
-
df_final, forecast_dates_csv, None, data_list=data_list)
|
801
|
+
forecast_out = self.get_forecast_out_from_csv_or_list(
|
802
|
+
df_final, forecast_dates_csv, None, data_list=data_list, list_and_perfect=list_and_perfect)
|
767
803
|
# Fill the final DF
|
768
804
|
df_final[self.var_prod_price] = forecast_out
|
769
805
|
else:
|
@@ -13,12 +13,12 @@ from emhass.command_line import set_input_data_dict
|
|
13
13
|
from emhass.machine_learning_forecaster import MLForecaster
|
14
14
|
from emhass.forecast import Forecast
|
15
15
|
from emhass.optimization import Optimization
|
16
|
-
from emhass
|
16
|
+
from emhass import utils
|
17
17
|
|
18
18
|
# the root folder
|
19
|
-
root = str(get_root(__file__, num_parent=2))
|
19
|
+
root = str(utils.get_root(__file__, num_parent=2))
|
20
20
|
# create logger
|
21
|
-
logger, ch = get_logger(__name__, root, save_to_file=False)
|
21
|
+
logger, ch = utils.get_logger(__name__, root, save_to_file=False)
|
22
22
|
|
23
23
|
class TestForecast(unittest.TestCase):
|
24
24
|
|
@@ -41,7 +41,7 @@ class TestForecast(unittest.TestCase):
|
|
41
41
|
def setUp(self):
|
42
42
|
self.get_data_from_file = True
|
43
43
|
params = None
|
44
|
-
retrieve_hass_conf, optim_conf, plant_conf = get_yaml_parse(pathlib.Path(root) / 'config_emhass.yaml', use_secrets=False)
|
44
|
+
retrieve_hass_conf, optim_conf, plant_conf = utils.get_yaml_parse(pathlib.Path(root) / 'config_emhass.yaml', use_secrets=False)
|
45
45
|
self.retrieve_hass_conf, self.optim_conf, self.plant_conf = \
|
46
46
|
retrieve_hass_conf, optim_conf, plant_conf
|
47
47
|
self.rh = RetrieveHass(self.retrieve_hass_conf['hass_url'], self.retrieve_hass_conf['long_lived_token'],
|
@@ -51,7 +51,7 @@ class TestForecast(unittest.TestCase):
|
|
51
51
|
with open(pathlib.Path(root) / 'data' / 'test_df_final.pkl', 'rb') as inp:
|
52
52
|
self.rh.df_final, self.days_list, self.var_list = pickle.load(inp)
|
53
53
|
else:
|
54
|
-
self.days_list = get_days_list(self.retrieve_hass_conf['days_to_retrieve'])
|
54
|
+
self.days_list = utils.get_days_list(self.retrieve_hass_conf['days_to_retrieve'])
|
55
55
|
self.var_list = [self.retrieve_hass_conf['var_load'], self.retrieve_hass_conf['var_PV']]
|
56
56
|
self.rh.get_data(self.days_list, self.var_list,
|
57
57
|
minimal_response=False, significant_changes_only=False)
|
@@ -192,10 +192,10 @@ class TestForecast(unittest.TestCase):
|
|
192
192
|
runtimeparams_json = json.dumps(runtimeparams)
|
193
193
|
params['passed_data'] = runtimeparams
|
194
194
|
params_json = json.dumps(params)
|
195
|
-
retrieve_hass_conf, optim_conf, plant_conf = get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'),
|
195
|
+
retrieve_hass_conf, optim_conf, plant_conf = utils.get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'),
|
196
196
|
use_secrets=False, params=params_json)
|
197
197
|
set_type = "dayahead-optim"
|
198
|
-
params, retrieve_hass_conf, optim_conf, plant_conf = treat_runtimeparams(
|
198
|
+
params, retrieve_hass_conf, optim_conf, plant_conf = utils.treat_runtimeparams(
|
199
199
|
runtimeparams_json, params_json, retrieve_hass_conf,
|
200
200
|
optim_conf, plant_conf, set_type, logger)
|
201
201
|
rh = RetrieveHass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
|
@@ -205,7 +205,7 @@ class TestForecast(unittest.TestCase):
|
|
205
205
|
with open(pathlib.Path(root+'/data/test_df_final.pkl'), 'rb') as inp:
|
206
206
|
rh.df_final, days_list, var_list = pickle.load(inp)
|
207
207
|
else:
|
208
|
-
days_list = get_days_list(retrieve_hass_conf['days_to_retrieve'])
|
208
|
+
days_list = utils.get_days_list(retrieve_hass_conf['days_to_retrieve'])
|
209
209
|
var_list = [retrieve_hass_conf['var_load'], retrieve_hass_conf['var_PV']]
|
210
210
|
rh.get_data(days_list, var_list,
|
211
211
|
minimal_response=False, significant_changes_only=False)
|
@@ -259,22 +259,22 @@ class TestForecast(unittest.TestCase):
|
|
259
259
|
}
|
260
260
|
})
|
261
261
|
runtimeparams = {
|
262
|
-
'pv_power_forecast':[i+1 for i in range(
|
263
|
-
'load_power_forecast':[i+1 for i in range(
|
264
|
-
'load_cost_forecast':[i+1 for i in range(
|
265
|
-
'prod_price_forecast':[i+1 for i in range(
|
262
|
+
'pv_power_forecast':[i+1 for i in range(3*48)],
|
263
|
+
'load_power_forecast':[i+1 for i in range(3*48)],
|
264
|
+
'load_cost_forecast':[i+1 for i in range(3*48)],
|
265
|
+
'prod_price_forecast':[i+1 for i in range(3*48)]
|
266
266
|
}
|
267
267
|
runtimeparams_json = json.dumps(runtimeparams)
|
268
268
|
params['passed_data'] = runtimeparams
|
269
269
|
params_json = json.dumps(params)
|
270
|
-
retrieve_hass_conf, optim_conf, plant_conf = get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'),
|
271
|
-
|
272
|
-
optim_conf['delta_forecast'] = pd.Timedelta(days=
|
273
|
-
params, retrieve_hass_conf, optim_conf, plant_conf = treat_runtimeparams(
|
270
|
+
retrieve_hass_conf, optim_conf, plant_conf = utils.get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'),
|
271
|
+
use_secrets=False, params=params_json)
|
272
|
+
optim_conf['delta_forecast'] = pd.Timedelta(days=3)
|
273
|
+
params, retrieve_hass_conf, optim_conf, plant_conf = utils.treat_runtimeparams(
|
274
274
|
runtimeparams_json, params_json, retrieve_hass_conf,
|
275
275
|
optim_conf, plant_conf, set_type, logger)
|
276
276
|
fcst = Forecast(retrieve_hass_conf, optim_conf, plant_conf,
|
277
|
-
params_json, root, logger,
|
277
|
+
params_json, root, logger, get_data_from_file=True)
|
278
278
|
P_PV_forecast = fcst.get_weather_forecast(method='list')
|
279
279
|
self.assertIsInstance(P_PV_forecast, type(pd.DataFrame()))
|
280
280
|
self.assertIsInstance(P_PV_forecast.index, pd.core.indexes.datetimes.DatetimeIndex)
|
@@ -282,7 +282,7 @@ class TestForecast(unittest.TestCase):
|
|
282
282
|
self.assertEqual(P_PV_forecast.index.tz, fcst.time_zone)
|
283
283
|
self.assertTrue(fcst.start_forecast < ts for ts in P_PV_forecast.index)
|
284
284
|
self.assertTrue(P_PV_forecast.values[0][0] == 1)
|
285
|
-
self.assertTrue(P_PV_forecast.values[-1][0] ==
|
285
|
+
self.assertTrue(P_PV_forecast.values[-1][0] == 3*48)
|
286
286
|
P_load_forecast = fcst.get_load_forecast(method='list')
|
287
287
|
self.assertIsInstance(P_load_forecast, pd.core.series.Series)
|
288
288
|
self.assertIsInstance(P_load_forecast.index, pd.core.indexes.datetimes.DatetimeIndex)
|
@@ -290,7 +290,20 @@ class TestForecast(unittest.TestCase):
|
|
290
290
|
self.assertEqual(P_load_forecast.index.tz, fcst.time_zone)
|
291
291
|
self.assertEqual(len(P_PV_forecast), len(P_load_forecast))
|
292
292
|
self.assertTrue(P_load_forecast.values[0] == 1)
|
293
|
-
self.assertTrue(P_load_forecast.values[-1] ==
|
293
|
+
self.assertTrue(P_load_forecast.values[-1] == 3*48)
|
294
|
+
df_input_data_dayahead = pd.concat([P_PV_forecast, P_load_forecast], axis=1)
|
295
|
+
df_input_data_dayahead = utils.set_df_index_freq(df_input_data_dayahead)
|
296
|
+
df_input_data_dayahead.columns = ['P_PV_forecast', 'P_load_forecast']
|
297
|
+
df_input_data_dayahead = fcst.get_load_cost_forecast(df_input_data_dayahead, method='list')
|
298
|
+
self.assertTrue(fcst.var_load_cost in df_input_data_dayahead.columns)
|
299
|
+
self.assertTrue(df_input_data_dayahead.isnull().sum().sum()==0)
|
300
|
+
self.assertTrue(df_input_data_dayahead[fcst.var_load_cost].iloc[0] == 1)
|
301
|
+
self.assertTrue(df_input_data_dayahead[fcst.var_load_cost].iloc[-1] == 3*48)
|
302
|
+
df_input_data_dayahead = fcst.get_prod_price_forecast(df_input_data_dayahead, method='list')
|
303
|
+
self.assertTrue(fcst.var_prod_price in df_input_data_dayahead.columns)
|
304
|
+
self.assertTrue(df_input_data_dayahead.isnull().sum().sum()==0)
|
305
|
+
self.assertTrue(df_input_data_dayahead[fcst.var_prod_price].iloc[0] == 1)
|
306
|
+
self.assertTrue(df_input_data_dayahead[fcst.var_prod_price].iloc[-1] == 3*48)
|
294
307
|
|
295
308
|
def test_get_forecasts_with_lists_special_case(self):
|
296
309
|
with open(root+'/config_emhass.yaml', 'r') as file:
|
@@ -312,10 +325,10 @@ class TestForecast(unittest.TestCase):
|
|
312
325
|
runtimeparams_json = json.dumps(runtimeparams)
|
313
326
|
params['passed_data'] = runtimeparams
|
314
327
|
params_json = json.dumps(params)
|
315
|
-
retrieve_hass_conf, optim_conf, plant_conf = get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'),
|
328
|
+
retrieve_hass_conf, optim_conf, plant_conf = utils.get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'),
|
316
329
|
use_secrets=False, params=params_json)
|
317
330
|
set_type = "dayahead-optim"
|
318
|
-
params, retrieve_hass_conf, optim_conf, plant_conf = treat_runtimeparams(
|
331
|
+
params, retrieve_hass_conf, optim_conf, plant_conf = utils.treat_runtimeparams(
|
319
332
|
runtimeparams_json, params_json, retrieve_hass_conf,
|
320
333
|
optim_conf, plant_conf, set_type, logger)
|
321
334
|
rh = RetrieveHass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
|
@@ -325,7 +338,7 @@ class TestForecast(unittest.TestCase):
|
|
325
338
|
with open(pathlib.Path(root+'/data/test_df_final.pkl'), 'rb') as inp:
|
326
339
|
rh.df_final, days_list, var_list = pickle.load(inp)
|
327
340
|
else:
|
328
|
-
days_list = get_days_list(retrieve_hass_conf['days_to_retrieve'])
|
341
|
+
days_list = utils.get_days_list(retrieve_hass_conf['days_to_retrieve'])
|
329
342
|
var_list = [retrieve_hass_conf['var_load'], retrieve_hass_conf['var_PV']]
|
330
343
|
rh.get_data(days_list, var_list,
|
331
344
|
minimal_response=False, significant_changes_only=False)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|