{ "cells": [ { "cell_type": "markdown", "id": "basic-appearance", "metadata": {}, "source": [ "# Generate metrics in Table 7.SM.7\n", "\n", "The script that pre-dated this notebook, and the calculations that now exist in `src/ar6/metrics`, were originally provided by Bill Collins (University of Reading, UK). \n", "\n", "I have modified them slightly and added documentation.\n", "\n", "Theme Song: Low Tide
\n", "Artist: Isis, Aereogramme
\n", "Album: In The Fishtank 14
\n", "Released: 2006" ] }, { "cell_type": "code", "execution_count": 1, "id": "c3a85738", "metadata": {}, "outputs": [], "source": [ "from fair.forcing.ghg import meinshausen\n", "\n", "from tqdm.notebook import tqdm\n", "import pandas as pd\n", "import numpy as np\n", "\n", "from ar6.metrics.halogen_generic import halogen_analytical\n", "from ar6.metrics.co2 import co2_analytical\n", "from ar6.metrics.ch4 import ch4_analytical\n", "from ar6.metrics.n2o import n2o_analytical\n", "from ar6.metrics.gasser import carbon_cycle_adjustment" ] }, { "cell_type": "markdown", "id": "aa9a4d1d", "metadata": {}, "source": [ "## Grab raw data, and define output tables" ] }, { "cell_type": "code", "execution_count": 2, "id": "d86f0c0b", "metadata": {}, "outputs": [], "source": [ "# Input data file\n", "# note, this is a file that has been cleaned up and standardised by Bill Collins\n", "# original file is from Hodnebrog et al. 2020, Reviews of Geophysics\n", "# https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2019RG000691\n", "# supplementary table S1\n", "halo_file = \"../data_input/Hodnebrog_et_al_2020_revgeo/hodnebrog20.csv\"" ] }, { "cell_type": "code", "execution_count": 3, "id": "180eb0c9", "metadata": {}, "outputs": [], "source": [ "# extract raw data\n", "halo = np.genfromtxt(\n", " halo_file,\n", " delimiter=',',\n", " comments='£', # seemed to work better than None\n", " names=True,\n", " dtype=\"U30, U20, U20, U30, f8, f8, f8\",\n", " usecols = (0, 1, 2, 3, 4, 5, 6)\n", ")" ] }, { "cell_type": "code", "execution_count": 4, "id": "e2865e18", "metadata": {}, "outputs": [], "source": [ "# Allocate output table\n", "num_halo = np.size(halo)\n", "names = ['Name', 'CASRN', 'Acronym', 'Formula', 'Lifetime',\n", " 'Radiative_efficiency', 'AGWP20', 'GWP20', 'AGWP100', 'GWP100', 'AGWP500', 'GWP500',\n", " 'AGTP50', 'GTP50', 'AGTP100', 'GTP100', 'CGTP50', 'CGTP100']\n", "formats = np.concatenate((np.repeat('U30',4), np.repeat('f8', 14)))\n", "table = np.zeros(\n", " num_halo+3,\n", " dtype={\n", " 'names': names,\n", " 'formats': formats\n", " }\n", ")" ] }, { "cell_type": "markdown", "id": "fe0f6532", "metadata": {}, "source": [ "## Define baseline GHG concentrations" ] }, { "cell_type": "code", "execution_count": 5, "id": "0e24bf03", "metadata": {}, "outputs": [], "source": [ "co2 = 409.9\n", "ch4 = 1866.3\n", "n2o = 332.1" ] }, { "cell_type": "markdown", "id": "29299b6d", "metadata": {}, "source": [ "## For non-CO2 gases, the metrics require a carbon cycle adjustment\n", "\n", "This has to be calculated using a numerical convolution, and we define a timestep of 0.1 years as well as our longest time horizon of interest" ] }, { "cell_type": "code", "execution_count": 6, "id": "fadf0db0", "metadata": {}, "outputs": [], "source": [ "ts_per_year = 10\n", "H_max = 500 # years" ] }, { "cell_type": "markdown", "id": "31eb4fa3", "metadata": {}, "source": [ "## First let's get the metrics for CO2" ] }, { "cell_type": "code", "execution_count": 7, "id": "94b45755", "metadata": {}, "outputs": [], "source": [ "rf_co2, agwp_co2, agtp_co2, iagtp_co2 = co2_analytical(\n", " np.linspace(0, H_max, H_max * ts_per_year + 1),\n", " d=np.array([3.424102092311, 285.003477841911]),\n", " #q=np.array([0.443767728883447, 0.319591049742508]), # this is what is in Zeb's file sent 25 Feb\n", " q = np.array([0.443767728883447, 0.313998206372015]), # this is what Bill used\n", " co2=co2, n2o=n2o,\n", " a=np.array([0.2173, 0.2240, 0.2824, 0.2763]),\n", " alpha_co2=np.array([0, 394.4, 36.54, 4.304]),\n", " co2_ra = 0.05\n", ")" ] }, { "cell_type": "code", "execution_count": 8, "id": "070db06a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('Carbon dioxide', '', '', 'CO2', nan, 1.33449857e-05, 2.43362466e-14, 1., 8.94651231e-14, 1., 3.13800615e-13, 1., 4.27703608e-16, 1., 3.94597382e-16, 1., 0., 0.)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Save to first row of output\n", "table[0]['Name'] = 'Carbon dioxide'\n", "table[0]['Formula'] = 'CO2'\n", "table[0]['Lifetime'] = np.nan\n", "table[0]['Radiative_efficiency'] = meinshausen(np.array([co2+0.001, 1866.3, n2o]), np.array([co2, 1866.3, n2o]), scale_F2x=False)[0] * 1.05\n", "table[0]['AGWP20'] = agwp_co2[20 * ts_per_year]\n", "table[0]['GWP20'] = 1.\n", "table[0]['AGWP100'] = agwp_co2[100 * ts_per_year]\n", "table[0]['GWP100'] = 1.\n", "table[0]['AGWP500'] = agwp_co2[500 * ts_per_year]\n", "table[0]['GWP500'] = 1.\n", "table[0]['AGTP50'] = agtp_co2[50 * ts_per_year]\n", "table[0]['GTP50'] = 1.\n", "table[0]['AGTP100'] = agtp_co2[100 * ts_per_year]\n", "table[0]['GTP100'] = 1.\n", "table[0]" ] }, { "cell_type": "markdown", "id": "fa58d412", "metadata": {}, "source": [ "## Then CH4" ] }, { "cell_type": "code", "execution_count": 9, "id": "c74b1f15", "metadata": {}, "outputs": [], "source": [ "rf_ch4, agwp_ch4, agtp_ch4, iagtp_ch4 = ch4_analytical(\n", " np.linspace(0, H_max, H_max * ts_per_year + 1),\n", " d=np.array([3.424102092311, 285.003477841911]),\n", " #q=np.array([0.443767728883447, 0.319591049742508]), # this is what is in Zeb's file sent 25 Feb\n", " q = np.array([0.443767728883447, 0.313998206372015]), # this is what Bill used\n", " co2=co2, ch4=ch4, n2o=n2o,\n", " ch4_ra = -0.14,\n", " alpha_ch4 = 11.8,\n", " ch4_o3=1.4e-4,\n", " ch4_h2o=0.00004\n", ")" ] }, { "cell_type": "markdown", "id": "270bae51", "metadata": {}, "source": [ "### For non-CO2 metrics, calculate the carbon cycle adjustment\n", "\n", "This is quite slow, because every timestep has to be calculated" ] }, { "cell_type": "code", "execution_count": 10, "id": "2172b197", "metadata": {}, "outputs": [], "source": [ "rf_cc, agwp_cc, agtp_cc = carbon_cycle_adjustment(\n", " np.linspace(0, H_max, H_max * ts_per_year + 1),\n", " agtp_ch4,\n", " co2=co2,\n", " n2o=n2o,\n", " co2_ra = 0.05,\n", " d = np.array([3.424102092311, 285.003477841911]),\n", " #q=np.array([0.443767728883447, 0.319591049742508]), # this is what is in Zeb's file sent 25 Feb\n", " q = np.array([0.443767728883447, 0.313998206372015]), # this is what Bill used\n", ")" ] }, { "cell_type": "code", "execution_count": 11, "id": "8460ba99", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('Methane', '', '', 'CH4', 11.8, 0.00038864, 1.97607794e-12, 81.19896117, 2.49242801e-12, 27.85921399, 2.49553803e-12, 7.95262314, 4.72554957e-15, 11.04865493, 2.12177589e-15, 5.3770653, 2732.01949364, 3323.33972966)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Save to second row of output\n", "table[1]['Name'] = 'Methane'\n", "table[1]['Formula'] = 'CH4'\n", "table[1]['Lifetime'] = 11.8\n", "table[1]['Radiative_efficiency'] = meinshausen(np.array([co2, ch4+1, n2o]), np.array([co2, ch4, n2o]), scale_F2x=False)[1] * 0.86\n", "table[1]['AGWP20'] = agwp_ch4[20 * ts_per_year] + agwp_cc[20 * ts_per_year]\n", "table[1]['GWP20'] = (agwp_ch4[20 * ts_per_year]+agwp_cc[20 * ts_per_year])/agwp_co2[20 * ts_per_year]\n", "table[1]['AGWP100'] = agwp_ch4[100 * ts_per_year] + agwp_cc[100 * ts_per_year]\n", "table[1]['GWP100'] = (agwp_ch4[100 * ts_per_year]+agwp_cc[100 * ts_per_year])/agwp_co2[100 * ts_per_year]\n", "table[1]['AGWP500'] = agwp_ch4[500 * ts_per_year] + agwp_cc[500 * ts_per_year]\n", "table[1]['GWP500'] = (agwp_ch4[500 * ts_per_year]+agwp_cc[500 * ts_per_year])/agwp_co2[500 * ts_per_year]\n", "table[1]['AGTP50'] = agtp_ch4[50 * ts_per_year] + agtp_cc[50 * ts_per_year]\n", "table[1]['GTP50'] = (agtp_ch4[50 * ts_per_year]+agtp_cc[50 * ts_per_year])/agtp_co2[50 * ts_per_year]\n", "table[1]['AGTP100'] = agtp_ch4[100 * ts_per_year] + agtp_cc[100 * ts_per_year]\n", "table[1]['GTP100'] = (agtp_ch4[100 * ts_per_year]+agtp_cc[100 * ts_per_year])/agtp_co2[100 * ts_per_year]\n", "### and also CGTP for methane\n", "rf_cc, agwp_cc, agtp_cc = carbon_cycle_adjustment(\n", " np.linspace(0, H_max, H_max * ts_per_year + 1),\n", " iagtp_ch4,\n", " co2=co2,\n", " n2o=n2o,\n", " co2_ra = 0.05,\n", " d = np.array([3.424102092311, 285.003477841911]),\n", " #q=np.array([0.443767728883447, 0.319591049742508]), # this is what is in Zeb's file sent 25 Feb\n", " q = np.array([0.443767728883447, 0.313998206372015]), # this is what Bill used\n", ")\n", "table[1]['CGTP50'] = (iagtp_ch4[50 * ts_per_year]+agtp_cc[50 * ts_per_year])/agtp_co2[50 * ts_per_year]\n", "table[1]['CGTP100'] = (iagtp_ch4[100 * ts_per_year]+agtp_cc[100 * ts_per_year])/agtp_co2[100 * ts_per_year]\n", "table[1]" ] }, { "cell_type": "markdown", "id": "5817d79a", "metadata": {}, "source": [ "## Then, N2O" ] }, { "cell_type": "code", "execution_count": 12, "id": "5fee10e6", "metadata": {}, "outputs": [], "source": [ "rf_n2o, agwp_n2o, agtp_n2o, iagtp_n2o = n2o_analytical(\n", " np.linspace(0, H_max, H_max * ts_per_year + 1),\n", " d=np.array([3.424102092311, 285.003477841911]),\n", " #q=np.array([0.443767728883447, 0.319591049742508]), # this is what is in Zeb's file sent 25 Feb\n", " q = np.array([0.443767728883447, 0.313998206372015]), # this is what Bill used\n", " co2=co2, ch4=ch4, n2o=n2o\n", ")\n", "rf_cc, agwp_cc, agtp_cc = carbon_cycle_adjustment(\n", " np.linspace(0, H_max, H_max * ts_per_year + 1),\n", " agtp_n2o,\n", " co2=co2,\n", " n2o=n2o,\n", " co2_ra = 0.05,\n", " d = np.array([3.424102092311, 285.003477841911]),\n", " #q=np.array([0.443767728883447, 0.319591049742508]), # this is what is in Zeb's file sent 25 Feb\n", " q = np.array([0.443767728883447, 0.313998206372015]), # this is what Bill used\n", ")" ] }, { "cell_type": "code", "execution_count": 13, "id": "82c07d4f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([3.56285141e-13, 3.55958424e-13, 3.55632006e-13, ...,\n", " 3.63427728e-15, 3.63094461e-15, 3.62761499e-15]),\n", " array([0.00000000e+00, 3.56121758e-14, 7.11916948e-14, ...,\n", " 3.84389442e-11, 3.84393074e-11, 3.84396703e-11]),\n", " array([0.00000000e+00, 4.58785456e-15, 9.04056787e-15, ...,\n", " 1.29540136e-14, 1.29489266e-14, 1.29438418e-14]),\n", " array([0.00000000e+00, 2.30535424e-16, 9.13066332e-16, ...,\n", " 2.59046361e-11, 2.59059313e-11, 2.59072259e-11]))" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rf_n2o, agwp_n2o, agtp_n2o, iagtp_n2o" ] }, { "cell_type": "code", "execution_count": 14, "id": "17b5e555", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('Nitrous oxide', '', '', 'N2O', 109., 0.00319551, 6.65001314e-12, 273.25549608, 2.44553474e-11, 273.35062615, 4.07045635e-11, 129.71473478, 1.24163669e-13, 290.30306731, 9.19268626e-14, 232.96369098, 0., 0.)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Save to third row of output\n", "table[2]['Name'] = 'Nitrous oxide'\n", "table[2]['Formula'] = 'N2O'\n", "table[2]['Lifetime'] = 109\n", "table[2]['Radiative_efficiency'] = meinshausen(np.array([co2, ch4, n2o+1]), np.array([co2, ch4, n2o]), scale_F2x=False)[2] * 1.07\n", "table[2]['AGWP20'] = agwp_n2o[20 * ts_per_year] + agwp_cc[20 * ts_per_year]\n", "table[2]['GWP20'] = (agwp_n2o[20 * ts_per_year]+agwp_cc[20 * ts_per_year])/agwp_co2[20 * ts_per_year]\n", "table[2]['AGWP100'] = agwp_n2o[100 * ts_per_year] + agwp_cc[100 * ts_per_year]\n", "table[2]['GWP100'] = (agwp_n2o[100 * ts_per_year]+agwp_cc[100 * ts_per_year])/agwp_co2[100 * ts_per_year]\n", "table[2]['AGWP500'] = agwp_n2o[500 * ts_per_year] + agwp_cc[500 * ts_per_year]\n", "table[2]['GWP500'] = (agwp_n2o[500 * ts_per_year]+agwp_cc[500 * ts_per_year])/agwp_co2[500 * ts_per_year]\n", "table[2]['AGTP50'] = agtp_n2o[50 * ts_per_year] + agtp_cc[50 * ts_per_year]\n", "table[2]['GTP50'] = (agtp_n2o[50 * ts_per_year]+agtp_cc[50 * ts_per_year])/agtp_co2[50 * ts_per_year]\n", "table[2]['AGTP100'] = agtp_n2o[100 * ts_per_year] + agtp_cc[100 * ts_per_year]\n", "table[2]['GTP100'] = (agtp_n2o[100 * ts_per_year]+agtp_cc[100 * ts_per_year])/agtp_co2[100 * ts_per_year]\n", "table[2]" ] }, { "cell_type": "markdown", "id": "ea891c82", "metadata": {}, "source": [ "## Now the halogens - this will take a while" ] }, { "cell_type": "markdown", "id": "07742760", "metadata": {}, "source": [ "### CFC11 and CFC12 need a 12% rapid adjustment\n", "\n", "See section 7.3. Although CFC11 is assessed to be 13% for ERF, we use 12% here." ] }, { "cell_type": "code", "execution_count": 15, "id": "cc773b11", "metadata": { "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "2388b24953854e1f9af38f413da86788", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/642 [00:00