Skip to main content

Package for accessing the NG ESO Carbon Intensity API

Project description

National Grid Data Portal API Wrapper


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()

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:


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',

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for CIDataPortal, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size CIDataPortal-1.0.0.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View
Filename, size CIDataPortal-1.0.0-py3-none-any.whl (6.7 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page