├── .gitignore ├── EEIO_software_instructions.md ├── IOT_n_national_accounts ├── Basics_IOA.ipynb ├── Basics_IOA_sv.ipynb ├── GDP_calculations_IO.xlsx ├── IOT_n_national.ipynb ├── IOT_n_national_sv.ipynb ├── Lecture_1_GDP.ipynb ├── Lecture_1_GDP_sv.ipynb └── figures │ └── IOT_basic_price.PNG ├── MRIO_seminal_works ├── MRIO_seminal_works.ipynb ├── MRIO_seminal_works_sv.ipynb └── figures │ ├── global_CO2_footprint.png │ └── growth_footprint_pc.png ├── README.md ├── carbon_based_accounting ├── carbon_based_accounting.ipynb ├── carbon_based_accounting_sv.ipynb └── data │ ├── 41558_2015_BFnclimate2555_MOESM453_ESM.xlsx │ └── IPCCsec.xlsx ├── intro_exiobase ├── data │ └── regions.csv ├── intro_exiobase.ipynb └── intro_exiobase_sv.ipynb ├── license ├── midterm └── mock_exam │ ├── 1_st │ └── mock_exam_1.ipynb │ └── 2_nd │ ├── mock_exam_2.ipynb │ ├── mock_exam_2_solutions.ipynb │ └── mock_exam_2_solutions_b.ipynb ├── national_enviro_footprint ├── data │ ├── F.txt │ ├── Fhh.txt │ ├── V.txt │ ├── Y.txt │ ├── Z.txt │ ├── labels │ │ ├── labels.csv │ │ ├── multi_reg_final_demand.csv │ │ └── multi_reg_sectors.csv │ └── pop.txt └── nat_enviro_footprint.ipynb ├── physical_n_hybrid_IO ├── figures │ ├── figure1.jpg │ └── figure2.png └── hybrid_IO_sv.ipynb ├── requirements.txt ├── scenario_analysis └── scenario_analysis.ipynb ├── structural_decomposition_analysis └── structural_decomposition_sv.ipynb ├── supplementary_session └── supplementary_session.ipynb ├── supply_chain_linkages ├── figures │ └── linkages.PNG ├── power_series_expansion.ipynb ├── supply_chain_linkages.ipynb └── supply_chain_linkages_sv.ipynb ├── supply_n_use_tables ├── data │ └── modified_supply_basic_price_AT_OECD_2015.xlsx ├── supply_n_use_tables.ipynb └── supply_n_use_tables_sv.ipynb └── waste_IO ├── data └── Japan_WIO2000sec103.xlsx ├── figures └── wio_1.gif ├── waste_IO.ipynb └── waste_IO_sv.ipynb /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | data/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | pip-wheel-metadata/ 25 | share/python-wheels/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | MANIFEST 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .nox/ 45 | .coverage 46 | .coverage.* 47 | .cache 48 | nosetests.xml 49 | coverage.xml 50 | *.cover 51 | *.py,cover 52 | .hypothesis/ 53 | .pytest_cache/ 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | local_settings.py 62 | db.sqlite3 63 | db.sqlite3-journal 64 | 65 | # Flask stuff: 66 | instance/ 67 | .webassets-cache 68 | 69 | # Scrapy stuff: 70 | .scrapy 71 | 72 | # Sphinx documentation 73 | docs/_build/ 74 | 75 | # PyBuilder 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | .python-version 87 | 88 | # pipenv 89 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 90 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 91 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 92 | # install all needed dependencies. 93 | #Pipfile.lock 94 | 95 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 96 | __pypackages__/ 97 | 98 | # Celery stuff 99 | celerybeat-schedule 100 | celerybeat.pid 101 | 102 | # SageMath parsed files 103 | *.sage.py 104 | 105 | # Environments 106 | .env 107 | .venv 108 | env/ 109 | venv/ 110 | ENV/ 111 | env.bak/ 112 | venv.bak/ 113 | 114 | # Spyder project settings 115 | .spyderproject 116 | .spyproject 117 | 118 | # Rope project settings 119 | .ropeproject 120 | 121 | # mkdocs documentation 122 | /site 123 | 124 | # mypy 125 | .mypy_cache/ 126 | .dmypy.json 127 | dmypy.json 128 | 129 | # Pyre type checker 130 | .pyre/ 131 | -------------------------------------------------------------------------------- /EEIO_software_instructions.md: -------------------------------------------------------------------------------- 1 | # Software management recommendations in preparation to the lectures’ practical exercises 2 | 3 | ## 1. Jupyter Notebooks 4 | 5 | During the practical exercises, we will use Jupyter notebooks to facilitate explanation of the code and breakdown of sections and exercises. You are not obliged to use Jupyter as the exercises can also be performed in any other Integrated Development Environment (IDE) such as Spyder or Visual Studio. However, we do recommend you familiarize yourself and try to use Jupyter because it will make it easier for you to follow instructions, and it is an important tool to know because of its broad use in many contexts, from tutorials to the development of interactive reports. 6 | 7 | **You can access Jupyter Notebooks or Jupyter Lab through the Anaconda Navigator.** 8 | 9 | To gain a better understanding of Jupyter notebooks, you can read or watch the following resource: 10 | 11 | - Nice intro with use contexts and tutorial: 12 | - Cut and dry guide: 13 | - Comprehensive video tutorial: 14 | - Additional information: 15 | 16 | ## 2. Virtual Environments 17 | 18 | Virtual environments allow you to have multiple isolated python installations independent from each other, thereby avoiding package conflicts across software and facilitating transfer and reuse of software. In practical terms, they are folders in which a specific python version is installed together with any of its packages. When you are using platforms such as Anaconda, or an IDE such as spyder or Visual Studio, their default settings will always use either a **base** environment or whatever python installation comes with your operating system. This can create problems such as conflicts with third party application or other software projects you may be working today or older ones. For these reasons, we recommend you work on a new virtual environment and not the base environment that comes by default with Anaconda. It’s always good practice to use a different environment than the base environment or the one that may come preinstalled in your operating system. 19 | 20 | To learn more: 21 | 22 | - How to create virtual environments in anaconda: 23 | - Comprehensive overview and instructions for virtual environments 24 | - Why you need virtual environment 25 | 26 | ## 3. Accessing the exercises 27 | 28 | All Jupyter Notebooks are provided through brightspace but if you want you can also access them on their original GitHub repository at this url: 29 | 30 | If you want to work with the original repository instead of the snippets of code through Github Gist, keep on reading the following Git optional instructions. 31 | 32 | ### 3.1 Git optional instructions: 33 | 34 | While you can download the exercises directly from brightSpace, we recommend you familiarize yourself with git procedures instead, as these are fundamental skills in good software management practices. 35 | 36 | If you don’t have it already, you will need to create a github account: 37 | 38 | All these procedures can be perfomed both in Github desktop or in any terminal such as Anaconda Prompt, Windows PowerShell or Linux Bash Shell 39 | 40 | **Step 1:** Open your terminal or Github desktop app (bash on Linux or PowerShell in windows) 41 | 42 | **Step 2:** If git is not already installed on your machine, you should install git by using the following procedures or installing Github desktop 43 | 44 | **Step 3:** Once you installed git you will need first to fork the repository (i.e., make a copy) . You will find the forked repository on your own Github page 45 | 46 | **Step 4:** Clone (i.e., download) your forked repository locally so that you can work on the code on your computer . By clicking on the green code button in your repository you will see the options you have to clone 47 | 48 | In the terminal: git clone [.git link to the repository] 49 | 50 | #### If at the end of the exercise you want to save your work 51 | 52 | **Step 5:** Check first what files were changed in your repository 53 | 54 | On the terminal: git status 55 | 56 | **Step 6:** Adding or removing files that you want to commit (i.e., save) 57 | 58 | In the terminal if you want to add files that have been changed: git add [name of the file] 59 | If you want to remove files that have been changed: git rm [name of the file] (or git rm --cached [name of the file] if you want to eliminate the file only on github) 60 | 61 | **Step 7:** 62 | 63 | - Commit your work by typing 64 | - git commit -m “Short comment on what you changed” 65 | 66 | **Step 8:** 67 | 68 | Finally add your changes to your remote (i.e., online) repository by typing 69 | - git push 70 | 71 | **Step 9:** 72 | 73 | - Every week, we will update the original repository so you will need to sync your fork by performing these procedures 74 | -------------------------------------------------------------------------------- /IOT_n_national_accounts/Basics_IOA.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "6049e475", 6 | "metadata": { 7 | "slideshow": { 8 | "slide_type": "slide" 9 | } 10 | }, 11 | "source": [ 12 | "# Practical 1: Basics of IOA" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 11, 18 | "id": "fd57de61", 19 | "metadata": { 20 | "slideshow": { 21 | "slide_type": "slide" 22 | } 23 | }, 24 | "outputs": [], 25 | "source": [ 26 | "# Import packages\n", 27 | "import numpy as np" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "id": "b57fb325", 33 | "metadata": { 34 | "slideshow": { 35 | "slide_type": "slide" 36 | } 37 | }, 38 | "source": [ 39 | "## Recreate a 3x3 IO system using numpy and calculate the total product output and total product input" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "id": "b9b026f0", 45 | "metadata": { 46 | "slideshow": { 47 | "slide_type": "slide" 48 | } 49 | }, 50 | "source": [ 51 | "#### Interindustry Transaction Table\n", 52 | "\n", 53 | "| Z (Unit: Trillion €/year) | Agriculture | Industry | Service |\n", 54 | "|----------------------------|-------------|----------|---------|\n", 55 | "| Agriculture | 0.6 | 2.6 | 0.5 |\n", 56 | "| Industry | 0.8 | 30.6 | 7.8 |\n", 57 | "| Service | 0.9 | 12.1 | 23.0 |" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 21, 63 | "id": "1668efe4", 64 | "metadata": { 65 | "slideshow": { 66 | "slide_type": "subslide" 67 | } 68 | }, 69 | "outputs": [ 70 | { 71 | "data": { 72 | "text/plain": [ 73 | "array([[ 0.6, 2.6, 0.5],\n", 74 | " [ 0.8, 30.6, 7.8],\n", 75 | " [ 0.9, 12.1, 23. ]])" 76 | ] 77 | }, 78 | "execution_count": 21, 79 | "metadata": {}, 80 | "output_type": "execute_result" 81 | } 82 | ], 83 | "source": [ 84 | "# interindustry transaction table\n", 85 | "Z = np.array([[0.6,2.6,0.5],[0.8,30.6,7.8],[0.9,12.1,23.0]])\n", 86 | "Z" 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "id": "32e831d0", 92 | "metadata": { 93 | "slideshow": { 94 | "slide_type": "slide" 95 | } 96 | }, 97 | "source": [ 98 | "#### Final Demand\n", 99 | "\n", 100 | "| Y (Unit: Trillion €/year)| Domestic | Export |\n", 101 | "|--------------------------|----------|----------|\n", 102 | "| Agriculture | 1.9 | 0 |\n", 103 | "| Industry | 28.5 | 0 |\n", 104 | "| Service | 47.8 | 0 |" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": 26, 110 | "id": "1555d7da", 111 | "metadata": { 112 | "slideshow": { 113 | "slide_type": "subslide" 114 | } 115 | }, 116 | "outputs": [ 117 | { 118 | "data": { 119 | "text/plain": [ 120 | "array([[ 1.9, 0. ],\n", 121 | " [28.5, 0. ],\n", 122 | " [47.8, 0. ]])" 123 | ] 124 | }, 125 | "execution_count": 26, 126 | "metadata": {}, 127 | "output_type": "execute_result" 128 | } 129 | ], 130 | "source": [ 131 | "Y = np.array([[1.9,0],[28.5,0],[47.8,0]])\n", 132 | "Y" 133 | ] 134 | }, 135 | { 136 | "cell_type": "markdown", 137 | "id": "35120e20", 138 | "metadata": { 139 | "slideshow": { 140 | "slide_type": "slide" 141 | } 142 | }, 143 | "source": [ 144 | "#### Value Added\n", 145 | "\n", 146 | "| V (Unit: Trillion €/year) | Agriculture | Industry | Service |\n", 147 | "|----------------------------|-------------|----------|---------|\n", 148 | "| Value Added | 3.3 | 22.3 | 52.5 |" 149 | ] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "execution_count": 27, 154 | "id": "ac4ab61c", 155 | "metadata": { 156 | "slideshow": { 157 | "slide_type": "subslide" 158 | } 159 | }, 160 | "outputs": [ 161 | { 162 | "data": { 163 | "text/plain": [ 164 | "array([ 3.3, 22.3, 52.5])" 165 | ] 166 | }, 167 | "execution_count": 27, 168 | "metadata": {}, 169 | "output_type": "execute_result" 170 | } 171 | ], 172 | "source": [ 173 | "V = np.array([3.3,22.3,52.5])\n", 174 | "V" 175 | ] 176 | }, 177 | { 178 | "cell_type": "markdown", 179 | "id": "1c3d0bb6", 180 | "metadata": { 181 | "slideshow": { 182 | "slide_type": "slide" 183 | } 184 | }, 185 | "source": [ 186 | "### Calculate the total product output $\\mathbf{x}$\n", 187 | "\n", 188 | "$\\mathbf{x}=\\displaystyle\\sum_{j=1}^{n} Z_{ij} + \\sum_{j=1}^{n} Y_{ij}$" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": 28, 194 | "id": "9f559de8", 195 | "metadata": { 196 | "slideshow": { 197 | "slide_type": "subslide" 198 | } 199 | }, 200 | "outputs": [ 201 | { 202 | "data": { 203 | "text/plain": [ 204 | "array([ 5.6, 67.7, 83.8])" 205 | ] 206 | }, 207 | "execution_count": 28, 208 | "metadata": {}, 209 | "output_type": "execute_result" 210 | } 211 | ], 212 | "source": [ 213 | "x = Z.sum(1) + Y.sum(1)\n", 214 | "x" 215 | ] 216 | }, 217 | { 218 | "cell_type": "markdown", 219 | "id": "de03e195", 220 | "metadata": { 221 | "slideshow": { 222 | "slide_type": "slide" 223 | } 224 | }, 225 | "source": [ 226 | "### Calculate the total product input $\\mathbf{x}'$\n", 227 | "\n", 228 | "$\\mathbf{x}'=\\displaystyle\\sum_{i=1}^{m} Z_{ij} + \\sum_{i=1}^{m} V_{ij}$" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": 29, 234 | "id": "65b14afe", 235 | "metadata": { 236 | "slideshow": { 237 | "slide_type": "subslide" 238 | } 239 | }, 240 | "outputs": [ 241 | { 242 | "data": { 243 | "text/plain": [ 244 | "array([ 5.6, 67.6, 83.8])" 245 | ] 246 | }, 247 | "execution_count": 29, 248 | "metadata": {}, 249 | "output_type": "execute_result" 250 | } 251 | ], 252 | "source": [ 253 | "x_ = Z.sum(0) + V\n", 254 | "x_" 255 | ] 256 | } 257 | ], 258 | "metadata": { 259 | "celltoolbar": "Slideshow", 260 | "kernelspec": { 261 | "display_name": "Python 3 (ipykernel)", 262 | "language": "python", 263 | "name": "python3" 264 | }, 265 | "language_info": { 266 | "codemirror_mode": { 267 | "name": "ipython", 268 | "version": 3 269 | }, 270 | "file_extension": ".py", 271 | "mimetype": "text/x-python", 272 | "name": "python", 273 | "nbconvert_exporter": "python", 274 | "pygments_lexer": "ipython3", 275 | "version": "3.11.9" 276 | } 277 | }, 278 | "nbformat": 4, 279 | "nbformat_minor": 5 280 | } 281 | -------------------------------------------------------------------------------- /IOT_n_national_accounts/Basics_IOA_sv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "141e7c39", 6 | "metadata": { 7 | "slideshow": { 8 | "slide_type": "slide" 9 | } 10 | }, 11 | "source": [ 12 | "# Practical 1: Basics of IOA" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 11, 18 | "id": "b06410d9", 19 | "metadata": { 20 | "slideshow": { 21 | "slide_type": "slide" 22 | } 23 | }, 24 | "outputs": [], 25 | "source": [ 26 | "# Import packages\n", 27 | "import numpy as np" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "id": "956b87fd", 33 | "metadata": { 34 | "slideshow": { 35 | "slide_type": "slide" 36 | } 37 | }, 38 | "source": [ 39 | "## Recreate a 3x3 IO system using numpy and calculate the total product output and total product input" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "id": "0745f324", 45 | "metadata": { 46 | "slideshow": { 47 | "slide_type": "slide" 48 | } 49 | }, 50 | "source": [ 51 | "#### Interindustry Transaction Table\n", 52 | "\n", 53 | "| Z (Unit: Trillion €/year) | Agriculture | Industry | Service |\n", 54 | "|----------------------------|-------------|----------|---------|\n", 55 | "| Agriculture | 0.6 | 2.6 | 0.5 |\n", 56 | "| Industry | 0.8 | 30.6 | 7.8 |\n", 57 | "| Service | 0.9 | 12.1 | 23.0 |" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 1, 63 | "id": "82129b4e", 64 | "metadata": { 65 | "slideshow": { 66 | "slide_type": "subslide" 67 | } 68 | }, 69 | "outputs": [], 70 | "source": [ 71 | "# interindustry transaction table\n", 72 | "Z = None\n", 73 | "Z" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "id": "d4762ee1", 79 | "metadata": { 80 | "slideshow": { 81 | "slide_type": "slide" 82 | } 83 | }, 84 | "source": [ 85 | "#### Final Demand\n", 86 | "\n", 87 | "| Y (Unit: Trillion €/year)| Domestic | Export |\n", 88 | "|--------------------------|----------|----------|\n", 89 | "| Agriculture | 1.9 | 0 |\n", 90 | "| Industry | 28.5 | 0 |\n", 91 | "| Service | 47.8 | 0 |" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": 2, 97 | "id": "639e99dc", 98 | "metadata": { 99 | "slideshow": { 100 | "slide_type": "subslide" 101 | } 102 | }, 103 | "outputs": [], 104 | "source": [ 105 | "Y = None\n", 106 | "Y" 107 | ] 108 | }, 109 | { 110 | "cell_type": "markdown", 111 | "id": "de8b57db", 112 | "metadata": { 113 | "slideshow": { 114 | "slide_type": "slide" 115 | } 116 | }, 117 | "source": [ 118 | "#### Value Added\n", 119 | "\n", 120 | "| V (Unit: Trillion €/year) | Agriculture | Industry | Service |\n", 121 | "|----------------------------|-------------|----------|---------|\n", 122 | "| Value Added | 3.3 | 22.3 | 52.5 |" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 3, 128 | "id": "b3f6e4a5", 129 | "metadata": { 130 | "slideshow": { 131 | "slide_type": "subslide" 132 | } 133 | }, 134 | "outputs": [], 135 | "source": [ 136 | "V = None\n", 137 | "V" 138 | ] 139 | }, 140 | { 141 | "cell_type": "markdown", 142 | "id": "c03b3cc5", 143 | "metadata": { 144 | "slideshow": { 145 | "slide_type": "slide" 146 | } 147 | }, 148 | "source": [ 149 | "### Calculate the total product output $\\mathbf{x}$\n", 150 | "\n", 151 | "$\\mathbf{x}=\\displaystyle\\sum_{i=1}^{m} Z_{ij} + \\sum_{i=1}^{m} Y_{ij}$" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": 4, 157 | "id": "aa4f62fa", 158 | "metadata": { 159 | "slideshow": { 160 | "slide_type": "subslide" 161 | } 162 | }, 163 | "outputs": [], 164 | "source": [ 165 | "x = None\n", 166 | "x" 167 | ] 168 | }, 169 | { 170 | "cell_type": "markdown", 171 | "id": "2a504231", 172 | "metadata": { 173 | "slideshow": { 174 | "slide_type": "slide" 175 | } 176 | }, 177 | "source": [ 178 | "### Calculate the total product input $\\mathbf{x}'$\n", 179 | "\n", 180 | "$\\mathbf{x}'=\\displaystyle\\sum_{j=1}^{n} Z_{ij} + \\sum_{j=1}^{n} V_{ij}$" 181 | ] 182 | }, 183 | { 184 | "cell_type": "code", 185 | "execution_count": 5, 186 | "id": "2add264b", 187 | "metadata": { 188 | "slideshow": { 189 | "slide_type": "subslide" 190 | } 191 | }, 192 | "outputs": [], 193 | "source": [ 194 | "x_ = None\n", 195 | "x_" 196 | ] 197 | } 198 | ], 199 | "metadata": { 200 | "celltoolbar": "Slideshow", 201 | "kernelspec": { 202 | "display_name": "Python 3 (ipykernel)", 203 | "language": "python", 204 | "name": "python3" 205 | }, 206 | "language_info": { 207 | "codemirror_mode": { 208 | "name": "ipython", 209 | "version": 3 210 | }, 211 | "file_extension": ".py", 212 | "mimetype": "text/x-python", 213 | "name": "python", 214 | "nbconvert_exporter": "python", 215 | "pygments_lexer": "ipython3", 216 | "version": "3.11.9" 217 | } 218 | }, 219 | "nbformat": 4, 220 | "nbformat_minor": 5 221 | } 222 | -------------------------------------------------------------------------------- /IOT_n_national_accounts/GDP_calculations_IO.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/IOT_n_national_accounts/GDP_calculations_IO.xlsx -------------------------------------------------------------------------------- /IOT_n_national_accounts/IOT_n_national_sv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "93ed8f12-cfff-4c86-8a77-0d0870a7be97", 6 | "metadata": {}, 7 | "source": [ 8 | "# Practical 1: IOT and National Accounts\n", 9 | "In this exercise, you will practice how to apply the three methods to calculate national GDP, using different databases and years. \n", 10 | "While the exercise is quantitive, try to reason about differences and implications of the methods as well as results from the method application." 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "id": "06dfb2a3-8454-4cab-9137-0f0cc247b4d3", 16 | "metadata": {}, 17 | "source": [ 18 | "### Learning goals\n", 19 | "\n", 20 | "- Analysing GDP trends\n", 21 | "- Implementing GDP calculation methods in different contexts\n", 22 | "- Understanding the data structure difference between SNA and IO tables \n", 23 | "- Understanding the implications of quantitative results" 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "id": "8ee1b689-c727-4b94-9c06-8212dc47c246", 29 | "metadata": {}, 30 | "source": [ 31 | "### Instructions\n", 32 | "\n", 33 | "Data should be downloaded into a data/ folder in the same directory your module is, then it should be loaded and plotted in python\n", 34 | "\n", 35 | "- Data source 1: eurostat, national accounts, main GDP aggregates https://ec.europa.eu/eurostat/web/national-accounts/database\n", 36 | "\n", 37 | "- Data source 2: CBS https://www.cbs.nl/-/media/_excel/2022/27/83-inputoutput-tables-20152021.xlsx\n", 38 | "\n", 39 | "Obtain, plot, and analyze the GDP time series for all years available" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "id": "1aaeffd1-b07a-41d1-8c07-f5e346518176", 45 | "metadata": {}, 46 | "source": [ 47 | "## Exercise 1\n", 48 | "Using the EUROSTAT data plot a graph showing the yearly GDP change using the following approaches\n", 49 | "\n", 50 | "- expenditure perspective (GDP = Consumption + Investment + Government Spending + Net Export)\n", 51 | "- production perspective (GDP = Sum of all value added of all production activities)\n", 52 | "- income perspective (GDP = Total National Income + Sales Taxes + Depreciation + Net Foreign Factor Income)\n", 53 | "\n", 54 | "Make sure to use the metadata accompanying the data to help you understand all data available within the CSV file and the GDP elements https://ec.europa.eu/eurostat/cache/metadata/en/nama10_esms.htm\n", 55 | "\n", 56 | "Tip: if you download csv.gz data this is CSV data that has been compressed. You can import it directly into python by using the \"compression\" argument in the method pd.read_csv() " 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": 2, 62 | "id": "89a776a4-3fd8-46c1-9940-53765b5dcbad", 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [ 66 | "# import modules\n", 67 | "import pandas as pd\n", 68 | "import matplotlib.pyplot as plt\n", 69 | "from matplotlib import style\n", 70 | "plt.style.use('bmh')\n", 71 | "\n", 72 | "# Import data\n", 73 | "# replace None with the rest of the function to load the data \n", 74 | "GDP_data = None\n", 75 | "\n", 76 | "# We are only interested in data in euros so make sure you slice the right currency\n", 77 | "\n", 78 | "# print the columns, it will help you understand how you can proceed in selecting the data\n" 79 | ] 80 | }, 81 | { 82 | "attachments": {}, 83 | "cell_type": "markdown", 84 | "id": "e0d6d14b-0df0-43a8-85ed-3757dafa5cc7", 85 | "metadata": {}, 86 | "source": [ 87 | "**Print all unique values in the National Account Item column (na_item) to use as a reference**\n", 88 | "\n", 89 | "You can investigate what each code means by checking the vocabulary on the European Environment Agency website \n", 90 | "\n", 91 | "https://dd.eionet.europa.eu/vocabulary/eurostat/na_item/view\n", 92 | "\n", 93 | "or you can check the statistical terms glossary for full definitions\n", 94 | "\n", 95 | "https://data.un.org/Glossary.aspx" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "id": "de4aa089-5c9d-4f22-92c8-90d1f73e45bf", 102 | "metadata": {}, 103 | "outputs": [], 104 | "source": [] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "id": "1742f376", 109 | "metadata": {}, 110 | "source": [ 111 | "#### Create a dictionary in which you will store your GDP results for comparison" 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": null, 117 | "id": "6b6d5aaa", 118 | "metadata": {}, 119 | "outputs": [], 120 | "source": [ 121 | "NA_GDP_approaches_results = {\"income\": None, \"expenditure\": None, \"production\": None}" 122 | ] 123 | }, 124 | { 125 | "cell_type": "markdown", 126 | "id": "d43256af", 127 | "metadata": {}, 128 | "source": [ 129 | "#### Income approach\n", 130 | "\n", 131 | "Isolate all data for the income approach:\n", 132 | "- comp_employees = \"D1\"\n", 133 | "- Gross operating surplus and mixed income = \"B2A3G\" \n", 134 | " - gross_operating_surplus = \"B2G\"\n", 135 | " - mixed_income = \"B3G\"\n", 136 | "- taxes less subsidies on production and imports (D2X3)\n", 137 | " - taxes_less_subsidies = \"D2\"\n", 138 | " - imports = \"D3\"\n" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": null, 144 | "id": "342a2a9e", 145 | "metadata": {}, 146 | "outputs": [], 147 | "source": [ 148 | "# select national account codes to be isolated in the data \n", 149 | "\n", 150 | "# Check wether all the items are available in the GDP breakdown csv" 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "execution_count": 1, 156 | "id": "adcdf780", 157 | "metadata": {}, 158 | "outputs": [], 159 | "source": [ 160 | "# organize and plot your results for the income approach" 161 | ] 162 | }, 163 | { 164 | "cell_type": "markdown", 165 | "id": "0e13244c", 166 | "metadata": { 167 | "slideshow": { 168 | "slide_type": "slide" 169 | } 170 | }, 171 | "source": [ 172 | "#### Expenditure approach\n", 173 | "Isolate all data for the expenditure approach:\n", 174 | "- final_consumption = \"P3\"\n", 175 | "- gross_fixed_capital_form = \"P51\"\n", 176 | "- changes_in_inventories = \"P52\"\n", 177 | "- acquisition_less_disposal_of_val = \"P53\"\n", 178 | "- exports = \"P6\"\n", 179 | "- imports = \"P7\"" 180 | ] 181 | }, 182 | { 183 | "cell_type": "code", 184 | "execution_count": null, 185 | "id": "febb2ccf", 186 | "metadata": {}, 187 | "outputs": [], 188 | "source": [ 189 | "# select national account codes to be isolated in the data \n", 190 | "\n", 191 | "\n", 192 | "# Check wether all the items are available in the GDP breakdown csv" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": null, 198 | "id": "00a59880", 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [ 202 | "\n", 203 | "# organize and plot your results for the expenditure approach\n" 204 | ] 205 | }, 206 | { 207 | "cell_type": "markdown", 208 | "id": "c954b3de", 209 | "metadata": {}, 210 | "source": [ 211 | "#### Production approach\n", 212 | "\n", 213 | "Isolate all data for the production approach:\n", 214 | "- total_gross_value_added = \"B1G\"\n", 215 | "- taxes_on_products = \"D21\"\n", 216 | "- subsidies = \"D31\"\n" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": null, 222 | "id": "2d8c9bae", 223 | "metadata": {}, 224 | "outputs": [], 225 | "source": [ 226 | "# select national account codes to be isolated in the data \n", 227 | "\n", 228 | "\n", 229 | "# Check wether all the items are available in the GDP breakdown csv\n", 230 | "\n" 231 | ] 232 | }, 233 | { 234 | "cell_type": "code", 235 | "execution_count": null, 236 | "id": "20d14d57", 237 | "metadata": {}, 238 | "outputs": [], 239 | "source": [ 240 | "\n", 241 | "# organize and plot your results for the production approach\n", 242 | "\n", 243 | " " 244 | ] 245 | }, 246 | { 247 | "cell_type": "markdown", 248 | "id": "6b504c1d", 249 | "metadata": {}, 250 | "source": [ 251 | "#### Check your results\n", 252 | "You don't have to check every single entry, just select one country for each approach, \"NL\" is fine too " 253 | ] 254 | }, 255 | { 256 | "cell_type": "code", 257 | "execution_count": null, 258 | "id": "bce4aa27", 259 | "metadata": {}, 260 | "outputs": [], 261 | "source": [] 262 | }, 263 | { 264 | "attachments": {}, 265 | "cell_type": "markdown", 266 | "id": "2f0fdec0-964b-442a-9689-32403f186e87", 267 | "metadata": {}, 268 | "source": [ 269 | "## Exercise 2\n", 270 | "\n", 271 | "Using the CBS data calculate the total GDP total and its composition using the three approaches\n", 272 | "\n", 273 | "Methods can be found using the following link in the file \"2 Macroeconomic totals.xlsx\" \n", 274 | "\n", 275 | "https://www.cbs.nl/en-gb/custom/2022/27/national-accounts-2021-tables\n", 276 | "\n", 277 | "Tip: once you download the data have a good look at how it is structure, how the labels are organized.\n", 278 | "\n", 279 | "In order to better understand how GDP can be calculated in IOTs, use the EUROSTAT manual table 11.6 on page 305\n", 280 | "\n", 281 | "\n", 282 | "![image](./figures/IOT_basic_price.PNG)\n" 283 | ] 284 | }, 285 | { 286 | "cell_type": "code", 287 | "execution_count": null, 288 | "id": "f4158925-2d16-4901-a5f1-08c422e976aa", 289 | "metadata": {}, 290 | "outputs": [], 291 | "source": [ 292 | "# Load the IO data\n", 293 | "CBS_IO = None\n", 294 | "\n", 295 | "# Print the list of sheets that are available in the xlsx file so that you can investigate what options you have\n" 296 | ] 297 | }, 298 | { 299 | "cell_type": "markdown", 300 | "id": "38883649", 301 | "metadata": {}, 302 | "source": [ 303 | "#### Parse your data" 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "execution_count": null, 309 | "id": "9a38df65", 310 | "metadata": {}, 311 | "outputs": [], 312 | "source": [ 313 | "# Parse the sheet for 2021 in current prices\n", 314 | "IO_2021_cp = None\n", 315 | "# Fill nan values\n", 316 | "\n", 317 | "# Labels sometimes have leading and trailing white spaces which makes it difficult to then slice the dataframe\n", 318 | "\n", 319 | "# There could also be errors in labels, always check. It won't matter for this exercise but keep in mind for the future. \n", 320 | "# Examples of mistakes are typos, wrong translaction, encoding issues \n", 321 | "\n", 322 | "# Negative items\n", 323 | "# Makes sure that the items marked with a negative sign in their labels are indeed negative\n", 324 | "\n", 325 | "\n", 326 | "# Print the columns and index to understand how the data is structured\n" 327 | ] 328 | }, 329 | { 330 | "cell_type": "markdown", 331 | "id": "1bccece1", 332 | "metadata": {}, 333 | "source": [ 334 | "#### Perfom some checks\n", 335 | "Before we begin working with the data, we typically want to perform some data sanity checks. \n", 336 | "We will only perform one check in this exercise, keeping in mind, however, that in most cases one needs to perform quite thorough cleaning (e.g., check for NaNs, decimal separators). \n", 337 | "\n", 338 | "\n", 339 | "Check that the total inputs are equal to the total outputs" 340 | ] 341 | }, 342 | { 343 | "cell_type": "code", 344 | "execution_count": null, 345 | "id": "8a282134", 346 | "metadata": {}, 347 | "outputs": [], 348 | "source": [ 349 | "# Check inputs and outputs\n", 350 | "total_inputs = None\n", 351 | "total_outputs = None\n", 352 | "\n", 353 | "print(f\"Inputs and Outputs match: {total_inputs/total_outputs*100}%\")" 354 | ] 355 | }, 356 | { 357 | "cell_type": "markdown", 358 | "id": "d8a79623", 359 | "metadata": {}, 360 | "source": [ 361 | "#### Create a dictionary in which you will store your results to be later compared" 362 | ] 363 | }, 364 | { 365 | "cell_type": "code", 366 | "execution_count": null, 367 | "id": "1f5fc6ef", 368 | "metadata": {}, 369 | "outputs": [], 370 | "source": [ 371 | "IO_GDP_approaches_results = {\"income\": None, \"expenditure\": None}" 372 | ] 373 | }, 374 | { 375 | "cell_type": "code", 376 | "execution_count": null, 377 | "id": "7a386c66-b7a8-4be5-8c33-713c682ebb99", 378 | "metadata": {}, 379 | "outputs": [], 380 | "source": [ 381 | "# Income perspective\n", 382 | "\n", 383 | "income_items = None\n", 384 | "\n", 385 | "income_breakdown = IO_2021_cp.loc[income_items]\n", 386 | "\n", 387 | "# We need to drop the aggregate and totals so that we don't double count \n", 388 | "income_breakdown = None\n", 389 | "\n", 390 | "IO_GDP_approaches_results[\"income\"] = income_breakdown.values.sum()\n", 391 | "\n", 392 | "IO_GDP_approaches_results[\"income\"]" 393 | ] 394 | }, 395 | { 396 | "cell_type": "code", 397 | "execution_count": null, 398 | "id": "cac67f38", 399 | "metadata": {}, 400 | "outputs": [], 401 | "source": [ 402 | "# Expenditure perspective\n", 403 | "\n", 404 | "expenditure_items = None\n", 405 | "\n", 406 | "imports_items = None\n", 407 | "\n", 408 | "expenditure_breakdown = IO_2021_cp.loc[:, expenditure_items]\n", 409 | "\n", 410 | "# we eliminate the rows with aggregates and totals\n", 411 | "expenditure_breakdown = expenditure_breakdown.drop([\"Total of rows (1–81)\", \"Total intermediate consumption (82–90)\", \"Total\", \"Value added at basic prices (92–96)\"], axis=0)\n", 412 | "\n", 413 | "# We sum all imports to be substracted\n", 414 | "imports_Z = None\n", 415 | "imports_Y = None\n", 416 | "tot_imports = imports_Z + imports_Y\n", 417 | "\n", 418 | "# Subtract imports from expenditure\n", 419 | "IO_GDP_approaches_results[\"expenditure\"] = None\n", 420 | "IO_GDP_approaches_results[\"expenditure\"]\n" 421 | ] 422 | }, 423 | { 424 | "cell_type": "code", 425 | "execution_count": null, 426 | "id": "36be71bb", 427 | "metadata": {}, 428 | "outputs": [], 429 | "source": [ 430 | "# Calculate the production perspective use the Value added row\n", 431 | "# we use the value added row provided by the table as a reference to see whether our calculations are correct\n", 432 | "value_added = IO_2021_cp.loc[\"Value added at basic prices (92–96)\" , :\"Goods and services n.e.c.\"]\n", 433 | "VA_total = value_added.values.sum() + taxes_less_subsidies.values.sum()\n", 434 | "\n", 435 | "for l in IO_GDP_approaches_results:\n", 436 | " print(f\"{l} approach results: {IO_GDP_approaches_results[l]} results are off by {round((1-VA_total/IO_GDP_approaches_results[l])*100)}%\")\n" 437 | ] 438 | } 439 | ], 440 | "metadata": { 441 | "kernelspec": { 442 | "display_name": "Python 3", 443 | "language": "python", 444 | "name": "python3" 445 | }, 446 | "language_info": { 447 | "codemirror_mode": { 448 | "name": "ipython", 449 | "version": 3 450 | }, 451 | "file_extension": ".py", 452 | "mimetype": "text/x-python", 453 | "name": "python", 454 | "nbconvert_exporter": "python", 455 | "pygments_lexer": "ipython3", 456 | "version": "3.10.6" 457 | }, 458 | "vscode": { 459 | "interpreter": { 460 | "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" 461 | } 462 | } 463 | }, 464 | "nbformat": 4, 465 | "nbformat_minor": 5 466 | } 467 | -------------------------------------------------------------------------------- /IOT_n_national_accounts/Lecture_1_GDP_sv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "93ed8f12-cfff-4c86-8a77-0d0870a7be97", 6 | "metadata": { 7 | "slideshow": { 8 | "slide_type": "slide" 9 | } 10 | }, 11 | "source": [ 12 | "# Practical 1: GDP calculations\n", 13 | "\n", 14 | "Learning objectives:\n", 15 | "\n", 16 | "- Apply one of the methods to calculate national GDP using Eurostat data. \n", 17 | "- Know how to visualize GDP trend\n", 18 | "- Analyse results and their implications" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "8ed9b949", 24 | "metadata": { 25 | "slideshow": { 26 | "slide_type": "slide" 27 | } 28 | }, 29 | "source": [ 30 | "![GDP vs Nature](https://cdn.unenvironment.org/2022-02/shutterstock_1879675894.jpeg)" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "id": "1aaeffd1-b07a-41d1-8c07-f5e346518176", 36 | "metadata": { 37 | "slideshow": { 38 | "slide_type": "slide" 39 | } 40 | }, 41 | "source": [ 42 | "## Exercise 1\n", 43 | "Using EUROSTAT data plot a graph showing the GDP trend of the Netherlands using the income approach" 44 | ] 45 | }, 46 | { 47 | "cell_type": "markdown", 48 | "id": "8ee1b689-c727-4b94-9c06-8212dc47c246", 49 | "metadata": { 50 | "slideshow": { 51 | "slide_type": "slide" 52 | } 53 | }, 54 | "source": [ 55 | "Data source 1: eurostat, national accounts, main GDP aggregates https://ec.europa.eu/eurostat/web/national-accounts/database" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": null, 61 | "id": "89a776a4-3fd8-46c1-9940-53765b5dcbad", 62 | "metadata": { 63 | "slideshow": { 64 | "slide_type": "slide" 65 | } 66 | }, 67 | "outputs": [], 68 | "source": [ 69 | "# import modules\n", 70 | "import pandas as pd\n", 71 | "import matplotlib.pyplot as plt" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": null, 77 | "id": "66b015a1", 78 | "metadata": { 79 | "slideshow": { 80 | "slide_type": "slide" 81 | } 82 | }, 83 | "outputs": [], 84 | "source": [ 85 | "# Import data\n", 86 | "GDP_data = None" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": null, 92 | "id": "054f85e4", 93 | "metadata": { 94 | "slideshow": { 95 | "slide_type": "slide" 96 | } 97 | }, 98 | "outputs": [], 99 | "source": [ 100 | "# We are only interested in data in euros so make sure you slice the right currency\n", 101 | "GDP_data = None" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": null, 107 | "id": "c4142ec8", 108 | "metadata": { 109 | "scrolled": false, 110 | "slideshow": { 111 | "slide_type": "fragment" 112 | } 113 | }, 114 | "outputs": [], 115 | "source": [ 116 | "# print the head of the dataframe to understand its structure\n" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": null, 122 | "id": "de4aa089-5c9d-4f22-92c8-90d1f73e45bf", 123 | "metadata": { 124 | "slideshow": { 125 | "slide_type": "slide" 126 | } 127 | }, 128 | "outputs": [], 129 | "source": [ 130 | "# Print all unique values in the National Account Item column (na_item) to use as a reference\n" 131 | ] 132 | }, 133 | { 134 | "cell_type": "markdown", 135 | "id": "e0d6d14b-0df0-43a8-85ed-3757dafa5cc7", 136 | "metadata": { 137 | "slideshow": { 138 | "slide_type": "slide" 139 | } 140 | }, 141 | "source": [ 142 | "you can check the statistical terms glossary for full definitions\n", 143 | "\n", 144 | "https://data.un.org/Glossary.aspx" 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "id": "ce69e04f", 150 | "metadata": { 151 | "slideshow": { 152 | "slide_type": "fragment" 153 | } 154 | }, 155 | "source": [ 156 | "And the metadata accompanying the data to help you identify the codes relevant to your analysis https://ec.europa.eu/eurostat/cache/metadata/en/nama10_esms.htm" 157 | ] 158 | }, 159 | { 160 | "cell_type": "markdown", 161 | "id": "d43256af", 162 | "metadata": { 163 | "slideshow": { 164 | "slide_type": "slide" 165 | } 166 | }, 167 | "source": [ 168 | "## Income approach\n", 169 | "\n", 170 | "Isolate all data for the income approach:\n", 171 | "* Comp_employees = \"D1\"\n", 172 | "* Gross operating surplus and mixed income = \"B2A3G\" \n", 173 | "* Taxes less subsidies on production and imports = \"D2X3\"" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": null, 179 | "id": "342a2a9e", 180 | "metadata": { 181 | "slideshow": { 182 | "slide_type": "slide" 183 | } 184 | }, 185 | "outputs": [], 186 | "source": [ 187 | "# select national account codes to be isolated in the data \n", 188 | "breakdown_income = []" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": null, 194 | "id": "67139a91", 195 | "metadata": { 196 | "slideshow": { 197 | "slide_type": "fragment" 198 | } 199 | }, 200 | "outputs": [], 201 | "source": [ 202 | "# Isolate the items you want to analyse\n", 203 | "GDP_breakdown = None\n", 204 | "GDP_breakdown.head()" 205 | ] 206 | }, 207 | { 208 | "cell_type": "code", 209 | "execution_count": null, 210 | "id": "adcdf780", 211 | "metadata": { 212 | "slideshow": { 213 | "slide_type": "slide" 214 | } 215 | }, 216 | "outputs": [], 217 | "source": [ 218 | "# Isolate the country you want to analyse\n", 219 | "\n", 220 | "country = None\n", 221 | "country_data = None\n", 222 | "country_data.head()" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": null, 228 | "id": "7cf74bd9", 229 | "metadata": { 230 | "slideshow": { 231 | "slide_type": "slide" 232 | } 233 | }, 234 | "outputs": [], 235 | "source": [ 236 | "# Collect your yearly data\n", 237 | "yearly_GDP = None" 238 | ] 239 | }, 240 | { 241 | "cell_type": "markdown", 242 | "id": "76f93af2", 243 | "metadata": { 244 | "slideshow": { 245 | "slide_type": "slide" 246 | } 247 | }, 248 | "source": [ 249 | "# Plot your results!" 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": null, 255 | "id": "17c90749", 256 | "metadata": { 257 | "slideshow": { 258 | "slide_type": "fragment" 259 | } 260 | }, 261 | "outputs": [], 262 | "source": [ 263 | "plt.figure(figsize=(8,4))\n", 264 | "plt.xlabel(\"Years\")\n", 265 | "plt.ylabel(\"Billion €\")\n", 266 | "GDP_plot = plt.plot(yearly_GDP.keys(), yearly_GDP.values(), label=country)" 267 | ] 268 | }, 269 | { 270 | "cell_type": "markdown", 271 | "id": "8cb14ebd", 272 | "metadata": { 273 | "slideshow": { 274 | "slide_type": "slide" 275 | } 276 | }, 277 | "source": [ 278 | "### Exercise 2 - In groups of 3\n", 279 | "\n", 280 | "Try to answer the following question\n", 281 | "* What do the changes the line graph tell us?\n", 282 | "* What can we hypothesise on the natural resources use and environmental emissions of those years?\n", 283 | "* Do other countries show a different trend than the Netherlands?\n", 284 | "* What can you tell about the historical natural resources use and emissions of one of those countries? " 285 | ] 286 | } 287 | ], 288 | "metadata": { 289 | "celltoolbar": "Slideshow", 290 | "kernelspec": { 291 | "display_name": "Python 3 (ipykernel)", 292 | "language": "python", 293 | "name": "python3" 294 | }, 295 | "language_info": { 296 | "codemirror_mode": { 297 | "name": "ipython", 298 | "version": 3 299 | }, 300 | "file_extension": ".py", 301 | "mimetype": "text/x-python", 302 | "name": "python", 303 | "nbconvert_exporter": "python", 304 | "pygments_lexer": "ipython3", 305 | "version": "3.11.9" 306 | }, 307 | "vscode": { 308 | "interpreter": { 309 | "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" 310 | } 311 | } 312 | }, 313 | "nbformat": 4, 314 | "nbformat_minor": 5 315 | } 316 | -------------------------------------------------------------------------------- /IOT_n_national_accounts/figures/IOT_basic_price.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/IOT_n_national_accounts/figures/IOT_basic_price.PNG -------------------------------------------------------------------------------- /MRIO_seminal_works/MRIO_seminal_works_sv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Practical 6: MRIO seminal works\n", 8 | "\n", 9 | "#### Objectives\n", 10 | "- Learn how to replicate the methods and results from a few studies. \n", 11 | "- Understand and explain main results from EEIOA studies using MRIO seminal works" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "### Exercise 1\n", 19 | "Hertwich and Peters (2009) developed an analysis of the carbon footprint of multiple countries in 2001. Their results show the carbon footprint of different final demand categories per product.\n", 20 | "\n", 21 | "In this exercise you will reproduce these results using EXIOBASE product by product Input-Output tables and compare any changes between 2001 and 2011\n", 22 | "\n", 23 | "N.b. in this and future exercises we sometimes refer to general dataframes as df" 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "\n", 31 | "\n", 32 | "Figure 1. Global CO2 footprint for different consumption categories and users retrieved from Hertwich and Peters (2009)" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "##### Steps in this exercise:\n", 40 | "- Import data\n", 41 | "- Calculate Leontief inverse and environmental intesity matrix\n", 42 | "- Final demand contribution to environmental footprint" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": null, 48 | "metadata": { 49 | "tags": [] 50 | }, 51 | "outputs": [], 52 | "source": [ 53 | "# Import modules\n", 54 | "import pandas as pd \n", 55 | "import numpy as np" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": null, 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [ 64 | "# Import exiobase" 65 | ] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "metadata": {}, 70 | "source": [ 71 | "### Import modules and data" 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "### Calculate the Leontief inverse" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": null, 84 | "metadata": {}, 85 | "outputs": [], 86 | "source": [ 87 | "# An identy matrix of the size as A-matrix\n", 88 | "\n", 89 | "## Leontief inverse matrix" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": null, 95 | "metadata": {}, 96 | "outputs": [], 97 | "source": [ 98 | "## Calculate total output vector (x)\n", 99 | "\n", 100 | "# Sum of all final demand categories\n", 101 | "\n", 102 | "# Total outputs" 103 | ] 104 | }, 105 | { 106 | "cell_type": "markdown", 107 | "metadata": {}, 108 | "source": [ 109 | "### Calculate environmental intensity matrix\n", 110 | "From satellite matrix (F), select row for CO2 (i.e., F_co2). This can be done using df.loc" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": null, 116 | "metadata": {}, 117 | "outputs": [], 118 | "source": [ 119 | "indicator = None\n", 120 | "# select CO2 vector\n", 121 | "F_ = None " 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": null, 127 | "metadata": {}, 128 | "outputs": [], 129 | "source": [ 130 | "# make a copy of the product output vector\n", 131 | "\n", 132 | "# divide 1 by the values that are non-0\n" 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": null, 138 | "metadata": {}, 139 | "outputs": [], 140 | "source": [ 141 | "# Calculate the intensity" 142 | ] 143 | }, 144 | { 145 | "cell_type": "markdown", 146 | "metadata": {}, 147 | "source": [ 148 | "As mentioned in the previous lecture the other option you have is to divide the extension vector by the total product output and then replace inf and nan values by 0's." 149 | ] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "execution_count": null, 154 | "metadata": {}, 155 | "outputs": [], 156 | "source": [ 157 | "f_ = F_/x.transpose() # co2 intensity vector\n", 158 | "f_ = f_.replace([np.inf, -np.inf, np.nan], 0) # replacing inf, -inf, and nan with zeros" 159 | ] 160 | }, 161 | { 162 | "cell_type": "markdown", 163 | "metadata": {}, 164 | "source": [ 165 | "### Contribution of Final Demand to the CO2 footprint\n", 166 | "From the final demand matrix (Y), calculate the global final demand of households (y_hh), government expenditures (y_gov) and gross capital formation (y_cap)." 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "## Calculation y_hh, y_gov, and y_cap\n", 176 | "\n", 177 | "# Select final demand categories\n", 178 | "\n", 179 | "\n", 180 | "# selecting hh columns for all countries/regions\n", 181 | "\n", 182 | "# global final expenditure by household \n", 183 | "\n", 184 | "# global final expenditure by government\n", 185 | "\n", 186 | "# global capital formation " 187 | ] 188 | }, 189 | { 190 | "cell_type": "markdown", 191 | "metadata": {}, 192 | "source": [ 193 | "In the previous lectures you have used the method df.loc[pd.IndexSlice[level_0, level_1], :] to slice dataframes with multi-index labels\n", 194 | "\n", 195 | "If you find it more practical you can also use the df.xs(label, axis, level, drop_level) method instead\n", 196 | "\n", 197 | "- the first argument is the label you want to select\n", 198 | "- the second argument axis is the axis (rows=0 or columns=1)\n", 199 | "- the third agument is the level (e.g., level=0 is the region)\n", 200 | "- the forth argument drop_level allows you to specify whether you want to keep the level of the multiindex you sliced or not" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": null, 206 | "metadata": {}, 207 | "outputs": [], 208 | "source": [] 209 | }, 210 | { 211 | "cell_type": "markdown", 212 | "metadata": {}, 213 | "source": [ 214 | "### Calculation CO2 footprint per final demand category per product" 215 | ] 216 | }, 217 | { 218 | "cell_type": "code", 219 | "execution_count": null, 220 | "metadata": {}, 221 | "outputs": [], 222 | "source": [ 223 | "# CO2 footprint by household expenditures\n", 224 | "\n", 225 | "# CO2 footprint by goverment expenditures \n", 226 | "\n", 227 | "# CO2 footprint by capital formation " 228 | ] 229 | }, 230 | { 231 | "cell_type": "code", 232 | "execution_count": 5, 233 | "metadata": {}, 234 | "outputs": [], 235 | "source": [ 236 | "# Check the shape of the resulting vectors" 237 | ] 238 | }, 239 | { 240 | "cell_type": "markdown", 241 | "metadata": {}, 242 | "source": [ 243 | "At this point, it should be 3 vectors (for each final demand category from point 2) of 1 row with 9800 columns (i.e., 49 regions x 200 products)\n", 244 | "\n", 245 | "Now reshape each vector using np.reshape so that you have 3 matrices with 49 rows (for each country/region) and 200 columns (for each product)" 246 | ] 247 | }, 248 | { 249 | "cell_type": "code", 250 | "execution_count": null, 251 | "metadata": {}, 252 | "outputs": [], 253 | "source": [ 254 | "## Reshape vectors\n", 255 | "\n", 256 | "# reshape to 49 countries/regions and 200 products\n", 257 | "\n", 258 | "# sum per product category\n", 259 | "\n", 260 | "\n", 261 | "# reshape to 49 countries/regions and 200 products\n", 262 | "\n", 263 | "# sum per product category\n", 264 | "\n", 265 | "\n", 266 | "# reshape to 49 countries/regions and 200 products\n", 267 | "\n", 268 | "# sum per product category" 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": null, 274 | "metadata": {}, 275 | "outputs": [], 276 | "source": [ 277 | "## Build new pandas dataframe by concatenating the 3 vectors together" 278 | ] 279 | }, 280 | { 281 | "cell_type": "markdown", 282 | "metadata": {}, 283 | "source": [ 284 | "### Separate results by sectors\n", 285 | "\n", 286 | "- Extraction\n", 287 | "- Manufacturing\n", 288 | "- Construction\n", 289 | "- Services" 290 | ] 291 | }, 292 | { 293 | "cell_type": "code", 294 | "execution_count": null, 295 | "metadata": {}, 296 | "outputs": [], 297 | "source": [ 298 | "### Index product categories\n", 299 | "\n", 300 | "# extraction categories (including agriculture, and mining)\n", 301 | "\n", 302 | "# manufacturing (including food, clothing, other products)\n", 303 | "\n", 304 | "# construction categories\n", 305 | "\n", 306 | "# services categories" 307 | ] 308 | }, 309 | { 310 | "cell_type": "code", 311 | "execution_count": null, 312 | "metadata": {}, 313 | "outputs": [], 314 | "source": [ 315 | "## Sum per product group" 316 | ] 317 | }, 318 | { 319 | "cell_type": "code", 320 | "execution_count": null, 321 | "metadata": {}, 322 | "outputs": [], 323 | "source": [ 324 | "## Re-group dataframe and add labels\n", 325 | "\n", 326 | "results = None\n", 327 | "results.index = ['Households', 'Goverment', 'Investment']\n", 328 | "results.columns = ['Agriculture and Mining', 'Manufacturing', 'Construction', 'Services']" 329 | ] 330 | }, 331 | { 332 | "cell_type": "markdown", 333 | "metadata": {}, 334 | "source": [ 335 | "### Visualize the results\n", 336 | "Create a bar graph showing the final contribution per product category to the CO2 footprint\n", 337 | "\n", 338 | "Note: This can be done by using:\n", 339 | "results.plot.barh(stacked=True)" 340 | ] 341 | }, 342 | { 343 | "cell_type": "code", 344 | "execution_count": null, 345 | "metadata": {}, 346 | "outputs": [], 347 | "source": [ 348 | "## Create a vertical bar chart" 349 | ] 350 | }, 351 | { 352 | "cell_type": "markdown", 353 | "metadata": {}, 354 | "source": [ 355 | "### Replicate these steps for 2011 data" 356 | ] 357 | }, 358 | { 359 | "cell_type": "markdown", 360 | "metadata": {}, 361 | "source": [ 362 | "## References\n", 363 | "Hertwich, E. G., & Peters, G. P. (2009). Carbon footprint of nations: A global, trade-linked analysis. Environmental Science and Technology, 43(16), 6414–6420. https://doi.org/10.1021/es803496a\n", 364 | "\n", 365 | "Wood, R., Stadler, K., Simas, M., Bulavskaya, T., Giljum, S., Lutter, S., & Tukker, A. (2018). Growth in Environmental Footprints and Environmental Impacts Embodied in Trade: Resource Efficiency Indicators from EXIOBASE3. Journal of Industrial Ecology, 22(3), 553–562. https://doi.org/10.1111/jiec.12735" 366 | ] 367 | } 368 | ], 369 | "metadata": { 370 | "kernelspec": { 371 | "display_name": "Python 3 (ipykernel)", 372 | "language": "python", 373 | "name": "python3" 374 | }, 375 | "language_info": { 376 | "codemirror_mode": { 377 | "name": "ipython", 378 | "version": 3 379 | }, 380 | "file_extension": ".py", 381 | "mimetype": "text/x-python", 382 | "name": "python", 383 | "nbconvert_exporter": "python", 384 | "pygments_lexer": "ipython3", 385 | "version": "3.9.16" 386 | }, 387 | "vscode": { 388 | "interpreter": { 389 | "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" 390 | } 391 | } 392 | }, 393 | "nbformat": 4, 394 | "nbformat_minor": 4 395 | } 396 | -------------------------------------------------------------------------------- /MRIO_seminal_works/figures/global_CO2_footprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/MRIO_seminal_works/figures/global_CO2_footprint.png -------------------------------------------------------------------------------- /MRIO_seminal_works/figures/growth_footprint_pc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/MRIO_seminal_works/figures/growth_footprint_pc.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Advanced EEIO course notebooks 2 | 3 | All exercises for the advanced course on EEIOA at Leiden University CML 4 | 5 | ## Learning goals of the course 6 | 7 | - G1. Develop a more in-depth understanding of the IO tables and EEIOA from the EEIOA basics introduced in MAPP. 8 | - G2. Articulate the advanced EEIOA techniques introduced in the course and their applications in sustainability research and decision-making. 9 | - G3. Model in Python, and analyze the economic and environmental effects of production and consumption and potential policies across supply chains. 10 | - G4. Develop and present a quantitative study using EEIOA, interpreting its main results and potential limitations. 11 | 12 | ### Exercises by Weekly program: 13 | 14 | - [1. IOT & National accounts](IOT_n_national_accounts) 15 | - [2. Supply and use tables](supply_n_use_tables) 16 | - [3. Supply chain linkages - Two IO models: Leontief v. Ghosh](supply_chain_linkages) 17 | - [4. Environmental footprints of nations](national_enviro_footprint) 18 | - [5. Introduction to EXIOBASE](intro_exiobase) 19 | - [6. MRIO seminal works](MRIO_seminal_works) 20 | - [7. Supplementary Session](supplementary_session) 21 | - [8. Mid-term exam](midterm) 22 | - [9. Waste IO](waste_IO) 23 | - [10. Physical and Hybrid IO tables](physical_n_hybrid_IO) 24 | - [11. Scenario_analysis](scenario_analysis) 25 | - [12. Technology-adjusted CBA](carbon_based_accounting) 26 | - [13. Structural decomposition analysis](structural_decomposition_analysis) 27 | 28 | ## Assessments 29 | 30 | Mid-term exam (50%; ≥5.5 to pass) 31 | 32 | - Mock exam & mid-term review 33 | - Retake (retake grade will be capped at 6.5) 34 | 35 | Integrated group assignment (50%; ≥5.5 to pass ) 36 | 37 | - 4 students/group (groups to be announced in mid April) 38 | - Consultation meeting, Q&As 39 | - Submission: script and presentation slides 40 | - Revise if <5.5 41 | -------------------------------------------------------------------------------- /carbon_based_accounting/carbon_based_accounting_sv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "slideshow": { 7 | "slide_type": "slide" 8 | } 9 | }, 10 | "source": [ 11 | "# Practical 7: Technology adjusted Carbon Based Accounting\n", 12 | "\n", 13 | "Objectives\n", 14 | "- Calculate TCBA\n", 15 | "- Calculate Scope 1, 2, 3 emissions\n", 16 | "- Visualize results\n", 17 | "\n", 18 | "**Technology adjusted consumption-based accounting**\n", 19 | "\n", 20 | "- In the [supplementary Information](https://static-content.springer.com/esm/art%3A10.1038%2Fnclimate2555/MediaObjects/41558_2015_BFnclimate2555_MOESM453_ESM.xlsx) file of [Kander et al. (2015), *National greenhouse-gas accounting for effective climate policy on international trade*](https://www.nature.com/articles/nclimate2555#Tab1), the authors illustrated the TCBA calculation and results in a spreadsheet.\n", 21 | "\n", 22 | "- Download and go through the spreadsheet example to further understand the TCBA calculations. \n" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "metadata": { 29 | "slideshow": { 30 | "slide_type": "slide" 31 | } 32 | }, 33 | "outputs": [], 34 | "source": [ 35 | "# Import packages\n", 36 | "import pandas as pd\n", 37 | "import numpy as np\n", 38 | "import matplotlib.pyplot as plt" 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": { 44 | "slideshow": { 45 | "slide_type": "slide" 46 | } 47 | }, 48 | "source": [ 49 | "## Exercise 1: Calculate and visualize CBA vs TCBA" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": { 55 | "slideshow": { 56 | "slide_type": "subslide" 57 | } 58 | }, 59 | "source": [ 60 | "### 1.1 Import the downloaded data" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "metadata": { 67 | "slideshow": { 68 | "slide_type": "fragment" 69 | } 70 | }, 71 | "outputs": [], 72 | "source": [ 73 | "# Import exiobase\n", 74 | "data_file = 'data/41558_2015_BFnclimate2555_MOESM453_ESM.xlsx' # add name of folder where data is stored\n", 75 | "\n", 76 | "Z = pd.read_excel(data_file, sheet_name='TCBA Example', header = 2, usecols='C:N', nrows=12).values\n", 77 | "\n", 78 | "Y = pd.read_excel(data_file, sheet_name='TCBA Example', header = 2, usecols='P:R', nrows=12).values\n", 79 | "\n", 80 | "V = pd.read_excel(data_file, sheet_name='TCBA Example', header = 15, usecols='C:N', nrows=3).sum(0).values\n", 81 | "\n", 82 | "F = pd.read_excel(\n", 83 | " data_file, sheet_name=\"TCBA Example\", header=21, usecols=\"C:N\", nrows=1\n", 84 | ").values[0]" 85 | ] 86 | }, 87 | { 88 | "cell_type": "markdown", 89 | "metadata": { 90 | "slideshow": { 91 | "slide_type": "subslide" 92 | } 93 | }, 94 | "source": [ 95 | "### 1.2 Calculate other IO variables" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "metadata": { 102 | "slideshow": { 103 | "slide_type": "fragment" 104 | } 105 | }, 106 | "outputs": [], 107 | "source": [ 108 | "x = Z.sum(1) + Y.sum(1)\n", 109 | "f = F/x\n", 110 | "A = Z/x\n", 111 | "I = np.identity(A.shape[0])\n", 112 | "L = np.linalg.inv(I - A)" 113 | ] 114 | }, 115 | { 116 | "cell_type": "markdown", 117 | "metadata": { 118 | "slideshow": { 119 | "slide_type": "subslide" 120 | } 121 | }, 122 | "source": [ 123 | "### 1.3 TCBA calculations" 124 | ] 125 | }, 126 | { 127 | "cell_type": "markdown", 128 | "metadata": { 129 | "slideshow": { 130 | "slide_type": "fragment" 131 | } 132 | }, 133 | "source": [ 134 | "#### 1.3.1 Export-related output" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": null, 140 | "metadata": { 141 | "slideshow": { 142 | "slide_type": "fragment" 143 | } 144 | }, 145 | "outputs": [], 146 | "source": [ 147 | "# output multiplier\n", 148 | "x_mult = L @ Y\n", 149 | "x_mult" 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": null, 155 | "metadata": { 156 | "slideshow": { 157 | "slide_type": "slide" 158 | } 159 | }, 160 | "outputs": [], 161 | "source": [ 162 | "# remove domestic trasactions (the diagonals)\n", 163 | "ex_mult = x_mult.copy()\n", 164 | "\n", 165 | "no_regions = 3 # number of regions\n", 166 | "no_sectors = 4 # number of sectors\n", 167 | "\n", 168 | "for i in range(no_regions):\n", 169 | " row_start = None\n", 170 | " row_end = None\n", 171 | "\n", 172 | " ex_mult[ row_start : row_end , i] = 0 \n", 173 | "\n", 174 | "ex_mult" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": null, 180 | "metadata": { 181 | "slideshow": { 182 | "slide_type": "subslide" 183 | } 184 | }, 185 | "outputs": [], 186 | "source": [ 187 | "# The total product output for only export \n", 188 | "ex = ex_mult.sum(1)\n", 189 | "ex" 190 | ] 191 | }, 192 | { 193 | "cell_type": "markdown", 194 | "metadata": { 195 | "slideshow": { 196 | "slide_type": "slide" 197 | } 198 | }, 199 | "source": [ 200 | "#### 1.3.2 Export-related emissions" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": null, 206 | "metadata": { 207 | "slideshow": { 208 | "slide_type": "fragment" 209 | } 210 | }, 211 | "outputs": [], 212 | "source": [ 213 | "# Export-related emissions (use np.diag(f)@ x_mult)\n", 214 | "F_ex = None\n", 215 | "F_ex" 216 | ] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "execution_count": null, 221 | "metadata": {}, 222 | "outputs": [], 223 | "source": [ 224 | "# Vector of export related emissions (direct emissions PBA sum=1)\n", 225 | "F_ex = None\n", 226 | "F_ex" 227 | ] 228 | }, 229 | { 230 | "cell_type": "markdown", 231 | "metadata": { 232 | "slideshow": { 233 | "slide_type": "slide" 234 | } 235 | }, 236 | "source": [ 237 | "#### 1.3.3 Calculate 'World market average emissions multiplier'" 238 | ] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "execution_count": null, 243 | "metadata": { 244 | "slideshow": { 245 | "slide_type": "fragment" 246 | } 247 | }, 248 | "outputs": [], 249 | "source": [ 250 | "# Split the ex and F into 3 arrays, one for each region (use np.split)\n", 251 | "sect_ex = None\n", 252 | "sect_F_ex = None\n", 253 | "sect_ex, sect_F_ex" 254 | ] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": null, 259 | "metadata": { 260 | "slideshow": { 261 | "slide_type": "subslide" 262 | } 263 | }, 264 | "outputs": [], 265 | "source": [ 266 | "# Sum them over axis 0, in this way you have the total global ex and F_ex by sector\n", 267 | "sect_ex_sum = None\n", 268 | "sect_F_ex_sum = None\n", 269 | "sect_ex_sum, sect_F_ex_sum" 270 | ] 271 | }, 272 | { 273 | "cell_type": "code", 274 | "execution_count": null, 275 | "metadata": { 276 | "slideshow": { 277 | "slide_type": "fragment" 278 | } 279 | }, 280 | "outputs": [], 281 | "source": [ 282 | "# calculate the average global environmental intensity by sector\n", 283 | "f_wa_sec = None\n", 284 | "f_wa_sec" 285 | ] 286 | }, 287 | { 288 | "cell_type": "code", 289 | "execution_count": null, 290 | "metadata": { 291 | "slideshow": { 292 | "slide_type": "fragment" 293 | } 294 | }, 295 | "outputs": [], 296 | "source": [ 297 | "# replicate it for each region\n", 298 | "f_wa = None\n", 299 | "f_wa" 300 | ] 301 | }, 302 | { 303 | "cell_type": "markdown", 304 | "metadata": { 305 | "slideshow": { 306 | "slide_type": "subslide" 307 | } 308 | }, 309 | "source": [ 310 | "#### 1.3.4 Export-related emissions by TCBA" 311 | ] 312 | }, 313 | { 314 | "cell_type": "code", 315 | "execution_count": null, 316 | "metadata": { 317 | "slideshow": { 318 | "slide_type": "fragment" 319 | } 320 | }, 321 | "outputs": [], 322 | "source": [ 323 | "# Export-related emissions by TCBA \n", 324 | "F_ex_TCBA = None\n", 325 | "F_ex_TCBA" 326 | ] 327 | }, 328 | { 329 | "cell_type": "markdown", 330 | "metadata": { 331 | "slideshow": { 332 | "slide_type": "subslide" 333 | } 334 | }, 335 | "source": [ 336 | "#### 1.3.5 Adjust export-related emissions (i.e. TCBA)" 337 | ] 338 | }, 339 | { 340 | "cell_type": "code", 341 | "execution_count": null, 342 | "metadata": { 343 | "slideshow": { 344 | "slide_type": "fragment" 345 | } 346 | }, 347 | "outputs": [], 348 | "source": [ 349 | "CBA = None # note F_hh is neglected in this example\n", 350 | "CBA" 351 | ] 352 | }, 353 | { 354 | "cell_type": "code", 355 | "execution_count": null, 356 | "metadata": { 357 | "slideshow": { 358 | "slide_type": "fragment" 359 | } 360 | }, 361 | "outputs": [], 362 | "source": [ 363 | "# calculate the different between the total emissions due to exports from the technolgy adjusted ones \n", 364 | "diff_ex = None\n", 365 | "diff_ex" 366 | ] 367 | }, 368 | { 369 | "cell_type": "code", 370 | "execution_count": null, 371 | "metadata": { 372 | "slideshow": { 373 | "slide_type": "subslide" 374 | } 375 | }, 376 | "outputs": [], 377 | "source": [ 378 | "# We aggregate this difference regionally\n", 379 | "diff_ex_r = None\n", 380 | "diff_ex_r" 381 | ] 382 | }, 383 | { 384 | "cell_type": "code", 385 | "execution_count": null, 386 | "metadata": { 387 | "slideshow": { 388 | "slide_type": "fragment" 389 | } 390 | }, 391 | "outputs": [], 392 | "source": [ 393 | "# Calculate the TCBA by summing the difference to the CBA\n", 394 | "TCBA = None\n", 395 | "TCBA" 396 | ] 397 | }, 398 | { 399 | "cell_type": "markdown", 400 | "metadata": { 401 | "slideshow": { 402 | "slide_type": "slide" 403 | } 404 | }, 405 | "source": [ 406 | "### 1.4 Visualize results" 407 | ] 408 | }, 409 | { 410 | "cell_type": "code", 411 | "execution_count": null, 412 | "metadata": { 413 | "slideshow": { 414 | "slide_type": "fragment" 415 | } 416 | }, 417 | "outputs": [], 418 | "source": [ 419 | "# Concatenate results to be visualized\n", 420 | "results = np.concatenate([[CBA], [TCBA]])\n", 421 | "results" 422 | ] 423 | }, 424 | { 425 | "cell_type": "code", 426 | "execution_count": null, 427 | "metadata": { 428 | "slideshow": { 429 | "slide_type": "subslide" 430 | } 431 | }, 432 | "outputs": [], 433 | "source": [ 434 | "# Plotting the figure\n", 435 | "fig = plt.figure()\n", 436 | "\n", 437 | "# settings and positioning of the bars\n", 438 | "X_axis_pos = np.arange(no_regions)\n", 439 | "plt.bar(X_axis_pos - 0.16, results[0], color = 'b', width = 0.3)\n", 440 | "plt.bar(X_axis_pos + 0.16, results[1], color = 'g', width = 0.3)\n", 441 | "\n", 442 | "#axis labels\n", 443 | "plt.ylabel('Consumption-based Emissions, kg/year')\n", 444 | "plt.xticks(X_axis_pos, ['R1', 'R2', 'R3'])\n", 445 | "\n", 446 | "# Title of the graph\n", 447 | "plt.title('CBA vs. TCBA')\n", 448 | "\n", 449 | "# Legend\n", 450 | "plt.legend(labels=['CBA', 'TCBA'])" 451 | ] 452 | }, 453 | { 454 | "cell_type": "markdown", 455 | "metadata": { 456 | "slideshow": { 457 | "slide_type": "slide" 458 | } 459 | }, 460 | "source": [ 461 | "## Exercise 2: Calculate emissions in the different scopes using exiobase" 462 | ] 463 | }, 464 | { 465 | "cell_type": "markdown", 466 | "metadata": { 467 | "slideshow": { 468 | "slide_type": "subslide" 469 | } 470 | }, 471 | "source": [ 472 | "### 2.1 Import exiobase and calculate all the IO variables" 473 | ] 474 | }, 475 | { 476 | "cell_type": "code", 477 | "execution_count": null, 478 | "metadata": { 479 | "slideshow": { 480 | "slide_type": "fragment" 481 | } 482 | }, 483 | "outputs": [], 484 | "source": [ 485 | "# Import exiobase\n", 486 | "path = 'data/IOT_2019_pxp/' # add name of folder where data is stored \n", 487 | "A = pd.read_csv(f'{path}A.txt', sep='\\t', index_col=[0, 1], header=[0, 1]) # A matrix\n", 488 | "Z = pd.read_csv(f'{path}Z.txt', sep='\\t', index_col=[0, 1], header=[0, 1]) # Z matrix\n", 489 | "Y = pd.read_csv(f'{path}Y.txt', sep='\\t', index_col=[0, 1], header=[0, 1]) # Y matrix\n", 490 | "F = pd.read_csv(f'{path}satellite/F.txt', sep='\\t', index_col=[0], header=[0, 1]) # satellite matrix\n", 491 | "F_hh = pd.read_csv(f'{path}satellite/F_Y.txt', sep='\\t', index_col=[0], header=[0, 1]) # satellite for FD matrix" 492 | ] 493 | }, 494 | { 495 | "cell_type": "code", 496 | "execution_count": null, 497 | "metadata": { 498 | "slideshow": { 499 | "slide_type": "subslide" 500 | } 501 | }, 502 | "outputs": [], 503 | "source": [ 504 | "\n", 505 | "# calculate the Leontief inverse\n", 506 | "I = np.identity(A.shape[0])\n", 507 | "L = np.linalg.inv(I - A)\n", 508 | "\n", 509 | "# Calculate total output vector (x)\n", 510 | "y_total = Y.sum(1)\n", 511 | "x = L @ y_total\n", 512 | "\n", 513 | "# No regions and no sector\n", 514 | "no_regions = 49\n", 515 | "no_sectors = 200" 516 | ] 517 | }, 518 | { 519 | "cell_type": "code", 520 | "execution_count": null, 521 | "metadata": { 522 | "slideshow": { 523 | "slide_type": "subslide" 524 | } 525 | }, 526 | "outputs": [], 527 | "source": [ 528 | "# Get the CO2 emissions by combustion (\"CO2 - combustion - air\")\n", 529 | "F_CO2 = F.loc[\"CO2 - combustion - air\"]" 530 | ] 531 | }, 532 | { 533 | "cell_type": "code", 534 | "execution_count": null, 535 | "metadata": { 536 | "slideshow": { 537 | "slide_type": "subslide" 538 | } 539 | }, 540 | "outputs": [], 541 | "source": [ 542 | "# we make a copy of our product output vector\n", 543 | "x_inv = x.copy() \n", 544 | "\n", 545 | "# we divide 1 by the values that are non-0\n", 546 | "x_inv[x_inv!=0] = 1/x_inv[x_inv!=0]" 547 | ] 548 | }, 549 | { 550 | "cell_type": "code", 551 | "execution_count": null, 552 | "metadata": { 553 | "slideshow": { 554 | "slide_type": "subslide" 555 | } 556 | }, 557 | "outputs": [], 558 | "source": [ 559 | "f_CO2 = F_CO2 * x_inv" 560 | ] 561 | }, 562 | { 563 | "cell_type": "markdown", 564 | "metadata": { 565 | "slideshow": { 566 | "slide_type": "subslide" 567 | } 568 | }, 569 | "source": [ 570 | "#### 2.2 Calculate CO2 multiplier from exiobase data" 571 | ] 572 | }, 573 | { 574 | "cell_type": "code", 575 | "execution_count": null, 576 | "metadata": { 577 | "slideshow": { 578 | "slide_type": "fragment" 579 | } 580 | }, 581 | "outputs": [], 582 | "source": [ 583 | "f_CO2_mult = None" 584 | ] 585 | }, 586 | { 587 | "cell_type": "markdown", 588 | "metadata": { 589 | "slideshow": { 590 | "slide_type": "subslide" 591 | } 592 | }, 593 | "source": [ 594 | "#### 2.3 Import IPCC concordancy matrix" 595 | ] 596 | }, 597 | { 598 | "cell_type": "code", 599 | "execution_count": null, 600 | "metadata": { 601 | "slideshow": { 602 | "slide_type": "fragment" 603 | } 604 | }, 605 | "outputs": [], 606 | "source": [ 607 | "ipcc_data = \"data/IPCCsec.xlsx\"\n", 608 | "\n", 609 | "# import the xio2detail data\n", 610 | "IPCCagg = pd.read_excel(ipcc_data, \"xio2detail\", header=0, index_col=0, usecols=\"A:H\")\n", 611 | "IPCCagg = IPCCagg.fillna(0) # Change NaN into 0.\n", 612 | "\n", 613 | "# This is what the concordancy looks like:\n", 614 | "IPCCagg.head()" 615 | ] 616 | }, 617 | { 618 | "cell_type": "code", 619 | "execution_count": null, 620 | "metadata": { 621 | "slideshow": { 622 | "slide_type": "subslide" 623 | } 624 | }, 625 | "outputs": [], 626 | "source": [ 627 | "# This is what the concordancy looks like:\n", 628 | "IPCCagg.head()" 629 | ] 630 | }, 631 | { 632 | "cell_type": "code", 633 | "execution_count": null, 634 | "metadata": { 635 | "slideshow": { 636 | "slide_type": "subslide" 637 | } 638 | }, 639 | "outputs": [], 640 | "source": [ 641 | "# This is its shape\n", 642 | "IPCCagg.shape" 643 | ] 644 | }, 645 | { 646 | "cell_type": "markdown", 647 | "metadata": { 648 | "slideshow": { 649 | "slide_type": "slide" 650 | } 651 | }, 652 | "source": [ 653 | "#### 2.4 Calculate scope 1 emissions" 654 | ] 655 | }, 656 | { 657 | "cell_type": "code", 658 | "execution_count": null, 659 | "metadata": { 660 | "slideshow": { 661 | "slide_type": "fragment" 662 | } 663 | }, 664 | "outputs": [], 665 | "source": [ 666 | "# use np.reshape to organize your array in a sector by region format (use np.reshape with order=\"F\")\n", 667 | "F_CO2 = None\n", 668 | "\n", 669 | "F_CO2.shape" 670 | ] 671 | }, 672 | { 673 | "cell_type": "code", 674 | "execution_count": null, 675 | "metadata": { 676 | "slideshow": { 677 | "slide_type": "subslide" 678 | } 679 | }, 680 | "outputs": [], 681 | "source": [ 682 | "# Aggregating sectors/products by the macro-categories using the concordancy matrix\n", 683 | "co2_scope1 = None\n", 684 | "\n", 685 | "# adding regional labels\n", 686 | "reg_labels = Y.index.to_frame(False).region.unique()\n", 687 | "co2_scope1.index = reg_labels\n", 688 | "\n", 689 | "# inspecting the data\n", 690 | "co2_scope1.head()" 691 | ] 692 | }, 693 | { 694 | "cell_type": "markdown", 695 | "metadata": { 696 | "slideshow": { 697 | "slide_type": "subslide" 698 | } 699 | }, 700 | "source": [ 701 | "#### 2.5 Calculate scope 2 emissions" 702 | ] 703 | }, 704 | { 705 | "cell_type": "code", 706 | "execution_count": null, 707 | "metadata": { 708 | "slideshow": { 709 | "slide_type": "fragment" 710 | } 711 | }, 712 | "outputs": [], 713 | "source": [ 714 | "first_el_pr_pos = 127 # first electricity product category\n", 715 | "last_el_pr_pos = 140 # last electricity product category\n", 716 | "\n", 717 | "elec = np.zeros(A.shape[0])\n", 718 | "\n", 719 | "for i in range(no_regions):\n", 720 | " start_pos = None\n", 721 | " end_pos = None\n", 722 | " elec[start_pos : end_pos] = 1" 723 | ] 724 | }, 725 | { 726 | "cell_type": "code", 727 | "execution_count": null, 728 | "metadata": { 729 | "slideshow": { 730 | "slide_type": "subslide" 731 | } 732 | }, 733 | "outputs": [], 734 | "source": [ 735 | "# Calculate the scope 2 emissions \n", 736 | "# by performing f×diag(electricity)×Z\n", 737 | "\n", 738 | "co2_scope2 = None\n", 739 | "\n", 740 | "# Reshape\n", 741 | "co2_scope2 = None\n", 742 | "\n", 743 | "# Aggregate sectors/products by the macro-categories using the concordancy matrix\n", 744 | "co2_scope2 = None\n", 745 | "\n", 746 | "# adding regional labels\n", 747 | "reg_labels = Y.index.to_frame(False).region.unique()\n", 748 | "co2_scope2.index = reg_labels\n", 749 | "\n", 750 | "# inspecting the data\n", 751 | "co2_scope2.head()" 752 | ] 753 | }, 754 | { 755 | "cell_type": "markdown", 756 | "metadata": { 757 | "slideshow": { 758 | "slide_type": "subslide" 759 | } 760 | }, 761 | "source": [ 762 | "#### 2.6 Calculate scope 3 emissions" 763 | ] 764 | }, 765 | { 766 | "cell_type": "code", 767 | "execution_count": null, 768 | "metadata": { 769 | "slideshow": { 770 | "slide_type": "fragment" 771 | } 772 | }, 773 | "outputs": [], 774 | "source": [ 775 | "# Calculate scope 2 emissions by peforming \n", 776 | "# f×L×Z - f×diag(Elec)×Z \n", 777 | "\n", 778 | "co2_scope3 = None\n", 779 | "\n", 780 | "# Reshape\n", 781 | "co2_scope3 = None\n", 782 | "\n", 783 | "# Aggregate sectors/products by the macro-categories using the concordancy matrix\n", 784 | "co2_scope3 = None\n", 785 | "\n", 786 | "# adding regional labels\n", 787 | "reg_labels = Y.index.to_frame(False).region.unique()\n", 788 | "co2_scope3.index = reg_labels\n", 789 | "\n", 790 | "# inspecting the data\n", 791 | "co2_scope3.head()" 792 | ] 793 | }, 794 | { 795 | "cell_type": "markdown", 796 | "metadata": { 797 | "slideshow": { 798 | "slide_type": "subslide" 799 | } 800 | }, 801 | "source": [ 802 | "#### 2.7 Make a stacked bar plot of the results for a region" 803 | ] 804 | }, 805 | { 806 | "cell_type": "code", 807 | "execution_count": null, 808 | "metadata": { 809 | "slideshow": { 810 | "slide_type": "fragment" 811 | } 812 | }, 813 | "outputs": [], 814 | "source": [ 815 | "region = \"NL\"\n", 816 | "\n", 817 | "results_dashboard = pd.DataFrame(\n", 818 | " data=[co2_scope1.loc[region], co2_scope2.loc[region], co2_scope3.loc[region]],\n", 819 | " columns=IPCCagg.columns,\n", 820 | " index=[\"1\", \"2\", \"3\"],\n", 821 | ")\n", 822 | "results_dashboard.T.plot(kind=\"bar\", stacked=True, ylabel=\"Pg CO2 eq\", title=f\"Scopes 2019 - region {region}\")" 823 | ] 824 | } 825 | ], 826 | "metadata": { 827 | "celltoolbar": "Slideshow", 828 | "kernelspec": { 829 | "display_name": "Python 3 (ipykernel)", 830 | "language": "python", 831 | "name": "python3" 832 | }, 833 | "language_info": { 834 | "codemirror_mode": { 835 | "name": "ipython", 836 | "version": 3 837 | }, 838 | "file_extension": ".py", 839 | "mimetype": "text/x-python", 840 | "name": "python", 841 | "nbconvert_exporter": "python", 842 | "pygments_lexer": "ipython3", 843 | "version": "3.9.16" 844 | } 845 | }, 846 | "nbformat": 4, 847 | "nbformat_minor": 2 848 | } 849 | -------------------------------------------------------------------------------- /carbon_based_accounting/data/41558_2015_BFnclimate2555_MOESM453_ESM.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/carbon_based_accounting/data/41558_2015_BFnclimate2555_MOESM453_ESM.xlsx -------------------------------------------------------------------------------- /carbon_based_accounting/data/IPCCsec.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/carbon_based_accounting/data/IPCCsec.xlsx -------------------------------------------------------------------------------- /intro_exiobase/data/regions.csv: -------------------------------------------------------------------------------- 1 | region,country_code,country_name,CountryGroup 2 | EU,AT,Austria,Europe 3 | EU,AT,Austria,Europe 4 | EU,AT,Austria,Europe 5 | EU,AT,Austria,Europe 6 | EU,AT,Austria,Europe 7 | EU,AT,Austria,Europe 8 | EU,AT,Austria,Europe 9 | EU,BE,Belgium,Europe 10 | EU,BE,Belgium,Europe 11 | EU,BE,Belgium,Europe 12 | EU,BE,Belgium,Europe 13 | EU,BE,Belgium,Europe 14 | EU,BE,Belgium,Europe 15 | EU,BE,Belgium,Europe 16 | EU,BG,Bulgaria,Europe 17 | EU,BG,Bulgaria,Europe 18 | EU,BG,Bulgaria,Europe 19 | EU,BG,Bulgaria,Europe 20 | EU,BG,Bulgaria,Europe 21 | EU,BG,Bulgaria,Europe 22 | EU,BG,Bulgaria,Europe 23 | ROW,CY,Cyprus,Middle East 24 | ROW,CY,Cyprus,Middle East 25 | ROW,CY,Cyprus,Middle East 26 | ROW,CY,Cyprus,Middle East 27 | ROW,CY,Cyprus,Middle East 28 | ROW,CY,Cyprus,Middle East 29 | ROW,CY,Cyprus,Middle East 30 | EU,CZ,Czech Republic,Europe 31 | EU,CZ,Czech Republic,Europe 32 | EU,CZ,Czech Republic,Europe 33 | EU,CZ,Czech Republic,Europe 34 | EU,CZ,Czech Republic,Europe 35 | EU,CZ,Czech Republic,Europe 36 | EU,CZ,Czech Republic,Europe 37 | EU,DE,Germany,Europe 38 | EU,DE,Germany,Europe 39 | EU,DE,Germany,Europe 40 | EU,DE,Germany,Europe 41 | EU,DE,Germany,Europe 42 | EU,DE,Germany,Europe 43 | EU,DE,Germany,Europe 44 | EU,DK,Denmark,Europe 45 | EU,DK,Denmark,Europe 46 | EU,DK,Denmark,Europe 47 | EU,DK,Denmark,Europe 48 | EU,DK,Denmark,Europe 49 | EU,DK,Denmark,Europe 50 | EU,DK,Denmark,Europe 51 | EU,EE,Estonia,Europe 52 | EU,EE,Estonia,Europe 53 | EU,EE,Estonia,Europe 54 | EU,EE,Estonia,Europe 55 | EU,EE,Estonia,Europe 56 | EU,EE,Estonia,Europe 57 | EU,EE,Estonia,Europe 58 | EU,ES,Spain,Europe 59 | EU,ES,Spain,Europe 60 | EU,ES,Spain,Europe 61 | EU,ES,Spain,Europe 62 | EU,ES,Spain,Europe 63 | EU,ES,Spain,Europe 64 | EU,ES,Spain,Europe 65 | EU,FI,Finland,Europe 66 | EU,FI,Finland,Europe 67 | EU,FI,Finland,Europe 68 | EU,FI,Finland,Europe 69 | EU,FI,Finland,Europe 70 | EU,FI,Finland,Europe 71 | EU,FI,Finland,Europe 72 | EU,FR,France,Europe 73 | EU,FR,France,Europe 74 | EU,FR,France,Europe 75 | EU,FR,France,Europe 76 | EU,FR,France,Europe 77 | EU,FR,France,Europe 78 | EU,FR,France,Europe 79 | EU,GR,Greece,Europe 80 | EU,GR,Greece,Europe 81 | EU,GR,Greece,Europe 82 | EU,GR,Greece,Europe 83 | EU,GR,Greece,Europe 84 | EU,GR,Greece,Europe 85 | EU,GR,Greece,Europe 86 | EU,HR,Croatia,Europe 87 | EU,HR,Croatia,Europe 88 | EU,HR,Croatia,Europe 89 | EU,HR,Croatia,Europe 90 | EU,HR,Croatia,Europe 91 | EU,HR,Croatia,Europe 92 | EU,HR,Croatia,Europe 93 | EU,HU,Hungary,Europe 94 | EU,HU,Hungary,Europe 95 | EU,HU,Hungary,Europe 96 | EU,HU,Hungary,Europe 97 | EU,HU,Hungary,Europe 98 | EU,HU,Hungary,Europe 99 | EU,HU,Hungary,Europe 100 | EU,IE,Ireland,Europe 101 | EU,IE,Ireland,Europe 102 | EU,IE,Ireland,Europe 103 | EU,IE,Ireland,Europe 104 | EU,IE,Ireland,Europe 105 | EU,IE,Ireland,Europe 106 | EU,IE,Ireland,Europe 107 | EU,IT,Italy,Europe 108 | EU,IT,Italy,Europe 109 | EU,IT,Italy,Europe 110 | EU,IT,Italy,Europe 111 | EU,IT,Italy,Europe 112 | EU,IT,Italy,Europe 113 | EU,IT,Italy,Europe 114 | EU,LT,Lithuania,Europe 115 | EU,LT,Lithuania,Europe 116 | EU,LT,Lithuania,Europe 117 | EU,LT,Lithuania,Europe 118 | EU,LT,Lithuania,Europe 119 | EU,LT,Lithuania,Europe 120 | EU,LT,Lithuania,Europe 121 | EU,LU,Luxembourg,Europe 122 | EU,LU,Luxembourg,Europe 123 | EU,LU,Luxembourg,Europe 124 | EU,LU,Luxembourg,Europe 125 | EU,LU,Luxembourg,Europe 126 | EU,LU,Luxembourg,Europe 127 | EU,LU,Luxembourg,Europe 128 | EU,LV,Latvia,Europe 129 | EU,LV,Latvia,Europe 130 | EU,LV,Latvia,Europe 131 | EU,LV,Latvia,Europe 132 | EU,LV,Latvia,Europe 133 | EU,LV,Latvia,Europe 134 | EU,LV,Latvia,Europe 135 | EU,MT,Malta,Europe 136 | EU,MT,Malta,Europe 137 | EU,MT,Malta,Europe 138 | EU,MT,Malta,Europe 139 | EU,MT,Malta,Europe 140 | EU,MT,Malta,Europe 141 | EU,MT,Malta,Europe 142 | EU,NL,Netherlands,Europe 143 | EU,NL,Netherlands,Europe 144 | EU,NL,Netherlands,Europe 145 | EU,NL,Netherlands,Europe 146 | EU,NL,Netherlands,Europe 147 | EU,NL,Netherlands,Europe 148 | EU,NL,Netherlands,Europe 149 | EU,PL,Poland,Europe 150 | EU,PL,Poland,Europe 151 | EU,PL,Poland,Europe 152 | EU,PL,Poland,Europe 153 | EU,PL,Poland,Europe 154 | EU,PL,Poland,Europe 155 | EU,PL,Poland,Europe 156 | EU,PT,Portugal,Europe 157 | EU,PT,Portugal,Europe 158 | EU,PT,Portugal,Europe 159 | EU,PT,Portugal,Europe 160 | EU,PT,Portugal,Europe 161 | EU,PT,Portugal,Europe 162 | EU,PT,Portugal,Europe 163 | EU,RO,Romania,Europe 164 | EU,RO,Romania,Europe 165 | EU,RO,Romania,Europe 166 | EU,RO,Romania,Europe 167 | EU,RO,Romania,Europe 168 | EU,RO,Romania,Europe 169 | EU,RO,Romania,Europe 170 | EU,SE,Sweden,Europe 171 | EU,SE,Sweden,Europe 172 | EU,SE,Sweden,Europe 173 | EU,SE,Sweden,Europe 174 | EU,SE,Sweden,Europe 175 | EU,SE,Sweden,Europe 176 | EU,SE,Sweden,Europe 177 | EU,SI,Slovenia,Europe 178 | EU,SI,Slovenia,Europe 179 | EU,SI,Slovenia,Europe 180 | EU,SI,Slovenia,Europe 181 | EU,SI,Slovenia,Europe 182 | EU,SI,Slovenia,Europe 183 | EU,SI,Slovenia,Europe 184 | EU,SK,Slovakia,Europe 185 | EU,SK,Slovakia,Europe 186 | EU,SK,Slovakia,Europe 187 | EU,SK,Slovakia,Europe 188 | EU,SK,Slovakia,Europe 189 | EU,SK,Slovakia,Europe 190 | EU,SK,Slovakia,Europe 191 | EU,GB,United Kingdom,Europe 192 | EU,GB,United Kingdom,Europe 193 | EU,GB,United Kingdom,Europe 194 | EU,GB,United Kingdom,Europe 195 | EU,GB,United Kingdom,Europe 196 | EU,GB,United Kingdom,Europe 197 | EU,GB,United Kingdom,Europe 198 | ROW,US,United States,America 199 | ROW,US,United States,America 200 | ROW,US,United States,America 201 | ROW,US,United States,America 202 | ROW,US,United States,America 203 | ROW,US,United States,America 204 | ROW,US,United States,America 205 | ROW,JP,Japan,Asia and Pacific 206 | ROW,JP,Japan,Asia and Pacific 207 | ROW,JP,Japan,Asia and Pacific 208 | ROW,JP,Japan,Asia and Pacific 209 | ROW,JP,Japan,Asia and Pacific 210 | ROW,JP,Japan,Asia and Pacific 211 | ROW,JP,Japan,Asia and Pacific 212 | ROW,CN,China,Asia and Pacific 213 | ROW,CN,China,Asia and Pacific 214 | ROW,CN,China,Asia and Pacific 215 | ROW,CN,China,Asia and Pacific 216 | ROW,CN,China,Asia and Pacific 217 | ROW,CN,China,Asia and Pacific 218 | ROW,CN,China,Asia and Pacific 219 | ROW,CA,Canada,America 220 | ROW,CA,Canada,America 221 | ROW,CA,Canada,America 222 | ROW,CA,Canada,America 223 | ROW,CA,Canada,America 224 | ROW,CA,Canada,America 225 | ROW,CA,Canada,America 226 | ROW,KR,South Korea,Asia and Pacific 227 | ROW,KR,South Korea,Asia and Pacific 228 | ROW,KR,South Korea,Asia and Pacific 229 | ROW,KR,South Korea,Asia and Pacific 230 | ROW,KR,South Korea,Asia and Pacific 231 | ROW,KR,South Korea,Asia and Pacific 232 | ROW,KR,South Korea,Asia and Pacific 233 | ROW,BR,Brazil,America 234 | ROW,BR,Brazil,America 235 | ROW,BR,Brazil,America 236 | ROW,BR,Brazil,America 237 | ROW,BR,Brazil,America 238 | ROW,BR,Brazil,America 239 | ROW,BR,Brazil,America 240 | ROW,IN,India,Asia and Pacific 241 | ROW,IN,India,Asia and Pacific 242 | ROW,IN,India,Asia and Pacific 243 | ROW,IN,India,Asia and Pacific 244 | ROW,IN,India,Asia and Pacific 245 | ROW,IN,India,Asia and Pacific 246 | ROW,IN,India,Asia and Pacific 247 | ROW,MX,Mexico,America 248 | ROW,MX,Mexico,America 249 | ROW,MX,Mexico,America 250 | ROW,MX,Mexico,America 251 | ROW,MX,Mexico,America 252 | ROW,MX,Mexico,America 253 | ROW,MX,Mexico,America 254 | EU,RU,Russia,Europe 255 | EU,RU,Russia,Europe 256 | EU,RU,Russia,Europe 257 | EU,RU,Russia,Europe 258 | EU,RU,Russia,Europe 259 | EU,RU,Russia,Europe 260 | EU,RU,Russia,Europe 261 | ROW,AU,Australia,Asia and Pacific 262 | ROW,AU,Australia,Asia and Pacific 263 | ROW,AU,Australia,Asia and Pacific 264 | ROW,AU,Australia,Asia and Pacific 265 | ROW,AU,Australia,Asia and Pacific 266 | ROW,AU,Australia,Asia and Pacific 267 | ROW,AU,Australia,Asia and Pacific 268 | EU,CH,Switzerland,Europe 269 | EU,CH,Switzerland,Europe 270 | EU,CH,Switzerland,Europe 271 | EU,CH,Switzerland,Europe 272 | EU,CH,Switzerland,Europe 273 | EU,CH,Switzerland,Europe 274 | EU,CH,Switzerland,Europe 275 | ROW,TR,Turkey,Middle East 276 | ROW,TR,Turkey,Middle East 277 | ROW,TR,Turkey,Middle East 278 | ROW,TR,Turkey,Middle East 279 | ROW,TR,Turkey,Middle East 280 | ROW,TR,Turkey,Middle East 281 | ROW,TR,Turkey,Middle East 282 | ROW,TW,Taiwan,Asia and Pacific 283 | ROW,TW,Taiwan,Asia and Pacific 284 | ROW,TW,Taiwan,Asia and Pacific 285 | ROW,TW,Taiwan,Asia and Pacific 286 | ROW,TW,Taiwan,Asia and Pacific 287 | ROW,TW,Taiwan,Asia and Pacific 288 | ROW,TW,Taiwan,Asia and Pacific 289 | EU,NO,Norway,Europe 290 | EU,NO,Norway,Europe 291 | EU,NO,Norway,Europe 292 | EU,NO,Norway,Europe 293 | EU,NO,Norway,Europe 294 | EU,NO,Norway,Europe 295 | EU,NO,Norway,Europe 296 | ROW,ID,Indonesia,Asia and Pacific 297 | ROW,ID,Indonesia,Asia and Pacific 298 | ROW,ID,Indonesia,Asia and Pacific 299 | ROW,ID,Indonesia,Asia and Pacific 300 | ROW,ID,Indonesia,Asia and Pacific 301 | ROW,ID,Indonesia,Asia and Pacific 302 | ROW,ID,Indonesia,Asia and Pacific 303 | ROW,ZA,South Africa,Africa 304 | ROW,ZA,South Africa,Africa 305 | ROW,ZA,South Africa,Africa 306 | ROW,ZA,South Africa,Africa 307 | ROW,ZA,South Africa,Africa 308 | ROW,ZA,South Africa,Africa 309 | ROW,ZA,South Africa,Africa 310 | ROW,WA,RoW Asia and Pacific,Asia and Pacific 311 | ROW,WA,RoW Asia and Pacific,Asia and Pacific 312 | ROW,WA,RoW Asia and Pacific,Asia and Pacific 313 | ROW,WA,RoW Asia and Pacific,Asia and Pacific 314 | ROW,WA,RoW Asia and Pacific,Asia and Pacific 315 | ROW,WA,RoW Asia and Pacific,Asia and Pacific 316 | ROW,WA,RoW Asia and Pacific,Asia and Pacific 317 | ROW,WL,RoW America,America 318 | ROW,WL,RoW America,America 319 | ROW,WL,RoW America,America 320 | ROW,WL,RoW America,America 321 | ROW,WL,RoW America,America 322 | ROW,WL,RoW America,America 323 | ROW,WL,RoW America,America 324 | EU,WE,RoW Europe,Europe 325 | EU,WE,RoW Europe,Europe 326 | EU,WE,RoW Europe,Europe 327 | EU,WE,RoW Europe,Europe 328 | EU,WE,RoW Europe,Europe 329 | EU,WE,RoW Europe,Europe 330 | EU,WE,RoW Europe,Europe 331 | ROW,WF,RoW Africa,Africa 332 | ROW,WF,RoW Africa,Africa 333 | ROW,WF,RoW Africa,Africa 334 | ROW,WF,RoW Africa,Africa 335 | ROW,WF,RoW Africa,Africa 336 | ROW,WF,RoW Africa,Africa 337 | ROW,WF,RoW Africa,Africa 338 | ROW,WM,RoW Middle East,Middle East 339 | ROW,WM,RoW Middle East,Middle East 340 | ROW,WM,RoW Middle East,Middle East 341 | ROW,WM,RoW Middle East,Middle East 342 | ROW,WM,RoW Middle East,Middle East 343 | ROW,WM,RoW Middle East,Middle East 344 | ROW,WM,RoW Middle East,Middle East 345 | -------------------------------------------------------------------------------- /intro_exiobase/intro_exiobase_sv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "slideshow": { 7 | "slide_type": "slide" 8 | } 9 | }, 10 | "source": [ 11 | "# Practical 5: Introduction to exiobase\n", 12 | "\n", 13 | "In this practical, you will learn how to load and work with exiobase\n", 14 | "\n", 15 | "You can download exiobase through this link https://zenodo.org/record/5589597\n", 16 | " \n", 17 | "We will work with: IOT_2019_pxp.zip\n", 18 | "\n", 19 | "The objectives of the practical are:\n", 20 | "- See the data available within exiobase\n", 21 | "- Calculate footprints using exiobase\n", 22 | "- Make a visualization" 23 | ] 24 | }, 25 | { 26 | "cell_type": "markdown", 27 | "metadata": { 28 | "slideshow": { 29 | "slide_type": "subslide" 30 | } 31 | }, 32 | "source": [ 33 | "## Exercise 1: Load the data\n", 34 | "\n", 35 | "Import the IO exiobase data for the year 2019 in product-by-product format" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": null, 41 | "metadata": { 42 | "slideshow": { 43 | "slide_type": "fragment" 44 | } 45 | }, 46 | "outputs": [], 47 | "source": [ 48 | "# Import modules\n", 49 | "import pandas as pd\n", 50 | "import numpy as np" 51 | ] 52 | }, 53 | { 54 | "cell_type": "markdown", 55 | "metadata": { 56 | "slideshow": { 57 | "slide_type": "subslide" 58 | } 59 | }, 60 | "source": [ 61 | "#### 1.1 Import exiobase\n", 62 | "\n", 63 | "Beware: exiobase is composed by large datasets so it may take some time to load and process" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": null, 69 | "metadata": { 70 | "slideshow": { 71 | "slide_type": "fragment" 72 | } 73 | }, 74 | "outputs": [], 75 | "source": [ 76 | "A = None # A matrix\n", 77 | "Y = None # Y matrix\n", 78 | "F = None # impacts matrix\n", 79 | "F_hh = None # impacts for FD matrix" 80 | ] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "metadata": { 85 | "slideshow": { 86 | "slide_type": "subslide" 87 | } 88 | }, 89 | "source": [ 90 | "#### 1.2 Look at the available labels in exiobase\n", 91 | "You may do this by printing the labels of your imported matrices or by opening the following files in your data folder:\n", 92 | "- finaldemands.txt\n", 93 | "- products.txt\n", 94 | "- impacts/unit.txt" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": null, 100 | "metadata": { 101 | "slideshow": { 102 | "slide_type": "fragment" 103 | } 104 | }, 105 | "outputs": [], 106 | "source": [ 107 | "units = None\n", 108 | "units" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": { 114 | "slideshow": { 115 | "slide_type": "subslide" 116 | } 117 | }, 118 | "source": [ 119 | "Since we don't have a file showing all individual regions. \n", 120 | "Here is a code example of how you can get a list of all the regions within exiobase" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": null, 126 | "metadata": { 127 | "slideshow": { 128 | "slide_type": "fragment" 129 | } 130 | }, 131 | "outputs": [], 132 | "source": [ 133 | "# First we collect all labels from A\n", 134 | "A_labels = None\n", 135 | "A_labels" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": null, 141 | "metadata": { 142 | "slideshow": { 143 | "slide_type": "subslide" 144 | } 145 | }, 146 | "outputs": [], 147 | "source": [ 148 | "# .to_frame to turn the collected labels into a dataframe\n", 149 | "A_labels = None\n", 150 | "A_labels" 151 | ] 152 | }, 153 | { 154 | "cell_type": "markdown", 155 | "metadata": { 156 | "slideshow": { 157 | "slide_type": "subslide" 158 | } 159 | }, 160 | "source": [ 161 | "A_labels is composed by two columns \"region\" and \"sector\"\n", 162 | "by doing \n", 163 | "\n", 164 | "> A_labels.region \n", 165 | "\n", 166 | "or \n", 167 | "\n", 168 | "> A_labels.sector \n", 169 | "\n", 170 | "you can access the specific columns \n", 171 | "\n", 172 | "N.b.\n", 173 | "it is the equivalent of doing \n", 174 | "\n", 175 | "> A_labels.loc[:, \"region\"]" 176 | ] 177 | }, 178 | { 179 | "cell_type": "markdown", 180 | "metadata": { 181 | "slideshow": { 182 | "slide_type": "slide" 183 | } 184 | }, 185 | "source": [ 186 | "How do we know how many regions, sectors or categories do we have available?" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": null, 192 | "metadata": { 193 | "slideshow": { 194 | "slide_type": "fragment" 195 | } 196 | }, 197 | "outputs": [], 198 | "source": [ 199 | "# Then we extract region column and eliminate any duplicate labels\n", 200 | "# We do this because the labels are replicated for each sectoral category in each region\n", 201 | "regions_labels = None\n", 202 | "\n", 203 | "# We print the regional labels so that we can see the regions we have to work with\n", 204 | "regions_labels" 205 | ] 206 | }, 207 | { 208 | "cell_type": "code", 209 | "execution_count": null, 210 | "metadata": { 211 | "slideshow": { 212 | "slide_type": "subslide" 213 | } 214 | }, 215 | "outputs": [], 216 | "source": [ 217 | "#Collect the sectors labels and get the u\n", 218 | "sectors_labels = None\n", 219 | "\n", 220 | "# Print your labels to analyse them (remember .to_frame)\n", 221 | "sectors_labels" 222 | ] 223 | }, 224 | { 225 | "cell_type": "markdown", 226 | "metadata": { 227 | "slideshow": { 228 | "slide_type": "slide" 229 | } 230 | }, 231 | "source": [ 232 | "## Exercise 2: Calculate the rest of the IO variables (I, L, x)" 233 | ] 234 | }, 235 | { 236 | "cell_type": "markdown", 237 | "metadata": { 238 | "slideshow": { 239 | "slide_type": "subslide" 240 | } 241 | }, 242 | "source": [ 243 | "#### 2.1 First we calculate the Leontief inverse" 244 | ] 245 | }, 246 | { 247 | "cell_type": "code", 248 | "execution_count": null, 249 | "metadata": { 250 | "slideshow": { 251 | "slide_type": "fragment" 252 | } 253 | }, 254 | "outputs": [], 255 | "source": [ 256 | "I = None # A.shape[0] is the total number of columns in the A matrix\n", 257 | "L = None" 258 | ] 259 | }, 260 | { 261 | "cell_type": "markdown", 262 | "metadata": { 263 | "slideshow": { 264 | "slide_type": "subslide" 265 | } 266 | }, 267 | "source": [ 268 | "#### 2.2 We calculate our product output x" 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": null, 274 | "metadata": { 275 | "slideshow": { 276 | "slide_type": "fragment" 277 | } 278 | }, 279 | "outputs": [], 280 | "source": [ 281 | "x = None\n", 282 | "\n", 283 | "# A check to see whether the resulting x is right\n", 284 | "print(x.shape)\n", 285 | "print(x)" 286 | ] 287 | }, 288 | { 289 | "cell_type": "markdown", 290 | "metadata": { 291 | "slideshow": { 292 | "slide_type": "slide" 293 | } 294 | }, 295 | "source": [ 296 | "## Exercise 3: Create a matrix of extension intensities \n", 297 | "\n", 298 | "When working with real data, you will find cases in which the produt output vector x contains 0's \n", 299 | "\n", 300 | "If you try to invert the diagonalized product output, it will tell you that you cannot invert a Singular matrix.\n", 301 | "\n", 302 | "There are various reasons why a matrix may be singular but in our case it is due to the fact that not all values are non-zeros\n", 303 | "\n", 304 | "You may then be tempted to perform 1/x, however, this may results in several divisions by 0's and the resulting matrix will be filled with NaN values or inf values.\n", 305 | "\n", 306 | "One way to get around this: Divide 1 by the values that are non-0 as shown in the following example" 307 | ] 308 | }, 309 | { 310 | "cell_type": "code", 311 | "execution_count": null, 312 | "metadata": { 313 | "scrolled": true, 314 | "slideshow": { 315 | "slide_type": "subslide" 316 | } 317 | }, 318 | "outputs": [], 319 | "source": [ 320 | "# we make a copy of our product output vector which we will call x_inv\n", 321 | "x_inv = None\n", 322 | "\n", 323 | "# we divide 1 by the values that are non-0\n", 324 | "x_inv[x_inv!=0] = 1/x_inv[x_inv!=0]" 325 | ] 326 | }, 327 | { 328 | "cell_type": "markdown", 329 | "metadata": { 330 | "slideshow": { 331 | "slide_type": "subslide" 332 | } 333 | }, 334 | "source": [ 335 | "We calculate our intensities (i.e., extension coefficients)" 336 | ] 337 | }, 338 | { 339 | "cell_type": "code", 340 | "execution_count": null, 341 | "metadata": { 342 | "slideshow": { 343 | "slide_type": "fragment" 344 | } 345 | }, 346 | "outputs": [], 347 | "source": [ 348 | "# We are essentially dividing the total extension by the product output\n", 349 | "# This gives us coefficients of extension by unit of output (e.g., kg/euro)\n", 350 | "f = None\n", 351 | "\n", 352 | "f" 353 | ] 354 | }, 355 | { 356 | "cell_type": "markdown", 357 | "metadata": { 358 | "slideshow": { 359 | "slide_type": "fragment" 360 | } 361 | }, 362 | "source": [ 363 | "N.b. inverting a matrix is a more complex operation than just dividing 1 by the values in your matrix. \n", 364 | "\n", 365 | "However, in the case of a diagonalized vector with non-zero values along the diagonal 1/diag(x) and inv(diag(x)) output the same results. \n", 366 | "\n", 367 | "If you have zero's in x vector to be diagonalized then you will not be able to perform the inversion. " 368 | ] 369 | }, 370 | { 371 | "cell_type": "markdown", 372 | "metadata": { 373 | "slideshow": { 374 | "slide_type": "slide" 375 | } 376 | }, 377 | "source": [ 378 | "## Exercise 4: Total footprint of the Netherlands\n", 379 | "\n", 380 | "\n", 381 | "- *What is the total carbon footprint of the Netherlands?*\n", 382 | "\n", 383 | "\n", 384 | "$\\text{F} = \\text{f} \\mathbf{L}\\text{Y} + \\text{F}_{hh}$" 385 | ] 386 | }, 387 | { 388 | "cell_type": "markdown", 389 | "metadata": { 390 | "slideshow": { 391 | "slide_type": "slide" 392 | } 393 | }, 394 | "source": [ 395 | "#### 4.1 We first create a (modified) final demand matrix" 396 | ] 397 | }, 398 | { 399 | "cell_type": "markdown", 400 | "metadata": { 401 | "slideshow": { 402 | "slide_type": "subslide" 403 | } 404 | }, 405 | "source": [ 406 | "4.1.1 Lets identify the range of the Y columns concerning the Netherlands" 407 | ] 408 | }, 409 | { 410 | "cell_type": "code", 411 | "execution_count": null, 412 | "metadata": { 413 | "slideshow": { 414 | "slide_type": "fragment" 415 | } 416 | }, 417 | "outputs": [], 418 | "source": [ 419 | "# we know NL is the 20th country (python counting starting from 0) in the list of countries \n", 420 | "# and that we have 7 final demand categories, therefore\n", 421 | "\n", 422 | "start_NL = None\n", 423 | "end_NL = None" 424 | ] 425 | }, 426 | { 427 | "cell_type": "markdown", 428 | "metadata": { 429 | "slideshow": { 430 | "slide_type": "subslide" 431 | } 432 | }, 433 | "source": [ 434 | "4.1.2 We calculate the modified Y" 435 | ] 436 | }, 437 | { 438 | "cell_type": "markdown", 439 | "metadata": { 440 | "slideshow": { 441 | "slide_type": "subslide" 442 | } 443 | }, 444 | "source": [ 445 | "You can slice your Y by using pandas iloc method \n", 446 | "\n", 447 | "> Y.iloc[:,start_NL:end_NL]" 448 | ] 449 | }, 450 | { 451 | "cell_type": "code", 452 | "execution_count": null, 453 | "metadata": { 454 | "slideshow": { 455 | "slide_type": "fragment" 456 | } 457 | }, 458 | "outputs": [], 459 | "source": [ 460 | "Y_mod = None\n", 461 | "Y_mod" 462 | ] 463 | }, 464 | { 465 | "cell_type": "markdown", 466 | "metadata": { 467 | "slideshow": { 468 | "slide_type": "subslide" 469 | } 470 | }, 471 | "source": [ 472 | "Or by using the labels through pandas loc method\n", 473 | "\n", 474 | "> Y.loc[:, \"NL\"]" 475 | ] 476 | }, 477 | { 478 | "cell_type": "code", 479 | "execution_count": null, 480 | "metadata": { 481 | "slideshow": { 482 | "slide_type": "fragment" 483 | } 484 | }, 485 | "outputs": [], 486 | "source": [ 487 | "Y_mod = None\n", 488 | "Y_mod" 489 | ] 490 | }, 491 | { 492 | "cell_type": "markdown", 493 | "metadata": { 494 | "slideshow": { 495 | "slide_type": "subslide" 496 | } 497 | }, 498 | "source": [ 499 | "#### 5.1 We isolate the extension in which we are interested" 500 | ] 501 | }, 502 | { 503 | "cell_type": "markdown", 504 | "metadata": { 505 | "slideshow": { 506 | "slide_type": "fragment" 507 | } 508 | }, 509 | "source": [ 510 | "For this exercise we only focus on the carbon fooprint\n", 511 | "\n", 512 | "*\"GHG emissions (GWP100) | Problem oriented approach: baseline (CML, 2001) | GWP100 (IPCC, 2007)\"* in kg" 513 | ] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": null, 518 | "metadata": { 519 | "slideshow": { 520 | "slide_type": "fragment" 521 | } 522 | }, 523 | "outputs": [], 524 | "source": [ 525 | "indicator = \"\"" 526 | ] 527 | }, 528 | { 529 | "cell_type": "code", 530 | "execution_count": null, 531 | "metadata": { 532 | "slideshow": { 533 | "slide_type": "fragment" 534 | } 535 | }, 536 | "outputs": [], 537 | "source": [ 538 | "# the intensity vector in which we are interested\n", 539 | "f_ = None\n", 540 | "\n", 541 | "f_" 542 | ] 543 | }, 544 | { 545 | "cell_type": "code", 546 | "execution_count": null, 547 | "metadata": { 548 | "slideshow": { 549 | "slide_type": "fragment" 550 | } 551 | }, 552 | "outputs": [], 553 | "source": [ 554 | "# the final demand CO2 emissions\n", 555 | "\n", 556 | "e_hh_ = None" 557 | ] 558 | }, 559 | { 560 | "cell_type": "markdown", 561 | "metadata": { 562 | "slideshow": { 563 | "slide_type": "subslide" 564 | } 565 | }, 566 | "source": [ 567 | "#### 5.2 We calculate the total footprint of the region" 568 | ] 569 | }, 570 | { 571 | "cell_type": "code", 572 | "execution_count": null, 573 | "metadata": { 574 | "slideshow": { 575 | "slide_type": "fragment" 576 | } 577 | }, 578 | "outputs": [], 579 | "source": [ 580 | "# Calculate the total global footprint\n", 581 | "e_total_reg = None\n", 582 | "e_total_reg" 583 | ] 584 | }, 585 | { 586 | "cell_type": "markdown", 587 | "metadata": { 588 | "slideshow": { 589 | "slide_type": "slide" 590 | } 591 | }, 592 | "source": [ 593 | "## Exercise 5: Which regions emit the most CO2 as a result of final consumption in the Netherlands?" 594 | ] 595 | }, 596 | { 597 | "cell_type": "markdown", 598 | "metadata": { 599 | "slideshow": { 600 | "slide_type": "subslide" 601 | } 602 | }, 603 | "source": [ 604 | "#### 5.3 Let's analyse in which regions CO2 is emitted the most as a result of NL consumption" 605 | ] 606 | }, 607 | { 608 | "cell_type": "code", 609 | "execution_count": null, 610 | "metadata": { 611 | "slideshow": { 612 | "slide_type": "fragment" 613 | } 614 | }, 615 | "outputs": [], 616 | "source": [ 617 | "# In this case we diagonalize the emission intensity vector \n", 618 | "e_breakdown = None" 619 | ] 620 | }, 621 | { 622 | "cell_type": "code", 623 | "execution_count": null, 624 | "metadata": { 625 | "slideshow": { 626 | "slide_type": "fragment" 627 | } 628 | }, 629 | "outputs": [], 630 | "source": [ 631 | "# we apply the sectoral labels\n", 632 | "e_breakdown.index = None\n", 633 | "\n", 634 | "e_breakdown" 635 | ] 636 | }, 637 | { 638 | "cell_type": "code", 639 | "execution_count": null, 640 | "metadata": { 641 | "slideshow": { 642 | "slide_type": "subslide" 643 | } 644 | }, 645 | "outputs": [], 646 | "source": [ 647 | "# Right now, we are only interested in the impacts of regions, so so we sum across axis 1\n", 648 | "e_prod_reg = None" 649 | ] 650 | }, 651 | { 652 | "cell_type": "code", 653 | "execution_count": null, 654 | "metadata": { 655 | "slideshow": { 656 | "slide_type": "fragment" 657 | } 658 | }, 659 | "outputs": [], 660 | "source": [ 661 | "# and then we sum the results by regions by using the groupby methods\n", 662 | "e_regional_breakdown = None" 663 | ] 664 | }, 665 | { 666 | "cell_type": "code", 667 | "execution_count": null, 668 | "metadata": { 669 | "slideshow": { 670 | "slide_type": "subslide" 671 | } 672 | }, 673 | "outputs": [], 674 | "source": [ 675 | "# We sort the results from largest to smallest to see the most impacting regions\n", 676 | "e_rb_sorted = None\n", 677 | "\n", 678 | "e_rb_sorted" 679 | ] 680 | }, 681 | { 682 | "cell_type": "markdown", 683 | "metadata": { 684 | "slideshow": { 685 | "slide_type": "slide" 686 | } 687 | }, 688 | "source": [ 689 | "## Exercise 6: Let's plot the results for the top 15 emitters \n", 690 | "\n", 691 | "Using pandas you can make simple visualizations directly from dataframes and series\n", 692 | "\n", 693 | "see more here: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.html" 694 | ] 695 | }, 696 | { 697 | "cell_type": "markdown", 698 | "metadata": { 699 | "slideshow": { 700 | "slide_type": "subslide" 701 | } 702 | }, 703 | "source": [ 704 | "#### 6.1 Totals of the top 15 emitters" 705 | ] 706 | }, 707 | { 708 | "cell_type": "code", 709 | "execution_count": null, 710 | "metadata": { 711 | "slideshow": { 712 | "slide_type": "fragment" 713 | } 714 | }, 715 | "outputs": [], 716 | "source": [ 717 | "# plot your results with plot.bar()\n", 718 | "top_15_results = None\n", 719 | "\n", 720 | "top_15_plot = None\n", 721 | "\n", 722 | "# applying bar labels\n", 723 | "top_15_plot = None" 724 | ] 725 | }, 726 | { 727 | "cell_type": "markdown", 728 | "metadata": { 729 | "slideshow": { 730 | "slide_type": "subslide" 731 | } 732 | }, 733 | "source": [ 734 | "#### 6.2 Let's normalize results by the total footprint of NL consumption" 735 | ] 736 | }, 737 | { 738 | "cell_type": "code", 739 | "execution_count": null, 740 | "metadata": { 741 | "slideshow": { 742 | "slide_type": "fragment" 743 | } 744 | }, 745 | "outputs": [], 746 | "source": [ 747 | "# Normalize your results\n", 748 | "e_rb_sorted_norm = None" 749 | ] 750 | }, 751 | { 752 | "cell_type": "code", 753 | "execution_count": null, 754 | "metadata": { 755 | "slideshow": { 756 | "slide_type": "slide" 757 | } 758 | }, 759 | "outputs": [], 760 | "source": [ 761 | "# Plot top 15 regions\n", 762 | "top_15_norm_plot = None\n", 763 | "\n", 764 | "# applying bar labels\n", 765 | "top_15_norm_plot = None" 766 | ] 767 | } 768 | ], 769 | "metadata": { 770 | "celltoolbar": "Slideshow", 771 | "kernelspec": { 772 | "display_name": "Python 3 (ipykernel)", 773 | "language": "python", 774 | "name": "python3" 775 | }, 776 | "language_info": { 777 | "codemirror_mode": { 778 | "name": "ipython", 779 | "version": 3 780 | }, 781 | "file_extension": ".py", 782 | "mimetype": "text/x-python", 783 | "name": "python", 784 | "nbconvert_exporter": "python", 785 | "pygments_lexer": "ipython3", 786 | "version": "3.9.16" 787 | }, 788 | "vscode": { 789 | "interpreter": { 790 | "hash": "a0de1fb450ee5e26d734f0aa5b4c4b29e20575809e5e66472467df7627fd957d" 791 | } 792 | } 793 | }, 794 | "nbformat": 4, 795 | "nbformat_minor": 2 796 | } 797 | -------------------------------------------------------------------------------- /midterm/mock_exam/1_st/mock_exam_1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": { 7 | "slideshow": { 8 | "slide_type": "slide" 9 | } 10 | }, 11 | "source": [ 12 | "# Mock mid-term exam \n", 13 | "\n", 14 | "## Topic of the exam: Pre-BREXIT analysis of Non-metallic Minerals vs. Metal Ores. \n", 15 | "\n", 16 | "Please ensure that you run each cell (ctrl+enter) so that your inputs are saved \n", 17 | "\n", 18 | "All questions have either coding cell or a text cell, or a combination of the two. \n", 19 | "\n", 20 | "You are allowed to create additional cells for each answer to facilitate your work " 21 | ] 22 | }, 23 | { 24 | "attachments": {}, 25 | "cell_type": "markdown", 26 | "metadata": { 27 | "slideshow": { 28 | "slide_type": "slide" 29 | } 30 | }, 31 | "source": [ 32 | "## Data preparation: Download and import exiobase" 33 | ] 34 | }, 35 | { 36 | "attachments": {}, 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "Data to be used in the exam: **year 2016 industry-by-industry format**\n", 41 | "\n", 42 | "Link to the data: https://zenodo.org/record/5589597" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 1, 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [ 51 | "# Write here your code" 52 | ] 53 | }, 54 | { 55 | "attachments": {}, 56 | "cell_type": "markdown", 57 | "metadata": { 58 | "slideshow": { 59 | "slide_type": "slide" 60 | } 61 | }, 62 | "source": [ 63 | "## Question 1: Territorial accounting (10 points)" 64 | ] 65 | }, 66 | { 67 | "attachments": {}, 68 | "cell_type": "markdown", 69 | "metadata": { 70 | "slideshow": { 71 | "slide_type": "fragment" 72 | } 73 | }, 74 | "source": [ 75 | "### Q1.1 What was the UK's domestic extractions of non-metallic minerals in 2016? (10 points) \n", 76 | "Hint 1: use the environmental extensions with keywords: \"Domestic Extraction Used - Non-Metallic Minerals\"\n", 77 | "\n", 78 | "Hint 2: UK's acronym is GB (i.e., Great Britain) in ISO3 " 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": null, 84 | "metadata": {}, 85 | "outputs": [], 86 | "source": [ 87 | "# Write here your code" 88 | ] 89 | }, 90 | { 91 | "attachments": {}, 92 | "cell_type": "markdown", 93 | "metadata": {}, 94 | "source": [ 95 | "## Question 2: Footprint analysis (10 points)" 96 | ] 97 | }, 98 | { 99 | "attachments": {}, 100 | "cell_type": "markdown", 101 | "metadata": {}, 102 | "source": [ 103 | "### Q2.1 What was the UK's non-metallic mineral footprint in 2016? (10 points)" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": null, 109 | "metadata": {}, 110 | "outputs": [], 111 | "source": [ 112 | "# Write here your code" 113 | ] 114 | }, 115 | { 116 | "attachments": {}, 117 | "cell_type": "markdown", 118 | "metadata": {}, 119 | "source": [ 120 | "## Questions 3: Trade (15 points)" 121 | ] 122 | }, 123 | { 124 | "attachments": {}, 125 | "cell_type": "markdown", 126 | "metadata": {}, 127 | "source": [ 128 | "### Q3.1: Based on Q1 & Q2, was the UK a net importer or net exporter of non-metallic minerals in 2016? (3 points)" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": null, 134 | "metadata": {}, 135 | "outputs": [], 136 | "source": [ 137 | "# Write here your code" 138 | ] 139 | }, 140 | { 141 | "attachments": {}, 142 | "cell_type": "markdown", 143 | "metadata": {}, 144 | "source": [ 145 | "_Write here your answer_" 146 | ] 147 | }, 148 | { 149 | "attachments": {}, 150 | "cell_type": "markdown", 151 | "metadata": {}, 152 | "source": [ 153 | "### Q3.2: Perform MRIO calculation and identify the top three regions from which the UK imported non-metallic minerals in 2016 (12 points)" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": null, 159 | "metadata": {}, 160 | "outputs": [], 161 | "source": [ 162 | "# Write here your code" 163 | ] 164 | }, 165 | { 166 | "attachments": {}, 167 | "cell_type": "markdown", 168 | "metadata": {}, 169 | "source": [ 170 | "## Question 4: Dashboard analysis - Non-metallic Minerals vs. Metal Ores (25 points)" 171 | ] 172 | }, 173 | { 174 | "attachments": {}, 175 | "cell_type": "markdown", 176 | "metadata": {}, 177 | "source": [ 178 | "### Q4.1 Quantify the reliance of the UK on each of the two global regions, EU27 and Non-EU27, in 2016 concerning Non-Metallic minerals and Metal Ores. (10 points)\n", 179 | "\n", 180 | "Hint 1: Replicate Qs 2-3 for metal ores\n", 181 | "\n", 182 | "Hint 2: use the environmental extensions with keywords: \"Domestic Extraction Used - Metal Ores\"\n", 183 | "\n", 184 | "Hint 3: remember that the first 27 regions in exiobase are the EU27\n", 185 | "\n", 186 | "Hint 4: use the last 21 countries/regions in exiobase for Non-EU27" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": null, 192 | "metadata": {}, 193 | "outputs": [], 194 | "source": [ 195 | "# Write here your code" 196 | ] 197 | }, 198 | { 199 | "attachments": {}, 200 | "cell_type": "markdown", 201 | "metadata": {}, 202 | "source": [ 203 | "### Q4.2 Focusing on the two types of materials, describe three significantly different findings about the UK's material reliance on the EU27 vs the rest of the world. (15 points)\n", 204 | "\n", 205 | "The description for each finding should:\n", 206 | "\n", 207 | "1) be supported by numerical results you obtained from above calculations and based on comparisons of numerical results; \n", 208 | "\n", 209 | "2) contains your reflections about the UK's trade relationship in the context of BREXIT.\n" 210 | ] 211 | }, 212 | { 213 | "attachments": {}, 214 | "cell_type": "markdown", 215 | "metadata": {}, 216 | "source": [ 217 | "_write your answer here_" 218 | ] 219 | } 220 | ], 221 | "metadata": { 222 | "celltoolbar": "Slideshow", 223 | "kernelspec": { 224 | "display_name": "Python 3 (ipykernel)", 225 | "language": "python", 226 | "name": "python3" 227 | }, 228 | "language_info": { 229 | "codemirror_mode": { 230 | "name": "ipython", 231 | "version": 3 232 | }, 233 | "file_extension": ".py", 234 | "mimetype": "text/x-python", 235 | "name": "python", 236 | "nbconvert_exporter": "python", 237 | "pygments_lexer": "ipython3", 238 | "version": "3.10.2" 239 | } 240 | }, 241 | "nbformat": 4, 242 | "nbformat_minor": 4 243 | } 244 | -------------------------------------------------------------------------------- /midterm/mock_exam/2_nd/mock_exam_2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "slideshow": { 7 | "slide_type": "slide" 8 | } 9 | }, 10 | "source": [ 11 | "# Mock mid-term exam\n", 12 | "\n", 13 | "The objectives of this mock mid-term exam are:\n", 14 | "- to gain acquaintance with the type of programming questions that you will be asked during the mid-term exam\n", 15 | "- Becoming more comfortable in performing Input-Output analysis calculations\n", 16 | "\n", 17 | "We are accounting that you will need around 100-120 minutes to complete the assignment\n", 18 | "\n", 19 | "Please ensure that you run each cell (ctrl+enter) so that your inputs are saved \n", 20 | "\n", 21 | "All questions have either coding cell or a text cell, or a combination of the two. \n", 22 | "\n", 23 | "You are allowed to create additional cells for each answer to facilitate your work " 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": { 29 | "slideshow": { 30 | "slide_type": "slide" 31 | } 32 | }, 33 | "source": [ 34 | "## Data preparation: Download and import exiobase data - year 2015, industry-by-industry format" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": null, 40 | "metadata": { 41 | "slideshow": { 42 | "slide_type": "fragment" 43 | } 44 | }, 45 | "outputs": [], 46 | "source": [ 47 | "# Import modules\n" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": null, 53 | "metadata": { 54 | "slideshow": { 55 | "slide_type": "subslide" 56 | } 57 | }, 58 | "outputs": [], 59 | "source": [ 60 | "# Import here your data" 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": { 66 | "slideshow": { 67 | "slide_type": "slide" 68 | } 69 | }, 70 | "source": [ 71 | "## Question 1: Carbon footprint of the nations (18 points)" 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": { 77 | "slideshow": { 78 | "slide_type": "fragment" 79 | } 80 | }, 81 | "source": [ 82 | "#### 1.1 What were the per capita carbon footprint of each of the 49 exiobase regions when considering only CO2 emissions in 2015? (8 points)" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": null, 88 | "metadata": { 89 | "slideshow": { 90 | "slide_type": "subslide" 91 | } 92 | }, 93 | "outputs": [], 94 | "source": [ 95 | "# Import population data\n" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "metadata": { 102 | "slideshow": { 103 | "slide_type": "slide" 104 | } 105 | }, 106 | "outputs": [], 107 | "source": [ 108 | "# Peform the rest of your calculations" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": { 114 | "slideshow": { 115 | "slide_type": "slide" 116 | } 117 | }, 118 | "source": [ 119 | "Tip! \n", 120 | "\n", 121 | "by running the following\n", 122 | "\n", 123 | "F_sat_hh.index.str.contains(\"CO2\")\n", 124 | "\n", 125 | "You obtain a boolean array (i.e., an array of true and false values), where true is assigned to the position of all labels that contain \"CO2\" in them.\n", 126 | "\n", 127 | "This is the equivalent of creating a list of all the labels concerning CO2 emissions in the extension such as\n", 128 | "\n", 129 | "```\n", 130 | "['CO2 - combustion - air',\n", 131 | "'CO2 - non combustion - Cement production - air',\n", 132 | "'CO2 - non combustion - Lime production - air',\n", 133 | "'CO2 - agriculture - peat decay - air',\n", 134 | "'CO2 - waste - biogenic - air', 'CO2 - waste - fossil - air']\n", 135 | "```\n", 136 | "\n", 137 | "##### Explanation\n", 138 | "\n", 139 | "**F_sat_gg.index** returns all labels of your index\n", 140 | "\n", 141 | "**.str** allows to treat each entry of the index as a string\n", 142 | "\n", 143 | "**.contains()** is a method for strings that allows you check whether a string may contain another string " 144 | ] 145 | }, 146 | { 147 | "cell_type": "markdown", 148 | "metadata": {}, 149 | "source": [ 150 | "#### 1.2 What were the per capita carbon footprint in kg or tonne of CO2e (CO2 equivalent) of each of the 49 regions when considering CH4, N2O, and CO2? (6 points)\n", 151 | "Instruction: Please use 29.8 and 273 for GWP100 of CH4 and N2O, respectively." 152 | ] 153 | }, 154 | { 155 | "cell_type": "markdown", 156 | "metadata": {}, 157 | "source": [ 158 | "#### 1.3 What is the proportion of CO2 emissions in CO2e in each region's carbon footprint measured in CO2e? (4 points)" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": null, 164 | "metadata": {}, 165 | "outputs": [], 166 | "source": [] 167 | }, 168 | { 169 | "cell_type": "markdown", 170 | "metadata": {}, 171 | "source": [ 172 | "Double click on this cell to write your answer. Run the cell (ctrl+enter) once you are done writing so that it saves your input" 173 | ] 174 | }, 175 | { 176 | "cell_type": "markdown", 177 | "metadata": {}, 178 | "source": [ 179 | "## Question 2: Territorial emissions (6 points)" 180 | ] 181 | }, 182 | { 183 | "cell_type": "markdown", 184 | "metadata": {}, 185 | "source": [ 186 | "#### 2.1 What were the per capita territorial emissions of the US and China, respectively, in 2015? Only consider CO2 emissions here. (6 points)" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": null, 192 | "metadata": {}, 193 | "outputs": [], 194 | "source": [] 195 | }, 196 | { 197 | "cell_type": "markdown", 198 | "metadata": {}, 199 | "source": [ 200 | "## Question 3: Emissions embodied in trade (20 points)" 201 | ] 202 | }, 203 | { 204 | "cell_type": "markdown", 205 | "metadata": {}, 206 | "source": [ 207 | "#### 3.1 Were the US and China net importers or exporters of CO2 emissions in 2015? (4 points)" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": null, 213 | "metadata": {}, 214 | "outputs": [], 215 | "source": [] 216 | }, 217 | { 218 | "cell_type": "markdown", 219 | "metadata": {}, 220 | "source": [ 221 | "Double click on this cell to write your answer. Run the cell (ctrl+enter) once you are done writing so that it saves your input" 222 | ] 223 | }, 224 | { 225 | "cell_type": "markdown", 226 | "metadata": {}, 227 | "source": [ 228 | "#### 3.2 Which were the top three regional contributers of US' and China's carbon footprints (only consider CO2 emissions), respectively, in 2015? (12 points)" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": null, 234 | "metadata": {}, 235 | "outputs": [], 236 | "source": [] 237 | }, 238 | { 239 | "cell_type": "markdown", 240 | "metadata": {}, 241 | "source": [ 242 | "#### 3.3 By conducting emissions embodied in trade calculations, how much CO2 emissions did the US outsourced to China in 2015? (4 points)" 243 | ] 244 | }, 245 | { 246 | "cell_type": "code", 247 | "execution_count": null, 248 | "metadata": {}, 249 | "outputs": [], 250 | "source": [] 251 | }, 252 | { 253 | "cell_type": "markdown", 254 | "metadata": {}, 255 | "source": [ 256 | "The net outsourcing of CO2 emissions by the US to China in 2015 was 338.8 Mt CO2" 257 | ] 258 | }, 259 | { 260 | "cell_type": "markdown", 261 | "metadata": {}, 262 | "source": [ 263 | "## Question 4 Environmental vs Economic Footprints Analysis (16 points)" 264 | ] 265 | }, 266 | { 267 | "cell_type": "markdown", 268 | "metadata": {}, 269 | "source": [ 270 | "#### 4.1 Using the \"impact\" accounts, what were the value added footprints of the US and China, respectively, in 2015? (8 points)" 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": null, 276 | "metadata": {}, 277 | "outputs": [], 278 | "source": [] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": null, 283 | "metadata": {}, 284 | "outputs": [], 285 | "source": [] 286 | }, 287 | { 288 | "cell_type": "markdown", 289 | "metadata": {}, 290 | "source": [ 291 | "#### 4.2 Make two main observations on the carbon vs value added footprint results regarding the relationships between the US and China? Please refer to the carbon footprint results obtained in Question 1 (8 points)" 292 | ] 293 | }, 294 | { 295 | "cell_type": "markdown", 296 | "metadata": {}, 297 | "source": [ 298 | "Double click on this cell to write your answer. Run the cell (ctrl+enter) once you are done writing so that it saves your input" 299 | ] 300 | } 301 | ], 302 | "metadata": { 303 | "celltoolbar": "Slideshow", 304 | "kernelspec": { 305 | "display_name": "Python 3 (ipykernel)", 306 | "language": "python", 307 | "name": "python3" 308 | }, 309 | "language_info": { 310 | "codemirror_mode": { 311 | "name": "ipython", 312 | "version": 3 313 | }, 314 | "file_extension": ".py", 315 | "mimetype": "text/x-python", 316 | "name": "python", 317 | "nbconvert_exporter": "python", 318 | "pygments_lexer": "ipython3", 319 | "version": "3.9.16" 320 | } 321 | }, 322 | "nbformat": 4, 323 | "nbformat_minor": 4 324 | } 325 | -------------------------------------------------------------------------------- /national_enviro_footprint/data/F.txt: -------------------------------------------------------------------------------- 1 | 3.987250000000000000e+08 5.597164600000000000e+07 4.138056600000000000e+09 6.539318800000000000e+08 9.415054000000000000e+08 1.476097800000000000e+09 5.722246600000000000e+07 6.363122600000000000e+08 3.710740800000000000e+08 6.665327000000000000e+07 6.976463200000000000e+09 2.447413600000000000e+09 2.814920100000000000e+09 7.198107100000000000e+08 3.008870400000000000e+07 4.650155300000000000e+08 3.951658500000000000e+08 2.272497100000000000e+08 3.480912800000000000e+09 1.127536400000000000e+09 8.395030300000000000e+08 7.923872400000000000e+08 8.027973900000000000e+07 4.484707200000000000e+08 2 | 1.568130400000000081e+05 4.901739600000000223e+02 6.443694900000000416e+03 6.940151200000000244e+02 6.113673899999999776e+03 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 4.873282600000000093e+05 1.869048800000000028e+03 7.714028900000000249e+03 1.282793599999999969e+03 5.843418000000000029e+04 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 3.636657899999999790e+05 3.002419100000000071e+03 2.513365699999999833e+03 1.394038600000000088e+03 8.285392299999997704e+03 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 3 | 2.240817399999999907e+04 3.788488400000000183e+03 1.327717300000000068e+04 3.473398700000000099e+04 4.114160100000000239e+04 1.585287399999999980e+04 5.290093400000000111e+04 2.604608599999999860e+05 4.846576099999999860e+05 3.392056599999999889e+04 5.539817100000000210e+04 1.121072400000000052e+05 1.329685400000000081e+05 5.368997400000000198e+04 6.710528900000000431e+04 2.816577399999999907e+05 5.235908099999999977e+05 1.838945699999999852e+04 7.720406799999999930e+04 1.481929200000000128e+05 1.746684400000000023e+05 6.268198399999999674e+04 1.171103000000000029e+05 3.662735999999999767e+05 4 | -------------------------------------------------------------------------------- /national_enviro_footprint/data/Fhh.txt: -------------------------------------------------------------------------------- 1 | 2643610400 0 0 0 1057966300 0 0 0 1415817700 0 0 0 2 | 13479.622 0 0 0 26402.664 0 0 0 33093.158 0 0 0 3 | 0 0 0 0 0 0 0 0 0 0 0 0 4 | -------------------------------------------------------------------------------- /national_enviro_footprint/data/V.txt: -------------------------------------------------------------------------------- 1 | 1.088200399254000280e+06 1.769070922970999964e+05 1.296423905672999565e+06 2.234269972399207298e+06 4.019671245159999933e+06 1.930619166516000871e+06 2.281685653672999237e+06 2.090325839499999955e+07 1.451079437551999930e+06 3.196858116302355193e+05 8.626554991782000288e+05 1.585283738105590455e+06 2.339446393859999254e+06 8.728190686229001731e+05 9.144488064010000089e+05 5.013401367140000686e+06 1.315414642089999514e+06 1.394982157331591588e+05 9.844086145519998390e+05 1.473630700288719963e+06 1.816251373399999691e+06 9.129474852699998301e+05 1.095099124925999902e+06 5.195889011699998751e+06 2 | -------------------------------------------------------------------------------- /national_enviro_footprint/data/Y.txt: -------------------------------------------------------------------------------- 1 | 1.753360000000000000e+06 1.610136099999999942e+03 5.428022399999999834e+03 4.556690200000000186e+04 1.729705900000000111e+04 1.872077099999999973e+03 4.913126100000000065e+02 2.303217999999999847e+03 9.794791999999999825e+04 8.819524499999999989e+01 2.234574499999999944e+02 1.864092900000000100e+03 2 | 2.884869199999999837e+05 1.290527699999999989e+01 2.499307499999999891e+03 1.213364899999999943e+04 5.679644900000000234e+03 3.799604099999999818e+01 2.927748000000000062e+01 1.605303900000000112e+02 3.204540499999999884e+04 2.092432499999999891e+02 8.363352500000000589e+01 1.310921100000000024e+03 3 | 6.622145799999999581e+05 1.939060300000000097e+03 2.244546099999999933e+04 1.178570299999999988e+05 7.094673300000000381e+03 1.158794199999999996e+01 5.981396600000000063e+01 2.478947300000000098e+02 2.579657499999999800e+03 2.598398500000000055e+01 3.151497600000000148e+02 1.421052300000000059e+03 4 | 6.848829799999999523e+04 1.349670500000000004e+02 2.973341800000000148e+03 3.064119500000000000e+06 5.513222700000000032e+02 7.777602599999999811e+00 3.717851999999999890e+01 5.940461299999999937e+03 2.675906300000000101e+03 8.931080700000000594e-02 7.002038800000000229e+00 1.295261599999999999e+04 5 | 1.786986300000000047e+06 4.629974699999999757e+03 1.276878099999999977e+05 2.092678300000000047e+06 4.471805399999999645e+04 3.551130400000000122e+02 4.401692699999999832e+02 2.028295199999999895e+05 2.080640400000000081e+05 6.009224500000000262e+02 3.344385299999999916e+03 3.042268499999999767e+05 6 | 1.157829500000000000e+06 9.812754300000000512e+03 5.882503500000000349e+04 2.761103499999999985e+04 4.606009900000000016e+03 1.479391599999999869e+02 1.060298500000000104e+03 3.840281100000000265e+02 3.996549199999999837e+04 3.758607800000000054e+01 5.588208499999999503e+02 2.045063000000000102e+03 7 | 4.004336900000000023e+05 2.697264099999999871e+03 5.440243000000000393e+03 5.979234300000000076e+04 1.695990000000000146e+04 1.720694300000000112e+03 1.353788199999999961e+03 1.899609099999999899e+03 8.266260700000000725e+03 2.002523300000000006e+02 4.350524800000000027e+02 3.657033199999999852e+03 8 | 1.070067800000000000e+07 2.968987100000000093e+06 5.909439700000000186e+06 1.191428100000000093e+06 3.880490400000000227e+04 7.956030499999999847e+03 3.881043400000000020e+03 3.957352699999999913e+03 8.441484900000000198e+04 3.059385400000000118e+03 1.167493200000000070e+04 3.117216100000000006e+04 9 | 2.223431299999999828e+04 1.416136599999999923e+01 1.499333699999999965e+02 6.421399300000000494e+02 1.074378899999999907e+06 2.684726599999999962e+04 2.223820799999999872e+04 7.795217699999999604e+04 3.769648000000000320e+04 1.306551100000000076e+01 6.441735500000000059e+01 4.663712300000000255e+02 10 | 1.077131900000000023e+05 2.482359599999999834e-04 3.766939500000000152e+01 1.020317599999999970e+03 2.783629699999999721e+05 3.167520799999999781e+03 3.134867099999999937e+03 1.838193000000000029e+04 6.458675800000000163e+04 1.360594900000000109e+02 9.660266000000000020e+01 2.013961900000000014e+03 11 | 1.453606300000000010e+04 2.450880499999999795e+00 1.847183199999999914e+01 2.315725100000000111e+03 2.533953699999999953e+05 4.477870199999999750e+04 1.283552599999999948e+05 7.618183500000000640e+04 2.206050799999999981e+03 8.562774700000000294e+00 5.596642500000000098e+01 2.712001000000000204e+03 12 | 3.443302799999999934e+03 1.208981200000000013e-02 1.108480200000000053e+02 1.893445300000000088e+03 5.772165899999999965e+04 1.290153700000000072e+03 1.866953400000000101e+03 2.474604299999999814e+06 2.205500599999999849e+03 2.678167899999999921e-02 1.792288099999999940e+00 4.056558199999999943e+03 13 | 1.644036600000000035e+05 4.023716900000000010e+02 3.303734599999999773e+03 1.738728099999999977e+05 5.657619499999999534e+05 1.101337299999999959e+04 1.358165899999999965e+04 1.728212100000000093e+06 1.465379400000000023e+05 3.097658200000000193e+02 1.524573799999999892e+03 1.790238599999999860e+05 14 | 1.929818899999999849e+04 2.489097399999999993e+01 1.868143699999999967e+02 8.899948799999999665e+02 3.131369000000000233e+05 5.284384100000000035e+04 4.030506700000000274e+04 2.382546099999999933e+04 1.701496299999999974e+04 6.290937900000000305e+00 8.398548200000000463e+01 2.334397299999999973e+02 15 | 1.828862200000000087e+02 3.124122499999999718e+02 1.383308600000000013e+02 5.621433999999999997e+01 2.049213999999999942e+05 2.278033199999999852e+04 6.746100300000000061e+03 1.402122899999999936e+04 1.915479499999999916e+03 4.522471800000000286e+01 9.370305500000000620e+01 8.162030899999999747e+02 16 | 2.200201199999999881e+04 9.771104900000000271e+02 1.287298399999999901e+03 4.325396800000000439e+03 1.890247899999999907e+06 9.979746899999999441e+05 1.726545100000000093e+06 3.518481500000000233e+05 9.697520800000000236e+03 2.939628200000000220e+02 8.885504899999999679e+02 5.585337000000000444e+03 17 | 1.361017099999999919e+05 1.065831100000000049e+02 3.719450499999999806e+02 2.170225300000000061e+03 3.781126000000000204e+04 1.127925700000000006e+03 4.187163300000000277e+02 2.982709600000000137e+03 1.008205699999999953e+06 1.342254599999999982e+03 3.715956900000000132e+03 3.061543600000000151e+04 18 | 7.658173799999999756e+04 7.118259200000000113e-03 4.591135899999999737e+01 8.070677299999999832e+02 5.236420399999999972e+03 4.520714199999999749e+01 3.869721799999999945e+01 1.534636099999999885e+02 1.477040499999999884e+05 4.994629699999999843e+02 2.990512499999999818e+02 8.833756900000000314e+03 19 | 2.659789600000000064e+04 2.482202200000000047e+01 1.109982600000000019e+02 9.482551400000000285e+03 6.054350900000000365e+03 1.565983600000000138e+02 1.745028000000000077e+02 1.679752799999999979e+03 2.438581300000000047e+05 1.301591300000000047e+04 3.704312500000000000e+04 3.151766700000000128e+04 20 | 5.852934500000000298e+03 1.707257199999999975e-01 3.931604699999999752e+02 5.776293800000000374e+03 6.485758299999999963e+02 3.614974500000000290e+01 6.061066699999999940e+01 7.029510299999999916e+03 5.298231199999999808e+04 2.302798499999999876e+03 2.747289699999999812e+03 1.960927199999999953e+06 21 | 2.829310300000000279e+05 2.148105900000000020e+03 1.441842200000000048e+04 2.374417200000000012e+05 4.560966900000000169e+04 6.545926799999999730e+02 7.485871200000000272e+02 9.256903100000000268e+04 7.009381700000000419e+05 2.880586600000000089e+03 1.125323099999999977e+04 8.127287500000000000e+05 22 | 4.871656500000000233e+04 2.460445100000000025e+02 2.029095600000000104e+03 9.315135999999999967e+02 6.386137099999999919e+03 2.127425299999999879e+02 9.852054299999999785e+02 5.840813699999999926e+02 4.047497700000000186e+05 9.960762199999999211e+03 3.684144000000000233e+04 4.738344799999999668e+04 23 | 5.448228299999999535e+02 9.219041300000000092e+02 5.540061399999999594e+02 1.336781100000000038e+02 1.849754200000000083e+03 5.411060099999999693e+02 4.275867000000000075e+02 2.179709200000000067e+02 1.587569500000000116e+05 1.904672499999999900e+03 3.900053600000000188e+03 5.916483899999999994e+04 24 | 8.166793300000000454e+04 2.246062500000000000e+04 2.482049100000000180e+04 1.267166100000000006e+04 1.480380299999999988e+04 3.594409900000000107e+03 1.651352900000000091e+03 1.527349099999999908e+03 2.781551799999999814e+06 1.001775000000000000e+06 1.772554500000000000e+06 3.227541900000000023e+05 25 | -------------------------------------------------------------------------------- /national_enviro_footprint/data/Z.txt: -------------------------------------------------------------------------------- 1 | 9.003899699999999721e+05 7.116257899999999609e+03 2.854393900000000031e+03 1.325704900000000089e+04 4.657418499999999767e+04 2.892332499999999982e+03 1.886703299999999899e+03 2.654992100000000210e+05 2.264347399999999834e+04 3.135755200000000059e+03 3.962018900000000031e+03 5.238150200000000041e+02 5.174119200000000092e+03 3.632646999999999935e+03 3.449128900000000186e+01 1.150371500000000015e+04 5.403867500000000291e+04 2.686744299999999839e+03 2.841936700000000201e+03 1.994564499999999953e+03 2.445297100000000137e+04 1.599708900000000085e+03 1.343664800000000014e+03 2.596844299999999930e+04 2 | 1.650295200000000023e+03 9.349010000000000582e+04 6.849547900000000027e+02 4.392185599999999795e+03 2.206677500000000146e+04 2.554419699999999978e+02 2.582817000000000007e+02 1.785968300000000090e+04 3.078854799999999869e+01 8.461349899999999252e+03 8.146149099999999521e+01 1.214733399999999932e+02 1.263289299999999912e+03 2.956975999999999871e+01 3.345165100000000002e+00 8.499655800000000454e+02 1.028165999999999940e+03 1.528601800000000003e+04 6.236472999999999729e+02 1.056976300000000037e+03 1.154094100000000071e+04 4.584829199999999787e+02 1.121186200000000099e+03 4.209013700000000426e+03 3 | 6.001039400000000023e+04 2.429085299999999916e+04 3.893283400000000256e+05 1.611561199999999953e+05 3.364578599999999860e+05 1.951168599999999860e+05 4.368376900000000205e+03 4.146752800000000279e+05 1.025235799999999927e+03 2.891147900000000277e+02 3.325086499999999887e+03 2.233149600000000191e+03 9.417465599999999540e+03 4.186036199999999553e+03 1.153743900000000053e+02 1.432888400000000047e+03 1.595539800000000014e+03 1.029640499999999975e+03 8.532822399999999107e+03 5.875075100000000020e+03 1.010160699999999997e+04 5.412202000000000226e+03 4.642419499999999744e+02 5.977448500000000422e+03 4 | 2.548502300000000105e+04 3.492028800000000047e+03 5.896217100000000210e+04 7.377224699999999721e+05 2.285616799999999930e+05 2.410118300000000090e+04 2.808603599999999915e+03 4.474095000000000000e+05 1.990066500000000076e+02 2.430558999999999870e+01 1.979801799999999901e+02 1.228078499999999985e+04 1.188331199999999990e+04 2.111968099999999993e+02 2.281133700000000175e+01 1.056922299999999950e+03 1.216784400000000005e+03 5.292968200000000252e+02 1.188542300000000068e+03 1.750342599999999948e+04 1.398168200000000070e+04 7.858397999999999683e+02 3.662655799999999999e+02 5.912368800000000192e+03 5 | 1.589786000000000058e+05 4.402701600000000326e+04 8.910888199999999779e+04 4.655694000000000233e+05 3.493586700000000186e+06 7.083661299999999756e+04 2.577213599999999860e+04 1.038022500000000000e+06 1.090515699999999924e+04 7.731646099999999933e+03 1.078561299999999937e+04 2.251497499999999854e+04 2.772672899999999790e+05 6.336949200000000019e+03 1.117915299999999888e+03 3.291941799999999785e+04 2.786245799999999872e+04 4.878984599999999773e+03 2.507462299999999959e+04 1.067275399999999936e+05 5.137243699999999953e+05 2.985313699999999881e+04 2.368692199999999866e+04 1.264126600000000035e+05 6 | 1.628155100000000093e+05 2.564655199999999968e+04 1.078561900000000023e+05 1.568557399999999907e+05 3.886920100000000093e+05 8.494446099999999860e+05 4.431230700000000070e+04 7.709042099999999627e+05 3.452037699999999859e+03 8.604759199999999737e+02 1.236945299999999952e+04 1.034934599999999955e+04 1.269714300000000003e+04 1.390046999999999935e+04 1.335846399999999903e+03 7.508477899999999863e+03 9.980116799999999785e+03 1.402179000000000087e+03 1.062488999999999942e+04 1.414936700000000019e+04 1.253542799999999988e+04 5.093494400000000314e+04 6.208941300000000410e+03 2.732524199999999837e+04 7 | 2.542351700000000128e+05 4.517279299999999785e+04 1.152210399999999936e+05 1.521844200000000128e+05 6.432371099999999860e+05 1.906407300000000105e+05 1.077474199999999983e+05 5.178203900000000140e+05 2.761832300000000032e+03 2.622848599999999806e+02 1.896825399999999945e+03 8.922425799999999754e+02 3.331646799999999985e+03 7.389132100000000491e+02 1.305180400000000134e+02 3.066924500000000080e+03 3.077767199999999775e+03 1.813173800000000028e+03 2.034829500000000053e+03 3.576230599999999868e+03 1.029314600000000064e+04 4.559760100000000421e+03 3.690448199999999815e+03 1.492642300000000068e+04 8 | 5.101360100000000093e+05 6.352280399999999645e+04 2.833659899999999907e+05 6.523107299999999814e+05 1.457110199999999953e+06 4.435163300000000163e+05 8.754619599999999627e+04 8.445863099999999627e+06 1.129372299999999996e+04 4.486171000000000276e+03 8.610215899999999237e+03 3.256528499999999985e+04 4.861426299999999901e+04 1.360881199999999990e+04 3.796381300000000010e+03 9.671759200000000419e+04 5.484379100000000108e+03 2.648075600000000122e+03 1.284764600000000064e+04 1.411768200000000070e+04 2.617770000000000073e+04 9.090712299999999232e+03 1.218695099999999911e+04 1.293857500000000000e+05 9 | 1.863090999999999985e+04 3.929285899999999856e+02 1.771705200000000104e+02 6.534701900000000023e+02 2.169410300000000007e+03 1.227663500000000028e+02 6.442901200000000017e+01 6.780605700000000070e+03 9.493215500000000466e+05 1.007253000000000029e+05 2.036582099999999991e+04 2.384427500000000146e+04 9.064438899999999558e+04 4.913660300000000279e+04 1.472159000000000106e+03 2.980045999999999767e+05 3.139595000000000073e+04 1.436999800000000050e+03 2.506094200000000001e+03 1.799644399999999905e+03 2.179476199999999881e+04 1.153818999999999960e+03 8.191828299999999672e+02 1.559039899999999943e+04 10 | 3.340513300000000072e+02 1.184796800000000076e+04 2.115714700000000050e+02 9.877145799999999554e+02 6.827370799999999690e+03 1.396447799999999972e+02 2.925803399999999854e+01 4.431913899999999558e+03 3.344605300000000170e+03 5.163637199999999721e+05 5.814351399999999558e+03 1.130919000000000051e+04 9.104958500000000640e+04 6.233927499999999782e+03 4.051173900000000003e+02 7.662116899999999441e+04 2.313722999999999956e+03 2.437493899999999849e+04 9.335234000000000378e+02 2.666980399999999918e+03 1.899063599999999860e+04 9.301123900000000049e+02 3.627513699999999972e+03 9.399195499999999811e+03 11 | 5.996369300000000067e+02 4.145516499999999951e+02 1.649600700000000143e+04 1.305642100000000028e+04 6.724214200000000346e+03 1.233977399999999943e+04 4.907689500000000038e+01 1.959000000000000000e+03 3.173918400000000111e+04 2.456538499999999840e+04 3.484781099999999860e+05 1.213235800000000017e+05 4.087983699999999953e+05 1.746341199999999953e+05 1.237539500000000089e+03 9.742486400000000140e+04 8.784105600000000322e+02 9.379017599999999675e+02 8.076700700000000325e+03 4.876501000000000204e+03 1.130469399999999951e+04 1.437504600000000028e+04 4.329260100000000193e+02 2.828408300000000054e+03 12 | 8.391278600000000552e+02 5.802604000000000184e+01 5.560561300000000529e+02 6.400755299999999806e+03 1.044640899999999965e+04 4.365647999999999911e+02 9.217860600000000204e+01 3.132775000000000091e+03 1.130883899999999994e+04 5.186768299999999726e+03 4.019042199999999866e+04 9.079305000000000000e+05 5.243903900000000140e+05 1.044898300000000017e+04 1.199890499999999975e+03 8.506755800000000454e+04 1.182827500000000100e+03 2.483916900000000112e+02 9.258465099999999666e+02 1.788742900000000009e+04 1.491388999999999942e+04 3.704233399999999961e+02 3.074290500000000179e+02 4.561365200000000186e+03 13 | 7.836697100000000319e+03 3.034239599999999882e+03 5.272346300000000156e+03 2.697804300000000148e+04 2.000644400000000023e+05 3.748661099999999806e+03 1.499796199999999999e+03 6.047382499999999709e+04 7.957922699999999895e+04 1.077173999999999942e+05 1.530051000000000058e+05 6.873315999999999767e+05 4.457143299999999814e+06 8.356125299999999697e+04 7.237635599999999613e+03 5.013234299999999930e+05 2.045320100000000093e+04 3.009441499999999905e+03 1.551922299999999996e+04 8.895564299999999639e+04 3.326682100000000210e+05 1.471443499999999949e+04 2.024904599999999846e+04 7.588843600000000151e+04 14 | 4.041016599999999926e+03 5.057287200000000098e+02 5.808829999999999927e+03 5.764971400000000358e+03 8.100031299999999646e+03 2.878406999999999971e+04 2.022552300000000059e+03 1.631574300000000039e+04 7.379799000000000524e+04 2.921587700000000041e+04 8.007391099999999278e+04 2.719683200000000070e+05 2.735938699999999953e+05 2.196948299999999872e+05 9.388906300000000556e+03 2.469715700000000070e+05 6.155686899999999696e+03 6.879444200000000365e+02 7.303406699999999546e+03 9.610923800000000483e+03 9.453181099999999788e+03 2.418319900000000052e+04 3.793400799999999890e+03 1.320931300000000010e+04 15 | 1.266352100000000064e+03 1.609560700000000111e+02 1.045881699999999910e+03 6.943301599999999780e+02 2.776735499999999774e+03 3.663744500000000244e+02 6.730838499999999840e+02 2.426821500000000015e+03 8.390900299999999697e+04 3.944539299999999639e+04 6.022321499999999651e+04 1.138750000000000000e+05 2.330370499999999884e+05 4.207848900000000140e+04 6.508279599999999846e+03 1.218128999999999942e+05 6.444093400000000429e+02 4.266057000000000130e+02 4.104204500000000166e+02 7.926527200000000448e+02 2.243989099999999780e+03 9.139714400000000296e+02 7.395723299999999654e+02 3.390127800000000207e+03 16 | 3.336323899999999867e+03 4.125135300000000029e+02 4.505864199999999983e+03 4.730639500000000226e+03 9.985193499999999403e+03 3.949882500000000164e+03 2.001891399999999976e+03 3.892026299999999901e+04 9.188441099999999278e+04 7.629392399999999907e+04 1.575786799999999930e+05 3.019292999999999884e+05 7.946642199999999721e+05 1.551031199999999953e+05 1.930212900000000081e+04 1.425024600000000093e+06 7.286257900000000518e+02 3.009294699999999807e+02 1.585514200000000073e+03 1.806743600000000015e+03 3.635110400000000027e+03 1.110474699999999984e+03 1.118891699999999901e+03 1.428530199999999968e+04 17 | 8.749759699999999430e+04 1.781435799999999972e+03 8.112862199999999575e+02 1.732352799999999888e+03 4.694989999999999782e+03 3.885709299999999757e+02 4.200177499999999782e+02 2.625869599999999991e+04 5.385748700000000099e+04 2.525454099999999926e+03 3.709050999999999931e+03 1.606402299999999968e+03 1.036067100000000028e+04 2.734707600000000184e+03 1.863643899999999860e+02 1.781042900000000009e+04 6.761510100000000093e+05 1.603849400000000060e+04 2.792698300000000017e+04 2.048554599999999846e+04 6.547608400000000256e+04 1.492021299999999974e+04 1.261201399999999921e+04 2.337336799999999930e+05 18 | 2.662158400000000142e+02 1.333315099999999984e+04 2.338288100000000043e+02 8.631656299999999646e+02 7.183551000000000386e+03 9.507476200000000688e+01 5.820161000000000229e+01 3.827136599999999817e+03 6.410237399999999752e+01 9.966867299999999886e+03 5.813342800000000210e+01 7.616889999999999361e+01 1.427545100000000048e+03 4.621140100000000217e+01 7.406270899999999990e+00 9.078172700000000077e+02 1.894044000000000096e+03 4.916676900000000023e+04 1.254803000000000111e+03 2.202370699999999943e+03 1.754356299999999828e+04 8.101199000000000296e+02 1.601919599999999946e+03 1.067989700000000084e+04 19 | 1.961758399999999938e+03 1.595022200000000112e+03 4.083321800000000076e+04 1.598961100000000079e+04 1.718000000000000000e+04 1.384657200000000012e+05 2.817375299999999925e+02 5.910184500000000298e+03 1.495062799999999925e+03 6.251377999999999702e+03 3.740858200000000215e+04 5.230029599999999846e+03 2.271617900000000009e+04 1.303399299999999930e+05 1.100517399999999952e+02 3.049142699999999877e+03 1.608516699999999946e+04 7.387752300000000105e+03 1.706307500000000000e+05 5.937714699999999721e+04 1.437545899999999965e+05 1.665549599999999919e+05 7.181090600000000450e+03 1.517153699999999953e+05 20 | 1.564739499999999907e+03 1.392331399999999917e+02 1.763788000000000011e+03 1.780217099999999846e+04 2.743025999999999840e+04 1.044682399999999916e+03 1.928308399999999949e+02 8.453432300000000396e+03 5.426526499999999942e+02 4.661624700000000132e+01 3.088183999999999969e+02 3.767991599999999744e+04 5.101400899999999820e+04 3.313388199999999983e+02 4.050067399999999651e+01 1.458488599999999906e+03 2.075966300000000047e+04 5.072123199999999997e+03 2.319743899999999849e+04 4.358793099999999977e+05 1.956579599999999919e+05 1.516963400000000001e+04 3.993060399999999845e+03 1.828157000000000116e+05 21 | 1.730914500000000044e+04 8.692405000000000655e+03 1.192622700000000077e+04 5.052194799999999668e+04 3.773495300000000279e+05 1.076164999999999964e+04 4.091049100000000180e+03 1.176088999999999942e+05 9.911201999999999316e+03 1.260707400000000052e+04 7.396568199999999706e+03 2.548424199999999837e+04 2.533064400000000023e+05 5.325634600000000319e+03 1.290844800000000077e+03 4.533605799999999726e+04 4.920743000000000029e+04 1.983179699999999866e+04 4.672299300000000221e+04 3.152477100000000210e+05 1.539526199999999953e+06 4.041674500000000262e+04 2.130527000000000044e+04 2.900485499999999884e+05 22 | 1.303123199999999997e+04 1.463923500000000104e+03 1.141922099999999955e+04 1.288479099999999926e+04 2.824718999999999869e+04 8.289072599999999511e+04 1.008369499999999971e+04 5.350529499999999825e+04 3.239665100000000166e+03 7.176957200000000512e+02 6.665975699999999961e+03 1.044145900000000074e+04 1.158742000000000007e+04 1.747814099999999962e+04 1.064726699999999937e+03 9.114522999999999229e+03 6.670927599999999802e+04 1.514371299999999974e+04 5.448657200000000012e+04 1.160014299999999930e+05 1.442012600000000093e+05 3.308978599999999860e+05 6.447482899999999790e+04 2.532736600000000035e+05 23 | 2.899852199999999812e+03 4.396529899999999884e+02 2.653040500000000065e+03 1.670473600000000033e+03 7.079772200000000339e+03 9.412088599999999587e+02 1.712074599999999919e+03 5.408037699999999859e+03 6.660919800000000350e+02 7.267060999999999638e+01 3.499984400000000164e+02 2.459830599999999947e+02 7.990084500000000389e+02 3.732459900000000061e+02 7.537785599999999420e+01 1.168032799999999952e+03 1.231725000000000000e+05 2.645868500000000131e+04 5.583541300000000047e+04 1.643993299999999872e+05 2.390571900000000023e+05 1.133023500000000058e+05 9.440385899999999674e+04 3.801793200000000070e+05 24 | 1.074321099999999933e+04 1.575592399999999998e+03 1.510875300000000061e+04 1.534270000000000073e+04 3.804608099999999831e+04 1.314641100000000006e+04 6.510618599999999788e+03 1.537313599999999860e+05 3.648905900000000202e+03 1.201190800000000081e+03 2.605990200000000186e+03 8.236622499999999491e+03 1.158505800000000090e+04 5.310912999999999556e+03 1.358710199999999986e+03 2.631512299999999959e+04 7.125950699999999779e+04 2.351808199999999852e+04 5.572750800000000163e+04 1.904944500000000116e+05 2.862669699999999721e+05 1.225854499999999971e+05 7.145276200000000244e+04 1.762311199999999953e+06 25 | -------------------------------------------------------------------------------- /national_enviro_footprint/data/labels/labels.csv: -------------------------------------------------------------------------------- 1 | region_name,sector_category,final_demand_category,value_added_category,extension_name 2 | OECD,Food,Final consumption expenditure by household,value_added,CO2 emissions (unit: tonnes/year) 3 | BRICS,Clothing,Final consumption expenditure by NPISHs,,Blue water consumption (unit: million m3/year) 4 | ROW,Shelter,Final consumption expenditure by government,,Employment (unit: 1000 people/year) 5 | ,Construction,Gross capital formation,, 6 | ,Manufactured products,,, 7 | ,Mobility,,, 8 | ,Trade,,, 9 | ,Services,,, 10 | -------------------------------------------------------------------------------- /national_enviro_footprint/data/labels/multi_reg_final_demand.csv: -------------------------------------------------------------------------------- 1 | region,final_demand_category 2 | OECD,Final consumption expenditure by household 3 | OECD,Final consumption expenditure by NPISHs 4 | OECD,Final consumption expenditure by government 5 | OECD,Gross capital formation 6 | BRICS,Final consumption expenditure by household 7 | BRICS,Final consumption expenditure by NPISHs 8 | BRICS,Final consumption expenditure by government 9 | BRICS,Gross capital formation 10 | ROW,Final consumption expenditure by household 11 | ROW,Final consumption expenditure by NPISHs 12 | ROW,Final consumption expenditure by government 13 | ROW,Gross capital formation 14 | -------------------------------------------------------------------------------- /national_enviro_footprint/data/labels/multi_reg_sectors.csv: -------------------------------------------------------------------------------- 1 | region,sector 2 | OECD,Food 3 | OECD,Clothing 4 | OECD,Shelter 5 | OECD,Construction 6 | OECD,Manufactured products 7 | OECD,Mobility 8 | OECD,Trade 9 | OECD,Services 10 | BRICS,Food 11 | BRICS,Clothing 12 | BRICS,Shelter 13 | BRICS,Construction 14 | BRICS,Manufactured products 15 | BRICS,Mobility 16 | BRICS,Trade 17 | BRICS,Services 18 | ROW,Food 19 | ROW,Clothing 20 | ROW,Shelter 21 | ROW,Construction 22 | ROW,Manufactured products 23 | ROW,Mobility 24 | ROW,Trade 25 | ROW,Services 26 | -------------------------------------------------------------------------------- /national_enviro_footprint/data/pop.txt: -------------------------------------------------------------------------------- 1 | 1.000422900000000000e+09 3.035558700000000000e+09 3.221559000000000000e+09 2 | -------------------------------------------------------------------------------- /physical_n_hybrid_IO/figures/figure1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/physical_n_hybrid_IO/figures/figure1.jpg -------------------------------------------------------------------------------- /physical_n_hybrid_IO/figures/figure2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/physical_n_hybrid_IO/figures/figure2.png -------------------------------------------------------------------------------- /physical_n_hybrid_IO/hybrid_IO_sv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Practical 8: Physical and Hybrid Input-Output Tables\n", 9 | "\n", 10 | "Objectives\n", 11 | "- Understand the structure of Hybrid Input-Output Tables (HIOT)\n", 12 | "- Analyze HIOT data\n", 13 | "\n", 14 | "Download the the MR_HIOT data from: https://zenodo.org/record/7244919 (n.b. ignore files that start with MR_HSUT or MR_HUSE )" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": null, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "# Import packages\n", 24 | "import pandas as pd\n", 25 | "import numpy as np" 26 | ] 27 | }, 28 | { 29 | "attachments": {}, 30 | "cell_type": "markdown", 31 | "metadata": {}, 32 | "source": [ 33 | "### Exercise 1: Understand data availability in HIOT" 34 | ] 35 | }, 36 | { 37 | "attachments": {}, 38 | "cell_type": "markdown", 39 | "metadata": {}, 40 | "source": [ 41 | "Import the following data\n", 42 | "\n", 43 | "- MR_HIOT_2011_v3_3_18_xx_principal_production.csv indicates the principal production of the productive activities;\n", 44 | "- MR_HIOT_2011_v3_3_18_xx_by_product_technology.csv indicates the matrix of the uses where by-products are included with a negative sign;\n", 45 | "- MR_HIOT_2011_v3_3_18_xx_FD.csv includes the consumption of final consumers\n", 46 | "- MR_HIOT_2011_v3_3_18_xx_stock_to_waste.csv includes the demand of waste treatment services to treat the stock reduction\n", 47 | "- MR_HIOT_2011_v3_3_18_xx_extensions.csv includes the extensions as reported in the HSUTs. Very minor changes are applied\n", 48 | "\n", 49 | "\n", 50 | "In this practical you will only use a few of the imported datasets, this exercise is to help you understand the variety of the data. If you so wish, you may also perform additional analysis with the imported datasets " 51 | ] 52 | }, 53 | { 54 | "attachments": {}, 55 | "cell_type": "markdown", 56 | "metadata": {}, 57 | "source": [ 58 | "1.1 Inter-industry matrix" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": null, 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [ 67 | "Z = None" 68 | ] 69 | }, 70 | { 71 | "attachments": {}, 72 | "cell_type": "markdown", 73 | "metadata": {}, 74 | "source": [ 75 | "1.2 Final demand" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [ 84 | "Y = None" 85 | ] 86 | }, 87 | { 88 | "attachments": {}, 89 | "cell_type": "markdown", 90 | "metadata": {}, 91 | "source": [ 92 | "1.3 Extensions" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "metadata": {}, 99 | "outputs": [], 100 | "source": [ 101 | "extensions = None" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": null, 107 | "metadata": {}, 108 | "outputs": [], 109 | "source": [ 110 | "extensions.sheet_names" 111 | ] 112 | }, 113 | { 114 | "attachments": {}, 115 | "cell_type": "markdown", 116 | "metadata": {}, 117 | "source": [ 118 | "1.4 Resource extraction" 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": null, 124 | "metadata": {}, 125 | "outputs": [], 126 | "source": [ 127 | "# Resource extraction matrix of Z\n", 128 | "RE = None\n", 129 | "# Resource extraction matrix of Y\n", 130 | "RE_FD = None" 131 | ] 132 | }, 133 | { 134 | "attachments": {}, 135 | "cell_type": "markdown", 136 | "metadata": {}, 137 | "source": [ 138 | "1.5 Waste supply and use accounts" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": null, 144 | "metadata": {}, 145 | "outputs": [], 146 | "source": [ 147 | "# Waste supply matrix of Z\n", 148 | "WS = None\n", 149 | "# Waste supply matrix of Y\n", 150 | "WS_FD = None\n", 151 | "\n", 152 | "# Waste use matrix of Z\n", 153 | "WU = None\n", 154 | "# Waste use matrix of Y => This is all 0's so it can also be ignored\n", 155 | "WU_FD = None" 156 | ] 157 | }, 158 | { 159 | "attachments": {}, 160 | "cell_type": "markdown", 161 | "metadata": {}, 162 | "source": [ 163 | "1.6 Stock additions" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": null, 169 | "metadata": {}, 170 | "outputs": [], 171 | "source": [ 172 | "# Stock addition matrix of Z\n", 173 | "SA = None\n", 174 | "# Stock addition matrix of Y\n", 175 | "SA_FD = None" 176 | ] 177 | }, 178 | { 179 | "attachments": {}, 180 | "cell_type": "markdown", 181 | "metadata": {}, 182 | "source": [ 183 | "1.7 Stock depletion matrix" 184 | ] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "execution_count": null, 189 | "metadata": {}, 190 | "outputs": [], 191 | "source": [ 192 | "# Stock depletion matrix\n", 193 | "SD = None" 194 | ] 195 | }, 196 | { 197 | "attachments": {}, 198 | "cell_type": "markdown", 199 | "metadata": {}, 200 | "source": [ 201 | "1.8 Emissions" 202 | ] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "execution_count": null, 207 | "metadata": {}, 208 | "outputs": [], 209 | "source": [ 210 | "EM = None\n", 211 | "EM_FD = None" 212 | ] 213 | }, 214 | { 215 | "attachments": {}, 216 | "cell_type": "markdown", 217 | "metadata": {}, 218 | "source": [ 219 | "## Exercise 2: Calculate the global circularity gap\n", 220 | "\n", 221 | "Circularity gap in absolute terms\n", 222 | "\n", 223 | "$ CG = W_{sup} + S_{dep} - W_{rec}$\n", 224 | "\n", 225 | "Where:\n", 226 | "- $CG$ is the circularity gap\n", 227 | "- $W_{sup}$ is the global waste supply\n", 228 | "- $S_{dep}$ is the global stock depletation \n", 229 | "- $W_{rec}$ is the global waste use/recovery \n", 230 | "\n", 231 | "\n", 232 | "Circularity gap index\n", 233 | "\n", 234 | "$ CGI = \\frac{CG}{W_{sup} + S_{dep}} \\times 100$\n", 235 | "\n", 236 | "\n", 237 | "\n", 238 | "Methods from:\n", 239 | " \n", 240 | "Aguilar-Hernandez, G. A., Sigüenza-Sanchez, C. P., Donati, F., Merciai, S., Schmidt, J., Rodrigues, J. F., & Tukker, A. (2019). The circularity gap of nations: A multiregional analysis of waste generation, recovery, and stock depletion in 2011. Resources, Conservation and Recycling, 151, 104452." 241 | ] 242 | }, 243 | { 244 | "attachments": {}, 245 | "cell_type": "markdown", 246 | "metadata": {}, 247 | "source": [ 248 | "### 2.1: Calculate the global total waste generation" 249 | ] 250 | }, 251 | { 252 | "cell_type": "code", 253 | "execution_count": null, 254 | "metadata": {}, 255 | "outputs": [], 256 | "source": [ 257 | "WS_tot = None\n", 258 | "WS_tot" 259 | ] 260 | }, 261 | { 262 | "attachments": {}, 263 | "cell_type": "markdown", 264 | "metadata": {}, 265 | "source": [ 266 | "### 2.2: Calculate global total waste use (i.e., recovery)" 267 | ] 268 | }, 269 | { 270 | "cell_type": "code", 271 | "execution_count": null, 272 | "metadata": {}, 273 | "outputs": [], 274 | "source": [ 275 | "WU_tot = None\n", 276 | "WU_tot" 277 | ] 278 | }, 279 | { 280 | "attachments": {}, 281 | "cell_type": "markdown", 282 | "metadata": {}, 283 | "source": [ 284 | "### 2.3: Calculate global total stock degradation" 285 | ] 286 | }, 287 | { 288 | "cell_type": "code", 289 | "execution_count": null, 290 | "metadata": {}, 291 | "outputs": [], 292 | "source": [ 293 | "SD_tot = None\n", 294 | "\n", 295 | "SD_tot" 296 | ] 297 | }, 298 | { 299 | "attachments": {}, 300 | "cell_type": "markdown", 301 | "metadata": {}, 302 | "source": [ 303 | "### 2.4: Circularity gap calculations\n" 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "execution_count": null, 309 | "metadata": {}, 310 | "outputs": [], 311 | "source": [ 312 | "# CIRCULARITY GAP CALCULATION\n", 313 | "circularity_gap = None\n" 314 | ] 315 | }, 316 | { 317 | "attachments": {}, 318 | "cell_type": "markdown", 319 | "metadata": {}, 320 | "source": [ 321 | "## Exercise 3: Sankey Diagram of global material flows\n", 322 | "\n", 323 | "In this exercise you will use precalculate global material flows obtained from an earlier version of exiobase MRHIOT (v3.3.15)\n", 324 | "\n", 325 | "Please, ensure that floweaver and ipysankeywidget are installed in your environment" 326 | ] 327 | }, 328 | { 329 | "cell_type": "code", 330 | "execution_count": null, 331 | "metadata": {}, 332 | "outputs": [], 333 | "source": [ 334 | "import floweaver as fw\n", 335 | "from ipysankeywidget import SankeyWidget" 336 | ] 337 | }, 338 | { 339 | "attachments": {}, 340 | "cell_type": "markdown", 341 | "metadata": {}, 342 | "source": [ 343 | "We want to create a Sankey diagram of the global material inputs and outputs. Figure 1 shows a diagram of the inputs and outputs of an economy. \n", 344 | "\n", 345 | "\n", 346 | "\n", 347 | "\n", 348 | "Figure 1. System definition of the input-output material flows of a country. Solid blocks indicate economic activities of: \n", 349 | "- I&C = Intermediate sectors and final demand; \n", 350 | "- T = waste treatment activities; \n", 351 | "- RoW = Rest of the world. Solid circles indicate resource stocks of: \n", 352 | " - N = Natural resources; \n", 353 | " - S = Material in-use stocks; \n", 354 | " - DPO = Domestic processed output. \n", 355 | "- Solid and dashed lines indicate flows of: \n", 356 | " - m = imports; \n", 357 | " - r = resource extraction domestically; \n", 358 | " - w_rec = waste recovery; \n", 359 | " - e = exports; \n", 360 | " - s_add = stock additions; \n", 361 | " - s_dep = stock depletion, \n", 362 | " - w_sup = waste generation; \n", 363 | " - b_(I&C) = dissipative emissions, others combustion and biomass residues from intermediate activities and final demand; \n", 364 | " - and b_T = dissipative emissions and others combustion and biomass residues from waste treatment.\n", 365 | "\n", 366 | "\n", 367 | "The input and outputs are balanced as:\n", 368 | "\n", 369 | "$ m + r + w_{rec}= e + b_{I\\&C} + w_{sup} + S_{add} $\n", 370 | "\n", 371 | "When considering the global inputs and outputs, imports and exports are zero. Thus, for global inputs and outputs:\n", 372 | "\n", 373 | "$ r + w_{rec} = b_{I\\&C} + w_{sup} + S_{add} $\n", 374 | "\n" 375 | ] 376 | }, 377 | { 378 | "cell_type": "code", 379 | "execution_count": null, 380 | "metadata": {}, 381 | "outputs": [], 382 | "source": [ 383 | "# Use this data for you calculations\n", 384 | "material_flows = {'Gigatonnes (Gt)': {'Material extraction': 73.475,\n", 385 | " 'Emissions': 40.529,\n", 386 | " 'Waste': 6.438,\n", 387 | " 'Inflows-to-Stocks': 29.624,\n", 388 | " 'Outflows-from-Stock': 2.268,\n", 389 | " 'Waste-from-treatment': 5.590,\n", 390 | " 'Waste-recovery': 3.116}}\n", 391 | "\n", 392 | "material_flows = pd.Series(material_flows['Gigatonnes (Gt)'])\n", 393 | "material_flows" 394 | ] 395 | }, 396 | { 397 | "attachments": {}, 398 | "cell_type": "markdown", 399 | "metadata": {}, 400 | "source": [ 401 | "### 3.1 Based on Figure 1, create a new dataframe with the Floweaver structure. \n", 402 | "\n", 403 | "Floweaver requires a pd.dataframe with four columns\n", 404 | "\n", 405 | "| Source |\tTarget | Type | Value |\n", 406 | "|--------|----------|-------|-------|\n", 407 | "| [Initial node] | [Final node] |\t[Name of flow] | [Value of flow]| \n", 408 | "\n", 409 | "For example, in figure 1, material extraction (N) is an initial node, demand (I&C) is a final node, with flow type called “material”, and a value of 73.4 Gt (which is allocated in material_flows.iloc[0,0]]). \n", 410 | "\n" 411 | ] 412 | }, 413 | { 414 | "cell_type": "code", 415 | "execution_count": null, 416 | "metadata": {}, 417 | "outputs": [], 418 | "source": [ 419 | "flows = None # Dataframe in structure required by Floweaver\n", 420 | "flows.columns = None\n", 421 | "\n", 422 | "flows" 423 | ] 424 | }, 425 | { 426 | "attachments": {}, 427 | "cell_type": "markdown", 428 | "metadata": {}, 429 | "source": [ 430 | "### 3.2 Create Floweaver settings (nodes, ordering, and bundle)" 431 | ] 432 | }, 433 | { 434 | "cell_type": "code", 435 | "execution_count": null, 436 | "metadata": {}, 437 | "outputs": [], 438 | "source": [ 439 | "# Nodes = Group of processes from the underlying dataset\n", 440 | "nodes = None\n", 441 | "# Ordering = The order of processes in the diagram\n", 442 | "ordering = None \n", 443 | "\n", 444 | "# Bundle = a set of flows between two processes\n", 445 | "bundles = None" 446 | ] 447 | }, 448 | { 449 | "attachments": {}, 450 | "cell_type": "markdown", 451 | "metadata": {}, 452 | "source": [ 453 | "### 3.3 Create Sankey diagram with the following code" 454 | ] 455 | }, 456 | { 457 | "cell_type": "code", 458 | "execution_count": null, 459 | "metadata": {}, 460 | "outputs": [], 461 | "source": [ 462 | "sdd = fw.SankeyDefinition(nodes, bundles, ordering) # Connect all settings\n", 463 | "size = dict(width=750, height=300) # Adjust diagram size\n", 464 | "fw.weave(sdd, flows, palette=['green']).to_widget(**size) # Display Sankey diagram" 465 | ] 466 | } 467 | ], 468 | "metadata": { 469 | "kernelspec": { 470 | "display_name": "env_advanced_eeio", 471 | "language": "python", 472 | "name": "python3" 473 | }, 474 | "language_info": { 475 | "codemirror_mode": { 476 | "name": "ipython", 477 | "version": 3 478 | }, 479 | "file_extension": ".py", 480 | "mimetype": "text/x-python", 481 | "name": "python", 482 | "nbconvert_exporter": "python", 483 | "pygments_lexer": "ipython3", 484 | "version": "3.9.16" 485 | }, 486 | "orig_nbformat": 4 487 | }, 488 | "nbformat": 4, 489 | "nbformat_minor": 2 490 | } 491 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pandas 2 | numpy 3 | matplotlib 4 | -------------------------------------------------------------------------------- /structural_decomposition_analysis/structural_decomposition_sv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": { 7 | "slideshow": { 8 | "slide_type": "slide" 9 | } 10 | }, 11 | "source": [ 12 | "# Practical 11: Structural decomposition analysis\n", 13 | "\n", 14 | "Objectives\n", 15 | "- Construct different SDA methods in Python\n", 16 | "- Reproduce the SDA examples on page 348-351 of Miller & Blair\n", 17 | "- Reproduce output of table 8.1 on page 351 of Miller & Blair" 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": null, 23 | "metadata": { 24 | "slideshow": { 25 | "slide_type": "slide" 26 | } 27 | }, 28 | "outputs": [], 29 | "source": [ 30 | "# Import packages\n", 31 | "import numpy as np\n", 32 | "import pandas as pd" 33 | ] 34 | }, 35 | { 36 | "attachments": {}, 37 | "cell_type": "markdown", 38 | "metadata": { 39 | "slideshow": { 40 | "slide_type": "slide" 41 | } 42 | }, 43 | "source": [ 44 | "## Exercise 1: Construct the SDA" 45 | ] 46 | }, 47 | { 48 | "attachments": {}, 49 | "cell_type": "markdown", 50 | "metadata": { 51 | "slideshow": { 52 | "slide_type": "subslide" 53 | } 54 | }, 55 | "source": [ 56 | "### 1.1 Define input data for baseline" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": null, 62 | "metadata": {}, 63 | "outputs": [], 64 | "source": [ 65 | "# t=0 transaction matrix and final demand vector\n", 66 | "Z_0 = pd.DataFrame([\n", 67 | " [10, 20, 25],\n", 68 | " [15, 5, 30],\n", 69 | " [30, 40, 5]\n", 70 | "])\n", 71 | "\n", 72 | "y_0 = pd.Series([45,30,25])" 73 | ] 74 | }, 75 | { 76 | "attachments": {}, 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "### 1.2 Define input data for delta" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [ 89 | "# t=1 transaction matrix and final demand vector\n", 90 | "\n", 91 | "Z_1 = pd.DataFrame([\n", 92 | " [12, 15, 35],\n", 93 | " [24, 11, 30],\n", 94 | " [36, 50, 8]\n", 95 | "])\n", 96 | "\n", 97 | "y_1 = pd.Series([50,35,26])" 98 | ] 99 | }, 100 | { 101 | "attachments": {}, 102 | "cell_type": "markdown", 103 | "metadata": { 104 | "slideshow": { 105 | "slide_type": "subslide" 106 | } 107 | }, 108 | "source": [ 109 | "### 1.3 Calculate total requirements matrix" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": null, 115 | "metadata": { 116 | "slideshow": { 117 | "slide_type": "fragment" 118 | } 119 | }, 120 | "outputs": [], 121 | "source": [ 122 | "# t=0 Baseline year\n", 123 | "\n", 124 | "x_0 = None\n", 125 | "A_0 = None\n", 126 | "L_0 = None" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": null, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [ 135 | "# t=1 next year\n", 136 | "\n", 137 | "x_1 = None\n", 138 | "A_1 = None\n", 139 | "L_1 = None" 140 | ] 141 | }, 142 | { 143 | "attachments": {}, 144 | "cell_type": "markdown", 145 | "metadata": { 146 | "slideshow": { 147 | "slide_type": "subslide" 148 | } 149 | }, 150 | "source": [ 151 | "### 1.4 Calculate your deltas for the decomposition" 152 | ] 153 | }, 154 | { 155 | "attachments": {}, 156 | "cell_type": "markdown", 157 | "metadata": {}, 158 | "source": [ 159 | "#### 1.4.1 Change in total requirement matrix" 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "execution_count": null, 165 | "metadata": {}, 166 | "outputs": [], 167 | "source": [ 168 | "L_delta = None" 169 | ] 170 | }, 171 | { 172 | "attachments": {}, 173 | "cell_type": "markdown", 174 | "metadata": {}, 175 | "source": [ 176 | "#### 1.4.2 Change in final demand" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": null, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [ 185 | "y_delta = None" 186 | ] 187 | }, 188 | { 189 | "attachments": {}, 190 | "cell_type": "markdown", 191 | "metadata": {}, 192 | "source": [ 193 | "#### 1.4.3 Change in total output to be used as check" 194 | ] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": null, 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [ 202 | "x_delta = None" 203 | ] 204 | }, 205 | { 206 | "attachments": {}, 207 | "cell_type": "markdown", 208 | "metadata": {}, 209 | "source": [ 210 | "### 1.5 Decomposition\n", 211 | "\n", 212 | "All input data for our SDA is now complete.\n", 213 | "\n", 214 | "Start decomposing the effect of technology change and final demand change on the total output. \n", 215 | "\n", 216 | "A two factor decomposition." 217 | ] 218 | }, 219 | { 220 | "attachments": {}, 221 | "cell_type": "markdown", 222 | "metadata": {}, 223 | "source": [ 224 | "#### 1.5.1 Decomposition (eq 8.3)" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": null, 230 | "metadata": {}, 231 | "outputs": [], 232 | "source": [ 233 | "tech_change = None\n", 234 | "y_change = None" 235 | ] 236 | }, 237 | { 238 | "cell_type": "code", 239 | "execution_count": null, 240 | "metadata": {}, 241 | "outputs": [], 242 | "source": [ 243 | "# Check if result is complete\n", 244 | "\n", 245 | "tot_change = None\n", 246 | "check = None\n", 247 | "\n", 248 | "if np.isclose(check, np.zeros(check.shape), atol=1E-6).all():\n", 249 | " print('Decomposition correct')\n", 250 | "else:\n", 251 | " print('ERROR - check your decomposition')" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "execution_count": null, 257 | "metadata": {}, 258 | "outputs": [], 259 | "source": [ 260 | "# Organize the labels for the table in which you will store your results\n", 261 | "sectors = None\n", 262 | "columns = None\n", 263 | "\n", 264 | "# create a dataframe where you will store your intermediary results\n", 265 | "step = None\n", 266 | "\n", 267 | "# add results to your dataframe\n", 268 | "\n", 269 | "# Add the row of total\n", 270 | "\n", 271 | "# Add the index labels\n", 272 | "\n", 273 | "\n", 274 | "step" 275 | ] 276 | }, 277 | { 278 | "cell_type": "code", 279 | "execution_count": null, 280 | "metadata": {}, 281 | "outputs": [], 282 | "source": [ 283 | "# Make a copy of step that you will call results \n", 284 | "# and which you can use as a basis to assemble all results\n", 285 | "results = None\n", 286 | "results" 287 | ] 288 | }, 289 | { 290 | "attachments": {}, 291 | "cell_type": "markdown", 292 | "metadata": {}, 293 | "source": [ 294 | "#### 1.5.2 Decomposition (eq 8.4)" 295 | ] 296 | }, 297 | { 298 | "cell_type": "code", 299 | "execution_count": null, 300 | "metadata": {}, 301 | "outputs": [], 302 | "source": [ 303 | "tech_change = None\n", 304 | "y_change = None" 305 | ] 306 | }, 307 | { 308 | "cell_type": "code", 309 | "execution_count": null, 310 | "metadata": {}, 311 | "outputs": [], 312 | "source": [ 313 | "# check if our result is complete\n", 314 | "tot_change = None\n", 315 | "\n", 316 | "check = None\n", 317 | "\n", 318 | "if np.isclose(check, np.zeros(check.shape), atol=1E-6).all():\n", 319 | " print('Decomposition correct')\n", 320 | "else:\n", 321 | " print('ERROR - check your decomposition')\n" 322 | ] 323 | }, 324 | { 325 | "cell_type": "code", 326 | "execution_count": null, 327 | "metadata": {}, 328 | "outputs": [], 329 | "source": [ 330 | "# create a dataframe where you will store your intermediary results\n", 331 | "step = None\n", 332 | "\n", 333 | "# add results to your dataframe\n", 334 | "\n", 335 | "# Add the row of total\n", 336 | "\n", 337 | "# Add the index labels\n", 338 | "\n", 339 | "\n", 340 | "step" 341 | ] 342 | }, 343 | { 344 | "cell_type": "code", 345 | "execution_count": null, 346 | "metadata": {}, 347 | "outputs": [], 348 | "source": [ 349 | "# Concatenate your results\n", 350 | "results = None\n", 351 | "results" 352 | ] 353 | }, 354 | { 355 | "attachments": {}, 356 | "cell_type": "markdown", 357 | "metadata": {}, 358 | "source": [ 359 | "#### 1.5.3 Decomposition (eq 8.5)" 360 | ] 361 | }, 362 | { 363 | "cell_type": "code", 364 | "execution_count": null, 365 | "metadata": {}, 366 | "outputs": [], 367 | "source": [ 368 | "tech_change = None\n", 369 | "y_change = None\n", 370 | "interaction = None" 371 | ] 372 | }, 373 | { 374 | "cell_type": "code", 375 | "execution_count": null, 376 | "metadata": {}, 377 | "outputs": [], 378 | "source": [ 379 | "# check if our result is complete\n", 380 | "tot_change = None\n", 381 | "\n", 382 | "check = None\n", 383 | "\n", 384 | "if np.isclose(check, np.zeros(check.shape), atol=1E-6).all():\n", 385 | " print('Decomposition correct')\n", 386 | "else:\n", 387 | " print('ERROR - check your decomposition')\n" 388 | ] 389 | }, 390 | { 391 | "cell_type": "code", 392 | "execution_count": null, 393 | "metadata": {}, 394 | "outputs": [], 395 | "source": [ 396 | "# create a dataframe where you will store your intermediary results\n", 397 | "step = None\n", 398 | "\n", 399 | "# add results to your dataframe\n", 400 | "\n", 401 | "# Add the row of total\n", 402 | "\n", 403 | "# Add the index labels\n", 404 | "\n", 405 | "\n", 406 | "step" 407 | ] 408 | }, 409 | { 410 | "cell_type": "code", 411 | "execution_count": null, 412 | "metadata": {}, 413 | "outputs": [], 414 | "source": [ 415 | "# Concatenate your results\n", 416 | "results = None\n", 417 | "results" 418 | ] 419 | }, 420 | { 421 | "attachments": {}, 422 | "cell_type": "markdown", 423 | "metadata": {}, 424 | "source": [ 425 | "#### 1.5.4 Decomposition (eq 8.6)" 426 | ] 427 | }, 428 | { 429 | "cell_type": "code", 430 | "execution_count": null, 431 | "metadata": {}, 432 | "outputs": [], 433 | "source": [ 434 | "tech_change = None\n", 435 | "y_change = None\n", 436 | "interaction = None" 437 | ] 438 | }, 439 | { 440 | "cell_type": "code", 441 | "execution_count": null, 442 | "metadata": {}, 443 | "outputs": [], 444 | "source": [ 445 | "# check if our result is complete\n", 446 | "tot_change = None\n", 447 | "check = None\n", 448 | "\n", 449 | "if np.isclose(check, np.zeros(check.shape), atol=1E-6).all():\n", 450 | " print('Decomposition correct')\n", 451 | "else:\n", 452 | " print('ERROR - check your decomposition')" 453 | ] 454 | }, 455 | { 456 | "cell_type": "code", 457 | "execution_count": null, 458 | "metadata": {}, 459 | "outputs": [], 460 | "source": [ 461 | "# create a dataframe where you will store your intermediary results\n", 462 | "step = None\n", 463 | "\n", 464 | "# add results to your dataframe\n", 465 | "\n", 466 | "# Add the row of total\n", 467 | "\n", 468 | "# Add the index labels\n", 469 | "\n", 470 | "\n", 471 | "step" 472 | ] 473 | }, 474 | { 475 | "cell_type": "code", 476 | "execution_count": null, 477 | "metadata": {}, 478 | "outputs": [], 479 | "source": [ 480 | "# Concatenate your results\n", 481 | "results = None\n", 482 | "results" 483 | ] 484 | }, 485 | { 486 | "attachments": {}, 487 | "cell_type": "markdown", 488 | "metadata": {}, 489 | "source": [ 490 | "#### 1.5.5 Decomposition (eq 8.7)" 491 | ] 492 | }, 493 | { 494 | "cell_type": "code", 495 | "execution_count": null, 496 | "metadata": {}, 497 | "outputs": [], 498 | "source": [ 499 | "tech_change = None\n", 500 | "y_change = None" 501 | ] 502 | }, 503 | { 504 | "cell_type": "code", 505 | "execution_count": null, 506 | "metadata": {}, 507 | "outputs": [], 508 | "source": [ 509 | "# check if our result is complete\n", 510 | "tot_change = None\n", 511 | "check = None\n", 512 | "\n", 513 | "if np.isclose(check, np.zeros(check.shape), atol=1E-6).all():\n", 514 | " print('Decomposition correct')\n", 515 | "else:\n", 516 | " print('ERROR - check your decomposition')" 517 | ] 518 | }, 519 | { 520 | "cell_type": "code", 521 | "execution_count": null, 522 | "metadata": {}, 523 | "outputs": [], 524 | "source": [ 525 | "# create a dataframe where you will store your intermediary results\n", 526 | "step = None\n", 527 | "\n", 528 | "# add results to your dataframe\n", 529 | "\n", 530 | "# Add the row of total\n", 531 | "\n", 532 | "# Add the index labels\n", 533 | "\n", 534 | "\n", 535 | "step" 536 | ] 537 | }, 538 | { 539 | "attachments": {}, 540 | "cell_type": "markdown", 541 | "metadata": {}, 542 | "source": [ 543 | "### 1.6 Output table 8.1" 544 | ] 545 | }, 546 | { 547 | "cell_type": "code", 548 | "execution_count": null, 549 | "metadata": {}, 550 | "outputs": [], 551 | "source": [ 552 | "# Concatenate your results\n", 553 | "results = None\n", 554 | "results" 555 | ] 556 | } 557 | ], 558 | "metadata": { 559 | "celltoolbar": "Slideshow", 560 | "kernelspec": { 561 | "display_name": "Python 3 (ipykernel)", 562 | "language": "python", 563 | "name": "python3" 564 | }, 565 | "language_info": { 566 | "codemirror_mode": { 567 | "name": "ipython", 568 | "version": 3 569 | }, 570 | "file_extension": ".py", 571 | "mimetype": "text/x-python", 572 | "name": "python", 573 | "nbconvert_exporter": "python", 574 | "pygments_lexer": "ipython3", 575 | "version": "3.9.16" 576 | } 577 | }, 578 | "nbformat": 4, 579 | "nbformat_minor": 2 580 | } 581 | -------------------------------------------------------------------------------- /supply_chain_linkages/figures/linkages.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/supply_chain_linkages/figures/linkages.PNG -------------------------------------------------------------------------------- /supply_chain_linkages/power_series_expansion.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "slideshow": { 7 | "slide_type": "slide" 8 | } 9 | }, 10 | "source": [ 11 | "# Example of power series expansion" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 31, 17 | "metadata": { 18 | "slideshow": { 19 | "slide_type": "fragment" 20 | } 21 | }, 22 | "outputs": [], 23 | "source": [ 24 | "# import modules\n", 25 | "import pandas as pd\n", 26 | "import numpy as np" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "metadata": { 32 | "slideshow": { 33 | "slide_type": "subslide" 34 | } 35 | }, 36 | "source": [ 37 | "1. Inter-industry transactions" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 32, 43 | "metadata": { 44 | "slideshow": { 45 | "slide_type": "fragment" 46 | } 47 | }, 48 | "outputs": [ 49 | { 50 | "data": { 51 | "text/plain": [ 52 | "array([[ 0.6, 2.6, 0.5],\n", 53 | " [ 0.8, 30.6, 7.8],\n", 54 | " [ 0.9, 12.1, 23. ]])" 55 | ] 56 | }, 57 | "execution_count": 32, 58 | "metadata": {}, 59 | "output_type": "execute_result" 60 | } 61 | ], 62 | "source": [ 63 | "Z = np.array([\n", 64 | " [0.6,2.6,0.5],\n", 65 | " [0.8, 30.6, 7.8],\n", 66 | " [0.9,12.1,23]])\n", 67 | "\n", 68 | "Z" 69 | ] 70 | }, 71 | { 72 | "cell_type": "markdown", 73 | "metadata": { 74 | "slideshow": { 75 | "slide_type": "subslide" 76 | } 77 | }, 78 | "source": [ 79 | "2. Value added vector" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 33, 85 | "metadata": { 86 | "slideshow": { 87 | "slide_type": "fragment" 88 | } 89 | }, 90 | "outputs": [ 91 | { 92 | "data": { 93 | "text/plain": [ 94 | "array([ 3.3, 22.4, 52.5])" 95 | ] 96 | }, 97 | "execution_count": 33, 98 | "metadata": {}, 99 | "output_type": "execute_result" 100 | } 101 | ], 102 | "source": [ 103 | "# Value added (last row of the first table)\n", 104 | "v = np.array([3.30, 22.4, 52.5])\n", 105 | "v" 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "metadata": { 111 | "slideshow": { 112 | "slide_type": "subslide" 113 | } 114 | }, 115 | "source": [ 116 | "3. Final demand vector of products purchased by final consumers" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 34, 122 | "metadata": { 123 | "slideshow": { 124 | "slide_type": "fragment" 125 | } 126 | }, 127 | "outputs": [ 128 | { 129 | "data": { 130 | "text/plain": [ 131 | "array([ 1.9, 28.5, 47.8])" 132 | ] 133 | }, 134 | "execution_count": 34, 135 | "metadata": {}, 136 | "output_type": "execute_result" 137 | } 138 | ], 139 | "source": [ 140 | "y = np.array([1.9, 28.5, 47.8])\n", 141 | "y" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": 35, 147 | "metadata": {}, 148 | "outputs": [ 149 | { 150 | "data": { 151 | "text/plain": [ 152 | "array([[0.10714286, 0.03840473, 0.00596659],\n", 153 | " [0.14285714, 0.45199409, 0.09307876],\n", 154 | " [0.16071429, 0.17872969, 0.27446301]])" 155 | ] 156 | }, 157 | "execution_count": 35, 158 | "metadata": {}, 159 | "output_type": "execute_result" 160 | } 161 | ], 162 | "source": [ 163 | "x = Z.sum(1) + y\n", 164 | "A = Z @ np.diag(1/x)\n", 165 | "A" 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": 36, 171 | "metadata": {}, 172 | "outputs": [ 173 | { 174 | "data": { 175 | "text/plain": [ 176 | "array([[1.1374997 , 0.08638219, 0.02043636],\n", 177 | " [0.35414416, 1.93137726, 0.25068774],\n", 178 | " [0.33920879, 0.49491248, 1.44457108]])" 179 | ] 180 | }, 181 | "execution_count": 36, 182 | "metadata": {}, 183 | "output_type": "execute_result" 184 | } 185 | ], 186 | "source": [ 187 | "L = np.linalg.inv(np.eye(A.shape[0])-A)\n", 188 | "L" 189 | ] 190 | }, 191 | { 192 | "cell_type": "markdown", 193 | "metadata": {}, 194 | "source": [ 195 | "The Leontief as a power series expansion\n", 196 | "\n", 197 | "$\\mathbf{L} = \\mathbf{I} + \\mathbf{A} + \\mathbf{A}^{2} + \\mathbf{A}^{3} + ... + \\mathbf{A}^{n}$" 198 | ] 199 | }, 200 | { 201 | "cell_type": "code", 202 | "execution_count": 43, 203 | "metadata": {}, 204 | "outputs": [], 205 | "source": [ 206 | "def leontief_inverse_power_series(A, n_terms):\n", 207 | " \"\"\"\n", 208 | " Compute the Leontief inverse using power series expansion.\n", 209 | "\n", 210 | " Args:\n", 211 | " A: numpy array or pandas dataframe, the input-output matrix.\n", 212 | " n_terms: int, the number of terms in the power series expansion.\n", 213 | "\n", 214 | " Returns:\n", 215 | " L_approximate: numpy array, the Leontief inverse approximation.\n", 216 | " \"\"\"\n", 217 | " I = np.eye(A.shape[0])\n", 218 | " L_approximate = I.copy()\n", 219 | " A_power = I.copy()\n", 220 | " \n", 221 | " for i in range(n_terms):\n", 222 | " A_power = A_power @ A\n", 223 | " L_approximate += A_power\n", 224 | "\n", 225 | " return L_approximate" 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": 44, 231 | "metadata": {}, 232 | "outputs": [ 233 | { 234 | "data": { 235 | "text/plain": [ 236 | "(array([[1.1374997 , 0.08638219, 0.02043636],\n", 237 | " [0.35414415, 1.93137726, 0.25068774],\n", 238 | " [0.33920879, 0.49491247, 1.44457108]]),\n", 239 | " array([[1.1374997 , 0.08638219, 0.02043636],\n", 240 | " [0.35414416, 1.93137726, 0.25068774],\n", 241 | " [0.33920879, 0.49491248, 1.44457108]]))" 242 | ] 243 | }, 244 | "execution_count": 44, 245 | "metadata": {}, 246 | "output_type": "execute_result" 247 | } 248 | ], 249 | "source": [ 250 | "leontief_inverse_power_series(A, 30),L" 251 | ] 252 | } 253 | ], 254 | "metadata": { 255 | "celltoolbar": "Slideshow", 256 | "kernelspec": { 257 | "display_name": "EEIO", 258 | "language": "python", 259 | "name": "python3" 260 | }, 261 | "language_info": { 262 | "codemirror_mode": { 263 | "name": "ipython", 264 | "version": 3 265 | }, 266 | "file_extension": ".py", 267 | "mimetype": "text/x-python", 268 | "name": "python", 269 | "nbconvert_exporter": "python", 270 | "pygments_lexer": "ipython3", 271 | "version": "3.11.9" 272 | } 273 | }, 274 | "nbformat": 4, 275 | "nbformat_minor": 4 276 | } 277 | -------------------------------------------------------------------------------- /supply_n_use_tables/data/modified_supply_basic_price_AT_OECD_2015.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/supply_n_use_tables/data/modified_supply_basic_price_AT_OECD_2015.xlsx -------------------------------------------------------------------------------- /supply_n_use_tables/supply_n_use_tables_sv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "slideshow": { 7 | "slide_type": "slide" 8 | } 9 | }, 10 | "source": [ 11 | "# Practical 2: Supply and use tables\n", 12 | "\n", 13 | "## Learning objectives\n", 14 | "- Calculate product outputs in different valuations\n", 15 | "- Understand the structure of supply and use tables in practice\n", 16 | "- Distinguish valuations and types of productions" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 2, 22 | "metadata": { 23 | "slideshow": { 24 | "slide_type": "slide" 25 | } 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "# import modules\n", 30 | "import pandas as pd\n", 31 | "\n", 32 | "# Import data\n", 33 | "supply_ = pd.read_excel(\"data/modified_supply_basic_price_AT_OECD_2015.xlsx\", engine=\"openpyxl\", skipfooter=3)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 3, 39 | "metadata": { 40 | "slideshow": { 41 | "slide_type": "slide" 42 | } 43 | }, 44 | "outputs": [], 45 | "source": [ 46 | "# organize you row and column labels\n", 47 | "supply_col_lb = supply_.iloc[9,7:].to_list()\n", 48 | "supply_row_lb = supply_.iloc[11:, 2].to_list()" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "metadata": { 55 | "slideshow": { 56 | "slide_type": "slide" 57 | } 58 | }, 59 | "outputs": [], 60 | "source": [ 61 | "# isolate array with only values\n", 62 | "supply = supply_.iloc[11:,7:]" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": null, 68 | "metadata": { 69 | "slideshow": { 70 | "slide_type": "fragment" 71 | } 72 | }, 73 | "outputs": [], 74 | "source": [ 75 | "# assign clean labels to columns and row\n", 76 | "supply.columns = supply_col_lb\n", 77 | "supply.index = supply_row_lb" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "metadata": { 83 | "slideshow": { 84 | "slide_type": "slide" 85 | } 86 | }, 87 | "source": [ 88 | "## Exercise 1\n", 89 | "\n", 90 | "1. Look at the product list and select two products" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": 3, 96 | "metadata": { 97 | "slideshow": { 98 | "slide_type": "fragment" 99 | } 100 | }, 101 | "outputs": [], 102 | "source": [ 103 | "# Print product list (i.e., the index of your table)" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": null, 109 | "metadata": { 110 | "slideshow": { 111 | "slide_type": "slide" 112 | } 113 | }, 114 | "outputs": [], 115 | "source": [ 116 | "# Select two products\n", 117 | "products = []" 118 | ] 119 | }, 120 | { 121 | "cell_type": "markdown", 122 | "metadata": { 123 | "slideshow": { 124 | "slide_type": "slide" 125 | } 126 | }, 127 | "source": [ 128 | "2. Can you quantify their total supply, import, and which industries supply them?" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": null, 134 | "metadata": { 135 | "slideshow": { 136 | "slide_type": "slide" 137 | } 138 | }, 139 | "outputs": [], 140 | "source": [ 141 | "# Slice your data\n", 142 | "# replace none with your function\n", 143 | "p_1_supply = None\n", 144 | "p_2_supply = None\n", 145 | "\n", 146 | "# Isolate non zero values \n", 147 | "p_1_supply = None\n", 148 | "p_2_supply = None\n", 149 | "\n", 150 | "# Print results\n", 151 | "print(f\"{products[0]}:\\n\\n{p_1_supply}\\n\\n{products[1]}:\\n\\n{p_2_supply}\")\n" 152 | ] 153 | }, 154 | { 155 | "cell_type": "markdown", 156 | "metadata": { 157 | "slideshow": { 158 | "slide_type": "slide" 159 | } 160 | }, 161 | "source": [ 162 | "3. What is the total product output at basic price and at purchaser price?\n", 163 | "\n", 164 | " N.b. in the Supply and Use table Non-Deductible VAT is included in the Taxes less subsidies on products (see also page 86 Eurostat Manual of Supply, Use and Input-Output Tables)\n", 165 | "\n", 166 | "Tip: in the file \"modified_supply_basic_price_AT_OECD_2015.xlsx\" you can check whether the calculations are right in the columns \"Total supply at purchasers' prices\" and \"Total supply at basic prices\"\n", 167 | "\n", 168 | "Tip: you can use p_1_supply.loc[] to select the right rows" 169 | ] 170 | }, 171 | { 172 | "cell_type": "code", 173 | "execution_count": null, 174 | "metadata": { 175 | "slideshow": { 176 | "slide_type": "slide" 177 | } 178 | }, 179 | "outputs": [], 180 | "source": [ 181 | "# Total supply at basic and purchaser prices for product 1\n", 182 | "p_1_basic_price = None\n", 183 | "\n", 184 | "p_1_taxes_less_subsidies = None\n", 185 | "p_1_trade_n_transport_margins = None\n", 186 | "\n", 187 | "p_1_purchaser_price = None" 188 | ] 189 | }, 190 | { 191 | "cell_type": "code", 192 | "execution_count": null, 193 | "metadata": { 194 | "slideshow": { 195 | "slide_type": "slide" 196 | } 197 | }, 198 | "outputs": [], 199 | "source": [ 200 | "# Total supply at basic and purchaser prices for product 2\n", 201 | "p_2_basic_price = None\n", 202 | "\n", 203 | "p_2_taxes_less_subsidies = None\n", 204 | "p_2_trade_n_transport_margins = None\n", 205 | "\n", 206 | "p_2_purchaser_price = None" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": null, 212 | "metadata": { 213 | "slideshow": { 214 | "slide_type": "slide" 215 | } 216 | }, 217 | "outputs": [], 218 | "source": [ 219 | "# basic and purchase prices for product 1\n", 220 | "print(f\"{products[0]}: \\n\\tBasic price: {p_1_basic_price}\\n\\tPurchaser price: {p_1_purchaser_price}\")\n", 221 | "\n", 222 | "# basic and purchase prices for product 2\n", 223 | "print(f\"{products[1]}: \\n\\tBasic price: {p_2_basic_price}\\n\\tPurchaser price: {p_2_purchaser_price}\")" 224 | ] 225 | }, 226 | { 227 | "cell_type": "markdown", 228 | "metadata": { 229 | "slideshow": { 230 | "slide_type": "slide" 231 | } 232 | }, 233 | "source": [ 234 | "## Exercise 2\n", 235 | "1. Look at the list of industries (i.e., columns of the supply table) and select two industries" 236 | ] 237 | }, 238 | { 239 | "cell_type": "code", 240 | "execution_count": 4, 241 | "metadata": { 242 | "slideshow": { 243 | "slide_type": "fragment" 244 | } 245 | }, 246 | "outputs": [], 247 | "source": [ 248 | "# Print list of industries (i.e., columns of your table)" 249 | ] 250 | }, 251 | { 252 | "cell_type": "code", 253 | "execution_count": null, 254 | "metadata": { 255 | "slideshow": { 256 | "slide_type": "slide" 257 | } 258 | }, 259 | "outputs": [], 260 | "source": [ 261 | "# Select two industries\n", 262 | "industries = []" 263 | ] 264 | }, 265 | { 266 | "cell_type": "markdown", 267 | "metadata": { 268 | "slideshow": { 269 | "slide_type": "slide" 270 | } 271 | }, 272 | "source": [ 273 | "2. Can you identify the main products and secondary products? " 274 | ] 275 | }, 276 | { 277 | "cell_type": "code", 278 | "execution_count": null, 279 | "metadata": { 280 | "slideshow": { 281 | "slide_type": "slide" 282 | } 283 | }, 284 | "outputs": [], 285 | "source": [ 286 | "# Slice your data\n", 287 | "i_1_supply = None\n", 288 | "i_2_supply = None" 289 | ] 290 | }, 291 | { 292 | "cell_type": "code", 293 | "execution_count": null, 294 | "metadata": { 295 | "slideshow": { 296 | "slide_type": "slide" 297 | } 298 | }, 299 | "outputs": [], 300 | "source": [ 301 | "# Isolate non zero values and sort them from biggest to smallest\n", 302 | "i_1_supply = None\n", 303 | "i_2_supply = None" 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "execution_count": null, 309 | "metadata": { 310 | "slideshow": { 311 | "slide_type": "slide" 312 | } 313 | }, 314 | "outputs": [], 315 | "source": [ 316 | "# Print results\n", 317 | "print(f\"{industries[0]}:\\n\\n{i_1_supply}\\n\\n{industries[1]}:\\n\\n{i_2_supply}\")" 318 | ] 319 | } 320 | ], 321 | "metadata": { 322 | "celltoolbar": "Slideshow", 323 | "kernelspec": { 324 | "display_name": "Python 3 (ipykernel)", 325 | "language": "python", 326 | "name": "python3" 327 | }, 328 | "language_info": { 329 | "codemirror_mode": { 330 | "name": "ipython", 331 | "version": 3 332 | }, 333 | "file_extension": ".py", 334 | "mimetype": "text/x-python", 335 | "name": "python", 336 | "nbconvert_exporter": "python", 337 | "pygments_lexer": "ipython3", 338 | "version": "3.9.16" 339 | }, 340 | "vscode": { 341 | "interpreter": { 342 | "hash": "a0de1fb450ee5e26d734f0aa5b4c4b29e20575809e5e66472467df7627fd957d" 343 | } 344 | } 345 | }, 346 | "nbformat": 4, 347 | "nbformat_minor": 4 348 | } 349 | -------------------------------------------------------------------------------- /waste_IO/data/Japan_WIO2000sec103.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/waste_IO/data/Japan_WIO2000sec103.xlsx -------------------------------------------------------------------------------- /waste_IO/figures/wio_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/advanced_EEIO_course_student_version/d2e567f09587d83f0d3c2b11260565b8a5c6f358/waste_IO/figures/wio_1.gif -------------------------------------------------------------------------------- /waste_IO/waste_IO_sv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Practical 8: Waste Input-Output\n", 8 | "\n", 9 | "Objectives:\n", 10 | "- Understand the structure of a WIOT\n", 11 | "- Build a WIO model in Python\n", 12 | "- Analyze data from a WIO model\n", 13 | "\n", 14 | "The methods used in this practical sessions come from:\n", 15 | "Nakamura, S. and Kondo, Y. (2002), Input-Output Analysis of Waste Management. Journal of Industrial Ecology, 6: 39-63. https://doi.org/10.1162/108819802320971632" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# Import packages\n", 25 | "import pandas as pd\n", 26 | "import numpy as np" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "metadata": {}, 32 | "source": [ 33 | "## Exercise 1: Conceptual understanding of waste input output tables and their treatment of economic and physical flows. " 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "\n", 41 | "
\n", 42 | "\n", 43 | "| | E | WT |\n", 44 | "|---|-----|----|\n", 45 | "| E | 52 | 22 |\n", 46 | "| WT| 349 | 44 |\n", 47 | "\n", 48 | "\n", 49 | "\n", 50 | "| y |\n", 51 | "|-----|\n", 52 | "| 100 |\n", 53 | "| 50 |\n", 54 | "\n", 55 | "
\n", 56 | "\n", 57 | "Table 1: WIOT of a country\n", 58 | "\n" 59 | ] 60 | }, 61 | { 62 | "cell_type": "markdown", 63 | "metadata": {}, 64 | "source": [ 65 | "### Question 1.1: What are the expected units in the following parts of the simplified WIO system shown above? \n", 66 | "\n", 67 | "- E-WT quadrant (i.e., with value 22)\n", 68 | "- WT-WT quadrant (i.e., with value 44)\n", 69 | "- and in Y (i.e., with values 100 and 50)" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": {}, 75 | "source": [ 76 | "### Question 1.2: Estimate the A-matrix. What do the coefficient represent in each quadrant? \n", 77 | "\n" 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": null, 83 | "metadata": {}, 84 | "outputs": [], 85 | "source": [ 86 | "Z = None\n", 87 | "y = None\n", 88 | "x = None\n", 89 | "inv_diag_x = None \n", 90 | "A = None\n", 91 | "A,x" 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "metadata": {}, 97 | "source": [ 98 | "## Exercise 2: Construct a Waste Input-Output model in Python and analyse the waste streams linked to economic activity\n", 99 | "\n", 100 | "Use the data provided and the following figures to help you\n", 101 | "\n", 102 | "- _Data adapted from source: https://www.f.waseda.jp/nakashin/WIO/wio2000sec103_0.06b_eng.xls_\n", 103 | "- _For additional info: http://www.f.waseda.jp/nakashin/WIO.html_\n", 104 | "\n", 105 | "\n", 106 | "\n", 107 | "\n", 119 | "\n", 132 | " \n", 133 | "
\n", 108 | "\n", 109 | "| **Z** | Economic sector | Waste treatment |\n", 110 | "|-----------------|----------------------|------------------------|\n", 111 | "| Economic sector | **Z**E,E | **Z**E,WT |\n", 112 | "| Waste treatment | **Z**WT,E | **Z**WT,WT |\n", 113 | "-------------------------------------------------------------------\n", 114 | "| **r**' | | |\n", 115 | "|-----------------|----------------------|------------------------|\n", 116 | "| Emissions | Econ. Sec. emissions | Waste Treat. emissions |\n", 117 | "\n", 118 | "\n", 120 | "\n", 121 | "| **Y** |\n", 122 | "|--------------------|\n", 123 | "| **Y**E |\n", 124 | "| **Y**WT |\n", 125 | "\n", 126 | "----------------------\n", 127 | "| **h** |\n", 128 | "|--------------------|\n", 129 | "| Emissions |\n", 130 | "\n", 131 | "
\n", 134 | "Table 2: Basic structure of a WIOT\n", 135 | "\n" 136 | ] 137 | }, 138 | { 139 | "cell_type": "markdown", 140 | "metadata": {}, 141 | "source": [ 142 | "| ![Waste Input-Output Accounting structure](figures/wio_1.gif) | \n", 143 | "|:--:| \n", 144 | "| *Waste Input-Output Accounting structure (Nakamura and Kondo, 2009)* |" 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "metadata": {}, 150 | "source": [ 151 | "#### 2.1 Import data" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": null, 157 | "metadata": {}, 158 | "outputs": [], 159 | "source": [ 160 | "file_data = None # use 'Japan_WIO2000sec103.xlsx'\n", 161 | "# Input-output table, including intermediate and final demand matrix\n", 162 | "ZYeconomy = None\n", 163 | "# Waste account, including intermediate and final demand matrix\n", 164 | "ZYwaste = None\n", 165 | "# VA and satellite account\n", 166 | "F = None\n", 167 | "# Waste allocation matrix\n", 168 | "Q = None\n", 169 | "# units\n", 170 | "unit = None" 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "metadata": {}, 176 | "source": [ 177 | "#### 2.2 identify the number of sectors and sector headers" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": null, 183 | "metadata": {}, 184 | "outputs": [], 185 | "source": [ 186 | "n_e = None # 103 number of economic sectors\n", 187 | "n_wt = None # 13 number of waste treatment sectors\n", 188 | "n_y = None # 11 number of final demand categories\n", 189 | "n_w = None # 79 number of waste flows" 190 | ] 191 | }, 192 | { 193 | "cell_type": "markdown", 194 | "metadata": {}, 195 | "source": [ 196 | "### 2.3 Separate the following variables:\n", 197 | "\n", 198 | "Look at the provided tables and separate the following elements: \n", 199 | "\n", 200 | "- **Z_e_e**: The inter-industry transactions of the economic transactions (i.e., IO economy with the 103 economic sectors)\n", 201 | "- **Z_e_wt**: The inter-industry transactions concerning waste (i.e., the IO 13 waste treatment categories)\n", 202 | "\n", 203 | "- **Y**: The final demand matrix (i.e., the 11 final demand categories)\n", 204 | "\n", 205 | "- **Z_wo_e**: The waste outflows of the 103 economic sectors\n", 206 | "- **Z_wi_e**: The waste inflows of the 103 economic sectors\n", 207 | "\n", 208 | "- **Z_wo_wt**: The waste outflows of the 13 waste treatments \n", 209 | "- **Z_wi_wt**: The waste inflows of the 13 waste treatments\n", 210 | "\n", 211 | "- **Y_wi**: The waste inflows of the 11 final demand categories\n", 212 | "- **Y_wo**: The waste outflows of the 11 final demand categories" 213 | ] 214 | }, 215 | { 216 | "cell_type": "code", 217 | "execution_count": null, 218 | "metadata": {}, 219 | "outputs": [], 220 | "source": [ 221 | "Z_e_e = None # IO economy with the 103 economic sectors\n", 222 | "Z_e_wt = None # IO waste treatment with the 13 waste treatment categories\n", 223 | "Y_e = None # Final demand matrix\n", 224 | "\n", 225 | "Z_wo_e = None # Waste outflow of 103 economic sectors\n", 226 | "Z_wi_e = None # Waste inflow of 103 economic sectors\n", 227 | "\n", 228 | "Z_wo_wt = None # Waste outflow of 13 waste treatments\n", 229 | "Z_wi_wt = None # Waste inflow of 13 waste treatments\n", 230 | "\n", 231 | "Y_wo = None # Waste outflow of 11 final demand categories\n", 232 | "Y_wi = None # Waste inflow of 11 final demand categories\n" 233 | ] 234 | }, 235 | { 236 | "cell_type": "markdown", 237 | "metadata": {}, 238 | "source": [ 239 | "### 2.4 Calculate net waste flows: \n", 240 | "\n", 241 | "\n", 242 | "**Z_wf_e**: Net waste flow of 103 economic sectors\n", 243 | "\n", 244 | "- given by $\\mathbf{Z}_{WF,E} = \\mathbf{Z}_{WFO,E} - \\mathbf{Z}_{WFI,E}$\n", 245 | "- where $\\mathbf{Z}_{WF,E}$ are the net waste flows for economic sector E,\n", 246 | "- $\\mathbf{Z}_{WFO,E}$ are the waste outflows for economic sector E\n", 247 | "- and $\\mathbf{Z}_{WFI,E}$ is the waste inflow for economic sector E;\n", 248 | "\n", 249 | "**Z_wf_wt**: Net waste flow of 13 waste treatmets\n", 250 | "- given by $\\mathbf{Z}_{WF,WT} = \\mathbf{Z}_{WFO,WT} - \\mathbf{Z}_{WFI,WT}$\n", 251 | "- where $\\mathbf{Z}_{WF,WT}$ are the net waste flows for waste treatment sector WT, \n", 252 | "- $\\mathbf{Z}_{WFO,WT}$ are the waste outflows for waste treatment sector WT, \n", 253 | "- and $\\mathbf{Z}_{WFI,WT}$ is the waste inflow for waste treatment sector WT;\n", 254 | "\n", 255 | "**Y_wf**: Net waste flow of 11 final demand categories\n", 256 | "- given by $\\mathbf{Y}_{WF} = \\mathbf{Y}_{WFO} - \\mathbf{Y}_{WFI}$\n", 257 | "- where $\\mathbf{Y}_{WF}$ are the net waste flows for final demand Y, \n", 258 | "- $\\mathbf{Y}_{WFO}$ is the waste outflows for final demand Y, \n", 259 | "- and $\\mathbf{Y}_{WFI}$ is the waste inflow for final demand Y.\n", 260 | "\n" 261 | ] 262 | }, 263 | { 264 | "cell_type": "code", 265 | "execution_count": null, 266 | "metadata": {}, 267 | "outputs": [], 268 | "source": [ 269 | "Z_wf_e_net = None # Net waste flow of 103 economic sectors.\n", 270 | "Z_wf_wt_net = None # Net waste flow of 13 waste treatmets\n", 271 | "Y_wf_net = None # Net waste flow of 11 final demand categories" 272 | ] 273 | }, 274 | { 275 | "cell_type": "markdown", 276 | "metadata": {}, 277 | "source": [ 278 | "### 2.5 Covert waste flows into waste treatments:\n", 279 | "\n", 280 | "**Z_wt_e**: Matrix of waste flows generated and/or absorbed by 103 economic sector\n", 281 | "- given by $\\mathbf{Z}_{WT,E} = \\mathbf{Q} \\mathbf{Z}_{WF,E}$\n", 282 | "- where $\\mathbf{Z}_{WT,E}$ is a matrix of waste flows generated and/or absorbed by economic sector E\n", 283 | "- and $\\mathbf{Q}$ is the allocation matrix;\n", 284 | "\n", 285 | "**Z_wt_wt**: Matrix of waste flows generated and/or absorbed by 13 waste treatment sectors sector\n", 286 | "- given by $\\mathbf{Z}_{WT,WT} = \\mathbf{Q} \\mathbf{Z}_{WF,WT}$\n", 287 | "- where $\\mathbf{Z}_{WT,WT}$ is a matrix of waste flows generated and/or absorbed by waste treatment sector WT;\n", 288 | "\n", 289 | "**Y_wt**: Matrix of waste flows generated and/or absorbed by 11 final demand categories\n", 290 | "- given by $\\mathbf{Y}_{WT} = \\mathbf{Q} \\mathbf{Y}_{WF}$\n", 291 | "- where $\\mathbf{Y}_{WT}$ is a matrix of waste flows generated by final demand $\\mathbf{Y}$." 292 | ] 293 | }, 294 | { 295 | "cell_type": "code", 296 | "execution_count": null, 297 | "metadata": {}, 298 | "outputs": [], 299 | "source": [ 300 | "Z_wt_e = None # Matrix of waste flows generated and/or absorbed by 103 economic sector\n", 301 | "Z_wt_wt = None # Matrix of waste flows generated and/or absorbed by 13 waste treatment sectors sector\n", 302 | "Y_wt = None # Matrix of waste flows generated and/or absorbed by 11 final demand categories\n", 303 | "\n", 304 | "# Reapply any missing labels\n" 305 | ] 306 | }, 307 | { 308 | "cell_type": "markdown", 309 | "metadata": {}, 310 | "source": [ 311 | "### 2.6 Group matrices in a WIOT arrangement" 312 | ] 313 | }, 314 | { 315 | "cell_type": "code", 316 | "execution_count": null, 317 | "metadata": {}, 318 | "outputs": [], 319 | "source": [ 320 | "wiot_e = None # Concat Z_e_e and Z_e_wt block\n", 321 | "wiot_wt = None # Concat Z_wt_e and Z_wt_wt block\n", 322 | "\n", 323 | "Z_wiot = None # Integrate WIOT\n", 324 | "Y_wiot = None # Concat Y_e and Y_wt" 325 | ] 326 | }, 327 | { 328 | "cell_type": "code", 329 | "execution_count": null, 330 | "metadata": {}, 331 | "outputs": [], 332 | "source": [ 333 | "Z_wiot.head()" 334 | ] 335 | }, 336 | { 337 | "cell_type": "code", 338 | "execution_count": null, 339 | "metadata": {}, 340 | "outputs": [], 341 | "source": [ 342 | "Y_wiot.head()" 343 | ] 344 | }, 345 | { 346 | "cell_type": "markdown", 347 | "metadata": {}, 348 | "source": [ 349 | "## Exercise 3: From a consumption-based perspective, which are the major contributors to landfill area footprint?" 350 | ] 351 | }, 352 | { 353 | "cell_type": "markdown", 354 | "metadata": {}, 355 | "source": [ 356 | "### 3.1 Calculate Leontief inverse" 357 | ] 358 | }, 359 | { 360 | "cell_type": "code", 361 | "execution_count": null, 362 | "metadata": {}, 363 | "outputs": [], 364 | "source": [] 365 | }, 366 | { 367 | "cell_type": "markdown", 368 | "metadata": {}, 369 | "source": [ 370 | "### 3.2 Calculate Landfill intensity" 371 | ] 372 | }, 373 | { 374 | "cell_type": "code", 375 | "execution_count": null, 376 | "metadata": {}, 377 | "outputs": [], 378 | "source": [] 379 | }, 380 | { 381 | "cell_type": "markdown", 382 | "metadata": {}, 383 | "source": [ 384 | "### 3.3 Calculate landfill footprint per economic sector (LF)" 385 | ] 386 | }, 387 | { 388 | "cell_type": "code", 389 | "execution_count": null, 390 | "metadata": {}, 391 | "outputs": [], 392 | "source": [] 393 | }, 394 | { 395 | "cell_type": "markdown", 396 | "metadata": {}, 397 | "source": [ 398 | "### Credits\n", 399 | "\n", 400 | "First version of the exercise developed by dr. J.F.D. Rodrigues, improvements by dr. G.A. Aguilar Hernandez (2022) and F. Donati (2023) " 401 | ] 402 | } 403 | ], 404 | "metadata": { 405 | "kernelspec": { 406 | "display_name": "Python 3 (ipykernel)", 407 | "language": "python", 408 | "name": "python3" 409 | }, 410 | "language_info": { 411 | "codemirror_mode": { 412 | "name": "ipython", 413 | "version": 3 414 | }, 415 | "file_extension": ".py", 416 | "mimetype": "text/x-python", 417 | "name": "python", 418 | "nbconvert_exporter": "python", 419 | "pygments_lexer": "ipython3", 420 | "version": "3.9.16" 421 | } 422 | }, 423 | "nbformat": 4, 424 | "nbformat_minor": 2 425 | } 426 | --------------------------------------------------------------------------------