From 5fc7d12797f61140babf954604dfdb5330b586ba Mon Sep 17 00:00:00 2001 From: Frank Boerman Date: Sun, 14 Nov 2021 13:28:52 +0100 Subject: [PATCH] fixed correct process parameter for parsing of xml for query_load added query_load_and_forecast as a helper function fixes #140 --- README.md | 5 +++-- entsoe/entsoe.py | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bbc5fa5..15ba954 100644 --- a/README.md +++ b/README.md @@ -95,8 +95,6 @@ type_marketagreement_type = 'A01' # methods that return Pandas Series client.query_day_ahead_prices(country_code, start=start,end=end) client.query_net_position_dayahead(country_code, start=start, end=end) -client.query_load(country_code, start=start,end=end) -client.query_load_forecast(country_code, start=start,end=end) client.query_crossborder_flows(country_code_from, country_code_to, start, end) client.query_scheduled_exchanges(country_code_from, country_code_to, start, end, dayahead=False) client.query_net_transfer_capacity_dayahead(country_code_from, country_code_to, start, end) @@ -106,6 +104,9 @@ client.query_net_transfer_capacity_yearahead(country_code_from, country_code_to, client.query_intraday_offered_capacity(country_code_from, country_code_to, start, end,implicit=True) # methods that return Pandas DataFrames +client.query_load(country_code, start=start,end=end) +client.query_load_forecast(country_code, start=start,end=end) +client.query_load_and_forecast(country_code, start=start, end=end) client.query_generation_forecast(country_code, start=start,end=end) client.query_wind_and_solar_forecast(country_code, start=start,end=end, psr_type=None) client.query_generation(country_code, start=start,end=end, psr_type=None) diff --git a/entsoe/entsoe.py b/entsoe/entsoe.py index 53088b2..b83a154 100644 --- a/entsoe/entsoe.py +++ b/entsoe/entsoe.py @@ -966,7 +966,7 @@ def query_load(self, country_code: Union[Area, str], start: pd.Timestamp, area = lookup_area(country_code) text = super(EntsoePandasClient, self).query_load( country_code=area, start=start, end=end) - series = parse_loads(text) + series = parse_loads(text, process_type='A16') series = series.tz_convert(area.tz) series = series.truncate(before=start, after=end) return series @@ -996,6 +996,27 @@ def query_load_forecast( df = df.truncate(before=start, after=end) return df + def query_load_and_forecast( + self, country_code: Union[Area, str], start: pd.Timestamp, + end: pd.Timestamp) -> pd.DataFrame: + """ + utility function to combina query realised load and forecasted day ahead load. + this mimics the html view on the page Total Load - Day Ahead / Actual + + Parameters + ---------- + country_code : Area|str + start : pd.Timestamp + end : pd.Timestamp + + Returns + ------- + pd.DataFrame + """ + df_load_forecast_da = self.query_load_forecast(country_code, start=start, end=end) + df_load = self.query_load(country_code, start=start, end=end) + return df_load_forecast_da.join(df_load, sort=True, how='inner') + @year_limited def query_generation_forecast(