<jupyter_start><jupyter_text>AR6 WG1 - SPM.8This notebook reproduces parts of **Figure SPM.8** of the IPCC's *Working Group I contribution to the Sixth Assessment Report* ([AR6 WG1](https://www.ipcc.ch/assessment-report/ar6/)).The data supporting the SPM figure is published under a Creative Commons CC-BY license at the [Centre for Environmental Data Analyis (CEDA)](https://catalogue.ceda.ac.uk/uuid/ae4f1eb6fce24adcb92ddca1a7838a5c).This notebook uses a version of that data which was processed for interoperability with the format used by IPCC WG3, the so-called IAMC format.  The notebook is available under an open-source [BSD-3 License](https://github.com/openscm/AR6-WG1-Data-Compilation/blob/main/LICENSE) in the [openscm/AR6-WG1-Data-Compilation](https://github.com/openscm/AR6-WG1-Data-Compilation) GitHub repository.The notebook uses the Python package [pyam](https://pyam-iamc.readthedocs.io), which provides a suite of features and methods for the analysis, validation and visualization of reference data and scenario resultsgenerated by integrated assessment models, macro-energy tools and other frameworksin the domain of energy transition, climate change mitigation and sustainable development.<jupyter_code>import matplotlib.pyplot as plt
import pandas as pd
import pyam
import utils
rc = pyam.run_control()
rc.update("plotting.yaml")<jupyter_output><empty_output><jupyter_text>Import and inspect the scenario dataThe processed time format for SPM 8 has two columns that are not standard IAMC/pyam columns *reference_period_end_year* and *reference_period_start_year* for advanced features with **smcdata**.To work with the data in pyam, we first import the data as a **pandas.DataFrame**.Then, we remove these columns and cast the data as a [pyam.IamDataFrame](https://pyam-iamc.readthedocs.io/en/stable/api/iamdataframe.html).<jupyter_code>data = pd.read_csv(utils.DATA_DIR / "processed" / "fig-spm8" / "fig-spm8-timeseries.csv")
data.drop(columns=["reference_period_end_year", "reference_period_start_year"], inplace=True)

df = pyam.IamDataFrame(data)
df<jupyter_output><empty_output><jupyter_text>Create a simple plot for surface air temperature change (Panel a)We use [matplotlib](https://matplotlib.org) andthe [pyam plotting module](https://pyam-iamc.readthedocs.io/en/stable/gallery/index.html)to create a figure composed of several elements (the mean and the ranges).The pyam-plotting feature `final_ranges` allows to highlight the ranges of temperature outcome by scenarioat the end of the century ([read the docs](https://pyam-iamc.readthedocs.io/en/stable/api/plotting.htmlpyam.plotting.line)).<jupyter_code>fig, ax = plt.subplots()

# Compile the variables to be used for this figure
variable = "Surface Air Temperature Change"
mean = f"{variable}|Mean"
ranges = [f"{variable}|{quant}" for quant in ["5%", "95%"]]

# Plot the data
df.filter(variable=mean).plot(ax=ax, color="scenario")
df.filter(variable=ranges).plot(ax=ax, color="scenario", alpha=0, fill_between=True, final_ranges=True)

# Clean and show the plot
ax.set_title("Global surface temperature change relative to 1850-1900")
plt.tight_layout()
fig<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10400252127324298, 'fraction_numerical': 0.013551843681058934, 'mean_word_length': 6.148648648648648, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 9, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '36054', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1014, 'n_tokens_neox': 975, 'n_words': 302, 'path': 'notebooks/ar6-wg1-spm8-pyam.ipynb', 'repo_name': 'openscm/AR6-WG1-Data-Compilation', 'size': '3173'}