Skip to content

Commit

Permalink
Fix - Fixed faulty forecast method for list of values and csv read
Browse files Browse the repository at this point in the history
  • Loading branch information
David HERNANDEZ authored and David HERNANDEZ committed Apr 26, 2022
1 parent 0b7ff74 commit 372e2b9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.10] - 2022-04-26
### Fix
- Fixed faulty forecast method for list of values and csv read.

## [0.2.9] - 2022-04-21
### Fix
- Fixed get_loc deprecation warning using now get_indexer pandas method. Improved selection of closest index.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'David HERNANDEZ'

# The full version, including alpha/beta/rc tags
release = '0.2.9'
release = '0.2.10'

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name='emhass', # Required
version='0.2.9', # Required
version='0.2.10', # Required
description='An Energy Management System for Home Assistant', # Optional
long_description=long_description, # Optional
long_description_content_type='text/markdown', # Optional (see note above)
Expand Down
8 changes: 3 additions & 5 deletions src/emhass/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,7 @@ def get_forecast_out_from_csv(self, df_final: pd.DataFrame, forecast_dates_csv:
:rtype: pd.DataFrame
"""
days_list = pd.date_range(start=df_final.index[0],
end=df_final.index[-1],
freq='D')
days_list = df_final.index.day.unique().tolist()

if csv_path is None:
data_dict = {'ts':forecast_dates_csv, 'yhat':data_list}
Expand All @@ -345,8 +343,8 @@ def get_forecast_out_from_csv(self, df_final: pd.DataFrame, forecast_dates_csv:

forecast_out = pd.DataFrame()
for day in days_list:
first_elm_index = [i for i, x in enumerate(df_final.index.day == day.day) if x][0]
last_elm_index = [i for i, x in enumerate(df_final.index.day == day.day) if x][-1]
first_elm_index = [i for i, x in enumerate(df_final.index.day == day) if x][0]
last_elm_index = [i for i, x in enumerate(df_final.index.day == day) if x][-1]
fcst_index = pd.date_range(start=df_final.index[first_elm_index],
end=df_final.index[last_elm_index],
freq=df_final.index.freq)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_get_forecasts_with_lists(self):
P_PV_forecast = fcst.get_power_from_weather(df_weather)
P_load_forecast = fcst.get_load_forecast(method=optim_conf['load_forecast_method'])
df_input_data_dayahead = pd.concat([P_PV_forecast, P_load_forecast], axis=1)
df_input_data_dayahead.index.freq=df_input_data.index.freq
df_input_data_dayahead.index.freq=rh.df_final.copy().index.freq
df_input_data_dayahead.columns = ['P_PV_forecast', 'P_load_forecast']
opt = optimization(retrieve_hass_conf, optim_conf, plant_conf,
fcst.var_load_cost, fcst.var_prod_price,
Expand Down

0 comments on commit 372e2b9

Please sign in to comment.