{ "cells": [ { "cell_type": "markdown", "metadata": { "lines_to_next_cell": 2 }, "source": [ "# Characterization of stressors" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Stressor characterization allows the calculation of environmental and social impacts of economic activities. It transforms raw stressor data into meaningful impact indicators." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Pymrio implements an innovative string-matching approach for characterization.\n", "This method matches stressors in the characterization table (provided in long format) with available stressors in the MRIO system. This brings the following benefits:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Ensures stressor correspondence across the MRIO system and characterization table\n", "- Performs automatic unit verification\n", "- Works regardless of entry order in the characterization table\n", "- Handles characterization tables that include factors for stressors not present in the satellite account\n", "- Efficiently manages region and sector-specific characterization factors\n", "- Enables characterization across different extensions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This contrasts with traditional approaches that rely on matrix multiplication between stressor and characterization matrices, requiring strict 1:1 correspondence between matrix dimensions and precise ordering of entries." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The characterization functionality is available both as an extension object method and as top-level function accepting complete MRIO objects or extension collections." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the following, we give some examples on how to use both methods, starting with some simple example and then advancing to more complex cases with regional specific factors." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Basic Example" ] }, { "cell_type": "markdown", "metadata": { "lines_to_next_cell": 2 }, "source": [ "For this example we use the test MRIO included in Pymrio. We also need\n", "the Pandas library for loading the characterization table and pathlib for some folder manipulation." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pathlib import Path" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [] }, "outputs": [], "source": [ "import pymrio\n", "from pymrio.core.constants import PYMRIO_PATH # noqa" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To load the test MRIO we use:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "tags": [] }, "outputs": [], "source": [ "io = pymrio.load_test()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and the characterization table with some foo factors can be loaded by" ] }, { "cell_type": "code", "execution_count": 3, "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", "
stressorcompartmentimpactfactorimpact_unitstressor_unit
0emission_type1airair water impact0.002tkg
1emission_type2waterair water impact0.001tkg
2emission_type1airtotal emissions1.000kgkg
3emission_type2watertotal emissions1.000kgkg
4emission_type3landtotal emissions1.000kgkg
5emission_type1airtotal air emissions0.001tkg
\n", "
" ], "text/plain": [ " stressor compartment impact factor impact_unit \\\n", "0 emission_type1 air air water impact 0.002 t \n", "1 emission_type2 water air water impact 0.001 t \n", "2 emission_type1 air total emissions 1.000 kg \n", "3 emission_type2 water total emissions 1.000 kg \n", "4 emission_type3 land total emissions 1.000 kg \n", "5 emission_type1 air total air emissions 0.001 t \n", "\n", " stressor_unit \n", "0 kg \n", "1 kg \n", "2 kg \n", "3 kg \n", "4 kg \n", "5 kg " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "charact_table = pd.read_csv(\n", " (PYMRIO_PATH[\"test_mrio\"] / Path(\"concordance\") / \"emissions_charact.tsv\"),\n", " sep=\"\\t\",\n", ")\n", "charact_table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This table contains the columns 'stressor' and 'compartment' which correspond\n", "to the index names of the test_mrio emission satellite accounts:" ] }, { "cell_type": "code", "execution_count": 4, "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": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "io.emissions.F" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Theses index-names / columns-names need to match in order to match\n", "characterization factors to the stressors." ] }, { "cell_type": "markdown", "metadata": { "lines_to_next_cell": 2 }, "source": [ "The other columns names can be passed to the characterization method. By default the method assumes the following column names:\n", "\n", "- impact: name of the characterization/impact\n", "- factor: the numerical (float) multiplication value for a specific stressor to derive the impact/characterized account\n", "- impact_unit: the unit of the calculated characterization/impact\n", "- stressor_unit: the unit of the stressor in the extension\n", "\n", "Alternative names can be passed through the parameters\n", "*characterized_name_column*, *characterization_factors_column*, *characterized_unit_column* and *orig_unit_column*\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To calculate the characterization we use" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "tags": [] }, "outputs": [], "source": [ "char_emis = io.emissions.characterize(charact_table, name=\"impacts\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The parameter *name* is optional, if omitted the name will be set to\n", "extension_name + _characterized. In case the passed name starts with an\n", "underscore, the return name with be the name of the original extension concatenated with the passed name." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The return value is a named tuple with the *validation* and *extension* as attriubtes." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "lines_to_next_cell": 2, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Extension impacts with parameters: name, F, F_Y, unit\n" ] } ], "source": [ "print(char_emis.extension)" ] }, { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
stressorcompartmentimpactfactorimpact_unitstressor_uniterror_unit_impacterror_unit_stressorerror_missing_stressor
0emission_type1airair water impact0.002tkgFalseFalseFalse
1emission_type1airtotal emissions1.000kgkgFalseFalseFalse
2emission_type1airtotal air emissions0.001tkgFalseFalseFalse
3emission_type2waterair water impact0.001tkgFalseFalseFalse
4emission_type2watertotal emissions1.000kgkgFalseFalseFalse
5emission_type3landtotal emissions1.000kgkgFalseFalseTrue
\n", "
" ], "text/plain": [ " stressor compartment impact factor impact_unit \\\n", "0 emission_type1 air air water impact 0.002 t \n", "1 emission_type1 air total emissions 1.000 kg \n", "2 emission_type1 air total air emissions 0.001 t \n", "3 emission_type2 water air water impact 0.001 t \n", "4 emission_type2 water total emissions 1.000 kg \n", "5 emission_type3 land total emissions 1.000 kg \n", "\n", " stressor_unit error_unit_impact error_unit_stressor \\\n", "0 kg False False \n", "1 kg False False \n", "2 kg False False \n", "3 kg False False \n", "4 kg False False \n", "5 kg False False \n", "\n", " error_missing_stressor \n", "0 False \n", "1 False \n", "2 False \n", "3 False \n", "4 False \n", "5 True " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "char_emis.validation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Checking the validation table is a recommended step that ensures accuracy and completeness before impact calculations. The validation process helps identify potential issues such as:\n", "\n", "- Missing characterization factors for specific region/sector/stressor combinations\n", "- Spelling mistakes or inconsistencies in stressor, sector, or region names\n", "- Unit mismatches between the MRIO system and characterization factors\n", "- Incomplete coverage that could affect impact assessment results\n", "\n", "By systematically checking these elements, users can avoid calculation errors and ensure their impact assessment captures all relevant environmental and social dimensions with the proper characterization factors.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the current case, the *charact_table* contains a characterization called 'total\n", "emissions', for which the calculation requires a stressor not present in the\n", "satellite account. This is indicated in the validation table in the *error_missing_stressor* column.\n", "The calculation can proceed, but for all impacts containing the stressor it is assumed to be 0." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is possible, to just the verification before doing any calculation with" ] }, { "cell_type": "code", "execution_count": 8, "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", "
stressorcompartmentimpactfactorimpact_unitstressor_uniterror_unit_impacterror_unit_stressorerror_missing_stressor
0emission_type1airair water impact0.002tkgFalseFalseFalse
1emission_type1airtotal emissions1.000kgkgFalseFalseFalse
2emission_type1airtotal air emissions0.001tkgFalseFalseFalse
3emission_type2waterair water impact0.001tkgFalseFalseFalse
4emission_type2watertotal emissions1.000kgkgFalseFalseFalse
5emission_type3landtotal emissions1.000kgkgFalseFalseTrue
\n", "
" ], "text/plain": [ " stressor compartment impact factor impact_unit \\\n", "0 emission_type1 air air water impact 0.002 t \n", "1 emission_type1 air total emissions 1.000 kg \n", "2 emission_type1 air total air emissions 0.001 t \n", "3 emission_type2 water air water impact 0.001 t \n", "4 emission_type2 water total emissions 1.000 kg \n", "5 emission_type3 land total emissions 1.000 kg \n", "\n", " stressor_unit error_unit_impact error_unit_stressor \\\n", "0 kg False False \n", "1 kg False False \n", "2 kg False False \n", "3 kg False False \n", "4 kg False False \n", "5 kg False False \n", "\n", " error_missing_stressor \n", "0 False \n", "1 False \n", "2 False \n", "3 False \n", "4 False \n", "5 True " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "only_val = io.emissions.characterize(charact_table, only_validation=True)\n", "only_val.validation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In that case the extension attribute is set to None.\n", "The same applies if a characterization needs to be aborted due to unit inconsistencies." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Anyways, in case everything works as expected, the extension can be attached to the MRIO object." ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "tags": [] }, "outputs": [], "source": [ "io.impacts = char_emis.extension" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and used for subsequent calculations:" ] }, { "cell_type": "code", "execution_count": 10, "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", "
regionreg1reg2...reg5reg6
sectorfoodminingmanufactoringelectricityconstructiontradetransportotherfoodmining...transportotherfoodminingmanufactoringelectricityconstructiontradetransportother
impact
air water impact4.354677e+03384.1252642.116984e+052.391231e+047.032641e+038.548388e+032.200050e+044.012355e+043.800328e+0342.024811...8.843384e+043.008044e+043.476528e+043.227857e+031.535829e+057.423616e+044.580343e+031.393218e+051.049447e+051.183949e+05
total air emissions2.056183e+03179.4235369.749300e+041.188759e+043.342906e+033.885884e+031.075027e+041.582152e+041.793338e+0319.145605...4.209505e+041.138661e+041.517235e+041.345318e+037.145075e+043.683167e+041.836696e+034.241568e+044.805409e+043.602298e+04
total emissions2.298494e+06204701.7279791.142054e+081.202472e+073.689735e+064.662504e+061.125023e+072.430203e+072.006991e+0622879.206385...4.633879e+071.869382e+071.959293e+071.882540e+068.213219e+073.740449e+072.743647e+069.690613e+075.689057e+078.237196e+07
\n", "

3 rows × 48 columns

\n", "
" ], "text/plain": [ "region reg1 \\\n", "sector food mining manufactoring electricity \n", "impact \n", "air water impact 4.354677e+03 384.125264 2.116984e+05 2.391231e+04 \n", "total air emissions 2.056183e+03 179.423536 9.749300e+04 1.188759e+04 \n", "total emissions 2.298494e+06 204701.727979 1.142054e+08 1.202472e+07 \n", "\n", "region \\\n", "sector construction trade transport other \n", "impact \n", "air water impact 7.032641e+03 8.548388e+03 2.200050e+04 4.012355e+04 \n", "total air emissions 3.342906e+03 3.885884e+03 1.075027e+04 1.582152e+04 \n", "total emissions 3.689735e+06 4.662504e+06 1.125023e+07 2.430203e+07 \n", "\n", "region reg2 ... reg5 \\\n", "sector food mining ... transport \n", "impact ... \n", "air water impact 3.800328e+03 42.024811 ... 8.843384e+04 \n", "total air emissions 1.793338e+03 19.145605 ... 4.209505e+04 \n", "total emissions 2.006991e+06 22879.206385 ... 4.633879e+07 \n", "\n", "region reg6 \\\n", "sector other food mining manufactoring \n", "impact \n", "air water impact 3.008044e+04 3.476528e+04 3.227857e+03 1.535829e+05 \n", "total air emissions 1.138661e+04 1.517235e+04 1.345318e+03 7.145075e+04 \n", "total emissions 1.869382e+07 1.959293e+07 1.882540e+06 8.213219e+07 \n", "\n", "region \\\n", "sector electricity construction trade transport \n", "impact \n", "air water impact 7.423616e+04 4.580343e+03 1.393218e+05 1.049447e+05 \n", "total air emissions 3.683167e+04 1.836696e+03 4.241568e+04 4.805409e+04 \n", "total emissions 3.740449e+07 2.743647e+06 9.690613e+07 5.689057e+07 \n", "\n", "region \n", "sector other \n", "impact \n", "air water impact 1.183949e+05 \n", "total air emissions 3.602298e+04 \n", "total emissions 8.237196e+07 \n", "\n", "[3 rows x 48 columns]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "io.calc_all()\n", "io.impacts.D_cba" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that units are checked against the unit specification of the extension.\n", "Thus, any mismatch of units will abort the calculation. The validation table\n", "helps to identify the issue." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "charact_table.loc[charact_table.stressor == \"emission_type1\", \"stressor_unit\"] = \"t\"" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/konstans/proj/pymrio/pymrio/core/mriosystem.py:1869: UserWarning: Unit errors/inconsistencies between passed units and extension units - check validation\n", " warnings.warn(\"Unit errors/inconsistencies between passed units and extension units - check validation\")\n" ] } ], "source": [ "ret_error = io.emissions.characterize(charact_table)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "ret_error.extension" ] }, { "cell_type": "code", "execution_count": 14, "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", "
stressorcompartmentimpactfactorimpact_unitstressor_uniterror_unit_impacterror_unit_stressorerror_missing_stressor
0emission_type1airair water impact0.002ttFalseTrueFalse
1emission_type1airtotal emissions1.000kgtFalseTrueFalse
2emission_type1airtotal air emissions0.001ttFalseTrueFalse
3emission_type2waterair water impact0.001tkgFalseFalseFalse
4emission_type2watertotal emissions1.000kgkgFalseFalseFalse
5emission_type3landtotal emissions1.000kgkgFalseFalseTrue
\n", "
" ], "text/plain": [ " stressor compartment impact factor impact_unit \\\n", "0 emission_type1 air air water impact 0.002 t \n", "1 emission_type1 air total emissions 1.000 kg \n", "2 emission_type1 air total air emissions 0.001 t \n", "3 emission_type2 water air water impact 0.001 t \n", "4 emission_type2 water total emissions 1.000 kg \n", "5 emission_type3 land total emissions 1.000 kg \n", "\n", " stressor_unit error_unit_impact error_unit_stressor \\\n", "0 t False True \n", "1 t False True \n", "2 t False True \n", "3 kg False False \n", "4 kg False False \n", "5 kg False False \n", "\n", " error_missing_stressor \n", "0 False \n", "1 False \n", "2 False \n", "3 False \n", "4 False \n", "5 True " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ret_error.validation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The error_unit_impact column indicate the stressor with the unit mismatch." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Regional specific characterization factors" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we use a table of regionally specific characterisation factors.\n", "The actual factors contained here are the same as in the basic example and we\n", "will modify them after loading.\n", "We will also investigate cases with missing data or conflicting units.\n", "The same principles can be used for sector specific characterization factors." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We use the same data test mrio system as before:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "tags": [] }, "outputs": [], "source": [ "io = pymrio.load_test()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "with the regional specific characterization factors from" ] }, { "cell_type": "code", "execution_count": 16, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
regionstressorcompartmentimpactfactorimpact_unitstressor_unit
0reg1emission_type1airair water impact0.002tkg
1reg1emission_type2waterair water impact0.001tkg
2reg1emission_type1airtotal emissions1.000kgkg
3reg1emission_type2watertotal emissions1.000kgkg
4reg1emission_type3landtotal emissions1.000kgkg
5reg1emission_type1airtotal air emissions0.001tkg
6reg2emission_type1airair water impact0.002tkg
7reg2emission_type2waterair water impact0.001tkg
8reg2emission_type1airtotal emissions1.000kgkg
9reg2emission_type2watertotal emissions1.000kgkg
10reg2emission_type3landtotal emissions1.000kgkg
11reg2emission_type1airtotal air emissions0.001tkg
12reg3emission_type1airair water impact0.002tkg
13reg3emission_type2waterair water impact0.001tkg
14reg3emission_type1airtotal emissions1.000kgkg
15reg3emission_type2watertotal emissions1.000kgkg
16reg3emission_type3landtotal emissions1.000kgkg
17reg3emission_type1airtotal air emissions0.001tkg
18reg4emission_type1airair water impact0.002tkg
19reg4emission_type2waterair water impact0.001tkg
20reg4emission_type1airtotal emissions1.000kgkg
21reg4emission_type2watertotal emissions1.000kgkg
22reg4emission_type3landtotal emissions1.000kgkg
23reg4emission_type1airtotal air emissions0.001tkg
24reg5emission_type1airair water impact0.002tkg
25reg5emission_type2waterair water impact0.001tkg
26reg5emission_type1airtotal emissions1.000kgkg
27reg5emission_type2watertotal emissions1.000kgkg
28reg5emission_type3landtotal emissions1.000kgkg
29reg5emission_type1airtotal air emissions0.001tkg
30reg6emission_type1airair water impact0.002tkg
31reg6emission_type2waterair water impact0.001tkg
32reg6emission_type1airtotal emissions1.000kgkg
33reg6emission_type2watertotal emissions1.000kgkg
34reg6emission_type3landtotal emissions1.000kgkg
35reg6emission_type1airtotal air emissions0.001tkg
\n", "
" ], "text/plain": [ " region stressor compartment impact factor \\\n", "0 reg1 emission_type1 air air water impact 0.002 \n", "1 reg1 emission_type2 water air water impact 0.001 \n", "2 reg1 emission_type1 air total emissions 1.000 \n", "3 reg1 emission_type2 water total emissions 1.000 \n", "4 reg1 emission_type3 land total emissions 1.000 \n", "5 reg1 emission_type1 air total air emissions 0.001 \n", "6 reg2 emission_type1 air air water impact 0.002 \n", "7 reg2 emission_type2 water air water impact 0.001 \n", "8 reg2 emission_type1 air total emissions 1.000 \n", "9 reg2 emission_type2 water total emissions 1.000 \n", "10 reg2 emission_type3 land total emissions 1.000 \n", "11 reg2 emission_type1 air total air emissions 0.001 \n", "12 reg3 emission_type1 air air water impact 0.002 \n", "13 reg3 emission_type2 water air water impact 0.001 \n", "14 reg3 emission_type1 air total emissions 1.000 \n", "15 reg3 emission_type2 water total emissions 1.000 \n", "16 reg3 emission_type3 land total emissions 1.000 \n", "17 reg3 emission_type1 air total air emissions 0.001 \n", "18 reg4 emission_type1 air air water impact 0.002 \n", "19 reg4 emission_type2 water air water impact 0.001 \n", "20 reg4 emission_type1 air total emissions 1.000 \n", "21 reg4 emission_type2 water total emissions 1.000 \n", "22 reg4 emission_type3 land total emissions 1.000 \n", "23 reg4 emission_type1 air total air emissions 0.001 \n", "24 reg5 emission_type1 air air water impact 0.002 \n", "25 reg5 emission_type2 water air water impact 0.001 \n", "26 reg5 emission_type1 air total emissions 1.000 \n", "27 reg5 emission_type2 water total emissions 1.000 \n", "28 reg5 emission_type3 land total emissions 1.000 \n", "29 reg5 emission_type1 air total air emissions 0.001 \n", "30 reg6 emission_type1 air air water impact 0.002 \n", "31 reg6 emission_type2 water air water impact 0.001 \n", "32 reg6 emission_type1 air total emissions 1.000 \n", "33 reg6 emission_type2 water total emissions 1.000 \n", "34 reg6 emission_type3 land total emissions 1.000 \n", "35 reg6 emission_type1 air total air emissions 0.001 \n", "\n", " impact_unit stressor_unit \n", "0 t kg \n", "1 t kg \n", "2 kg kg \n", "3 kg kg \n", "4 kg kg \n", "5 t kg \n", "6 t kg \n", "7 t kg \n", "8 kg kg \n", "9 kg kg \n", "10 kg kg \n", "11 t kg \n", "12 t kg \n", "13 t kg \n", "14 kg kg \n", "15 kg kg \n", "16 kg kg \n", "17 t kg \n", "18 t kg \n", "19 t kg \n", "20 kg kg \n", "21 kg kg \n", "22 kg kg \n", "23 t kg \n", "24 t kg \n", "25 t kg \n", "26 kg kg \n", "27 kg kg \n", "28 kg kg \n", "29 t kg \n", "30 t kg \n", "31 t kg \n", "32 kg kg \n", "33 kg kg \n", "34 kg kg \n", "35 t kg " ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "charact_table_reg = pd.read_csv(\n", " (PYMRIO_PATH[\"test_mrio\"] / Path(\"concordance\") / \"emissions_charact_reg_spec.tsv\"),\n", " sep=\"\\t\",\n", ")\n", "charact_table_reg" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compared with the previous table (charact_table), this table contains an additional\n", "column *region* which contains the regional specific data.\n", "Currently, the factors are actually the same as before, thus" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "tags": [] }, "outputs": [], "source": [ "char_reg = io.emissions.characterize(charact_table_reg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For regional specific characterization, the validation table contains information per region" ] }, { "cell_type": "code", "execution_count": 18, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
stressorcompartmentregionimpactfactorimpact_unitstressor_uniterror_unit_impacterror_unit_stressorerror_missing_stressorerror_missing_region
0emission_type1airreg1air water impact0.002tkgFalseFalseFalseFalse
1emission_type1airreg1total emissions1.000kgkgFalseFalseFalseFalse
2emission_type1airreg1total air emissions0.001tkgFalseFalseFalseFalse
3emission_type1airreg2air water impact0.002tkgFalseFalseFalseFalse
4emission_type1airreg2total emissions1.000kgkgFalseFalseFalseFalse
5emission_type1airreg2total air emissions0.001tkgFalseFalseFalseFalse
6emission_type1airreg3air water impact0.002tkgFalseFalseFalseFalse
7emission_type1airreg3total emissions1.000kgkgFalseFalseFalseFalse
8emission_type1airreg3total air emissions0.001tkgFalseFalseFalseFalse
9emission_type1airreg4air water impact0.002tkgFalseFalseFalseFalse
10emission_type1airreg4total emissions1.000kgkgFalseFalseFalseFalse
11emission_type1airreg4total air emissions0.001tkgFalseFalseFalseFalse
12emission_type1airreg5air water impact0.002tkgFalseFalseFalseFalse
13emission_type1airreg5total emissions1.000kgkgFalseFalseFalseFalse
14emission_type1airreg5total air emissions0.001tkgFalseFalseFalseFalse
15emission_type1airreg6air water impact0.002tkgFalseFalseFalseFalse
16emission_type1airreg6total emissions1.000kgkgFalseFalseFalseFalse
17emission_type1airreg6total air emissions0.001tkgFalseFalseFalseFalse
18emission_type2waterreg1air water impact0.001tkgFalseFalseFalseFalse
19emission_type2waterreg1total emissions1.000kgkgFalseFalseFalseFalse
20emission_type2waterreg2air water impact0.001tkgFalseFalseFalseFalse
21emission_type2waterreg2total emissions1.000kgkgFalseFalseFalseFalse
22emission_type2waterreg3air water impact0.001tkgFalseFalseFalseFalse
23emission_type2waterreg3total emissions1.000kgkgFalseFalseFalseFalse
24emission_type2waterreg4air water impact0.001tkgFalseFalseFalseFalse
25emission_type2waterreg4total emissions1.000kgkgFalseFalseFalseFalse
26emission_type2waterreg5air water impact0.001tkgFalseFalseFalseFalse
27emission_type2waterreg5total emissions1.000kgkgFalseFalseFalseFalse
28emission_type2waterreg6air water impact0.001tkgFalseFalseFalseFalse
29emission_type2waterreg6total emissions1.000kgkgFalseFalseFalseFalse
30emission_type3landreg1total emissions1.000kgkgFalseFalseTrueFalse
31emission_type3landreg2total emissions1.000kgkgFalseFalseTrueFalse
32emission_type3landreg3total emissions1.000kgkgFalseFalseTrueFalse
33emission_type3landreg4total emissions1.000kgkgFalseFalseTrueFalse
34emission_type3landreg5total emissions1.000kgkgFalseFalseTrueFalse
35emission_type3landreg6total emissions1.000kgkgFalseFalseTrueFalse
\n", "
" ], "text/plain": [ " stressor compartment region impact factor \\\n", "0 emission_type1 air reg1 air water impact 0.002 \n", "1 emission_type1 air reg1 total emissions 1.000 \n", "2 emission_type1 air reg1 total air emissions 0.001 \n", "3 emission_type1 air reg2 air water impact 0.002 \n", "4 emission_type1 air reg2 total emissions 1.000 \n", "5 emission_type1 air reg2 total air emissions 0.001 \n", "6 emission_type1 air reg3 air water impact 0.002 \n", "7 emission_type1 air reg3 total emissions 1.000 \n", "8 emission_type1 air reg3 total air emissions 0.001 \n", "9 emission_type1 air reg4 air water impact 0.002 \n", "10 emission_type1 air reg4 total emissions 1.000 \n", "11 emission_type1 air reg4 total air emissions 0.001 \n", "12 emission_type1 air reg5 air water impact 0.002 \n", "13 emission_type1 air reg5 total emissions 1.000 \n", "14 emission_type1 air reg5 total air emissions 0.001 \n", "15 emission_type1 air reg6 air water impact 0.002 \n", "16 emission_type1 air reg6 total emissions 1.000 \n", "17 emission_type1 air reg6 total air emissions 0.001 \n", "18 emission_type2 water reg1 air water impact 0.001 \n", "19 emission_type2 water reg1 total emissions 1.000 \n", "20 emission_type2 water reg2 air water impact 0.001 \n", "21 emission_type2 water reg2 total emissions 1.000 \n", "22 emission_type2 water reg3 air water impact 0.001 \n", "23 emission_type2 water reg3 total emissions 1.000 \n", "24 emission_type2 water reg4 air water impact 0.001 \n", "25 emission_type2 water reg4 total emissions 1.000 \n", "26 emission_type2 water reg5 air water impact 0.001 \n", "27 emission_type2 water reg5 total emissions 1.000 \n", "28 emission_type2 water reg6 air water impact 0.001 \n", "29 emission_type2 water reg6 total emissions 1.000 \n", "30 emission_type3 land reg1 total emissions 1.000 \n", "31 emission_type3 land reg2 total emissions 1.000 \n", "32 emission_type3 land reg3 total emissions 1.000 \n", "33 emission_type3 land reg4 total emissions 1.000 \n", "34 emission_type3 land reg5 total emissions 1.000 \n", "35 emission_type3 land reg6 total emissions 1.000 \n", "\n", " impact_unit stressor_unit error_unit_impact error_unit_stressor \\\n", "0 t kg False False \n", "1 kg kg False False \n", "2 t kg False False \n", "3 t kg False False \n", "4 kg kg False False \n", "5 t kg False False \n", "6 t kg False False \n", "7 kg kg False False \n", "8 t kg False False \n", "9 t kg False False \n", "10 kg kg False False \n", "11 t kg False False \n", "12 t kg False False \n", "13 kg kg False False \n", "14 t kg False False \n", "15 t kg False False \n", "16 kg kg False False \n", "17 t kg False False \n", "18 t kg False False \n", "19 kg kg False False \n", "20 t kg False False \n", "21 kg kg False False \n", "22 t kg False False \n", "23 kg kg False False \n", "24 t kg False False \n", "25 kg kg False False \n", "26 t kg False False \n", "27 kg kg False False \n", "28 t kg False False \n", "29 kg kg False False \n", "30 kg kg False False \n", "31 kg kg False False \n", "32 kg kg False False \n", "33 kg kg False False \n", "34 kg kg False False \n", "35 kg kg False False \n", "\n", " error_missing_stressor error_missing_region \n", "0 False False \n", "1 False False \n", "2 False False \n", "3 False False \n", "4 False False \n", "5 False False \n", "6 False False \n", "7 False False \n", "8 False False \n", "9 False False \n", "10 False False \n", "11 False False \n", "12 False False \n", "13 False False \n", "14 False False \n", "15 False False \n", "16 False False \n", "17 False False \n", "18 False False \n", "19 False False \n", "20 False False \n", "21 False False \n", "22 False False \n", "23 False False \n", "24 False False \n", "25 False False \n", "26 False False \n", "27 False False \n", "28 False False \n", "29 False False \n", "30 True False \n", "31 True False \n", "32 True False \n", "33 True False \n", "34 True False \n", "35 True False " ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "char_reg.validation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The extension is again available in the extension attribute" ] }, { "cell_type": "code", "execution_count": 19, "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", " \n", " \n", "
regionreg1reg2...reg5reg6
sectorfoodminingmanufactoringelectricityconstructiontradetransportotherfoodmining...transportotherfoodminingmanufactoringelectricityconstructiontradetransportother
impact
air water impact3.835380e+031.995239e+034.799114e+045.655218e+045.485680e+039.519790e+034.454697e+041.813336e+043.600710e+03724.220244...8.879848e+042.873866e+043.638210e+041.470754e+042.390451e+051.127983e+051.242297e+045.028356e+041.028589e+056.004829e+04
total air emissions1.848065e+039.864481e+022.361379e+042.813910e+042.584142e+034.132656e+032.176699e+047.842091e+031.697937e+03347.378150...4.229932e+041.077383e+041.577800e+046.420956e+031.131724e+055.602253e+044.861838e+031.819562e+044.704654e+042.163287e+04
total emissions1.987315e+061.008791e+062.437736e+072.841308e+072.901538e+065.387134e+062.277999e+071.029127e+071.902773e+06376842.094000...4.649916e+071.796483e+072.060410e+078.286581e+061.258726e+085.677575e+077.561127e+063.208793e+075.581233e+073.841542e+07
\n", "

3 rows × 48 columns

\n", "
" ], "text/plain": [ "region reg1 \\\n", "sector food mining manufactoring electricity \n", "impact \n", "air water impact 3.835380e+03 1.995239e+03 4.799114e+04 5.655218e+04 \n", "total air emissions 1.848065e+03 9.864481e+02 2.361379e+04 2.813910e+04 \n", "total emissions 1.987315e+06 1.008791e+06 2.437736e+07 2.841308e+07 \n", "\n", "region \\\n", "sector construction trade transport other \n", "impact \n", "air water impact 5.485680e+03 9.519790e+03 4.454697e+04 1.813336e+04 \n", "total air emissions 2.584142e+03 4.132656e+03 2.176699e+04 7.842091e+03 \n", "total emissions 2.901538e+06 5.387134e+06 2.277999e+07 1.029127e+07 \n", "\n", "region reg2 ... reg5 \\\n", "sector food mining ... transport \n", "impact ... \n", "air water impact 3.600710e+03 724.220244 ... 8.879848e+04 \n", "total air emissions 1.697937e+03 347.378150 ... 4.229932e+04 \n", "total emissions 1.902773e+06 376842.094000 ... 4.649916e+07 \n", "\n", "region reg6 \\\n", "sector other food mining manufactoring \n", "impact \n", "air water impact 2.873866e+04 3.638210e+04 1.470754e+04 2.390451e+05 \n", "total air emissions 1.077383e+04 1.577800e+04 6.420956e+03 1.131724e+05 \n", "total emissions 1.796483e+07 2.060410e+07 8.286581e+06 1.258726e+08 \n", "\n", "region \\\n", "sector electricity construction trade transport \n", "impact \n", "air water impact 1.127983e+05 1.242297e+04 5.028356e+04 1.028589e+05 \n", "total air emissions 5.602253e+04 4.861838e+03 1.819562e+04 4.704654e+04 \n", "total emissions 5.677575e+07 7.561127e+06 3.208793e+07 5.581233e+07 \n", "\n", "region \n", "sector other \n", "impact \n", "air water impact 6.004829e+04 \n", "total air emissions 2.163287e+04 \n", "total emissions 3.841542e+07 \n", "\n", "[3 rows x 48 columns]" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "char_reg.extension.F" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "gives the same result as before. To highlight regional\n", "specificity, we double the total emission factors of region 3." ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "tags": [] }, "outputs": [], "source": [ "charact_table_reg.loc[\n", " (charact_table_reg.region == \"reg3\")\n", " & (charact_table_reg.impact == \"total emissions\"),\n", " \"factor\",\n", "] = (\n", " charact_table_reg.loc[\n", " (charact_table_reg.region == \"reg3\")\n", " & (charact_table_reg.impact == \"total emissions\"),\n", " \"factor\",\n", " ]\n", " * 2\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and calculate the new impacts" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "region sector \n", "reg1 food 1.987315e+06\n", " mining 1.008791e+06\n", " manufactoring 2.437736e+07\n", " electricity 2.841308e+07\n", " construction 2.901538e+06\n", " trade 5.387134e+06\n", " transport 2.277999e+07\n", " other 1.029127e+07\n", "reg2 food 1.902773e+06\n", " mining 3.768421e+05\n", " manufactoring 1.598022e+07\n", " electricity 1.660779e+07\n", " construction 1.868660e+06\n", " trade 3.511220e+06\n", " transport 6.836824e+06\n", " other 6.185187e+06\n", "reg3 food 1.100035e+07\n", " mining 9.531717e+06\n", " manufactoring 2.150874e+08\n", " electricity 1.503010e+08\n", " construction 3.996900e+07\n", " trade 1.213563e+08\n", " transport 1.301629e+08\n", " other 3.714520e+08\n", "reg4 food 6.479508e+06\n", " mining 9.508597e+06\n", " manufactoring 4.755267e+07\n", " electricity 4.478230e+07\n", " construction 6.364480e+06\n", " trade 1.444928e+07\n", " transport 3.071924e+07\n", " other 2.961040e+07\n", "reg5 food 6.628066e+06\n", " mining 4.867714e+06\n", " manufactoring 1.192319e+08\n", " electricity 4.324482e+07\n", " construction 3.465382e+06\n", " trade 1.967876e+07\n", " transport 4.649916e+07\n", " other 1.796483e+07\n", "reg6 food 2.060410e+07\n", " mining 8.286581e+06\n", " manufactoring 1.258726e+08\n", " electricity 5.677575e+07\n", " construction 7.561127e+06\n", " trade 3.208793e+07\n", " transport 5.581233e+07\n", " other 3.841542e+07\n", "Name: total emissions, dtype: float64" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "char_reg_dbl = io.emissions.characterize(charact_table_reg).extension\n", "char_reg_dbl.F.loc[\"total emissions\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "compared to" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "region sector \n", "reg1 food 1.987315e+06\n", " mining 1.008791e+06\n", " manufactoring 2.437736e+07\n", " electricity 2.841308e+07\n", " construction 2.901538e+06\n", " trade 5.387134e+06\n", " transport 2.277999e+07\n", " other 1.029127e+07\n", "reg2 food 1.902773e+06\n", " mining 3.768421e+05\n", " manufactoring 1.598022e+07\n", " electricity 1.660779e+07\n", " construction 1.868660e+06\n", " trade 3.511220e+06\n", " transport 6.836824e+06\n", " other 6.185187e+06\n", "reg3 food 5.500174e+06\n", " mining 4.765858e+06\n", " manufactoring 1.075437e+08\n", " electricity 7.515049e+07\n", " construction 1.998450e+07\n", " trade 6.067817e+07\n", " transport 6.508145e+07\n", " other 1.857260e+08\n", "reg4 food 6.479508e+06\n", " mining 9.508597e+06\n", " manufactoring 4.755267e+07\n", " electricity 4.478230e+07\n", " construction 6.364480e+06\n", " trade 1.444928e+07\n", " transport 3.071924e+07\n", " other 2.961040e+07\n", "reg5 food 6.628066e+06\n", " mining 4.867714e+06\n", " manufactoring 1.192319e+08\n", " electricity 4.324482e+07\n", " construction 3.465382e+06\n", " trade 1.967876e+07\n", " transport 4.649916e+07\n", " other 1.796483e+07\n", "reg6 food 2.060410e+07\n", " mining 8.286581e+06\n", " manufactoring 1.258726e+08\n", " electricity 5.677575e+07\n", " construction 7.561127e+06\n", " trade 3.208793e+07\n", " transport 5.581233e+07\n", " other 3.841542e+07\n", "Name: total emissions, dtype: float64" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "char_reg.extension.F.loc[\"total emissions\"]" ] }, { "cell_type": "markdown", "metadata": { "lines_to_next_cell": 2 }, "source": [ "## Some more notes on validation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can put some more inconsistencies into the table to showcase the validation process.\n", "Some unit error in the stressors:" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "charact_table_reg.loc[\n", " (charact_table_reg.region == \"reg4\")\n", " & (charact_table_reg.stressor == \"emission_type1\"),\n", " \"stressor_unit\",\n", "] = \"s\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Some inconsistent impact units:" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "lines_to_next_cell": 2, "tags": [] }, "outputs": [], "source": [ "charact_table_reg.loc[\n", " (charact_table_reg.region == \"reg2\")\n", " & (charact_table_reg.impact == \"total emissions\"),\n", " \"impact_unit\",\n", "] = \"kt\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Some spelling mistake in region 2 for some stressor:" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "charact_table_reg.loc[\n", " (charact_table_reg.region == \"reg2\")\n", " & (charact_table_reg.stressor == \"emission_type2\"),\n", " \"region\",\n", "] = \"reg22\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Another region data which is not available in the extension" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "lines_to_next_cell": 2, "tags": [] }, "outputs": [], "source": [ "new_data = charact_table_reg.iloc[[0]]\n", "new_data.loc[:, \"region\"] = \"reg_additional\"\n", "charact_table_reg = charact_table_reg.merge(new_data, how=\"outer\")" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "report = io.emissions.characterize(charact_table_reg, only_validation=True).validation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The unit errors are reported for each row, and the one additional region not present in the extension is report under *error_missing_region*.\n", "The column *error_unit_impact* indicates the impact with inconsistent units" ] }, { "cell_type": "code", "execution_count": 28, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
stressorcompartmentregionimpactfactorimpact_unitstressor_uniterror_unit_impacterror_unit_stressorerror_missing_stressorerror_missing_region
0emission_type1airreg1air water impact0.002tkgFalseFalseFalseFalse
1emission_type1airreg1total air emissions0.001tkgFalseFalseFalseFalse
2emission_type1airreg1total emissions1.000kgkgTrueFalseFalseFalse
3emission_type1airreg2air water impact0.002tkgFalseFalseFalseFalse
4emission_type1airreg2total air emissions0.001tkgFalseFalseFalseFalse
5emission_type1airreg2total emissions1.000ktkgTrueFalseFalseFalse
6emission_type1airreg3air water impact0.002tkgFalseFalseFalseFalse
7emission_type1airreg3total air emissions0.001tkgFalseFalseFalseFalse
8emission_type1airreg3total emissions2.000kgkgTrueFalseFalseFalse
9emission_type1airreg4air water impact0.002tsFalseTrueFalseFalse
10emission_type1airreg4total air emissions0.001tsFalseTrueFalseFalse
11emission_type1airreg4total emissions1.000kgsTrueTrueFalseFalse
12emission_type1airreg5air water impact0.002tkgFalseFalseFalseFalse
13emission_type1airreg5total air emissions0.001tkgFalseFalseFalseFalse
14emission_type1airreg5total emissions1.000kgkgTrueFalseFalseFalse
15emission_type1airreg6air water impact0.002tkgFalseFalseFalseFalse
16emission_type1airreg6total air emissions0.001tkgFalseFalseFalseFalse
17emission_type1airreg6total emissions1.000kgkgTrueFalseFalseFalse
18emission_type1airreg_additionalair water impact0.002tkgFalseFalseFalseTrue
\n", "
" ], "text/plain": [ " stressor compartment region impact factor \\\n", "0 emission_type1 air reg1 air water impact 0.002 \n", "1 emission_type1 air reg1 total air emissions 0.001 \n", "2 emission_type1 air reg1 total emissions 1.000 \n", "3 emission_type1 air reg2 air water impact 0.002 \n", "4 emission_type1 air reg2 total air emissions 0.001 \n", "5 emission_type1 air reg2 total emissions 1.000 \n", "6 emission_type1 air reg3 air water impact 0.002 \n", "7 emission_type1 air reg3 total air emissions 0.001 \n", "8 emission_type1 air reg3 total emissions 2.000 \n", "9 emission_type1 air reg4 air water impact 0.002 \n", "10 emission_type1 air reg4 total air emissions 0.001 \n", "11 emission_type1 air reg4 total emissions 1.000 \n", "12 emission_type1 air reg5 air water impact 0.002 \n", "13 emission_type1 air reg5 total air emissions 0.001 \n", "14 emission_type1 air reg5 total emissions 1.000 \n", "15 emission_type1 air reg6 air water impact 0.002 \n", "16 emission_type1 air reg6 total air emissions 0.001 \n", "17 emission_type1 air reg6 total emissions 1.000 \n", "18 emission_type1 air reg_additional air water impact 0.002 \n", "\n", " impact_unit stressor_unit error_unit_impact error_unit_stressor \\\n", "0 t kg False False \n", "1 t kg False False \n", "2 kg kg True False \n", "3 t kg False False \n", "4 t kg False False \n", "5 kt kg True False \n", "6 t kg False False \n", "7 t kg False False \n", "8 kg kg True False \n", "9 t s False True \n", "10 t s False True \n", "11 kg s True True \n", "12 t kg False False \n", "13 t kg False False \n", "14 kg kg True False \n", "15 t kg False False \n", "16 t kg False False \n", "17 kg kg True False \n", "18 t kg False False \n", "\n", " error_missing_stressor error_missing_region \n", "0 False False \n", "1 False False \n", "2 False False \n", "3 False False \n", "4 False False \n", "5 False False \n", "6 False False \n", "7 False False \n", "8 False False \n", "9 False False \n", "10 False False \n", "11 False False \n", "12 False False \n", "13 False False \n", "14 False False \n", "15 False False \n", "16 False False \n", "17 False False \n", "18 False True " ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "report[report.stressor == \"emission_type1\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In case of emission_type2, the *error_missing_region* is True for the whole stressor, since reg2 is \"no longer present\" in the factor sheets due to the spelling mistake.\n", "Thus, not all regions are covered in the specifications.\n", "Again, the column *error_unit_impact* indicates the impact with inconsistent units" ] }, { "cell_type": "code", "execution_count": 29, "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", " \n", " \n", " \n", " \n", " \n", " \n", "
stressorcompartmentregionimpactfactorimpact_unitstressor_uniterror_unit_impacterror_unit_stressorerror_missing_stressorerror_missing_region
19emission_type2waterreg1air water impact0.001tkgFalseFalseFalseTrue
20emission_type2waterreg1total emissions1.000kgkgTrueFalseFalseTrue
21emission_type2waterreg22air water impact0.001tkgFalseFalseFalseTrue
22emission_type2waterreg22total emissions1.000ktkgTrueFalseFalseTrue
23emission_type2waterreg3air water impact0.001tkgFalseFalseFalseTrue
24emission_type2waterreg3total emissions2.000kgkgTrueFalseFalseTrue
25emission_type2waterreg4air water impact0.001tkgFalseFalseFalseTrue
26emission_type2waterreg4total emissions1.000kgkgTrueFalseFalseTrue
27emission_type2waterreg5air water impact0.001tkgFalseFalseFalseTrue
28emission_type2waterreg5total emissions1.000kgkgTrueFalseFalseTrue
29emission_type2waterreg6air water impact0.001tkgFalseFalseFalseTrue
30emission_type2waterreg6total emissions1.000kgkgTrueFalseFalseTrue
\n", "
" ], "text/plain": [ " stressor compartment region impact factor impact_unit \\\n", "19 emission_type2 water reg1 air water impact 0.001 t \n", "20 emission_type2 water reg1 total emissions 1.000 kg \n", "21 emission_type2 water reg22 air water impact 0.001 t \n", "22 emission_type2 water reg22 total emissions 1.000 kt \n", "23 emission_type2 water reg3 air water impact 0.001 t \n", "24 emission_type2 water reg3 total emissions 2.000 kg \n", "25 emission_type2 water reg4 air water impact 0.001 t \n", "26 emission_type2 water reg4 total emissions 1.000 kg \n", "27 emission_type2 water reg5 air water impact 0.001 t \n", "28 emission_type2 water reg5 total emissions 1.000 kg \n", "29 emission_type2 water reg6 air water impact 0.001 t \n", "30 emission_type2 water reg6 total emissions 1.000 kg \n", "\n", " stressor_unit error_unit_impact error_unit_stressor \\\n", "19 kg False False \n", "20 kg True False \n", "21 kg False False \n", "22 kg True False \n", "23 kg False False \n", "24 kg True False \n", "25 kg False False \n", "26 kg True False \n", "27 kg False False \n", "28 kg True False \n", "29 kg False False \n", "30 kg True False \n", "\n", " error_missing_stressor error_missing_region \n", "19 False True \n", "20 False True \n", "21 False True \n", "22 False True \n", "23 False True \n", "24 False True \n", "25 False True \n", "26 False True \n", "27 False True \n", "28 False True \n", "29 False True \n", "30 False True " ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "report[report.stressor == \"emission_type2\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Characterization across multiple extensions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In addition to characterizing a single extension, pymrio also offers functionality\n", "to apply characterization across multiple extensions simultaneously. This is useful\n", "when your impacts depend on stressors that are distributed across different satellite accounts." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's demonstrate this using our test MRIO system:" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "io = pymrio.load_test()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, let's create multiple extensions from our emissions data to better showcase this functionality:" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "# Create copies of the emissions extension with different names and data subsets\n", "io.water = io.emissions.copy(\"water\")\n", "io.air = io.emissions.copy(\"air\")" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "# Keep only water emissions in the water extension\n", "io.water.F = io.water.F.loc[[(\"emission_type2\", \"water\")], :]\n", "io.water.F_Y = io.water.F_Y.loc[[(\"emission_type2\", \"water\")], :]" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "# Keep only air emissions in the air extension\n", "io.air.F = io.air.F.loc[[(\"emission_type1\", \"air\")], :]\n", "io.air.F_Y = io.air.F_Y.loc[[(\"emission_type1\", \"air\")], :]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Examining the extensions:" ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "lines_to_next_cell": 2 }, "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", "
regionreg1reg2...reg5reg6
sectorfoodminingmanufactoringelectricityconstructiontradetransportotherfoodmining...transportotherfoodminingmanufactoringelectricityconstructiontradetransportother
stressorcompartment
emission_type1air1848064.8986448.0923613787.028139100.02584141.84132656.321766987.07842090.61697937.3347378.15...4229931910773826.015777996.06420955.5113172450.056022534.04861838.51819562147046542.021632868
\n", "

1 rows × 48 columns

\n", "
" ], "text/plain": [ "region reg1 \\\n", "sector food mining manufactoring electricity \n", "stressor compartment \n", "emission_type1 air 1848064.8 986448.09 23613787.0 28139100.0 \n", "\n", "region \\\n", "sector construction trade transport other \n", "stressor compartment \n", "emission_type1 air 2584141.8 4132656.3 21766987.0 7842090.6 \n", "\n", "region reg2 ... reg5 \\\n", "sector food mining ... transport other \n", "stressor compartment ... \n", "emission_type1 air 1697937.3 347378.15 ... 42299319 10773826.0 \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", "\n", "region \n", "sector construction trade transport other \n", "stressor compartment \n", "emission_type1 air 4861838.5 18195621 47046542.0 21632868 \n", "\n", "[1 rows x 48 columns]" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "io.air.F" ] }, { "cell_type": "code", "execution_count": 35, "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", "
regionreg1reg2...reg5reg6
sectorfoodminingmanufactoringelectricityconstructiontradetransportotherfoodmining...transportotherfoodminingmanufactoringelectricityconstructiontradetransportother
stressorcompartment
emission_type2water139250.4722343.295763569.18273981.55317396.511254477.81012999.12449178.0204835.4429463.944...41998417191006.34826108.11865625.112700193.0753213.72699288.3138923138765784.316782553
\n", "

1 rows × 48 columns

\n", "
" ], "text/plain": [ "region reg1 \\\n", "sector food mining manufactoring electricity \n", "stressor compartment \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_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_type2 water 204835.44 29463.944 ... 4199841 7191006.3 \n", "\n", "region reg6 \\\n", "sector food mining manufactoring electricity \n", "stressor compartment \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_type2 water 2699288.3 13892313 8765784.3 16782553 \n", "\n", "[1 rows x 48 columns]" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "io.water.F" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To characterize across multiple extensions, we need a characterization table that includes\n", "an 'extension' column specifying which extension each stressor belongs to:" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "# Start with our regional characterization table\n", "factors_reg_spec = pd.read_csv(\n", " (PYMRIO_PATH[\"test_mrio\"] / Path(\"concordance\") / \"emissions_charact_reg_spec.tsv\"),\n", " sep=\"\\t\",\n", ")" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "# Create a copy and add an extension column based on compartment\n", "factors_reg_ext = factors_reg_spec.copy()\n", "factors_reg_ext.loc[:, \"extension\"] = factors_reg_ext.loc[:, \"compartment\"]" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [], "source": [ "# Filter out any entries that don't correspond to our extensions\n", "factors_reg_ext = factors_reg_ext[factors_reg_ext.compartment.isin([\"air\", \"water\"])]" ] }, { "cell_type": "code", "execution_count": 39, "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", "
regionstressorcompartmentimpactfactorimpact_unitstressor_unitextension
0reg1emission_type1airair water impact0.002tkgair
1reg1emission_type2waterair water impact0.001tkgwater
2reg1emission_type1airtotal emissions1.000kgkgair
3reg1emission_type2watertotal emissions1.000kgkgwater
5reg1emission_type1airtotal air emissions0.001tkgair
6reg2emission_type1airair water impact0.002tkgair
7reg2emission_type2waterair water impact0.001tkgwater
8reg2emission_type1airtotal emissions1.000kgkgair
9reg2emission_type2watertotal emissions1.000kgkgwater
11reg2emission_type1airtotal air emissions0.001tkgair
\n", "
" ], "text/plain": [ " region stressor compartment impact factor \\\n", "0 reg1 emission_type1 air air water impact 0.002 \n", "1 reg1 emission_type2 water air water impact 0.001 \n", "2 reg1 emission_type1 air total emissions 1.000 \n", "3 reg1 emission_type2 water total emissions 1.000 \n", "5 reg1 emission_type1 air total air emissions 0.001 \n", "6 reg2 emission_type1 air air water impact 0.002 \n", "7 reg2 emission_type2 water air water impact 0.001 \n", "8 reg2 emission_type1 air total emissions 1.000 \n", "9 reg2 emission_type2 water total emissions 1.000 \n", "11 reg2 emission_type1 air total air emissions 0.001 \n", "\n", " impact_unit stressor_unit extension \n", "0 t kg air \n", "1 t kg water \n", "2 kg kg air \n", "3 kg kg water \n", "5 t kg air \n", "6 t kg air \n", "7 t kg water \n", "8 kg kg air \n", "9 kg kg water \n", "11 t kg air " ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Examine our multi-extension characterization table:\n", "factors_reg_ext.head(10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are two ways to characterize across multiple extensions:" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [], "source": [ "# 1. Using the top-level function with specific extensions:\n", "ex_reg_multi = pymrio.extension_characterize(\n", " io.air,\n", " io.water, # List the extensions you want to include\n", " factors=factors_reg_ext,\n", " new_extension_name=\"multi_top_level\",\n", ").extension" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "# 2. Using the MRIO object's method which automatically includes all available extensions:\n", "ex_reg_mrio = io.extension_characterize(\n", " factors=factors_reg_ext, new_extension_name=\"multi_mrio_method\"\n", ").extension" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Are the characterized F matrices equal? True\n" ] } ], "source": [ "# Both approaches produce the same result when the same extensions are involved:\n", "print(\"Are the characterized F matrices equal?\", ex_reg_multi.F.equals(ex_reg_mrio.F))" ] }, { "cell_type": "code", "execution_count": 43, "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", " \n", " \n", "
regionreg1reg2...reg5reg6
sectorfoodminingmanufactoringelectricityconstructiontradetransportotherfoodmining...transportotherfoodminingmanufactoringelectricityconstructiontradetransportother
impact
air water impact4.354677e+03384.1252642.116984e+052.391231e+047.032641e+038.548388e+032.200050e+044.012355e+043.800328e+0342.024811...8.843384e+043.008044e+043.476528e+043.227857e+031.535829e+057.423616e+044.580343e+031.393218e+051.049447e+051.183949e+05
total air emissions2.056183e+03179.4235369.749300e+041.188759e+043.342906e+033.885884e+031.075027e+041.582152e+041.793338e+0319.145605...4.209505e+041.138661e+041.517235e+041.345318e+037.145075e+043.683167e+041.836696e+034.241568e+044.805409e+043.602298e+04
total emissions2.298494e+06204701.7279791.142054e+081.202472e+073.689735e+064.662504e+061.125023e+072.430203e+072.006991e+0622879.206385...4.633879e+071.869382e+071.959293e+071.882540e+068.213219e+073.740449e+072.743647e+069.690613e+075.689057e+078.237196e+07
\n", "

3 rows × 48 columns

\n", "
" ], "text/plain": [ "region reg1 \\\n", "sector food mining manufactoring electricity \n", "impact \n", "air water impact 4.354677e+03 384.125264 2.116984e+05 2.391231e+04 \n", "total air emissions 2.056183e+03 179.423536 9.749300e+04 1.188759e+04 \n", "total emissions 2.298494e+06 204701.727979 1.142054e+08 1.202472e+07 \n", "\n", "region \\\n", "sector construction trade transport other \n", "impact \n", "air water impact 7.032641e+03 8.548388e+03 2.200050e+04 4.012355e+04 \n", "total air emissions 3.342906e+03 3.885884e+03 1.075027e+04 1.582152e+04 \n", "total emissions 3.689735e+06 4.662504e+06 1.125023e+07 2.430203e+07 \n", "\n", "region reg2 ... reg5 \\\n", "sector food mining ... transport \n", "impact ... \n", "air water impact 3.800328e+03 42.024811 ... 8.843384e+04 \n", "total air emissions 1.793338e+03 19.145605 ... 4.209505e+04 \n", "total emissions 2.006991e+06 22879.206385 ... 4.633879e+07 \n", "\n", "region reg6 \\\n", "sector other food mining manufactoring \n", "impact \n", "air water impact 3.008044e+04 3.476528e+04 3.227857e+03 1.535829e+05 \n", "total air emissions 1.138661e+04 1.517235e+04 1.345318e+03 7.145075e+04 \n", "total emissions 1.869382e+07 1.959293e+07 1.882540e+06 8.213219e+07 \n", "\n", "region \\\n", "sector electricity construction trade transport \n", "impact \n", "air water impact 7.423616e+04 4.580343e+03 1.393218e+05 1.049447e+05 \n", "total air emissions 3.683167e+04 1.836696e+03 4.241568e+04 4.805409e+04 \n", "total emissions 3.740449e+07 2.743647e+06 9.690613e+07 5.689057e+07 \n", "\n", "region \n", "sector other \n", "impact \n", "air water impact 1.183949e+05 \n", "total air emissions 3.602298e+04 \n", "total emissions 8.237196e+07 \n", "\n", "[3 rows x 48 columns]" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Add the extension to our MRIO and calculate results:\n", "io.multi = ex_reg_multi\n", "io.calc_all()\n", "io.multi.D_cba" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [], "source": [ "# As with single extension characterization, validation is crucial:\n", "validation_report = pymrio.extension_characterize(\n", " io.air, io.water, factors=factors_reg_ext, only_validation=True\n", ").validation" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Validation report:\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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
stressorcompartmentregionimpactfactorimpact_unitstressor_uniterror_unit_impacterror_unit_stressorerror_missing_stressorerror_missing_region
0emission_type1airreg1air water impact0.002tkgFalseFalseFalseFalse
1emission_type1airreg1total emissions1.000kgkgFalseFalseFalseFalse
2emission_type1airreg1total air emissions0.001tkgFalseFalseFalseFalse
3emission_type1airreg2air water impact0.002tkgFalseFalseFalseFalse
4emission_type1airreg2total emissions1.000kgkgFalseFalseFalseFalse
5emission_type1airreg2total air emissions0.001tkgFalseFalseFalseFalse
6emission_type1airreg3air water impact0.002tkgFalseFalseFalseFalse
7emission_type1airreg3total emissions1.000kgkgFalseFalseFalseFalse
8emission_type1airreg3total air emissions0.001tkgFalseFalseFalseFalse
9emission_type1airreg4air water impact0.002tkgFalseFalseFalseFalse
10emission_type1airreg4total emissions1.000kgkgFalseFalseFalseFalse
11emission_type1airreg4total air emissions0.001tkgFalseFalseFalseFalse
12emission_type1airreg5air water impact0.002tkgFalseFalseFalseFalse
13emission_type1airreg5total emissions1.000kgkgFalseFalseFalseFalse
14emission_type1airreg5total air emissions0.001tkgFalseFalseFalseFalse
15emission_type1airreg6air water impact0.002tkgFalseFalseFalseFalse
16emission_type1airreg6total emissions1.000kgkgFalseFalseFalseFalse
17emission_type1airreg6total air emissions0.001tkgFalseFalseFalseFalse
18emission_type2waterreg1air water impact0.001tkgFalseFalseFalseFalse
19emission_type2waterreg1total emissions1.000kgkgFalseFalseFalseFalse
20emission_type2waterreg2air water impact0.001tkgFalseFalseFalseFalse
21emission_type2waterreg2total emissions1.000kgkgFalseFalseFalseFalse
22emission_type2waterreg3air water impact0.001tkgFalseFalseFalseFalse
23emission_type2waterreg3total emissions1.000kgkgFalseFalseFalseFalse
24emission_type2waterreg4air water impact0.001tkgFalseFalseFalseFalse
25emission_type2waterreg4total emissions1.000kgkgFalseFalseFalseFalse
26emission_type2waterreg5air water impact0.001tkgFalseFalseFalseFalse
27emission_type2waterreg5total emissions1.000kgkgFalseFalseFalseFalse
28emission_type2waterreg6air water impact0.001tkgFalseFalseFalseFalse
29emission_type2waterreg6total emissions1.000kgkgFalseFalseFalseFalse
\n", "
" ], "text/plain": [ " stressor compartment region impact factor \\\n", "0 emission_type1 air reg1 air water impact 0.002 \n", "1 emission_type1 air reg1 total emissions 1.000 \n", "2 emission_type1 air reg1 total air emissions 0.001 \n", "3 emission_type1 air reg2 air water impact 0.002 \n", "4 emission_type1 air reg2 total emissions 1.000 \n", "5 emission_type1 air reg2 total air emissions 0.001 \n", "6 emission_type1 air reg3 air water impact 0.002 \n", "7 emission_type1 air reg3 total emissions 1.000 \n", "8 emission_type1 air reg3 total air emissions 0.001 \n", "9 emission_type1 air reg4 air water impact 0.002 \n", "10 emission_type1 air reg4 total emissions 1.000 \n", "11 emission_type1 air reg4 total air emissions 0.001 \n", "12 emission_type1 air reg5 air water impact 0.002 \n", "13 emission_type1 air reg5 total emissions 1.000 \n", "14 emission_type1 air reg5 total air emissions 0.001 \n", "15 emission_type1 air reg6 air water impact 0.002 \n", "16 emission_type1 air reg6 total emissions 1.000 \n", "17 emission_type1 air reg6 total air emissions 0.001 \n", "18 emission_type2 water reg1 air water impact 0.001 \n", "19 emission_type2 water reg1 total emissions 1.000 \n", "20 emission_type2 water reg2 air water impact 0.001 \n", "21 emission_type2 water reg2 total emissions 1.000 \n", "22 emission_type2 water reg3 air water impact 0.001 \n", "23 emission_type2 water reg3 total emissions 1.000 \n", "24 emission_type2 water reg4 air water impact 0.001 \n", "25 emission_type2 water reg4 total emissions 1.000 \n", "26 emission_type2 water reg5 air water impact 0.001 \n", "27 emission_type2 water reg5 total emissions 1.000 \n", "28 emission_type2 water reg6 air water impact 0.001 \n", "29 emission_type2 water reg6 total emissions 1.000 \n", "\n", " impact_unit stressor_unit error_unit_impact error_unit_stressor \\\n", "0 t kg False False \n", "1 kg kg False False \n", "2 t kg False False \n", "3 t kg False False \n", "4 kg kg False False \n", "5 t kg False False \n", "6 t kg False False \n", "7 kg kg False False \n", "8 t kg False False \n", "9 t kg False False \n", "10 kg kg False False \n", "11 t kg False False \n", "12 t kg False False \n", "13 kg kg False False \n", "14 t kg False False \n", "15 t kg False False \n", "16 kg kg False False \n", "17 t kg False False \n", "18 t kg False False \n", "19 kg kg False False \n", "20 t kg False False \n", "21 kg kg False False \n", "22 t kg False False \n", "23 kg kg False False \n", "24 t kg False False \n", "25 kg kg False False \n", "26 t kg False False \n", "27 kg kg False False \n", "28 t kg False False \n", "29 kg kg False False \n", "\n", " error_missing_stressor error_missing_region \n", "0 False False \n", "1 False False \n", "2 False False \n", "3 False False \n", "4 False False \n", "5 False False \n", "6 False False \n", "7 False False \n", "8 False False \n", "9 False False \n", "10 False False \n", "11 False False \n", "12 False False \n", "13 False False \n", "14 False False \n", "15 False False \n", "16 False False \n", "17 False False \n", "18 False False \n", "19 False False \n", "20 False False \n", "21 False False \n", "22 False False \n", "23 False False \n", "24 False False \n", "25 False False \n", "26 False False \n", "27 False False \n", "28 False False \n", "29 False False " ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(\"Validation report:\")\n", "validation_report" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The validation process helps identify issues such as:\n", "- Missing stressors or extensions\n", "- Unit inconsistencies\n", "- Missing regions or sectors\n", "- Extension name mismatches" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Important considerations for multi-extension characterization:\n", "\n", "1. The 'extension' column in your characterization table must match the extension names in your MRIO\n", "2. All extensions must have compatible region and sector classifications\n", "3. Units must be consistent across extensions and characterization factors\n", "4. If a characterization table references an extension that doesn't exist,\n", " it will be noted in the validation report" ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:light" }, "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.12.2" } }, "nbformat": 4, "nbformat_minor": 4 }