{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0 source reader found and added into \"datatoolbox.sources\".\n" ] }, { "data": { "application/javascript": [ "IPython.OutputArea.prototype._should_scroll = function(lines) { return false; }" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import datatoolbox as dt\n", "import pyam as pyam\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Analysing reduction levels in 1.5 pathways" ] }, { "cell_type": "code", "execution_count": 190, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "pyam.iiasa - INFO: You are connected to the IXSE_SR15 scenario explorer hosted by IIASA. If you use this data in any published format, please cite the data as provided in the explorer guidelines: https://data.ene.iiasa.ac.at/iamc-1.5c-explorer/#/about\n", "pyam.iiasa - INFO: You are connected as an anonymous user\n", "pyam.iiasa - INFO: You are connected to the IXSE_SR15 scenario explorer hosted by IIASA. If you use this data in any published format, please cite the data as provided in the explorer guidelines: https://data.ene.iiasa.ac.at/iamc-1.5c-explorer/#/about\n", "pyam.iiasa - INFO: You are connected as an anonymous user\n", "pyam.iiasa - INFO: You are connected to the IXSE_SR15 scenario explorer hosted by IIASA. If you use this data in any published format, please cite the data as provided in the explorer guidelines: https://data.ene.iiasa.ac.at/iamc-1.5c-explorer/#/about\n", "pyam.iiasa - INFO: You are connected as an anonymous user\n" ] } ], "source": [ "iam_data_15_co2 = pyam.read_iiasa('iamc15', region = 'World',\n", " variable = 'Emissions|CO2')\n", "iam_data_15_ghg = pyam.read_iiasa('iamc15', region = 'World',\n", " variable = 'Emissions|Kyoto Gases (AR4-GWP100)')\n", "\n", "iam_data_15_lu = pyam.read_iiasa('iamc15', region = 'World',\n", " variable = 'Emissions|CO2|AFOLU')\n" ] }, { "cell_type": "code", "execution_count": 192, "metadata": {}, "outputs": [], "source": [ "# Filtered pathway scenarios\n", "filtered = pd.read_csv('ca_sustainable_scenarios.csv')" ] }, { "cell_type": "code", "execution_count": 219, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
modelscenarioexclude
0AIM/CGE 2.0SSP2-19True
1AIM/CGE 2.1TERL_15D_LowCarbonTransportPolicyTrue
2C-ROADS-5.005Ratchet-1.5-noCDRTrue
3C-ROADS-5.005Ratchet-1.5-noCDR-noOSTrue
4IMAGE 3.0.1IMA15-LiStChTrue
5IMAGE 3.0.1SSP1-19True
6MESSAGE-GLOBIOM 1.0SSP1-19True
7MESSAGE-GLOBIOM 1.0SSP2-19True
8MESSAGEix-GLOBIOM 1.0LowEnergyDemandTrue
9POLES EMF33EMF33_1.5C_cost100True
10POLES EMF33EMF33_1.5C_fullTrue
11POLES EMF33EMF33_1.5C_limbioTrue
12POLES EMF33EMF33_1.5C_nofuelTrue
13POLES EMF33EMF33_WB2C_cost100True
14POLES EMF33EMF33_WB2C_limbioTrue
15POLES EMF33EMF33_WB2C_nobeccsTrue
16POLES EMF33EMF33_WB2C_nofuelTrue
17POLES EMF33EMF33_WB2C_noneTrue
18REMIND 1.7CEMICS-1.5-CDR8True
19WITCH-GLOBIOM 4.4CD-LINKS_NPi2020_400True
\n", "
" ], "text/plain": [ " model scenario exclude\n", "0 AIM/CGE 2.0 SSP2-19 True\n", "1 AIM/CGE 2.1 TERL_15D_LowCarbonTransportPolicy True\n", "2 C-ROADS-5.005 Ratchet-1.5-noCDR True\n", "3 C-ROADS-5.005 Ratchet-1.5-noCDR-noOS True\n", "4 IMAGE 3.0.1 IMA15-LiStCh True\n", "5 IMAGE 3.0.1 SSP1-19 True\n", "6 MESSAGE-GLOBIOM 1.0 SSP1-19 True\n", "7 MESSAGE-GLOBIOM 1.0 SSP2-19 True\n", "8 MESSAGEix-GLOBIOM 1.0 LowEnergyDemand True\n", "9 POLES EMF33 EMF33_1.5C_cost100 True\n", "10 POLES EMF33 EMF33_1.5C_full True\n", "11 POLES EMF33 EMF33_1.5C_limbio True\n", "12 POLES EMF33 EMF33_1.5C_nofuel True\n", "13 POLES EMF33 EMF33_WB2C_cost100 True\n", "14 POLES EMF33 EMF33_WB2C_limbio True\n", "15 POLES EMF33 EMF33_WB2C_nobeccs True\n", "16 POLES EMF33 EMF33_WB2C_nofuel True\n", "17 POLES EMF33 EMF33_WB2C_none True\n", "18 REMIND 1.7 CEMICS-1.5-CDR8 True\n", "19 WITCH-GLOBIOM 4.4 CD-LINKS_NPi2020_400 True" ] }, "execution_count": 219, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered" ] }, { "cell_type": "code", "execution_count": 193, "metadata": {}, "outputs": [], "source": [ "pathways_ghg = iam_data_15_ghg.filter(category = ['Below 1.5C', '1.5C low overshoot'])\n", "pathways_co2 = iam_data_15_co2.filter(category = ['Below 1.5C', '1.5C low overshoot'])\n", "pathways_lu = iam_data_15_lu.filter(category = ['Below 1.5C', '1.5C low overshoot'])" ] }, { "cell_type": "code", "execution_count": 181, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "pyam.core - INFO: Importing meta indicators for 20 scenarios (for total of 53)\n", "pyam.core - INFO: Importing meta indicators for 20 scenarios (for total of 47)\n", "pyam.core - INFO: Importing meta indicators for 20 scenarios (for total of 53)\n" ] } ], "source": [ "# To filter:\n", "pathways_co2.load_meta(\"ca_sustainable_scenarios.csv\")\n", "pathways_ghg.load_meta(\"ca_sustainable_scenarios.csv\")\n", "pathways_lu.load_meta(\"ca_sustainable_scenarios.csv\")\n", "\n", "pathways_co2_filt = pathways_co2.filter(exclude = True)\n", "pathways_ghg_filt = pathways_ghg.filter(exclude = True)\n", "pathways_lu_filt = pathways_lu.filter(exclude = True)" ] }, { "cell_type": "code", "execution_count": 212, "metadata": {}, "outputs": [], "source": [ "def find_stats(pathways_co2, pathways_ghg, pathways_lu):\n", " \n", " filt_ghg = pathways_ghg.timeseries()\n", " filt_co2= pathways_co2.timeseries()\n", " filt_lu = pathways_lu.timeseries()\n", " pathways_lu_eq = pathways_lu.convert_unit('Mt CO2/yr', to = 'Mt CO2-equiv/yr')\n", " \n", " a = pathways_co2.filter(variable=\"Emissions|CO2\")._data.droplevel(\"variable\")\n", " b = pathways_lu.filter(variable=\"Emissions|CO2|AFOLU\")._data.droplevel(\"variable\")\n", " result = pyam.IamDataFrame(a - b, variable=\"CO2_noAFOLU\")\n", " co2_nolu_series = result.timeseries()\n", " compare_co2_nolu = co2_nolu_series[2030] / co2_nolu_series[2010] * 100\n", "\n", " a = pathways_ghg.filter(variable=\"Emissions|Kyoto Gases (AR4-GWP100)\")._data.droplevel(\"variable\")\n", " b = pathways_lu_eq.filter(variable=\"Emissions|CO2|AFOLU\")._data.droplevel(\"variable\")\n", " result = pyam.IamDataFrame(a - b, variable=\"GHG_noAFOLU\")\n", " ghg_nolu_series = result.timeseries()\n", " compare_ghg_nolu = ghg_nolu_series[2030] / ghg_nolu_series[2010] * 100\n", " \n", " compare_co2 = filt_co2[2030] / filt_co2[2010]*100\n", " compare_ghg = filt_ghg[2030] / filt_ghg[2010]*100\n", " \n", " co2 = 100 - np.percentile(compare_co2,[50, 25, 75])\n", " ghg = 100 - np.percentile(compare_ghg,[50, 25, 75])\n", " co2_nolu = 100 - np.percentile(compare_co2_nolu,[50, 25, 75])\n", " ghg_nolu = 100 - np.percentile(compare_ghg_nolu,[50, 25, 75])\n", " \n", " ghg_2030 = np.percentile(ghg_nolu_series[2030],[50, 25, 75])\n", " pd.Data\n", " return(co2, ghg, co2_nolu, ghg_nolu, ghg_2030)\n", " " ] }, { "cell_type": "code", "execution_count": 213, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(array([51.87086399, 60.70108796, 41.52112777]), array([49.43110323, 56.38805332, 39.2470201 ]), array([42.67461495, 52.28010326, 30.81882904]), array([43.41705238, 49.25178407, 32.36960276]), array([25335.71448315, 22812.86260975, 30130.0615842 ]))\n", "(array([45.58881003, 58.90345434, 40.25862868]), array([45.79594533, 54.58340818, 37.75399871]), array([38.28646879, 50.15621219, 30.88933733]), array([38.62325866, 45.97057305, 30.84050826]), array([27476.48719 , 24132.0585445, 31860.1597895]))\n" ] } ], "source": [ "with_filters = find_stats(pathways_co2_filt, pathways_ghg_filt, pathways_lu_filt)\n", "print(with_filters[0:5])\n", "\n", "no_filters = find_stats(pathways_co2, pathways_ghg, pathways_lu)\n", "print(no_filters[0:5])" ] }, { "cell_type": "code", "execution_count": 233, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
50%25%75%
co245.58881058.90345440.258629
ghg45.79594554.58340837.753999
co2_nolu38.28646950.15621230.889337
ghg_nolu38.62325945.97057330.840508
ghg_203027476.48719024132.05854431860.159790
\n", "
" ], "text/plain": [ " 50% 25% 75%\n", "co2 45.588810 58.903454 40.258629\n", "ghg 45.795945 54.583408 37.753999\n", "co2_nolu 38.286469 50.156212 30.889337\n", "ghg_nolu 38.623259 45.970573 30.840508\n", "ghg_2030 27476.487190 24132.058544 31860.159790" ] }, "execution_count": 233, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd.DataFrame(no_filters, index = ['co2','ghg','co2_nolu','ghg_nolu','ghg_2030'], columns = ['50%', '25%', '75%'])" ] }, { "cell_type": "code", "execution_count": 234, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
50%25%75%
co251.87086460.70108841.521128
ghg49.43110356.38805339.247020
co2_nolu42.67461552.28010330.818829
ghg_nolu43.41705249.25178432.369603
ghg_203025335.71448322812.86261030130.061584
\n", "
" ], "text/plain": [ " 50% 25% 75%\n", "co2 51.870864 60.701088 41.521128\n", "ghg 49.431103 56.388053 39.247020\n", "co2_nolu 42.674615 52.280103 30.818829\n", "ghg_nolu 43.417052 49.251784 32.369603\n", "ghg_2030 25335.714483 22812.862610 30130.061584" ] }, "execution_count": 234, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd.DataFrame(with_filters, index = ['co2','ghg','co2_nolu','ghg_nolu','ghg_2030'], columns = ['50%', '25%', '75%'])" ] }, { "cell_type": "code", "execution_count": 228, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([25335.71448315, 22812.86260975, 30130.0615842 ])" ] }, "execution_count": 228, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Find emissions in 2030 in pathways (median, 25th and 75th percentiles)\n", "with_filters[4] " ] }, { "cell_type": "code", "execution_count": 226, "metadata": {}, "outputs": [], "source": [ "# Calculate change from original NDC level\n", "#(Is this a good source?)\n", "catfinal_old = pd.read_excel('../tool/Data prep/Data/CATFINAL_190823_data.xlsx', header = 28, sheet_name= 'CATFINAL_NDCA0_CATM0EL').set_index('Countries\\Years')" ] }, { "cell_type": "code", "execution_count": 157, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "51619.91\n" ] } ], "source": [ "catold_ndc_2030 = catfinal_old.loc['EARTH', 2030]\n", "print(catold_ndc_2030)" ] }, { "cell_type": "code", "execution_count": 217, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0.50918716 0.55806078 0.4163093 ]\n", "[0.46771532 0.53250483 0.38279319]\n" ] } ], "source": [ "print(1 - with_filters[4]/catold_ndc_2030)\n", "print(1 - no_filters[4]/catold_ndc_2030)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#OLD - ignore" ] }, { "cell_type": "code", "execution_count": 199, "metadata": {}, "outputs": [], "source": [ "pathways_lu_eq = pathways_lu.convert_unit('Mt CO2/yr', to = 'Mt CO2-equiv/yr')" ] }, { "cell_type": "code", "execution_count": 200, "metadata": {}, "outputs": [], "source": [ "a = pathways_co2.filter(variable=\"Emissions|CO2\")._data.droplevel(\"variable\")\n", "b = pathways_lu.filter(variable=\"Emissions|CO2|AFOLU\")._data.droplevel(\"variable\")\n", "result = pyam.IamDataFrame(a - b, variable=\"CO2_noAFOLU\")\n", "co2_nolu_series = result.timeseries()\n", "compare_co2_nolu = co2_nolu_series[2030] / co2_nolu_series[2010] * 100\n", "\n", "a = pathways_ghg.filter(variable=\"Emissions|Kyoto Gases (AR4-GWP100)\")._data.droplevel(\"variable\")\n", "b = pathways_lu_eq.filter(variable=\"Emissions|CO2|AFOLU\")._data.droplevel(\"variable\")\n", "result = pyam.IamDataFrame(a - b, variable=\"GHG_noAFOLU\")\n", "ghg_nolu_series = result.timeseries()\n", "compare_ghg_nolu = ghg_nolu_series[2030] / ghg_nolu_series[2010] * 100" ] }, { "cell_type": "code", "execution_count": 201, "metadata": {}, "outputs": [], "source": [ "compare_co2 = filt_co2[2030] / filt_co2[2010]*100\n", "compare_ghg = filt_ghg[2030] / filt_ghg[2010]*100" ] }, { "cell_type": "code", "execution_count": 202, "metadata": {}, "outputs": [], "source": [ "co2 = 100 - np.percentile(compare_co2,[50, 25, 75])\n", "ghg = 100 - np.percentile(compare_ghg,[50, 25, 75])\n", "co2_nolu = 100 - np.percentile(compare_co2_nolu,[50, 25, 75])\n", "ghg_nolu = 100 - np.percentile(compare_ghg_nolu,[50, 25, 75])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Kyoto gases (SAR) for all no / low overshoot pathways: 46% below 2010\n", "Kyoto gases (AR4) for all no / low overshoot pathways: 46% below 2010\n", "CO2: 46% (45.59%) below 2010" ] }, { "cell_type": "code", "execution_count": 203, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[38.62325866 45.97057305 30.84050826]\n", "[49.43110323 56.38805332 39.2470201 ]\n" ] } ], "source": [ "print(ghg_nolu)\n", "print(ghg)\n" ] }, { "cell_type": "code", "execution_count": 128, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 167, "metadata": {}, "outputs": [], "source": [ "stats_2030_15 = np.percentile(ghg_nolu_series[2030],[50, 25, 75])" ] }, { "cell_type": "code", "execution_count": 171, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.50918716, 0.55806078, 0.4163093 ])" ] }, "execution_count": 171, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1 - stats_2030_15 / catold_ndc_2030" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:myenv]", "language": "python", "name": "conda-env-myenv-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.1" } }, "nbformat": 4, "nbformat_minor": 4 }