{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Run a tier sequence\n", "\n", "This tutorial explains the core functionality of the `bonsai_ipcc` package.\n", "Let´s assume we want to determine the CO2 emissions from waste incineration based on the tier 1 approach. According to the IPCC guidelines, different waste fractions are available. Here we chose year 2010, Germany and waste type `msw_plastics`, which stands for municipal plastic waste (you can check all availbe waste types by `my_ipcc.waste.incineration.dimension.waste_type`) and unspecified incineration technology." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import bonsai_ipcc\n", "my_ipcc = bonsai_ipcc.IPCC()\n", "my_ipcc.waste.incineration.sequence.tier1_co2(year=2010, region=\"DE\",wastetype=\"msw_plastics\", incintype=\"inc_unspecified\", uncertainty=\"def\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Trying to do so, generates a an KeyError mentioning that it could not find the coordinate for year 2010 and Germany in the paramter table `urb_population`. Let´s have a look into this parameter table." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "my_ipcc.waste.incineration.parameter.urb_population" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is empty. The reason is that the IPCC guidelines do not provide default data for all parameters. In these cases we need to add the data to the specific parameter.\n", "Let´s do this for the urban population in Germany in 2010." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", "# urban population\n", "d = {\n", " \"year\": [2010,2010,2010,2010,2010],\n", " \"region\": [\"DE\",\"DE\",\"DE\",\"DE\",\"DE\"],\n", " \"property\": [\n", " \"def\",\"min\",\"max\",\"abs_min\",\"abs_max\"\n", " ],\n", " \"value\": [\n", " 62940432,61996325.52,63884538.48,0.0,\"inf\",\n", " ],\n", " \"unit\": [\n", " \"cap/yr\",\"cap/yr\",\"cap/yr\",\"cap/yr\",\"cap/yr\",\n", " ],\n", "}\n", "urb_pop = pd.DataFrame(d).set_index([\"year\", \"region\", \"property\"])\n", "\n", "my_ipcc.waste.incineration.parameter.urb_population=urb_pop" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And run the sequence again." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "my_tier = my_ipcc.waste.incineration.sequence.tier1_co2(\n", " year=2010, region=\"DE\",wastetype=\"msw_plastics\", incintype=\"inc_unspecified\", uncertainty=\"def\")\n", "my_tier.to_dict()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Each step involved in the calculation is stored in the dictionary. It starts with the input signature and ends with the final result of CO2 emsissions." ] } ], "metadata": { "kernelspec": { "display_name": "ipcc", "language": "python", "name": "python3" }, "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.12.1" } }, "nbformat": 4, "nbformat_minor": 2 }