Package for accessing the NG ESO Carbon Intensity API
Project description
National Grid Data Portal API Wrapper
Overview
About the Portal
The National Grid ESO Carbon Intensity API provides an interface to data on the Carbon Intensity of the UK electricity system at both a national and regional (DNO) level. It was developed as a collaboration between WFF, Environmental Defense Fund, NG ESO & Oxford University.
This Python wrapper makes it easier to query data from the API and receive back Panda's DataFrames ready for further analysis, as well as simplify the querying procedure itself. If you have any ideas for the module please feel free to contribute!
The package can be installed using:
pip install CIDataPortal
Module Usage
Getting Started
The module's Wrapper class is the main interface with the API, it can be imported as follows:
from CIDataPortal import Wrapper
To make a query you must first initialise the Wrapper class. You can then use the .query_API() to (by default) retrieve data for todays obsrrved and forecasted carbon intensity. The response is then automatically parsed into a Panda's DataFrame.
wrapper = Wrapper()
df = wrapper.query_API()
df.head()
forecast | actual | |
---|---|---|
2020-06-17 00:00:00+00:00 | 263 | 265.0 |
2020-06-17 00:30:00+00:00 | 259 | 263.0 |
2020-06-17 01:00:00+00:00 | 259 | 262.0 |
2020-06-17 01:30:00+00:00 | 259 | 262.0 |
2020-06-17 02:00:00+00:00 | 256 | 264.0 |
It is then trivial to then plot and carry out further analysis with the data, e.g:
wrapper.query_API().plot()
plt.ylabel('gCO2/kWh')
Advanced Usage
We can also specify the data stream, spatial aggregation level and date range to be returned from the API. Whilst the API limits requests to a maximum of 2-weeks, the Python wrapper automatically handles the splitting of queries and collation of returned data.
wrapper = Wrapper()
df = wrapper.query_API('2020-01-01',
'2020-06-01',
level='national',
data_stream='generation')
df.head()
biomass | coal | imports | gas | nuclear | other | hydro | solar | wind | |
---|---|---|---|---|---|---|---|---|---|
2020-01-01 00:00:00+00:00 | 8.7 | 2.5 | 9.5 | 29.5 | 25.8 | 0.5 | 2.5 | 0.0 | 21.0 |
2020-01-01 00:30:00+00:00 | 8.6 | 2.4 | 9.3 | 30.8 | 25.3 | 0.4 | 2.4 | 0.0 | 20.8 |
2020-01-01 01:00:00+00:00 | 8.9 | 2.5 | 9.6 | 29.1 | 26.2 | 0.5 | 2.5 | 0.0 | 20.7 |
2020-01-01 01:30:00+00:00 | 9.0 | 2.6 | 9.8 | 28.5 | 26.7 | 0.5 | 2.3 | 0.0 | 20.6 |
2020-01-01 02:00:00+00:00 | 9.2 | 2.6 | 10.0 | 27.5 | 27.3 | 0.5 | 2.1 | 0.0 | 20.8 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file CIDataPortal-1.0.0.tar.gz
.
File metadata
- Download URL: CIDataPortal-1.0.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ac810a161c831c8afbbf454219a56f7ec62eb48ef2b27929a171da98ff9640a |
|
MD5 | 2c74b040814b457b389a8cc984d27041 |
|
BLAKE2b-256 | f114d22515aecb8c597a693c14c00e599b9d3f754bb2a38b91a4884857da938d |
File details
Details for the file CIDataPortal-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: CIDataPortal-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64a3f793bca2e65bbecf617b098843c8563830d454035a6984124aa4f27b4066 |
|
MD5 | ee46c73dee19ad47f009f4734c81d4af |
|
BLAKE2b-256 | b8197ef278bc123030b3908a42c78456535c6f1e56f03da25c9e1776ab9c6c3b |