{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# General concept\n", "\n", "This tutorial demonstrates basic concepts of the package." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import bonsai_ipcc\n", "my_ipcc = bonsai_ipcc.IPCC()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Structure\n", "The structure of the package is as followed:\n", "- ipcc.``.``.sequence.``\n", "- ipcc.``.``.parameter.``\n", "- ipcc.``.``.dimension.``\n", "- ipcc.``.``.concordance.``\n", "- ipcc.``.``.elementary.``" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Get information about a tier sequence" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on function tier1_co2 in module ipcc.waste.incineration.sequence:\n", "\n", "tier1_co2(year=2010, region='BG', wastetype='msw_food', incintype='open_burn', uncertainty='def')\n", " Tier 1 method CO2 Emissions.\n", " \n", " Default data to quantify waste generation, composition and management practice\n", " (requirement: incineration or open burning is not a key category)\n", " \n", " Argument\n", " ---------\n", " year : int\n", " year under study\n", " region : str\n", " region under study\n", " wastetype : str\n", " Fraction of solid waste.\n", " incintype : str\n", " Type of incineration.\n", " uncertainty : str\n", " 'analytical', 'monte_carlo' or a property dimension, e.g. 'def'\n", " \n", " Returns\n", " -------\n", " VALUE: DataClass\n", " Inlcudes the results of each step of the sequence.\n", "\n" ] } ], "source": [ "help(my_ipcc.waste.incineration.sequence.tier1_co2)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Inspect the involved parameters" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['cf',\n", " 'SW',\n", " 'isw_gen_rate',\n", " 'msw_frac_to_incin',\n", " 'of',\n", " 'fcf',\n", " 'msw_type_frac',\n", " 'gdp',\n", " 'b_frac',\n", " 'isw_frac_to_incin',\n", " 'urb_population',\n", " 'msw_gen_rate',\n", " 'dm',\n", " 'total_population',\n", " 'incintype_frac',\n", " 'p_frac']" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_ipcc.inspect(my_ipcc.waste.incineration.sequence.tier1_co2)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Show the table of a parameter" ] }, { "cell_type": "code", "execution_count": 4, "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", "
valueunit
yearregionwaste_typeproperty
2006Worldmsw_fooddef0.40kg/kg
msw_gardendef0.40kg/kg
msw_paperdef0.90kg/kg
msw_wooddef0.84kg/kg
msw_textilesdef0.80kg/kg
\n", "
" ], "text/plain": [ " value unit\n", "year region waste_type property \n", "2006 World msw_food def 0.40 kg/kg\n", " msw_garden def 0.40 kg/kg\n", " msw_paper def 0.90 kg/kg\n", " msw_wood def 0.84 kg/kg\n", " msw_textiles def 0.80 kg/kg" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_ipcc.waste.incineration.parameter.dm.head()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on function msw_to_incin in module ipcc.waste.waste_generation.elementary:\n", "\n", "msw_to_incin(urb_population, msw_gen_rate, msw_frac_to_incin, msw_type_frac)\n", " Equation 2.y (not explicit in guidelines, tier 1)\n", " \n", " Calculates the amount of municipal solid waste (MSW) disposed to incineration sites,\n", " by using default data from chapter 2 (Waste Generation, Composition amd Management).\n", " \n", " Argument\n", " --------\n", " urb_population (cap/year) : float\n", " Urban population of a region in a given year.\n", " msw_gen_rate (t/cap) : float\n", " rate of municipal solid waste per capita.\n", " msw_frac_to_incin (kg/kg) : float\n", " Fraction of waste disposed to incineration in municipal solid waste.\n", " \n", " Returns\n", " -------\n", " VALUE: float\n", " amount of certain MSW type which is incinerated (tonnes/year)\n", "\n" ] } ], "source": [ "help(my_ipcc.waste.incineration.elementary.msw_to_incin)\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Check dimension tables of the parameter msw_frac_to_swds\n" ] }, { "cell_type": "code", "execution_count": 6, "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", "
descriptionregion_type
code
AFAfghanistancountry
AXÅland Islandscountry
ALAlbaniacountry
DZAlgeriacountry
ASAmerican Samoacountry
.........
ANTAntarcticacontinent
AFRAfricacontinent
EUREuropecontinent
ASIAsiacontinent
AUSAustralia and New Zealandcontinent
\n", "

285 rows × 2 columns

\n", "
" ], "text/plain": [ " description region_type\n", "code \n", "AF Afghanistan country\n", "AX Åland Islands country\n", "AL Albania country\n", "DZ Algeria country\n", "AS American Samoa country\n", "... ... ...\n", "ANT Antarctica continent\n", "AFR Africa continent\n", "EUR Europe continent\n", "ASI Asia continent\n", "AUS Australia and New Zealand continent\n", "\n", "[285 rows x 2 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_ipcc.waste.incineration.dimension.region" ] }, { "cell_type": "code", "execution_count": 7, "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", "
description
code
0place holder for emtpy tables
1900year in which activity occurs
1901year in which activity occurs
1902year in which activity occurs
1903year in which activity occurs
\n", "
" ], "text/plain": [ " description\n", "code \n", "0 place holder for emtpy tables\n", "1900 year in which activity occurs\n", "1901 year in which activity occurs\n", "1902 year in which activity occurs\n", "1903 year in which activity occurs" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_ipcc.waste.incineration.dimension.year.head()" ] }, { "cell_type": "code", "execution_count": 8, "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", "
descriptionremarks
code
defdefaultmean
minminimum2.5th percentile
maxmaximum97.5th percentile
abs_maxabsolute maximuntheoretical upper bound
abs_minabsolute minimumtheoretical lower bound
dummyplace holder for emtpy tablesNaN
\n", "
" ], "text/plain": [ " description remarks\n", "code \n", "def default mean\n", "min minimum 2.5th percentile\n", "max maximum 97.5th percentile\n", "abs_max absolute maximun theoretical upper bound\n", "abs_min absolute minimum theoretical lower bound\n", "dummy place holder for emtpy tables NaN" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_ipcc.waste.incineration.dimension.property" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Concordance tables\n", "\n", "Concordance tables are used to automated reading `parameter` values within a tier sequence. \n", "When reading the `parameter` value for a certain `dimension`, in general, this value is specified in the `parameter` table. \n", "\n", "However, the requirement to define all `parameter` values for each `dimension` explicitally in the `parameter` table would lead to a lot of repetition. To avoid this, the concept of `concordance` tables is used. Each attribute of a `dimension` can be hierarchically mapped to others. When using the `concordance` table for a `dimension`, the algorithm checks automatically if values for other `dimension` attributes are available in the `parameter` table\n", "\n", "Let´s have a look to the `concordance` table for the `dimension` 'region'." ] }, { "cell_type": "code", "execution_count": 9, "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", "
unregiongeographicregioncontinentworld
country
AFSouthern AsiaNaNASIWorld
AXNorthern EuropeNaNEURWorld
ALSouthern EuropeNaNEURWorld
DZNorthern AfricaNaNAFRWorld
ASPolynesiaNaNAUSWorld
\n", "
" ], "text/plain": [ " unregion geographicregion continent world\n", "country \n", "AF Southern Asia NaN ASI World\n", "AX Northern Europe NaN EUR World\n", "AL Southern Europe NaN EUR World\n", "DZ Northern Africa NaN AFR World\n", "AS Polynesia NaN AUS World" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_ipcc.waste.incineration.concordance.region.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When reading a `parameter` within a sequence for the `region` Albania ('AL'), the algorithm would start trying to find the value for 'AL'. If there is no value for 'AL' in the `parameter` table, it would try to find the value for 'Southern Europe', stepwise until to the last item of the column. In this case this is 'World', which indicates the validity of the `parameter` value for all regions.\n", "\n", "('NaN' is skipped during the approach)" ] }, { "cell_type": "code", "execution_count": 10, "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", "
cat3cat2cat1cat0
cat4
20062019NaNNaNNaN
200720062019.0NaNNaN
200820062019.0NaNNaN
200920062019.0NaNNaN
201020062019.0NaNNaN
\n", "
" ], "text/plain": [ " cat3 cat2 cat1 cat0\n", "cat4 \n", "2006 2019 NaN NaN NaN\n", "2007 2006 2019.0 NaN NaN\n", "2008 2006 2019.0 NaN NaN\n", "2009 2006 2019.0 NaN NaN\n", "2010 2006 2019.0 NaN NaN" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_ipcc.waste.incineration.concordance.year.head()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Look at the additional tutorials how to run a tier sequence." ] } ], "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.10.4" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }