Skip to content

Fix problem with naive load forecast, issue 516 #522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/emhass/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,11 +1371,11 @@
with open(data_path, "rb") as fid:
data, _, _, _ = pickle.load(fid)
# Ensure the data index is timezone-aware and matches self.forecast_dates' timezone
data.index = (
data.index.tz_localize(self.forecast_dates.tz)
if data.index.tz is None
else data.index.tz_convert(self.forecast_dates.tz)
)
# data.index = (
# data.index.tz_localize(self.forecast_dates.tz)
# if data.index.tz is None
# else data.index.tz_convert(self.forecast_dates.tz)
# )
# Resample the data if needed
data = data[[self.var_load]]
current_freq = pd.Timedelta("30min")
Expand Down Expand Up @@ -1403,10 +1403,12 @@
forecast = forecast_tmp
else:
forecast = pd.concat([forecast, forecast_tmp], axis=0)
forecast_dates = self.forecast_dates.tz_convert('UTC').round(self.freq, ambiguous="infer", nonexistent="shift_forward")

Check failure on line 1406 in src/emhass/forecast.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Ruff (Q000)

src/emhass/forecast.py:1406:61: Q000 Single quotes found but double quotes preferred
forecast_out = forecast.loc[
forecast.index.intersection(self.forecast_dates)
forecast.index.intersection(forecast_dates)
]
forecast_out.index = self.forecast_dates
# forecast_out.index = self.forecast_dates
forecast_out.index = forecast_out.index.tz_convert(self.forecast_dates.tz)
forecast_out.index.name = "ts"
forecast_out = forecast_out.rename(columns={"load": "yhat"})
elif method == "naive": # using a naive approach
Expand Down
Loading