Descriptive statistics of global primary energy supply (Table 2.6)¶
Notebook sr15_2.4.2.1_primary_energy_statistics¶
This notebook is based on the Release 1.1 of the IAMC 1.5C Scenario Explorer and Data and refers to the published version of the IPCC Special Report on Global Warming of 1.5C (SR15).
The notebook is run with pyam release 0.5.0.
The source code of this notebook is available on GitHub (release 2.0.2).
IPCC SR15 scenario assessment¶
Descriptive statistics of the primary energy development¶
This notebook computes indicators and diagnostics of the primary-energy timeseries by fuel for Table 2.6 in the IPCC's "Special Report on Global Warming of 1.5°C".
The scenario data used in this analysis can be accessed and downloaded at https://data.ene.iiasa.ac.at/iamc-1.5c-explorer.
Load pyam
package and other dependencies¶
import pandas as pd
import numpy as np
import io
import itertools
import yaml
import math
import matplotlib.pyplot as plt
plt.style.use('style_sr15.mplstyle')
%matplotlib inline
import pyam
Import scenario data, categorization and specifications files¶
The metadata file with scenario categorisation and quantitative indicators can be downloaded at https://data.ene.iiasa.ac.at/iamc-1.5c-explorer.
Alternatively, it can be re-created using the notebook sr15_2.0_categories_indicators
.
The last cell of this section loads and assigns a number of auxiliary lists as defined in the categorization notebook.
sr1p5 = pyam.IamDataFrame(data='../data/iamc15_scenario_data_world_r2.0.xlsx')
sr1p5.load_meta('sr15_metadata_indicators.xlsx')
with open("sr15_specs.yaml", 'r') as stream:
specs = yaml.load(stream, Loader=yaml.FullLoader)
rc = pyam.run_control()
for item in specs.pop('run_control').items():
rc.update({item[0]: item[1]})
cats = specs.pop('cats')
cats_15 = specs.pop('cats_15')
cats_15_no_lo = specs.pop('cats_15_no_lo')
marker= specs.pop('marker')
Downselect scenario ensemble to categories of interest for this assessment¶
years = [2020, 2030, 2050]
df = sr1p5.filter(category=cats_15, year=years)
Initialize a pyam.Statistics
instance¶
stats = pyam.Statistics(df=df,
filters=[('all 1.5', {}),
('no & lo os 1.5', {'category': cats_15_no_lo}),
('hi os 1.5', {'category': ['1.5C high overshoot']})
], rows=True)
header='Primary energy supply (EJ)'
header_share='Share in primary energy (%)'
header_growth='Growth (factor)'
statistics_settings = dict(
header=header,
header_share=header_share,
header_growth= header_growth,
growth_year=2050,
base_year=2020
)
def add_statistics(data, base, row, growth_year, base_year,
header, header_share, header_growth):
stats.add(data, header=header, row=row)
if base is not None:
stats.add(data / base * 100, header=header_share, row=row)
stats.add(data[growth_year] / data[base_year] - 1,
header=header_growth, row=row,
subheader='{}-{}'.format(base_year, growth_year))
Extract primary energy timeseries data and add summary statistics¶
pe = df.filter(variable='Primary Energy').timeseries()
pe.index = pe.index.droplevel([2, 3, 4])
add_statistics(pe, None, 'total primary', **statistics_settings)
Compute share of renewables by various types in primary energy¶
Only use scenarios for this indicator that report both biomass and the aggregate non-biomass timeseries - otherwise, the share would be distorted.
All renewables (biomass and non-biomass)¶
df_pe_res = df.filter()
df_pe_res.require_variable('Primary Energy|Non-Biomass Renewables', exclude_on_fail=True)
df_pe_res.require_variable('Primary Energy|Biomass', exclude_on_fail=True)
df_pe_res.filter(exclude=False, inplace=True)
res = (
df_pe_res.filter(variable=['Primary Energy|Biomass', 'Primary Energy|Non-Biomass Renewables'])
.timeseries()
.groupby(['model', 'scenario']).sum()
)
add_statistics(res, pe, 'renewables', **statistics_settings)
Biomass¶
res_bio = (
df.filter(variable=['Primary Energy|Biomass'])
.timeseries()
.groupby(['model', 'scenario']).sum()
)
add_statistics(res_bio, pe, 'biomass', **statistics_settings)
Non-biomass renewables¶
res_non_bio = (
df.filter(variable=['Primary Energy|Non-Biomass Renewables'])
.timeseries()
.groupby(['model', 'scenario']).sum()
)
add_statistics(res_non_bio, pe, 'non-biomass', **statistics_settings)
Renewable energy from wind and solar¶
As above, verify that scenarios report values for both 'Wind' and 'Solar'
df_win_sol = df.filter()
df_win_sol.require_variable('Primary Energy|Wind', exclude_on_fail=True)
df_win_sol.require_variable('Primary Energy|Solar', exclude_on_fail=True)
df_win_sol.filter(exclude=False, inplace=True)
win_sol = (
df_win_sol.filter(variable=['Primary Energy|Wind',
'Primary Energy|Solar'])
.timeseries()
.groupby(['model', 'scenario']).sum()
)
add_statistics(win_sol, pe, 'wind & solar', **statistics_settings)
Compute share of nuclear in primary energy¶
nuc = (
df.filter(variable=['Primary Energy|Nuclear'])
.timeseries()
.groupby(['model', 'scenario']).sum()
)
add_statistics(nuc, pe, 'nuclear', **statistics_settings)
Compute share of fossil in primary energy¶
fossil = (
df.filter(variable=['Primary Energy|Coal', 'Primary Energy|Gas', 'Primary Energy|Oil'])
.timeseries()
.groupby(['model', 'scenario']).sum()
)
add_statistics(fossil, pe, 'fossil', **statistics_settings)
coal = (
df.filter(variable=['Primary Energy|Coal'])
.timeseries()
.groupby(['model', 'scenario']).sum()
)
add_statistics(coal, pe, 'coal', **statistics_settings)
gas = (
df.filter(variable=['Primary Energy|Gas'])
.timeseries()
.groupby(['model', 'scenario']).sum()
)
add_statistics(gas, pe, 'gas', **statistics_settings)
oil = (
df.filter(variable=['Primary Energy|Oil'])
.timeseries()
.groupby(['model', 'scenario']).sum()
)
add_statistics(oil, pe, 'oil', **statistics_settings)
Display and export summary statistics for all 1.5C scenarios to xlsx
¶
summary = (
stats.summarize(center='median', fullrange=True)
.reindex(columns=['count', header, header_share, header_growth], level=0)
)
summary
summary.to_excel('output/table_2.6_primary_energy_supply.xlsx')