emhass 0.8.5__py3-none-any.whl → 0.8.6__py3-none-any.whl
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/command_line.py +12 -10
- emhass/forecast.py +61 -25
- {emhass-0.8.5.dist-info → emhass-0.8.6.dist-info}/METADATA +1 -1
- {emhass-0.8.5.dist-info → emhass-0.8.6.dist-info}/RECORD +8 -8
- {emhass-0.8.5.dist-info → emhass-0.8.6.dist-info}/LICENSE +0 -0
- {emhass-0.8.5.dist-info → emhass-0.8.6.dist-info}/WHEEL +0 -0
- {emhass-0.8.5.dist-info → emhass-0.8.6.dist-info}/entry_points.txt +0 -0
- {emhass-0.8.5.dist-info → emhass-0.8.6.dist-info}/top_level.txt +0 -0
emhass/command_line.py
CHANGED
@@ -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:
|
emhass/forecast.py
CHANGED
@@ -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:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
emhass/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
emhass/command_line.py,sha256=
|
3
|
-
emhass/forecast.py,sha256=
|
2
|
+
emhass/command_line.py,sha256=TrNJnP1V94NoGanR7-Ik1ZVWlE6fsbDjWUIuH0l-0bs,37580
|
3
|
+
emhass/forecast.py,sha256=38WF2XkopDOwvSZJU3_m01BXyiENVypEVOeXcHP-5Fo,45704
|
4
4
|
emhass/machine_learning_forecaster.py,sha256=8Rm0-pltsjIYqLv01zCeO_Ij_n2HKC62dv_kCno7UsU,15640
|
5
5
|
emhass/optimization.py,sha256=WcUJSDSBK7wgx0jaX25mhco7ZfqG1g066Ebh6ACyruQ,37197
|
6
6
|
emhass/retrieve_hass.py,sha256=COf8LD6B0arFI-P71PXyLT7snB7_Wg5c3bMhRdVMdI4,18406
|
@@ -17,9 +17,9 @@ emhass/static/img/emhass_logo_short.svg,sha256=yzMcqtBRCV8rH84-MwnigZh45_f9Eoqwh
|
|
17
17
|
emhass/static/img/feather-sprite.svg,sha256=VHjMJQg88wXa9CaeYrKGhNtyK0xdd47zCqwSIa-hxo8,60319
|
18
18
|
emhass/templates/index.html,sha256=_BsvUJ981uSQkx5H9tq_3es__x4WdPiOy7FjNoNYU9w,2744
|
19
19
|
emhass/templates/template.html,sha256=TkGgMecQEbFUZA4ymPwMUzNjKHsENvCgroUWbPt7G4Y,158
|
20
|
-
emhass-0.8.
|
21
|
-
emhass-0.8.
|
22
|
-
emhass-0.8.
|
23
|
-
emhass-0.8.
|
24
|
-
emhass-0.8.
|
25
|
-
emhass-0.8.
|
20
|
+
emhass-0.8.6.dist-info/LICENSE,sha256=1X3-S1yvOCBDBeox1aK3dq00m7dA8NDtcPrpKPISzbE,1077
|
21
|
+
emhass-0.8.6.dist-info/METADATA,sha256=KR8yrRLmiYFe6ljkjXrQO-De3j-26I1d3WO3pZXMSvs,34758
|
22
|
+
emhass-0.8.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
23
|
+
emhass-0.8.6.dist-info/entry_points.txt,sha256=6Bp1NFOGNv_fSTxYl1ke3K3h3aqAcBxI-bgq5yq-i1M,52
|
24
|
+
emhass-0.8.6.dist-info/top_level.txt,sha256=L7fIX4awfmxQbAePtSdVg2e6x_HhghfReHfsKSpKr9I,7
|
25
|
+
emhass-0.8.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|