UKCarbonIntensityData
Documentation for UKCarbonIntensityData.
Retrieving Data
We can use this package to retrieve the recorded carbon intensity (measured in gCO₂/kWh) over a specified date range.
National data
using UKCarbonIntensityData
using Plots
using TimeZones
using Dates
start_date = ZonedDateTime(2022, 01, 01, tz"UTC")
end_date = ZonedDateTime(2022, 01, 10, tz"UTC")
# get national level intensity data for the given period
national_data = get_carbon_intensity(start_date, end_date)
first(national_data, 5)5×5 DataFrame
| Row | from | to | actual | forecast | index |
|---|---|---|---|---|---|
| DateTime | DateTime | Any | Any | Any | |
| 1 | 2021-12-31T23:30:00 | 2022-01-01T00:00:00 | 71 | 83 | low |
| 2 | 2022-01-01T00:00:00 | 2022-01-01T00:30:00 | 74 | 74 | low |
| 3 | 2022-01-01T00:30:00 | 2022-01-01T01:00:00 | 75 | 70 | low |
| 4 | 2022-01-01T01:00:00 | 2022-01-01T01:30:00 | 73 | 70 | low |
| 5 | 2022-01-01T01:30:00 | 2022-01-01T02:00:00 | 68 | 61 | low |
Regional data
We can also retrieve the forecasted carbon intensity at the regional level
regional_data = get_regional_data(end_date - Day(5), end_date)
regional_intensity = regional_data.intensity;
regional_mix = regional_data.generation;
display(first(regional_mix))Todays forecast
We can also grab the forecast data for the next 48 hours, at both national or regional levels.
national_data = get_todays_forecast()
first(national_data)DataFrameRow (5 columns)
| Row | from | to | actual | forecast | index |
|---|---|---|---|---|---|
| DateTime | DateTime | Any | Any | Any | |
| 1 | 2026-09-09T23:30:00 | 2026-09-10T00:00:00 | 153 | 162 | moderate |
regional_data = get_todays_forecast(regional = true)
first(regional_data)DataFrameRow (8 columns)
| Row | from | to | regionid | generationmix | shortname | dnoregion | forecast | index |
|---|---|---|---|---|---|---|---|---|
| DateTime | DateTime | Any | Any | Any | Any | Any | Any | |
| 1 | 2026-09-09T23:30:00 | 2026-09-10T00:00:00 | 1 | Any[Dict{String, Any}("fuel"=>"biomass", "perc"=>0), Dict{String, Any}("fuel"=>"coal", "perc"=>0), Dict{String, Any}("fuel"=>"imports", "perc"=>0), Dict{String, Any}("fuel"=>"gas", "perc"=>0), Dict{String, Any}("fuel"=>"nuclear", "perc"=>0), Dict{String, Any}("fuel"=>"other", "perc"=>0), Dict{String, Any}("fuel"=>"hydro", "perc"=>0), Dict{String, Any}("fuel"=>"solar", "perc"=>0), Dict{String, Any}("fuel"=>"wind", "perc"=>100)] | North Scotland | Scottish Hydro Electric Power Distribution | 0 | very low |
Plotting Data
This package also exports some recipes to plot the data. Below shows how we can retrieve the 48 hour forecast data, for the nation as a whole,
todays_plot()or for a specific region
todays_plot(region = "South Scotland")todays_plot(region = "North West England")We can also view the recorded carbon intensity over a given time period
carbon_intensity(start_date, end_date)