-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
composite functions and main function improvements
- Loading branch information
Showing
5 changed files
with
143 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from eptr2.composite.consumption import get_hourly_consumption_and_forecast_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from eptr2 import EPTR2 | ||
import pandas as pd | ||
|
||
|
||
def get_hourly_consumption_and_forecast_data( | ||
eptr: EPTR2, start_date: str, end_date: str, verbose: bool = False | ||
): | ||
""" | ||
This composite function gets load plan, UECM (settlement consumption), real time and consumption data. If end date is after the last settlement data, UECM is filled with real time consumption under consumption column. | ||
""" | ||
|
||
if verbose: | ||
print("Loading load plan...") | ||
|
||
lp_df = eptr.call("load-plan", start_date=start_date, end_date=start_date) | ||
|
||
df = lp_df[["date", "lep"]].rename(columns={"lep": "load_plan", "date": "dt"}) | ||
|
||
if verbose: | ||
print("Loading UECM...") | ||
|
||
uecm_df = eptr.call("uecm", start_date=start_date, end_date=end_date) | ||
|
||
df = df.merge( | ||
uecm_df[["period", "swv"]].rename(columns={"period": "dt", "swv": "uecm"}), | ||
on="dt", | ||
how="outer", | ||
) | ||
|
||
if verbose: | ||
print("Loading real time consumption...") | ||
|
||
rt_cons = eptr.call("rt-cons", start_date=start_date, end_date=end_date) | ||
|
||
df = df.merge( | ||
rt_cons[["date", "consumption"]].rename( | ||
columns={"date": "dt", "consumption": "rt_cons"} | ||
), | ||
on="dt", | ||
how="outer", | ||
) | ||
|
||
df["consumption"] = df.apply( | ||
lambda x: x["rt_cons"] if pd.isnull(x["uecm"]) else x["uecm"], axis=1 | ||
) | ||
|
||
return df | ||
|
||
|
||
if __name__ == "__main__": | ||
eptr = EPTR2(credentials_file_path="creds/eptr_credentials.json") | ||
|
||
df = get_hourly_consumption_and_forecast_data( | ||
eptr=eptr, start_date="2024-01-01", end_date="2024-12-23", verbose=True | ||
) | ||
|
||
print("End") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters