Git Product home page Git Product logo

entsog-py's Introduction

Entsog-py

Python client for the ENTSO-G API (european network of transmission system operators for gas)

Documentation of the API found on https://transparency.entsog.eu/api/archiveDirectories/8/api-manual/TP_REG715_Documentation_TP_API%20-%20v2.1.pdf

Documentation of the data (user manual) found on https://www.entsog.eu/sites/default/files/2021-07/ENTSOG%20-%20TP%20User%20Manual_v_4.5.pdf

Heavily inspired upon (and forked from) https://github.com/EnergieID/entsoe-py

Installation

python3 -m pip install entsog-py

Usage

The package comes with 2 clients:

It's preferable to use the Pandas Client as this will handle most API limitations itself. However, if you want to obtain the pure raw data; you can use the raw client.

Example Use Case

On wwww.gasparency.com you can find example use cases of the data. Almost everything there is achieved with the help of this package!

EntsogRawClient

from entsog import EntsogRawClient
import pandas as pd

client = EntsogRawClient()

start = pd.Timestamp('20171201', tz='Europe/Brussels')
end = pd.Timestamp('20180101', tz='Europe/Brussels')
country_code = 'NL'  # Netherlands

client.query_connection_points()
client.query_operators()
client.query_balancing_zones()
client.query_operator_point_directions(country_code)
client.query_interconnections()
client.query_aggregate_interconnections()
client.query_urgent_market_messages()
client.query_tariffs(start = start, end = end, country_code = country_code)
client.query_tariffs_sim(start = start, end = end, country_code = country_code)

    operational_options = {   
    interruption_capacity : "Actual interruption of interruptible capacity",
    allocation : "Allocation",
    firm_available : "Firm Available",
    firm_booked : "Firm Booked",
    firm_interruption_planned : "Firm Interruption Planned - Interrupted",
    firm_interruption_unplanned :"Firm Interruption Unplanned - Interrupted",
    firm_technical : "Firm Technical",
    gcv : "GCV",
    interruptible_available : "Interruptible Available",
    interruptible_booked : "Interruptible Booked",
    interruptible_interruption_actual : "Interruptible Interruption Actual – Interrupted",
    interruptible_interruption_planned : "Interruptible Interruption Planned - Interrupted",
    interruptible_total : "Interruptible Total",
    nomination : "Nomination",
    physical_flow : "Physical Flow",
    firm_interruption_capacity_planned : "Planned interruption of firm capacity",
    renomination : "Renomination",
    firm_interruption_capacity_unplanned : "Unplanned interruption of firm capacity",
    wobbe_index : "Wobbe Index",
    oversubscription_available : "Available through Oversubscription",
    surrender_available : "Available through Surrender",
    uioli_available_lt : "Available through UIOLI long-term",
    uioli_available_st : "Available through UIOLI short-term"}

EntsogPandasClient

The Pandas Client works similar to the Raw Client, with extras:

  • API limitations of big requests are automatically dealt with and put into multiple calls.
  • Tariffs (and simulated tariffs) can be melted into nice storable format. Instead of having row with EUR, local currency, shared currency for each seperate product, it will create a row for each.
  • Operational data can be either requested as in the raw format (which requires some loading time) or in an aggregate function query_operational_data_all which will aggressively request all points in Europe and a lot faster.
  • It's easier to navigate points, for instance if you want to check gazprom points. See below.
from entsog import EntsogPandasClient
import pandas as pd

client = EntsogPandasClient()

start = pd.Timestamp('20171228', tz='Europe/Brussels')
end = pd.Timestamp('20180101', tz='Europe/Brussels')
country_code = 'NL'  # Netherlands

client.query_connection_points()
client.query_operators(country_code)
client.query_balancing_zones()
client.query_operator_point_directions()
client.query_interconnections()
client.query_aggregate_interconnections()
client.query_urgent_market_messages()


client.query_tariffs(start = start, end = end, country_code = country_code, melt = True, verbose = True)
client.query_tariffs_sim(start = start, end = end, country_code = country_code, verbose = True)

client.query_aggregated_data(start = start, end = end, country_code = country_code)
# TODO: Add interruptions...
# client.query_interruptions(start = start, end = end)
client.query_CMP_auction_premiums(start = start, end = end)
client.query_CMP_unavailable_firm_capacity(start = start, end = end)

client.query_CMP_unsuccesful_requests(start = start, end = end)

operational_options = {   
    'interruption_capacity' : "Actual interruption of interruptible capacity",
    'allocation' : "Allocation",
    'firm_available' : "Firm Available",
    'firm_booked' : "Firm Booked",
    'firm_interruption_planned' : "Firm Interruption Planned - Interrupted",
    'firm_interruption_unplanned' :"Firm Interruption Unplanned - Interrupted",
    'firm_technical' : "Firm Technical",
    'gcv' : "GCV",
    'interruptible_available' : "Interruptible Available",
    'interruptible_booked' : "Interruptible Booked",
    'interruptible_interruption_actual' : "Interruptible Interruption Actual – Interrupted",
    'interruptible_interruption_planned' : "Interruptible Interruption Planned - Interrupted",
    'interruptible_total' : "Interruptible Total",
    'nomination' : "Nomination",
    'physical_flow' : "Physical Flow",
    'firm_interruption_capacity_planned' : "Planned interruption of firm capacity",
    'renomination' : "Renomination",
    'firm_interruption_capacity_unplanned' : "Unplanned interruption of firm capacity",
    'wobbe_index' : "Wobbe Index",
    'oversubscription_available' : "Available through Oversubscription",
    'surrender_available' : "Available through Surrender",
    'uioli_available_lt' : "Available through UIOLI long-term",
    'uioli_available_st' : "Available through UIOLI short-term"
}

client.query_operational_data(start = start, end = end, country_code = country_code, indicators = ['renomination', 'physical_flow'])
# You should use this when you want to query operational data for the entirety of continental europe.
client.query_operational_data_all(start = start, end = end, indicators = ['renomination', 'physical_flow'])
# Example for if you would like to see Gazprom points.
points = client.query_operator_point_directions()
mask = points['connected_operators'].str.contains('Gazprom')
masked_points = points[mask]
print(masked_points)

keys = []
for idx, item in masked_points.iterrows():
    keys.append(f"{item['operator_key']}{item['point_key']}{item['direction_key']}")

data = client.query_operational_point_data(start = start, end = end, indicators = ['physical_flow'], point_directions = keys, verbose = False)

print(data.head())

entsog-py's People

Contributors

bchaudron avatar consideratio avatar dave-cz avatar duizendnegen avatar fabianhofmann avatar fboerman avatar fgenoese avatar fleimgruber avatar fortizflexidao avatar frankboermantennet avatar gmohandas avatar jakobkruse1 avatar jimich avatar jm-sm avatar jpaduart avatar jrtpec avatar maurerle avatar mikaello avatar nhcb avatar pponl avatar quintinnicolas avatar shatteringlass avatar tinkaa avatar tranberg avatar waldemarmeier avatar xytreyum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

entsog-py's Issues

Tried the example without succes

Hi,

I've found you library very useful. However, when trying to run the example, it raises an error for plot_utils not being part of entsog. Could you help me with this?

Thanks.

Offset Issue and Gateway time out

There are too many requests being pushed with an offset at 1000, increase it to 10.000. Also, catch 504 server error additionally; by waiting some more (using the logic already defined).

Day ahead prices

Hi,

Probably not an issue with the package, but rather on my knowledge side.

I stumbled upon this repository in my search for calculating/retrieving day ahead prices for energy and gas. With the entsoe API I managed to retrieve the day ahead prices. Is this also possible with the entsog API, and by extension with this package?

More specifically, I'm trying to get the day ahead prices for ZTP in Belgium (both ZTP Day Ahead and ZTP Weekend).

My apologies if this question is too far out of scope. I tried several queries using your library and managed to get a very extensive list of operator points (related to Fluxys/ZTP/...) and tariffs (although I had to revert to requests queries to narrow down the search scope so that the query would not take longer than 5 seconds). But none of those made me any wiser. Do you have any directions? (Hoping you would have gather some knowledge around this by building this library)

Thanks,
Olivier

Documentation examples don't work

Package installed and example code run in environment. The following error message is output:

C:\Users\XXXXX\PycharmProjects\entsog-test\venv\Scripts\python.exe C:/Users/XXXXX/PycharmProjects/entsog-test/main.py
Traceback (most recent call last):
File "C:/Users/XXXXX/PycharmProjects/entsog-test/main.py", line 10, in
client.query_connection_points()
File "C:\Users\XXXXX\PycharmProjects\entsog-test\venv\lib\site-packages\entsog\entsog.py", line 180, in query_connection_points
response = self._base_request(endpoint='/connectionpoints')
File "C:\Users\XXXXX\PycharmProjects\entsog-test\venv\lib\site-packages\entsog\decorators.py", line 22, in retry_wrapper
result = func(*args, **kwargs)
TypeError: _base_request() missing 1 required positional argument: 'params'

Issue with country code

Hi, when trying to use the EntsogPandasClient I get the following error on 'country_code'.

TypeError: query_operational_data() got an unexpected keyword argument 'country_code'

I would like to pull the data by country but I also struggled with identifying a way to do this when looking at the ENTSOG API user manual as well. It looks like in mappings.py that there was code developed to map the operator labels to countries, but not sure how to resolve the error when running the sample code for NL. The gazprom example with the plot runs perfectly.

Thank you!

'EntsogPandasClient' object has no attribute 'query_operational_point_data'

Hi,

Thanks for the package. I'm trying to use the function query_operational_point_data as you do in the description but I get an error saying that it does not exist. I look in the class and it seems that the function does exist. Do you know what's going on? I have installed the package as you describe in the description.

Best.

Fail to get the correct Dataframe data from Json

Hi nhcb,

I run the scripts today and it returned with the key error message below:

File "", line 15, in <cell line: 15>
df = client.query_operational_data_all(start = start, end = end, indicators = ['physical_flow'])
df = pd.json_normalize(json_data[keys[1]])
IndexError: list index out of range

I think their original json format data had changed a little bit.

Data no longer in DataFrame format

Hi,
Since I updated to entsog-py 1.0.2 the downloaded data cannot be correctly formatted by Pandas and remains as a long string. This was not the case with the previous versions.
Lucas

tests.py unupdated?

Hi,

I'm trying to use your code (thanks a lot for having it public) to download some data and I'm reading the tests.py file. However, I think there are some things that are not yet updated or nor working. First, when using query_interruptions, there are not "country_code", "start"; "end" inputs anymore, right? Second, when using the small loop to aggregate data (lines 64-78), you don't include the balancing_zone, why?

Sorry to bother you and thanks a lot for your work.

Best,
R

Fail to connect

Once I used the package to get the data in Dataframe, the error shows "Max retries exceeded with url"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.