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 |
Metadata
Release files for CIDataPortal 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| CIDataPortal-1.0.0.tar.gz | 5.3 kB | Without provenance | Details for CIDataPortal-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| CIDataPortal-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for CIDataPortal-1.0.0-py3-none-any.whl |
Total release size: 12.0 kB
Release files / CIDataPortal-1.0.0.tar.gz
| Download URL | CIDataPortal-1.0.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ac810a161c831c8afbbf454219a56f7ec62eb48ef2b27929a171da98ff9640a
|
|
BLAKE2b-256 checksum How to use checksums |
f114d22515aecb8c597a693c14c00e599b9d3f754bb2a38b91a4884857da938d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / CIDataPortal-1.0.0-py3-none-any.whl
| Download URL | CIDataPortal-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64a3f793bca2e65bbecf617b098843c8563830d454035a6984124aa4f27b4066
|
|
BLAKE2b-256 checksum How to use checksums |
b8197ef278bc123030b3908a42c78456535c6f1e56f03da25c9e1776ab9c6c3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for CIDataPortal 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.