Skip to content

Commit

Permalink
Merge pull request #317 from awarsewa/master
Browse files Browse the repository at this point in the history
+mRID parameter for query_unavailability
  • Loading branch information
fboerman authored Sep 18, 2024
2 parents fd1238f + f9773fa commit 647ae2b
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions entsoe/entsoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ def _query_unavailability(
end: pd.Timestamp, doctype: str, docstatus: Optional[str] = None,
periodstartupdate: Optional[pd.Timestamp] = None,
periodendupdate: Optional[pd.Timestamp] = None,
mRID=None,
offset: int = 0) -> bytes:
"""
Generic unavailibility query method.
Expand Down Expand Up @@ -1017,6 +1018,8 @@ def _query_unavailability(
params['periodStartUpdate'] = self._datetime_to_str(
periodstartupdate)
params['periodEndUpdate'] = self._datetime_to_str(periodendupdate)
if mRID:
params['mRID'] = mRID
response = self._base_request(params=params, start=start, end=end)
return response.content

Expand All @@ -1025,6 +1028,7 @@ def query_unavailability_of_generation_units(
end: pd.Timestamp, docstatus: Optional[str] = None,
periodstartupdate: Optional[pd.Timestamp] = None,
periodendupdate: Optional[pd.Timestamp] = None,
mRID = None,
offset: int = 0) -> bytes:
"""
This endpoint serves ZIP files.
Expand All @@ -1048,14 +1052,15 @@ def query_unavailability_of_generation_units(
content = self._query_unavailability(
country_code=country_code, start=start, end=end, doctype="A80",
docstatus=docstatus, periodstartupdate=periodstartupdate,
periodendupdate=periodendupdate, offset=offset)
periodendupdate=periodendupdate, mRID=mRID, offset=offset)
return content

def query_unavailability_of_production_units(
self, country_code: Union[Area, str], start: pd.Timestamp,
end: pd.Timestamp, docstatus: Optional[str] = None,
periodstartupdate: Optional[pd.Timestamp] = None,
periodendupdate: Optional[pd.Timestamp] = None) -> bytes:
periodendupdate: Optional[pd.Timestamp] = None,
mRID: Optional[str] = None) -> bytes:
"""
This endpoint serves ZIP files.
The query is limited to 200 items per request.
Expand All @@ -1076,7 +1081,8 @@ def query_unavailability_of_production_units(
content = self._query_unavailability(
country_code=country_code, start=start, end=end, doctype="A77",
docstatus=docstatus, periodstartupdate=periodstartupdate,
periodendupdate=periodendupdate)
periodendupdate=periodendupdate,
mRID = mRID)
return content

def query_unavailability_transmission(
Expand Down Expand Up @@ -1126,7 +1132,7 @@ def query_unavailability_transmission(

def query_withdrawn_unavailability_of_generation_units(
self, country_code: Union[Area, str], start: pd.Timestamp,
end: pd.Timestamp) -> bytes:
end: pd.Timestamp, mRID: Optional[str] = None) -> bytes:
"""
Parameters
----------
Expand All @@ -1140,7 +1146,7 @@ def query_withdrawn_unavailability_of_generation_units(
"""
content = self._query_unavailability(
country_code=country_code, start=start, end=end,
doctype="A80", docstatus='A13')
doctype="A80", docstatus='A13', mRID=mRID)
return content

class EntsoePandasClient(EntsoeRawClient):
Expand Down Expand Up @@ -2009,6 +2015,7 @@ def _query_unavailability(
end: pd.Timestamp, doctype: str, docstatus: Optional[str] = None,
periodstartupdate: Optional[pd.Timestamp] = None,
periodendupdate: Optional[pd.Timestamp] = None,
mRID: Optional[str] = None,
offset: int = 0) -> pd.DataFrame:
"""
Parameters
Expand All @@ -2030,7 +2037,7 @@ def _query_unavailability(
content = super(EntsoePandasClient, self)._query_unavailability(
country_code=area, start=start, end=end, doctype=doctype,
docstatus=docstatus, periodstartupdate=periodstartupdate,
periodendupdate=periodendupdate, offset=offset)
periodendupdate=periodendupdate, mRID=mRID, offset=offset)
df = parse_unavailabilities(content, doctype)
df = df.tz_convert(area.tz)
df['start'] = df['start'].apply(lambda x: x.tz_convert(area.tz))
Expand All @@ -2042,7 +2049,8 @@ def query_unavailability_of_generation_units(
self, country_code: Union[Area, str], start: pd.Timestamp,
end: pd.Timestamp, docstatus: Optional[str] = None,
periodstartupdate: Optional[pd.Timestamp] = None,
periodendupdate: Optional[pd.Timestamp] = None) -> pd.DataFrame:
periodendupdate: Optional[pd.Timestamp] = None,
mRID = None) -> pd.DataFrame:
"""
Parameters
----------
Expand All @@ -2060,14 +2068,15 @@ def query_unavailability_of_generation_units(
df = self._query_unavailability(
country_code=country_code, start=start, end=end, doctype="A80",
docstatus=docstatus, periodstartupdate=periodstartupdate,
periodendupdate=periodendupdate)
periodendupdate=periodendupdate, mRID=mRID)
return df

def query_unavailability_of_production_units(
self, country_code: Union[Area, str], start: pd.Timestamp,
end: pd.Timestamp, docstatus: Optional[str] = None,
periodstartupdate: Optional[pd.Timestamp] = None,
periodendupdate: Optional[pd.Timestamp] = None) -> pd.DataFrame:
periodendupdate: Optional[pd.Timestamp] = None,
mRID: Optional[str] = None) -> pd.DataFrame:
"""
Parameters
----------
Expand All @@ -2085,7 +2094,7 @@ def query_unavailability_of_production_units(
df = self._query_unavailability(
country_code=country_code, start=start, end=end, doctype="A77",
docstatus=docstatus, periodstartupdate=periodstartupdate,
periodendupdate=periodendupdate)
periodendupdate=periodendupdate, mRID=mRID)
return df

@paginated
Expand Down

0 comments on commit 647ae2b

Please sign in to comment.