{ "cells": [ { "cell_type": "markdown", "id": "60fd7d0e-a46e-4db0-8bbe-00256058ee71", "metadata": {}, "source": [ "# Convert MRIO satellite rows" ] }, { "cell_type": "markdown", "id": "850708b0-66c3-4ca8-a50b-f7396ec4c1a7", "metadata": {}, "source": [ "Here we discuss the possibilities for converting entries in MRIO satellite accounts (Extensions).\n", "The term *convert* is used very broadly here, it includes the following tasks:\n", "\n", "- renaming the index names of results/extensions\n", "- adjusting the numerical values of the data,\n", " e.g. for unit conversion\n", "- finding and extracting data based on indices across a table or an mrio(-extension).\n", " This can be system based on name and potentially constrained by sector/region\n", " or any other specification.\n", "- Aggregation/Summation of satellite accounts\n", "- Characterization of stressors to impact categories (with low performance, see [the Notebook on stressor characterization](./stressor_characterization.ipynb) for a faster method).\n", "\n", "We will cover each of these points in the examples below.\n", "First [we will go through the general setup](#Basic-setup) describing the structure of the bridging/mapping table.\n", "We will then cover the application of the [conversion function to a single, standalone table](#Converting-standalone-tables).\n", "There we will show how to rename the index/stressor names, do [unit conversions](#Unit-conversion),\n", "and then do [global](#Global-characterization-factors) and [regional](#Regional-specific-characterization-factors) characterizations.\n", "For the case of converting a full pymrio Extension, see the [converting pymrio extensions](#Converting-pymrio-Extensions) section.\n", "\n", "For the connected topics of *Aggregation of MRIOs*\n", "see the [Aggregation](./aggregation_examples.ipynb) page and for *Characterization of Stressors* see [the Notebook on stressor characterization](./stressor_characterization.ipynb)." ] }, { "cell_type": "markdown", "id": "bde3cf89-6c36-47dd-b9d5-48433f4473b5", "metadata": {}, "source": [ "## Basic setup" ] }, { "cell_type": "markdown", "id": "49bc1d78", "metadata": {}, "source": [ "All conversion relies on a *mapping table* that maps (bridges)\n", "the index/columns of the source data to the indices of the target data." ] }, { "cell_type": "markdown", "id": "849bc1ef", "metadata": {}, "source": [ "This tables requires headers (columns) corresponding to the\n", "index.names and columns.names of the source data (constraining data)\n", "as well as bridge data which specify the new target index.\n", "The later are indicated by \"NewIndex__OldIndex\" - **the important part are\n", "the two underscore in the column name**. Another (optional)\n", "column named \"factor\" specifies\n", "the multiplication factor for the conversion.\n", "Finally, additional columns can be used to indicate units and other information. However, for the basic conversion this information will not be used. This becomes important later for the [converting Pymrio extensions](#Converting-pymrio-Extensions)." ] }, { "cell_type": "markdown", "id": "a4b5425f", "metadata": {}, "source": [ "Constraining data columns can either specify columns or index.\n", "However, any constraining data to be bridged/mapped to a new name need to be\n", "in the index of the original data." ] }, { "cell_type": "markdown", "id": "0c3ec2d8", "metadata": {}, "source": [ "The first example below shows the simplest case of renaming a single table.\n", "This will make the concept of the mapping table clear." ] }, { "cell_type": "markdown", "id": "ff2125d8", "metadata": { "lines_to_next_cell": 2 }, "source": [ "## Converting standalone tables" ] }, { "cell_type": "markdown", "id": "2cc15f8b", "metadata": {}, "source": [ "### Renaming the index entries of a single table" ] }, { "cell_type": "markdown", "id": "71e97063", "metadata": {}, "source": [ "Assume we have a small MRIO result table with the following structure:" ] }, { "cell_type": "code", "execution_count": 1, "id": "ae7e3af0", "metadata": { "tags": [] }, "outputs": [], "source": [ "import pandas as pd\n", "\n", "import pymrio\n", "\n", "ghg_result = pd.DataFrame(\n", " columns=[\"Region1\", \"Region2\", \"Region3\"],\n", " index=pd.MultiIndex.from_tuples(\n", " [\n", " (\"Carbon Dioxide\", \"Air\"),\n", " (\"Methane\", \"air\"),\n", " ]\n", " ),\n", " data=[[5, 6, 7], [0.5, 0.6, 0.7]],\n", ")\n", "ghg_result.index.names = [\"stressor\", \"compartment\"]\n", "ghg_result.columns.names = [\"region\"]" ] }, { "cell_type": "markdown", "id": "06bf2941", "metadata": {}, "source": [ "Our first task here is to rename to the chemical names of the stressors\n", "and fix the compartment spelling." ] }, { "cell_type": "code", "execution_count": 2, "id": "f72ae844", "metadata": { "tags": [] }, "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", "
stressorcompartmentchem_stressor__stressorcompartment__compartmentfactor
0Carbon Dioxide[A|a]irCO2Air1.0
1Methane[A|a]irCH4Air1.0
\n", "
" ], "text/plain": [ " stressor compartment chem_stressor__stressor \\\n", "0 Carbon Dioxide [A|a]ir CO2 \n", "1 Methane [A|a]ir CH4 \n", "\n", " compartment__compartment factor \n", "0 Air 1.0 \n", "1 Air 1.0 " ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ghg_map = pd.DataFrame(\n", " columns=[\n", " \"stressor\",\n", " \"compartment\",\n", " \"chem_stressor__stressor\",\n", " \"compartment__compartment\",\n", " \"factor\",\n", " ],\n", " data=[\n", " [\"Carbon Dioxide\", \"[A|a]ir\", \"CO2\", \"Air\", 1.0],\n", " [\"Methane\", \"[A|a]ir\", \"CH4\", \"Air\", 1.0],\n", " ],\n", ")\n", "ghg_map" ] }, { "cell_type": "code", "execution_count": 3, "id": "f73cd886", "metadata": { "tags": [] }, "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", "
regionRegion1Region2Region3
chem_stressorcompartment
CH4Air0.50.60.7
CO2Air5.06.07.0
\n", "
" ], "text/plain": [ "region Region1 Region2 Region3\n", "chem_stressor compartment \n", "CH4 Air 0.5 0.6 0.7\n", "CO2 Air 5.0 6.0 7.0" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ghg_new = pymrio.convert(ghg_result, ghg_map)\n", "ghg_new" ] }, { "cell_type": "markdown", "id": "e17f0c5d", "metadata": {}, "source": [ "Explanation: The column headers indicates that the stressor index level\n", "should be renamed from \"stressor\" to \"chem_stressor\" and the compartment index level\n", "should stay the same (NewName__OldName). The factor column is not used in this case.\n", "All renaming columns consider regular expressions,\n", "so that the spelling of the compartment can be fixed in one go." ] }, { "cell_type": "markdown", "id": "da9d7152", "metadata": {}, "source": [ "For simple rename (and aggregation cases, see below) we can omit the factor column.\n", "Thus we obtain the same result with the following mapping table:" ] }, { "cell_type": "code", "execution_count": 4, "id": "48688b14", "metadata": { "tags": [] }, "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", "
stressorcompartmentchem_stressor__stressorcompartment__compartment
0Carbon Dioxide[A|a]irCO2Air
1Methane[A|a]irCH4Air
\n", "
" ], "text/plain": [ " stressor compartment chem_stressor__stressor compartment__compartment\n", "0 Carbon Dioxide [A|a]ir CO2 Air\n", "1 Methane [A|a]ir CH4 Air" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ghg_map_wo_factor = pd.DataFrame(\n", " columns=[\n", " \"stressor\",\n", " \"compartment\",\n", " \"chem_stressor__stressor\",\n", " \"compartment__compartment\",\n", " ],\n", " data=[\n", " [\"Carbon Dioxide\", \"[A|a]ir\", \"CO2\", \"Air\"],\n", " [\"Methane\", \"[A|a]ir\", \"CH4\", \"Air\"],\n", " ],\n", ")\n", "ghg_map_wo_factor" ] }, { "cell_type": "code", "execution_count": 5, "id": "826f558a", "metadata": { "lines_to_next_cell": 2, "tags": [] }, "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", "
regionRegion1Region2Region3
chem_stressorcompartment
CH4Air0.50.60.7
CO2Air5.06.07.0
\n", "
" ], "text/plain": [ "region Region1 Region2 Region3\n", "chem_stressor compartment \n", "CH4 Air 0.5 0.6 0.7\n", "CO2 Air 5.0 6.0 7.0" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ghg_new_wo_factor = pymrio.convert(ghg_result, ghg_map_wo_factor)\n", "ghg_new_wo_factor" ] }, { "cell_type": "markdown", "id": "e5f1c043", "metadata": {}, "source": [ "### Unit conversion" ] }, { "cell_type": "markdown", "id": "c77c7c19", "metadata": {}, "source": [ "With the factor column it is easy to apply unit conversion to any result table.\n", "So, to start with the same table as above, we can apply a simple unit conversion.\n", "Assuming the data is in tonnes" ] }, { "cell_type": "code", "execution_count": 6, "id": "e4fe084e", "metadata": { "tags": [] }, "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", "
regionRegion1Region2Region3
stressorcompartment
Carbon DioxideAir5.06.07.0
Methaneair0.50.60.7
\n", "
" ], "text/plain": [ "region Region1 Region2 Region3\n", "stressor compartment \n", "Carbon Dioxide Air 5.0 6.0 7.0\n", "Methane air 0.5 0.6 0.7" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ghg_result_ton = pd.DataFrame(\n", " columns=[\"Region1\", \"Region2\", \"Region3\"],\n", " index=pd.MultiIndex.from_tuples(\n", " [\n", " (\"Carbon Dioxide\", \"Air\"),\n", " (\"Methane\", \"air\"),\n", " ]\n", " ),\n", " data=[[5, 6, 7], [0.5, 0.6, 0.7]],\n", ")\n", "ghg_result_ton.index.names = [\"stressor\", \"compartment\"]\n", "ghg_result_ton.columns.names = [\"region\"]\n", "ghg_result_ton" ] }, { "cell_type": "markdown", "id": "1ad41ad6", "metadata": {}, "source": [ "We can get the data in kg by" ] }, { "cell_type": "code", "execution_count": 7, "id": "ae5eba1e", "metadata": { "tags": [] }, "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", "
stressorcompartmentchem_stressor__stressorcompartment__compartmentfactor
0Carbon Dioxide[A|a]irCO2Air1000
1Methane[A|a]irCH4Air1000
\n", "
" ], "text/plain": [ " stressor compartment chem_stressor__stressor \\\n", "0 Carbon Dioxide [A|a]ir CO2 \n", "1 Methane [A|a]ir CH4 \n", "\n", " compartment__compartment factor \n", "0 Air 1000 \n", "1 Air 1000 " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ghg_map_to_kg = pd.DataFrame(\n", " columns=[\n", " \"stressor\",\n", " \"compartment\",\n", " \"chem_stressor__stressor\",\n", " \"compartment__compartment\",\n", " \"factor\",\n", " ],\n", " data=[\n", " [\"Carbon Dioxide\", \"[A|a]ir\", \"CO2\", \"Air\", 1000],\n", " [\"Methane\", \"[A|a]ir\", \"CH4\", \"Air\", 1000],\n", " ],\n", ")\n", "ghg_map_to_kg" ] }, { "cell_type": "code", "execution_count": 8, "id": "77effc7a", "metadata": { "tags": [] }, "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", "
regionRegion1Region2Region3
chem_stressorcompartment
CH4Air500.0600.0700.0
CO2Air5000.06000.07000.0
\n", "
" ], "text/plain": [ "region Region1 Region2 Region3\n", "chem_stressor compartment \n", "CH4 Air 500.0 600.0 700.0\n", "CO2 Air 5000.0 6000.0 7000.0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ghg_new_kg = pymrio.convert(ghg_result_ton, ghg_map_to_kg)\n", "ghg_new_kg" ] }, { "cell_type": "markdown", "id": "c7738e2d", "metadata": { "lines_to_next_cell": 2 }, "source": [ "In case of unit conversion of pymrio satellite accounts,\n", "we can also check the unit before and set the unit after conversion:\n", "TODO: unit conversion extensions, link to extension beow" ] }, { "cell_type": "markdown", "id": "7024fc74", "metadata": {}, "source": [ "### Characterization" ] }, { "cell_type": "markdown", "id": "b0f00d51", "metadata": {}, "source": [ "The main power of the convert function is to aggregate and characterize satellite accounts.\n", "If needed, region and sector specific characterizations can be applied." ] }, { "cell_type": "markdown", "id": "643b8d26", "metadata": {}, "source": [ "### Global characterization factors" ] }, { "cell_type": "markdown", "id": "44aabe37", "metadata": {}, "source": [ "An simple example is a conversion/aggregation based on GWP100 characterization factors.\n", "Here, we continue with the unit converted and cleanup dataframe from above:" ] }, { "cell_type": "code", "execution_count": 9, "id": "677f3872", "metadata": { "lines_to_next_cell": 2, "tags": [] }, "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", "
regionRegion1Region2Region3
chem_stressorcompartment
CH4Air500.0600.0700.0
CO2Air5000.06000.07000.0
\n", "
" ], "text/plain": [ "region Region1 Region2 Region3\n", "chem_stressor compartment \n", "CH4 Air 500.0 600.0 700.0\n", "CO2 Air 5000.0 6000.0 7000.0" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ghg_new_kg" ] }, { "cell_type": "markdown", "id": "a102de0a", "metadata": {}, "source": [ "We define a general purpose characterization map for GHG emissions\n", "(based on\n", "[AR6 GWP100 and GWP20 factors](https://www.ipcc.ch/report/ar6/wg1/downloads/report/IPCC_AR6_WGI_Chapter07.pdf)\n", ",with some simplifications):" ] }, { "cell_type": "code", "execution_count": 10, "id": "289eae3b", "metadata": { "tags": [] }, "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", "
chem_stressorGWP__chem_stressorfactor
0CO2GWP1001
1CH4GWP10029
2NHxGWP100273
3CO2GWP201
4CH4GWP2080
5NHxGWP20273
6CO2GWP5001
7CH4GWP5008
8NHxGWP500130
\n", "
" ], "text/plain": [ " chem_stressor GWP__chem_stressor factor\n", "0 CO2 GWP100 1\n", "1 CH4 GWP100 29\n", "2 NHx GWP100 273\n", "3 CO2 GWP20 1\n", "4 CH4 GWP20 80\n", "5 NHx GWP20 273\n", "6 CO2 GWP500 1\n", "7 CH4 GWP500 8\n", "8 NHx GWP500 130" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GWP_characterization = pd.DataFrame(\n", " columns=[\"chem_stressor\", \"GWP__chem_stressor\", \"factor\"],\n", " data=[\n", " [\"CO2\", \"GWP100\", 1],\n", " [\"CH4\", \"GWP100\", 29],\n", " [\"NHx\", \"GWP100\", 273],\n", " [\"CO2\", \"GWP20\", 1],\n", " [\"CH4\", \"GWP20\", 80],\n", " [\"NHx\", \"GWP20\", 273],\n", " [\"CO2\", \"GWP500\", 1],\n", " [\"CH4\", \"GWP500\", 8],\n", " [\"NHx\", \"GWP500\", 130],\n", " ],\n", ")\n", "GWP_characterization" ] }, { "cell_type": "code", "execution_count": 11, "id": "04df3552", "metadata": { "lines_to_next_cell": 2, "tags": [] }, "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", "
regionRegion1Region2Region3
GWP
GWP10019500.023400.027300.0
GWP2045000.054000.063000.0
GWP5009000.010800.012600.0
\n", "
" ], "text/plain": [ "region Region1 Region2 Region3\n", "GWP \n", "GWP100 19500.0 23400.0 27300.0\n", "GWP20 45000.0 54000.0 63000.0\n", "GWP500 9000.0 10800.0 12600.0" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GWP_result = pymrio.convert(ghg_new_kg, GWP_characterization)\n", "GWP_result" ] }, { "cell_type": "markdown", "id": "0706fdb9", "metadata": {}, "source": [ "As we can see, GWP_characterization can include factors for stressors not actually\n", "present in the data.\n", "These are silently ignored in the conversion process.\n", "We also did not specify the compartment and assumed the same factors apply\n", "independent of the compartment (we could pass through the compartment to\n", "the new result table via passing drop_not_bridge=False to the convert function)." ] }, { "cell_type": "code", "execution_count": 12, "id": "ab77360e", "metadata": { "tags": [] }, "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", "
regionRegion1Region2Region3
GWPcompartment
GWP100Air19500.023400.027300.0
GWP20Air45000.054000.063000.0
GWP500Air9000.010800.012600.0
\n", "
" ], "text/plain": [ "region Region1 Region2 Region3\n", "GWP compartment \n", "GWP100 Air 19500.0 23400.0 27300.0\n", "GWP20 Air 45000.0 54000.0 63000.0\n", "GWP500 Air 9000.0 10800.0 12600.0" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GWP_result_with_comp = pymrio.convert(\n", " ghg_new_kg, GWP_characterization, drop_not_bridged_index=False\n", ")\n", "GWP_result_with_comp" ] }, { "cell_type": "markdown", "id": "8347eaf5", "metadata": {}, "source": [ "All stressors mapped to the same \"impact\" are first converted via the\n", "value given in the factor column\n", "and then summed up (the aggregation function can be changed\n", "via the `agg_func` parameter)." ] }, { "cell_type": "markdown", "id": "44bb8bec", "metadata": { "lines_to_next_cell": 2 }, "source": [ "### Regional specific characterization factors" ] }, { "cell_type": "markdown", "id": "8fe2789b", "metadata": {}, "source": [ "A more complex example is the application of regional specific characterization\n", "factors (the same principle applies to sector specific factors.).\n", "For that, we assume some land use results for different regions:" ] }, { "cell_type": "code", "execution_count": 13, "id": "00156b6d", "metadata": { "tags": [] }, "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", "
regionRegion1Region2Region3
stressor
Wheat3101
Maize5203
Rice01234
Pasture12349
Forest extensive322711
Forest intensive431724
\n", "
" ], "text/plain": [ "region Region1 Region2 Region3\n", "stressor \n", "Wheat 3 10 1\n", "Maize 5 20 3\n", "Rice 0 12 34\n", "Pasture 12 34 9\n", "Forest extensive 32 27 11\n", "Forest intensive 43 17 24" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "land_use_data = pd.DataFrame(\n", " columns=[\"Region1\", \"Region2\", \"Region3\"],\n", " index=[\n", " \"Wheat\",\n", " \"Maize\",\n", " \"Rice\",\n", " \"Pasture\",\n", " \"Forest extensive\",\n", " \"Forest intensive\",\n", " ],\n", " data=[\n", " [3, 10, 1],\n", " [5, 20, 3],\n", " [0, 12, 34],\n", " [12, 34, 9],\n", " [32, 27, 11],\n", " [43, 17, 24],\n", " ],\n", ")\n", "land_use_data.index.names = [\"stressor\"]\n", "land_use_data.columns.names = [\"region\"]\n", "land_use_data" ] }, { "cell_type": "markdown", "id": "9e356ee1", "metadata": {}, "source": [ "Now we setup a pseudo characterization table for converting the land use data into\n", "biodiversity impacts. We assume, that the characterization factors vary based on\n", "land use type and region. However, the \"region\" information is a pure\n", "constraining column (specifying the region for which the factor applies) without\n", "any bridge column mapping it to a new name. Thus, the \"region\" can either be in the index\n", "or in the columns of the source data - in the given case it is in the columns." ] }, { "cell_type": "code", "execution_count": 14, "id": "e3ed4128", "metadata": { "lines_to_next_cell": 2, "tags": [] }, "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", "
stressorBioDiv__stressorregionfactor
0Wheat|MaizeBioImpactRegion13
1WheatBioImpactRegion[2,3]4
2MaizeBioImpactRegion[2,3]7
3RiceBioImpactRegion112
4RiceBioImpactRegion212
5RiceBioImpactRegion312
6PastureBioImpactRegion[1,2,3]12
7Forest.*BioImpactRegion12
8Forest.*BioImpactRegion23
9Forest ext.*BioImpactRegion31
10Forest int.*BioImpactRegion33
\n", "
" ], "text/plain": [ " stressor BioDiv__stressor region factor\n", "0 Wheat|Maize BioImpact Region1 3\n", "1 Wheat BioImpact Region[2,3] 4\n", "2 Maize BioImpact Region[2,3] 7\n", "3 Rice BioImpact Region1 12\n", "4 Rice BioImpact Region2 12\n", "5 Rice BioImpact Region3 12\n", "6 Pasture BioImpact Region[1,2,3] 12\n", "7 Forest.* BioImpact Region1 2\n", "8 Forest.* BioImpact Region2 3\n", "9 Forest ext.* BioImpact Region3 1\n", "10 Forest int.* BioImpact Region3 3" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "landuse_characterization = pd.DataFrame(\n", " columns=[\"stressor\", \"BioDiv__stressor\", \"region\", \"factor\"],\n", " data=[\n", " [\"Wheat|Maize\", \"BioImpact\", \"Region1\", 3],\n", " [\"Wheat\", \"BioImpact\", \"Region[2,3]\", 4],\n", " [\"Maize\", \"BioImpact\", \"Region[2,3]\", 7],\n", " [\"Rice\", \"BioImpact\", \"Region1\", 12],\n", " [\"Rice\", \"BioImpact\", \"Region2\", 12],\n", " [\"Rice\", \"BioImpact\", \"Region3\", 12],\n", " [\"Pasture\", \"BioImpact\", \"Region[1,2,3]\", 12],\n", " [\"Forest.*\", \"BioImpact\", \"Region1\", 2],\n", " [\"Forest.*\", \"BioImpact\", \"Region2\", 3],\n", " [\"Forest ext.*\", \"BioImpact\", \"Region3\", 1],\n", " [\"Forest int.*\", \"BioImpact\", \"Region3\", 3],\n", " ],\n", ")\n", "landuse_characterization" ] }, { "cell_type": "markdown", "id": "6ee910ad", "metadata": { "lines_to_next_cell": 2 }, "source": [ "The table shows several possibilities to specify factors which apply to several\n", "regions/stressors.\n", "All of them are based on the [regular expression](https://docs.python.org/3/howto/regex.html):\n", "\n", "- In the first data line we use the \"or\" operator \"|\" to specify that the\n", "same factor applies to Wheat and Maize.\n", "- On the next line we use the grouping capabilities of regular expressions\n", "to indicate the same factor for Region 2 and 3.\n", "- At the last four lines .* matches any number of characters. This\n", "allows to specify the same factor for both forest types or to abbreviate\n", "the naming of the stressor (last 2 lines).\n", "\n", "The use of regular expression is optional, one can also use one line per factor.\n", "In the example above, we indicate the factor for Rice in 3 subsequent entries.\n", "This would be equivalent to ```[\"Rice\", \"BioImpact\", \"Region[1,2,3]\", 12]```." ] }, { "cell_type": "markdown", "id": "ce0e5a7c", "metadata": {}, "source": [ "With that setup we can now characterize the land use data in land_use_result." ] }, { "cell_type": "code", "execution_count": 15, "id": "8f2e3a37", "metadata": { "tags": [] }, "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", "
regionRegion1Region2Region3
BioDiv
BioImpact318864624
\n", "
" ], "text/plain": [ "region Region1 Region2 Region3\n", "BioDiv \n", "BioImpact 318 864 624" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "biodiv_characterised = pymrio.convert(land_use_data, landuse_characterization)\n", "biodiv_characterised" ] }, { "cell_type": "markdown", "id": "04c48b45", "metadata": {}, "source": [ "Note, that in this example the region is not in the index\n", "but in the columns.\n", "The convert function can handle both cases.\n", "The only difference is that constraints which are\n", "in the columns will never be aggregated but keep the column resolution at the\n", "output. Thus the result is equivalent to" ] }, { "cell_type": "code", "execution_count": 16, "id": "157dd099", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "stressor region \n", "Wheat Region1 3\n", " Region2 10\n", " Region3 1\n", "Maize Region1 5\n", " Region2 20\n", " Region3 3\n", "Rice Region1 0\n", " Region2 12\n", " Region3 34\n", "Pasture Region1 12\n", " Region2 34\n", " Region3 9\n", "Forest extensive Region1 32\n", " Region2 27\n", " Region3 11\n", "Forest intensive Region1 43\n", " Region2 17\n", " Region3 24\n", "dtype: int64" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "land_use_data_stacked = land_use_data.stack(level=\"region\")\n", "land_use_data_stacked" ] }, { "cell_type": "code", "execution_count": 17, "id": "9d435a0a", "metadata": { "tags": [] }, "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", "
regionRegion1Region2Region3
BioDiv
BioImpact318864624
\n", "
" ], "text/plain": [ "region Region1 Region2 Region3\n", "BioDiv \n", "BioImpact 318 864 624" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "biodiv_characterised_stacked = pymrio.convert(\n", " land_use_data_stacked, landuse_characterization, drop_not_bridged_index=False\n", ")\n", "biodiv_characterised_stacked.unstack(level=\"region\")[0]" ] }, { "cell_type": "markdown", "id": "0e09b7d4", "metadata": { "lines_to_next_cell": 2 }, "source": [ "In this case we have to specify to not drop the not bridged \"region\" index.\n", "We then unstack the result again, and have to select the first element ([0]),\n", "since there where not other columns left after stacking them before the\n", "characterization." ] }, { "cell_type": "markdown", "id": "c2b48a82", "metadata": {}, "source": [ "TODO: section perhaps needed somewhere?\n", "Irrespectively of the table or the mrio system, the convert function always follows the same pattern.\n", "It requires a bridge table, which contains the mapping of the indices of the source data to the indices of the target data.\n", "This bridge table has to follow a specific format, depending on the table to be converted." ] }, { "cell_type": "markdown", "id": "2467c22e", "metadata": {}, "source": [ "# Converting pymrio Extensions" ] }, { "cell_type": "markdown", "id": "fbe6d4cc", "metadata": {}, "source": [ "The same principles as for individual tables can be used for converting full pymrio type Extensions (aka satellite accounts).\n", "In difference to the single tables, pymrio Extensions consist of several pandas DataFrames which can be converted in one go.\n", "Almost the same bridge table structure as for single tables can be used. The main additional information needed is in regard to\n", "units. Since pymrio Extensions include a unit dataframe, information about the unit names need to be included." ] }, { "cell_type": "markdown", "id": "da124a31", "metadata": {}, "source": [ "Extensions can be converted either one at a time, but the main power of the method lies in collecting stressor data across different extensions\n", "and converting them in one go." ] }, { "cell_type": "markdown", "id": "f45b56f0", "metadata": {}, "source": [ "We start with a simple example for converting a single extension of a pymrio MRIO system.\n", "To do so, we load the test MRIO system from pymrio." ] }, { "cell_type": "code", "execution_count": 18, "id": "ac3f7133", "metadata": { "tags": [] }, "outputs": [], "source": [ "mrio = pymrio.load_test()" ] }, { "cell_type": "markdown", "id": "c2024493", "metadata": { "lines_to_next_cell": 2 }, "source": [ "Among others, this system has an extension \"emissions\" with industry and final demand emissions." ] }, { "cell_type": "code", "execution_count": 19, "id": "9b090fbb", "metadata": { "tags": [] }, "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", "
regionreg1reg2...reg5reg6
sectorfoodminingmanufactoringelectricityconstructiontradetransportotherfoodmining...transportotherfoodminingmanufactoringelectricityconstructiontradetransportother
stressorcompartment
emission_type1air1848064.80986448.09023613787.0028139100.002584141.804132656.321766987.07842090.61697937.30347378.150...4229931910773826.015777996.06420955.5113172450.056022534.04861838.51819562147046542.021632868
emission_type2water139250.4722343.295763569.18273981.55317396.511254477.81012999.12449178.0204835.4429463.944...41998417191006.34826108.11865625.112700193.0753213.72699288.3138923138765784.316782553
\n", "

2 rows × 48 columns

\n", "
" ], "text/plain": [ "region reg1 \\\n", "sector food mining manufactoring electricity \n", "stressor compartment \n", "emission_type1 air 1848064.80 986448.090 23613787.00 28139100.00 \n", "emission_type2 water 139250.47 22343.295 763569.18 273981.55 \n", "\n", "region \\\n", "sector construction trade transport other \n", "stressor compartment \n", "emission_type1 air 2584141.80 4132656.3 21766987.0 7842090.6 \n", "emission_type2 water 317396.51 1254477.8 1012999.1 2449178.0 \n", "\n", "region reg2 ... reg5 \\\n", "sector food mining ... transport other \n", "stressor compartment ... \n", "emission_type1 air 1697937.30 347378.150 ... 42299319 10773826.0 \n", "emission_type2 water 204835.44 29463.944 ... 4199841 7191006.3 \n", "\n", "region reg6 \\\n", "sector food mining manufactoring electricity \n", "stressor compartment \n", "emission_type1 air 15777996.0 6420955.5 113172450.0 56022534.0 \n", "emission_type2 water 4826108.1 1865625.1 12700193.0 753213.7 \n", "\n", "region \n", "sector construction trade transport other \n", "stressor compartment \n", "emission_type1 air 4861838.5 18195621 47046542.0 21632868 \n", "emission_type2 water 2699288.3 13892313 8765784.3 16782553 \n", "\n", "[2 rows x 48 columns]" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mrio.emissions.F" ] }, { "cell_type": "code", "execution_count": 20, "id": "7d52ba38", "metadata": { "tags": [] }, "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", "
regionreg1reg2...reg5reg6
categoryFinal consumption expenditure by householdsFinal consumption expenditure by non-profit organisations serving households (NPISH)Final consumption expenditure by governmentGross fixed capital formationChanges in inventoriesChanges in valuablesExportFinal consumption expenditure by householdsFinal consumption expenditure by non-profit organisations serving households (NPISH)Final consumption expenditure by government...Changes in inventoriesChanges in valuablesExportFinal consumption expenditure by householdsFinal consumption expenditure by non-profit organisations serving households (NPISH)Final consumption expenditure by governmentGross fixed capital formationChanges in inventoriesChanges in valuablesExport
stressorcompartment
emission_type1air623353210000003856692900...000571278300.0000000
emission_type2water592064050000004021400200...000163362050.0000000
\n", "

2 rows × 42 columns

\n", "
" ], "text/plain": [ "region reg1 \\\n", "category Final consumption expenditure by households \n", "stressor compartment \n", "emission_type1 air 62335321 \n", "emission_type2 water 59206405 \n", "\n", "region \\\n", "category Final consumption expenditure by non-profit organisations serving households (NPISH) \n", "stressor compartment \n", "emission_type1 air 0 \n", "emission_type2 water 0 \n", "\n", "region \\\n", "category Final consumption expenditure by government \n", "stressor compartment \n", "emission_type1 air 0 \n", "emission_type2 water 0 \n", "\n", "region \\\n", "category Gross fixed capital formation \n", "stressor compartment \n", "emission_type1 air 0 \n", "emission_type2 water 0 \n", "\n", "region \\\n", "category Changes in inventories Changes in valuables Export \n", "stressor compartment \n", "emission_type1 air 0 0 0 \n", "emission_type2 water 0 0 0 \n", "\n", "region reg2 \\\n", "category Final consumption expenditure by households \n", "stressor compartment \n", "emission_type1 air 38566929 \n", "emission_type2 water 40214002 \n", "\n", "region \\\n", "category Final consumption expenditure by non-profit organisations serving households (NPISH) \n", "stressor compartment \n", "emission_type1 air 0 \n", "emission_type2 water 0 \n", "\n", "region ... \\\n", "category Final consumption expenditure by government ... \n", "stressor compartment ... \n", "emission_type1 air 0 ... \n", "emission_type2 water 0 ... \n", "\n", "region reg5 \\\n", "category Changes in inventories Changes in valuables Export \n", "stressor compartment \n", "emission_type1 air 0 0 0 \n", "emission_type2 water 0 0 0 \n", "\n", "region reg6 \\\n", "category Final consumption expenditure by households \n", "stressor compartment \n", "emission_type1 air 571278300.0 \n", "emission_type2 water 163362050.0 \n", "\n", "region \\\n", "category Final consumption expenditure by non-profit organisations serving households (NPISH) \n", "stressor compartment \n", "emission_type1 air 0 \n", "emission_type2 water 0 \n", "\n", "region \\\n", "category Final consumption expenditure by government \n", "stressor compartment \n", "emission_type1 air 0 \n", "emission_type2 water 0 \n", "\n", "region \\\n", "category Gross fixed capital formation \n", "stressor compartment \n", "emission_type1 air 0 \n", "emission_type2 water 0 \n", "\n", "region \n", "category Changes in inventories Changes in valuables Export \n", "stressor compartment \n", "emission_type1 air 0 0 0 \n", "emission_type2 water 0 0 0 \n", "\n", "[2 rows x 42 columns]" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mrio.emissions.F_Y" ] }, { "cell_type": "code", "execution_count": 21, "id": "107697bc", "metadata": { "tags": [] }, "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", "
unit
stressorcompartment
emission_type1airkg
emission_type2waterkg
\n", "
" ], "text/plain": [ " unit\n", "stressor compartment \n", "emission_type1 air kg\n", "emission_type2 water kg" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mrio.emissions.unit" ] }, { "cell_type": "markdown", "id": "93107bf8", "metadata": {}, "source": [ "We now setup a bridge table for converting/characterizing these emission data\n", "to several other accounts." ] }, { "cell_type": "code", "execution_count": 22, "id": "1a1fbdcd", "metadata": { "tags": [] }, "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", "
stressorcompartmenttotal__stressorfactorunit_origunit_new
0emis.*air|watertotal_sum_tonnes0.001kgt
1emission_type[1|2].*total_sum1.000kgkg
2emission_type1.*air_emissions0.001kgt
3emission_type2.*water_emissions1000.000kgg
4emission_type1.*char_emissions2.000kgkg_eq
5emission_type2.*char_emissions10.000kgkg_eq
\n", "
" ], "text/plain": [ " stressor compartment total__stressor factor unit_orig \\\n", "0 emis.* air|water total_sum_tonnes 0.001 kg \n", "1 emission_type[1|2] .* total_sum 1.000 kg \n", "2 emission_type1 .* air_emissions 0.001 kg \n", "3 emission_type2 .* water_emissions 1000.000 kg \n", "4 emission_type1 .* char_emissions 2.000 kg \n", "5 emission_type2 .* char_emissions 10.000 kg \n", "\n", " unit_new \n", "0 t \n", "1 kg \n", "2 t \n", "3 g \n", "4 kg_eq \n", "5 kg_eq " ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "emis_bridge = pd.DataFrame(\n", " columns=[\n", " \"stressor\",\n", " \"compartment\",\n", " \"total__stressor\",\n", " \"factor\",\n", " \"unit_orig\",\n", " \"unit_new\",\n", " ],\n", " data=[\n", " [\"emis.*\", \"air|water\", \"total_sum_tonnes\", 1e-3, \"kg\", \"t\"],\n", " [\"emission_type[1|2]\", \".*\", \"total_sum\", 1, \"kg\", \"kg\"],\n", " [\"emission_type1\", \".*\", \"air_emissions\", 1e-3, \"kg\", \"t\"],\n", " [\"emission_type2\", \".*\", \"water_emissions\", 1000, \"kg\", \"g\"],\n", " [\"emission_type1\", \".*\", \"char_emissions\", 2, \"kg\", \"kg_eq\"],\n", " [\"emission_type2\", \".*\", \"char_emissions\", 10, \"kg\", \"kg_eq\"],\n", " ],\n", ")\n", "emis_bridge" ] }, { "cell_type": "markdown", "id": "72db9156", "metadata": { "lines_to_next_cell": 2 }, "source": [ "This is a fully made up example showing various capabilities of the method.\n", "In line\n", " - 0: find all stressors with emissions (emis.*) in either air or water (air|water) compartment, rename it to \"total_sum_tonnes\" (total__stressor) by multiplying with a factor 0.0001 which converts the original unit \"kg\" to tonnes.\n", " - 1: find emission_type1 and 2, over all compartments and sum them together without any multiplication\n", " - 2: convert emissions of type 1 to air emissions in tons\n", " - 3: convert emissions of type 2 to water emissions in g\n", " - 4 and 5: two different characterization factors of 2 (type1) and 10 (type2) to convert to kg equivalent (kg_eq) of some kind and then add them together to a summary impact \"char_emissions\"" ] }, { "cell_type": "markdown", "id": "de6c294d", "metadata": {}, "source": [ "The new extensino can then be calculated with:" ] }, { "cell_type": "code", "execution_count": 23, "id": "d536db02", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Extension new_ext with parameters: name, F, F_Y, unit\n" ] } ], "source": [ "mrio.new_ext = mrio.emissions.convert(emis_bridge, new_extension_name=\"new_ext\")\n", "print(mrio.new_ext)" ] }, { "cell_type": "markdown", "id": "4fd2c82d", "metadata": {}, "source": [ "And then the new accounts can be calculated with" ] }, { "cell_type": "code", "execution_count": 24, "id": "85a8e3a2", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Extension new_ext with parameters: name, F, F_Y, S, S_Y, M, M_down, D_cba, D_pba, D_imp, D_exp, unit, D_cba_reg, D_pba_reg, D_imp_reg, D_exp_reg, D_cba_cap, D_pba_cap, D_imp_cap, D_exp_cap\n" ] }, { "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", "
unit
total
air_emissionst
char_emissionskg_eq
total_sumkg
total_sum_tonnest
water_emissionsg
\n", "
" ], "text/plain": [ " unit\n", "total \n", "air_emissions t\n", "char_emissions kg_eq\n", "total_sum kg\n", "total_sum_tonnes t\n", "water_emissions g" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mrio.calc_all()\n", "print(mrio.new_ext)\n", "mrio.new_ext.unit" ] }, { "cell_type": "code", "execution_count": 25, "id": "63b953a2", "metadata": { "tags": [] }, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
regionreg1reg2...reg5reg6
sectorfoodminingmanufactoringelectricityconstructiontradetransportotherfoodmining...transportotherfoodminingmanufactoringelectricityconstructiontradetransportother
total
air_emissions2.056183e+031.794235e+029.749300e+041.188759e+043.342906e+033.885884e+031.075027e+041.582152e+041.793338e+031.914560e+01...4.209505e+041.138661e+041.517235e+041.345318e+037.145075e+043.683167e+041.836696e+034.241568e+044.805409e+043.602298e+04
char_emissions6.535470e+066.116290e+053.621100e+082.514649e+071.015410e+071.553797e+072.650016e+071.164481e+085.723203e+067.562722e+04...1.266275e+089.584531e+077.455045e+078.062852e+062.497159e+087.939148e+071.274291e+076.297358e+081.844730e+085.355358e+08
total_sum2.298494e+062.047017e+051.142054e+081.202472e+073.689735e+064.662504e+061.125023e+072.430203e+072.006991e+062.287921e+04...4.633879e+071.869382e+071.959293e+071.882540e+068.213219e+073.740449e+072.743647e+069.690613e+075.689057e+078.237196e+07
total_sum_tonnes2.298494e+032.047017e+021.142054e+051.202472e+043.689735e+034.662504e+031.125023e+042.430203e+042.006991e+032.287921e+01...4.633879e+041.869382e+041.959293e+041.882540e+038.213219e+043.740449e+042.743647e+039.690613e+045.689057e+048.237196e+04
water_emissions2.423103e+082.527819e+071.671240e+101.371303e+083.468292e+087.766205e+084.999628e+088.480505e+092.136528e+083.733601e+06...4.243738e+097.307208e+094.420574e+095.372216e+081.068144e+105.728136e+089.069515e+085.449044e+108.836484e+094.634899e+10
\n", "

5 rows × 48 columns

\n", "
" ], "text/plain": [ "region reg1 \\\n", "sector food mining manufactoring electricity \n", "total \n", "air_emissions 2.056183e+03 1.794235e+02 9.749300e+04 1.188759e+04 \n", "char_emissions 6.535470e+06 6.116290e+05 3.621100e+08 2.514649e+07 \n", "total_sum 2.298494e+06 2.047017e+05 1.142054e+08 1.202472e+07 \n", "total_sum_tonnes 2.298494e+03 2.047017e+02 1.142054e+05 1.202472e+04 \n", "water_emissions 2.423103e+08 2.527819e+07 1.671240e+10 1.371303e+08 \n", "\n", "region \\\n", "sector construction trade transport other \n", "total \n", "air_emissions 3.342906e+03 3.885884e+03 1.075027e+04 1.582152e+04 \n", "char_emissions 1.015410e+07 1.553797e+07 2.650016e+07 1.164481e+08 \n", "total_sum 3.689735e+06 4.662504e+06 1.125023e+07 2.430203e+07 \n", "total_sum_tonnes 3.689735e+03 4.662504e+03 1.125023e+04 2.430203e+04 \n", "water_emissions 3.468292e+08 7.766205e+08 4.999628e+08 8.480505e+09 \n", "\n", "region reg2 ... reg5 \\\n", "sector food mining ... transport other \n", "total ... \n", "air_emissions 1.793338e+03 1.914560e+01 ... 4.209505e+04 1.138661e+04 \n", "char_emissions 5.723203e+06 7.562722e+04 ... 1.266275e+08 9.584531e+07 \n", "total_sum 2.006991e+06 2.287921e+04 ... 4.633879e+07 1.869382e+07 \n", "total_sum_tonnes 2.006991e+03 2.287921e+01 ... 4.633879e+04 1.869382e+04 \n", "water_emissions 2.136528e+08 3.733601e+06 ... 4.243738e+09 7.307208e+09 \n", "\n", "region reg6 \\\n", "sector food mining manufactoring electricity \n", "total \n", "air_emissions 1.517235e+04 1.345318e+03 7.145075e+04 3.683167e+04 \n", "char_emissions 7.455045e+07 8.062852e+06 2.497159e+08 7.939148e+07 \n", "total_sum 1.959293e+07 1.882540e+06 8.213219e+07 3.740449e+07 \n", "total_sum_tonnes 1.959293e+04 1.882540e+03 8.213219e+04 3.740449e+04 \n", "water_emissions 4.420574e+09 5.372216e+08 1.068144e+10 5.728136e+08 \n", "\n", "region \n", "sector construction trade transport other \n", "total \n", "air_emissions 1.836696e+03 4.241568e+04 4.805409e+04 3.602298e+04 \n", "char_emissions 1.274291e+07 6.297358e+08 1.844730e+08 5.355358e+08 \n", "total_sum 2.743647e+06 9.690613e+07 5.689057e+07 8.237196e+07 \n", "total_sum_tonnes 2.743647e+03 9.690613e+04 5.689057e+04 8.237196e+04 \n", "water_emissions 9.069515e+08 5.449044e+10 8.836484e+09 4.634899e+10 \n", "\n", "[5 rows x 48 columns]" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mrio.new_ext.D_cba\n", "\n", "\n", "# CONT: test/explain characterization across different extensions" ] }, { "cell_type": "code", "execution_count": null, "id": "9f017e1b-d5ee-497e-a0bb-2c531195a50b", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.21" } }, "nbformat": 4, "nbformat_minor": 5 }