├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── AUTHORS.rst ├── CONTRIBUTING.rst ├── HISTORY.rst ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── README.rst ├── bitbucket-pipelines.yml ├── conftest.py ├── description.txt ├── docs ├── Makefile ├── _build │ ├── doctrees │ │ ├── authors.doctree │ │ ├── contributing.doctree │ │ ├── environment.pickle │ │ ├── history.doctree │ │ ├── index.doctree │ │ ├── installation.doctree │ │ ├── modules.doctree │ │ ├── pycirk.doctree │ │ ├── readme.doctree │ │ └── usage.doctree │ └── html │ │ ├── .buildinfo │ │ ├── _modules │ │ ├── index.html │ │ └── pycirk │ │ │ ├── fundamental_operations.html │ │ │ ├── labels.html │ │ │ ├── make_scenarios.html │ │ │ ├── make_secondary_flows.html │ │ │ ├── organize_io.html │ │ │ ├── positions.html │ │ │ ├── pycirk.html │ │ │ ├── pycirk_settings.html │ │ │ ├── results.html │ │ │ ├── save_utils.html │ │ │ └── transformation_methods.html │ │ ├── _sources │ │ ├── authors.rst.txt │ │ ├── contributing.rst.txt │ │ ├── history.rst.txt │ │ ├── index.rst.txt │ │ ├── installation.rst.txt │ │ ├── modules.rst.txt │ │ ├── pycirk.rst.txt │ │ ├── readme.rst.txt │ │ └── usage.rst.txt │ │ ├── _static │ │ ├── alabaster.css │ │ ├── basic.css │ │ ├── custom.css │ │ ├── doctools.js │ │ ├── documentation_options.js │ │ ├── file.png │ │ ├── jquery-3.5.1.js │ │ ├── jquery.js │ │ ├── language_data.js │ │ ├── minus.png │ │ ├── plus.png │ │ ├── pygments.css │ │ ├── searchtools.js │ │ ├── underscore-1.12.0.js │ │ └── underscore.js │ │ ├── authors.html │ │ ├── contributing.html │ │ ├── genindex.html │ │ ├── history.html │ │ ├── index.html │ │ ├── installation.html │ │ ├── modules.html │ │ ├── objects.inv │ │ ├── py-modindex.html │ │ ├── pycirk.html │ │ ├── readme.html │ │ ├── search.html │ │ ├── searchindex.js │ │ └── usage.html ├── authors.rst ├── conf.py ├── contributing.rst ├── history.rst ├── index.rst ├── installation.rst ├── make.bat ├── modules.rst ├── pycirk.rst ├── readme.rst └── usage.rst ├── pycirk ├── __init__.py ├── cli.py ├── data │ └── README.txt ├── fundamental_operations.py ├── labels.py ├── labels │ ├── charact_emissions.csv │ ├── charact_factor_inputs.csv │ ├── charact_materials.csv │ ├── charact_resources.csv │ ├── emissions.csv │ ├── factor_inputs.csv │ ├── final_demand.csv │ ├── industry.csv │ ├── materials.csv │ ├── products.csv │ └── resources.csv ├── make_scenarios.py ├── make_secondary_flows.py ├── organize_io.py ├── positions.py ├── pycirk.py ├── pycirk_settings.py ├── results.py ├── save_utils.py ├── scenarios.xlsx └── transformation_methods.py ├── requirements.txt ├── requirements_dev.txt ├── resources ├── categories.ods ├── classifications3.0.13_3_dec_2016.xlsx └── index.xls ├── setup.cfg ├── setup.py ├── tests ├── scenarios.xlsx └── test_pycirk.py └── tox.ini /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | pycirk/for_testing.py 2 | *.pkl 3 | pycirk/make_graphs.py 4 | tests/output 5 | tests/output* 6 | __pycache__ 7 | env_pycirk/ 8 | dist 9 | 10 | pycirk.egg-info -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * Franco Donati 9 | 10 | Contributors 11 | ------------ 12 | 13 | None yet. Why not be the first? 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Contributing 5 | ============ 6 | 7 | Contributions are welcome, and they are greatly appreciated! Every little bit 8 | helps, and credit will always be given. 9 | 10 | You can contribute in many ways: 11 | 12 | Types of Contributions 13 | ---------------------- 14 | 15 | Report Bugs 16 | ~~~~~~~~~~~ 17 | 18 | Report bugs at https://github.com/FDonati/pycirk/issues. 19 | 20 | If you are reporting a bug, please include: 21 | 22 | * Your operating system name and version. 23 | * Any details about your local setup that might be helpful in troubleshooting. 24 | * Detailed steps to reproduce the bug. 25 | 26 | Fix Bugs 27 | ~~~~~~~~ 28 | 29 | Look through the GitHub issues for bugs. Anything tagged with "bug" and "help 30 | wanted" is open to whoever wants to implement it. 31 | 32 | Implement Features 33 | ~~~~~~~~~~~~~~~~~~ 34 | 35 | Look through the GitHub issues for features. Anything tagged with "enhancement" 36 | and "help wanted" is open to whoever wants to implement it. 37 | 38 | Write Documentation 39 | ~~~~~~~~~~~~~~~~~~~ 40 | 41 | pycirk could always use more documentation, whether as part of the 42 | official pycirk docs, in docstrings, or even on the web in blog posts, 43 | articles, and such. 44 | 45 | Submit Feedback 46 | ~~~~~~~~~~~~~~~ 47 | 48 | The best way to send feedback is to file an issue at https://github.com/FDonati/pycirk/issues. 49 | 50 | If you are proposing a feature: 51 | 52 | * Explain in detail how it would work. 53 | * Keep the scope as narrow as possible, to make it easier to implement. 54 | * Remember that this is a volunteer-driven project, and that contributions 55 | are welcome :) 56 | 57 | Get Started! 58 | ------------ 59 | 60 | Ready to contribute? Here's how to set up `pycirk` for local development. 61 | 62 | 1. Fork the `pycirk` repo on GitHub. 63 | 2. Clone your fork locally:: 64 | 65 | $ git clone git@github.com:your_name_here/pycirk.git 66 | 67 | 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: 68 | 69 | $ mkvirtualenv pycirk 70 | $ cd pycirk/ 71 | $ python setup.py develop 72 | 73 | 4. Create a branch for local development:: 74 | 75 | $ git checkout -b name-of-your-bugfix-or-feature 76 | 77 | Now you can make your changes locally. 78 | 79 | 5. When you're done making changes, check that your changes pass flake8 and the 80 | tests, including testing other Python versions with tox:: 81 | 82 | $ flake8 pycirk tests 83 | $ python setup.py test or py.test 84 | $ tox 85 | 86 | To get flake8 and tox, just pip install them into your virtualenv. 87 | 88 | 6. Commit your changes and push your branch to GitHub:: 89 | 90 | $ git add . 91 | $ git commit -m "Your detailed description of your changes." 92 | $ git push origin name-of-your-bugfix-or-feature 93 | 94 | 7. Submit a pull request through the GitHub website. 95 | 96 | Pull Request Guidelines 97 | ----------------------- 98 | 99 | Before you submit a pull request, check that it meets these guidelines: 100 | 101 | 1. The pull request should include tests. 102 | 2. If the pull request adds functionality, the docs should be updated. Put 103 | your new functionality into a function with a docstring, and add the 104 | feature to the list in README.rst. 105 | 3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check 106 | https://travis-ci.org/FDonati/pycirk/pull_requests 107 | and make sure that the tests pass for all supported Python versions. 108 | 109 | Tips 110 | ---- 111 | 112 | To run a subset of tests:: 113 | 114 | $ py.test tests.test_pycirk 115 | 116 | 117 | Deploying 118 | --------- 119 | 120 | A reminder for the maintainers on how to deploy. 121 | Make sure all your changes are committed (including an entry in HISTORY.rst). 122 | Then run:: 123 | 124 | $ bumpversion patch # possible: major / minor / patch 125 | $ git push 126 | $ git push --tags 127 | 128 | Travis will then deploy to PyPI if tests pass. 129 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | History 3 | ======= 4 | 5 | 0.1.0 (2018-05-11) 6 | ------------------ 7 | 8 | * First release on PyPI. 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | A software to model policy and technological interventions in Environmental Input Output Analysis 5 | Copyright (C) 2018 Franco Donati 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | 20 | Also add information on how to contact you by electronic and paper mail. 21 | 22 | You should also get your employer (if you work as a programmer) or school, 23 | if any, to sign a "copyright disclaimer" for the program, if necessary. 24 | For more information on this, and how to apply and follow the GNU GPL, see 25 | . 26 | 27 | The GNU General Public License does not permit incorporating your program 28 | into proprietary programs. If your program is a subroutine library, you 29 | may consider it more useful to permit linking proprietary applications with 30 | the library. If this is what you want to do, use the GNU Lesser General 31 | Public License instead of this License. But first, please read 32 | . 33 | 34 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS.rst 2 | include CONTRIBUTING.rst 3 | include HISTORY.rst 4 | include LICENSE 5 | include README.rst 6 | 7 | recursive-include tests * 8 | recursive-include pycirk * 9 | recursive-exclude * __pycache__ 10 | recursive-exclude * *.py[co] 11 | recursive-exclude * *.pkl 12 | 13 | recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean clean-test clean-pyc clean-build docs help 2 | .DEFAULT_GOAL := help 3 | 4 | define BROWSER_PYSCRIPT 5 | import os, webbrowser, sys 6 | 7 | try: 8 | from urllib import pathname2url 9 | except: 10 | from urllib.request import pathname2url 11 | 12 | webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) 13 | endef 14 | export BROWSER_PYSCRIPT 15 | 16 | define PRINT_HELP_PYSCRIPT 17 | import re, sys 18 | 19 | for line in sys.stdin: 20 | match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) 21 | if match: 22 | target, help = match.groups() 23 | print("%-20s %s" % (target, help)) 24 | endef 25 | export PRINT_HELP_PYSCRIPT 26 | 27 | BROWSER := python -c "$$BROWSER_PYSCRIPT" 28 | 29 | help: 30 | @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) 31 | 32 | clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts 33 | 34 | clean-build: ## remove build artifacts 35 | rm -fr build/ 36 | rm -fr dist/ 37 | rm -fr .eggs/ 38 | find . -name '*.egg-info' -exec rm -fr {} + 39 | find . -name '*.egg' -exec rm -f {} + 40 | 41 | clean-pyc: ## remove Python file artifacts 42 | find . -name '*.pyc' -exec rm -f {} + 43 | find . -name '*.pyo' -exec rm -f {} + 44 | find . -name '*~' -exec rm -f {} + 45 | find . -name '__pycache__' -exec rm -fr {} + 46 | 47 | clean-test: ## remove test and coverage artifacts 48 | rm -fr .tox/ 49 | rm -f .coverage 50 | rm -fr htmlcov/ 51 | rm -fr .pytest_cache 52 | 53 | lint: ## check style with flake8 54 | flake8 pycirk tests 55 | 56 | test: ## run tests quickly with the default Python 57 | py.test 58 | 59 | test-all: ## run tests on every Python version with tox 60 | tox 61 | 62 | coverage: ## check code coverage quickly with the default Python 63 | coverage run --source pycirk -m pytest 64 | coverage report -m 65 | coverage html 66 | $(BROWSER) htmlcov/index.html 67 | 68 | docs: ## generate Sphinx HTML documentation, including API docs 69 | rm -f docs/pycirk.rst 70 | rm -f docs/modules.rst 71 | sphinx-apidoc -o docs/ pycirk 72 | $(MAKE) -C docs clean 73 | $(MAKE) -C docs html 74 | $(BROWSER) docs/_build/html/index.html 75 | 76 | servedocs: docs ## compile the docs watching for changes 77 | watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . 78 | 79 | release: dist ## package and upload a release 80 | twine upload dist/* 81 | 82 | dist: clean ## builds source and wheel package 83 | python setup.py sdist 84 | python setup.py bdist_wheel 85 | ls -l dist 86 | 87 | install: clean ## install the package to the active Python's site-packages 88 | python setup.py install 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pycirk 2 | 3 | _A python package to model Circular Economy policy and technological interventions in Environmentally Extended Input-Output Analysis starting from SUTs (EXIOBASE V3.3)_ 4 | 5 | [![DOI](https://zenodo.org/badge/157891556.svg)](https://zenodo.org/badge/latestdoi/157891556) 6 | [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) 7 | [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](resources/docs/CONTRIBUTING.md) 8 | 9 | Documentation: https://pycirk.readthedocs.io/en/latest/readme.html 10 | 11 | To cite the use of the software in your research please use the following publication: 12 | 13 | "Modeling the circular economy in environmentally extended input-output tables: Methods, software and case study" 14 | 15 | https://doi.org/10.1016/j.resconrec.2019.104508 16 | 17 | 18 | ## Installation 19 | 20 | ### Stable release 21 | 22 | Run in your terminal: 23 | 24 | $ pip install pycirk 25 | 26 | ### From source 27 | 28 | Clone repository: 29 | 30 | $ git clone https://fdonati@bitbucket.org/CML-IE/pycirk.git 31 | or 32 | 33 | $ git clone https://github.com/CMLPlatform/pycirk.git 34 | 35 | 36 | Once you have a copy of the source, you can install it with: 37 | 38 | $ python setup.py install 39 | 40 | ### Data 41 | 42 | You can download the biregional or multiregional database by following this link 43 | 44 | http://doi.org/10.5281/zenodo.4695823 45 | 46 | You need to place the data inside the package 47 | e.g. /home/UserName/.local/lib/python3.6/site-packages/pycirk/data 48 | 49 | ## Usage 50 | 51 | ### Import package 52 | 53 | import pycirk 54 | 55 | ### Initialize 56 | 57 | my_work = pycirk.Launch(method, directory, aggregation, make_secondary) 58 | 59 | ### set your scenarios and analysis 60 | 61 | 1. Open scenarios.xls in the directory that was specified 62 | 2. From there you can specify interventions and parameters for the analysis 63 | 3. save and continue to the following steps 64 | 65 | ### Run scenarios 66 | 67 | Run one specific scenario 68 | 69 | my_work.scenario_results(scen_no, output_dataset) 70 | (0 = baseline) 71 | 72 | Run all scenarios 73 | 74 | my_work.all_results() 75 | 76 | ### save scenarios 77 | 78 | Save your results 79 | 80 | my_work.save_results() 81 | 82 | 83 | ### Use from command line 84 | 85 | pycirk --help 86 | 87 | Usage: pycirk [OPTIONS] 88 | 89 | Console script for pycirk. A software to model policy and technological 90 | interventions in Environmentally Extended Input-Output Analysis (EXIOBASE 91 | V3.3, 2011) 92 | 93 | Options: 94 | 95 | | Command | Variables | 96 | |----------------------------|--------------------------------------| 97 | | -tm, --transf_method TEXT | 0 = PXP ITA_TC; 1 = PXP ITA_MSC | 98 | | -dr, --directory TEXT | if left black it will be default | 99 | | -ag, --aggregation | 1 = bi-regional (EU-ROW) | 100 | | | 0 = None (49 regions) | 101 | | -sc, --scenario TEXT | all, 1, 2,... accepted - 0=baseline | 102 | | -s, --save TEXT | False=no, True=yes | 103 | | -od, --output_dataset | False=no, True=yes | 104 | | --help | Show this message and exit. | 105 | 106 | 107 | Command example 108 | 109 | pycirk -tm 0 -dr "" -sc "1" -s True -od False 110 | 111 | ## Features 112 | 113 | Examples of policies that can be modelled through the software: 114 | 115 | - sharing 116 | - recycling 117 | - life extension 118 | - rebound effects 119 | - substituion 120 | - market and value added changes 121 | - efficiency 122 | 123 | The tables in which it is possible to apply changes: 124 | 125 | - total requirement matrix (A) 126 | - intermediate transactions (Z) 127 | - final demand (Y) 128 | - primary inputs (W) 129 | 130 | - emission intermediate extentions (E) 131 | - material intermediate extensions (M) 132 | - resource intermediate extensions (R) 133 | - emission final demand extension (EY) 134 | - material final demand extension (MY) 135 | - resource final demand extensions (RY) 136 | 137 | - primary inputs coefficients (w) 138 | - emission intermediate extentions coefficients (e) 139 | - material intermediate extensions coefficients (m) 140 | - resource intermediate extensions coefficients (r) 141 | - emission final demand extension coefficients (eY) 142 | - material final demand extension coefficients (mY) 143 | - resource final demand extensions coefficients (rY) 144 | 145 | It is possible to specify: 146 | 147 | - region of the intervention 148 | - whether the intervention affects domestic, import transactions or both 149 | 150 | 151 | This package was created with Cookiecutter and the `audreyr/cookiecutter-pypackage` project template. 152 | 153 | Cookiecutter: https://github.com/audreyr/cookiecutter 154 | audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage 155 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ###### 2 | pycirk 3 | ###### 4 | 5 | 6 | 7 | *A python package to model Circular Economy policy and technological interventions in Environmentally Extended Input-Output Analysis starting from SUTs (EXIOBASE V3.3)* 8 | 9 | .. image:: https://zenodo.org/badge/157891556.svg 10 | :target: https://zenodo.org/badge/latestdoi/157891556 11 | .. image:: https://img.shields.io/badge/License-GPL%20v3-blue.svg 12 | :target: https://www.gnu.org/licenses/gpl-3.0 13 | .. image:: https://img.shields.io/badge/contributions-welcome-brightgreen.svg 14 | :target: resources/docs/CONTRIBUTING.md) 15 | 16 | 17 | | Documentation: https://pycirk.readthedocs.io/en/latest/readme.html 18 | 19 | 10.5281/zenodo.1492957 20 | 21 | To cite the use of the software in your research please use the following publication: 22 | 23 | "Modeling the circular economy in environmentally extended input-output tables: Methods, software and case study" 24 | 25 | https://doi.org/10.1016/j.resconrec.2019.104508 26 | 27 | =============== 28 | 1. Installation 29 | =============== 30 | 31 | 32 | 1.1. Stable release 33 | ------------------- 34 | 35 | Run in your terminal:0 36 | 37 | $ pip install pycirk 38 | 39 | 40 | 1.2. From source 41 | ---------------- 42 | 43 | Clone repository: 44 | 45 | $ git clone https://fdonati@bitbucket.org/CML-IE/pycirk.git 46 | 47 | Once you have a copy of the source, you can install it with: 48 | 49 | $ python setup.py install 50 | 51 | 1.3 Data 52 | -------- 53 | 54 | You can download the biregional or multiregional database by following this link 55 | 56 | http://doi.org/10.5281/zenodo.4695823 57 | 58 | You need to place the data inside the package 59 | e.g. /home/UserName/.local/lib/python3.6/site-packages/pycirk/data 60 | 61 | ======== 62 | 2. Usage 63 | ======== 64 | 65 | 2.1. Import package 66 | ------------------- 67 | 68 | import pycirk 69 | 70 | 71 | 2.2. Initialize 72 | --------------- 73 | 74 | my_work = pycirk.Launch(method, directory, aggregation) 75 | 76 | 77 | 2.3. set your scenarios and analysis 78 | ------------------------------------ 79 | 80 | 1. Open scenarios.xls in the directory that was specified 81 | 2. From there you can specify interventions and parameters for the analysis 82 | 3. save and continue to the following steps 83 | 84 | 85 | 86 | 2.4. Run scenarios 87 | ------------------ 88 | 89 | Run one specific scenario 90 | 91 | my_work.scenario_results(scen_no, output_dataset) 92 | (0 = baseline) 93 | 94 | Run all scenarios 95 | 96 | my_work.all_results() 97 | 98 | 99 | 2.5. save scenarios 100 | ------------------- 101 | 102 | Save your results 103 | 104 | my_work.save_results() 105 | 106 | 107 | 2.6. Use from command line 108 | 109 | 2.6.1. pycirk --help 110 | 111 | Usage: pycirk [OPTIONS] 112 | 113 | Console script for pycirk. A software to model policy and technological 114 | interventions in Environmentally Extended Input-Output Analysis (EXIOBASE 115 | V3.3, 2011) 116 | 117 | Options: 118 | 119 | +----------------------------+--------------------------------------+ 120 | | Command | Variables | 121 | +============================+======================================+ 122 | | -tm, --transf_method TEXT | 0 = PXP ITA_TC; 1 = PXP ITA_MSC | 123 | +----------------------------+--------------------------------------+ 124 | | -dr, --directory TEXT | if left black it will be default | 125 | +----------------------------+--------------------------------------+ 126 | | -ag, --aggregation | 1 = bi-regional (EU-ROW) | 127 | | | 0 = None (49 regions) | 128 | +----------------------------+--------------------------------------+ 129 | | -sc, --scenario TEXT | all, 1, 2,... accepted - 0=baseline | 130 | +----------------------------+--------------------------------------+ 131 | | -s, --save TEXT | False=no, True=yes | 132 | +----------------------------+--------------------------------------+ 133 | | -od, --output_dataset | False=no, True=yes | 134 | +----------------------------+--------------------------------------+ 135 | | --help | Show this message and exit. | 136 | +----------------------------+--------------------------------------+ 137 | 138 | 2.6.2. Command example 139 | 140 | pycirk -tm 0 -dr "" -sc "1" -s True -od False 141 | 142 | 143 | 144 | =========== 145 | 3. Features 146 | =========== 147 | 148 | 149 | Examples of policies that can be modelled through the software: 150 | 151 | - sharing 152 | - recycling 153 | - life extension 154 | - rebound effects 155 | - substituion 156 | - market and value added changes 157 | - efficiency 158 | 159 | The tables in which it is possible to apply changes: 160 | 161 | - total requirement matrix (A) 162 | - intermediate transactions (Z) 163 | - final demand (Y) 164 | - primary inputs (W) 165 | 166 | - emission intermediate extentions (E) 167 | - material intermediate extensions (M) 168 | - resource intermediate extensions (R) 169 | - emission final demand extension (EY) 170 | - material final demand extension (MY) 171 | - resource final demand extensions (RY) 172 | 173 | - primary inputs coefficients (w) 174 | - emission intermediate extentions coefficients (e) 175 | - material intermediate extensions coefficients (m) 176 | - resource intermediate extensions coefficients (r) 177 | - emission final demand extension coefficients (eY) 178 | - material final demand extension coefficients (mY) 179 | - resource final demand extensions coefficients (rY) 180 | 181 | It is possible to specify: 182 | 183 | - region of the intervention 184 | - whether the intervention affects domestic, import transactions or both 185 | 186 | 187 | ==================== 188 | 4. Important modules 189 | ==================== 190 | 191 | 4.1. scenarios.xls 192 | ------------------ 193 | 194 | From this .xls file it is possible to set different types of interventions and the analysis to perform: 195 | 196 | - matrix = specifies in which matrix of IOT the changes are applied 197 | - change_type = Primary and ancillary are only used to specify the type of intervention from a conceptual level 198 | - reg_o or reg_d = Regional coordinates (o=origin or row, d=destination or column) 199 | - cat_o or cat_d = category (e.g. products or extensions ) coordinates (o=origin or row, d=destination or column) 200 | - kt = technical coefficient (max achievable technically); a negative value means reduction; unit = % 201 | - ka = absolute values for addition 202 | - kp = penetration coefficient (level of market penetration of the policy); unit = % 203 | - copy = allows you to copy a specific transation to a different point in the matrices (useful for proxy creation) 204 | - substitution = tells the software whether it needs to substitute values among specified categories 205 | - sk = which intervention should be substituted 206 | - swk = Substitution weighing factor (how much of the original transaction should be substituted); allows to simulate difference in prices and physical properties between categories; unit = % 207 | 208 | These can be set for: 209 | 210 | - product category e.g. C_STEL (basic iron), C_PULP (pulp), etc. 211 | - final demand category e.g. F_HOUS (households), F_GOVE (government), etc. 212 | - primary input category e.g. E_HRHS (employment highly skilled), T_TLSA (taxes less subsidies), etc. 213 | - emissions extensions e.g. E_CO2_c (CO2 - combustion) 214 | - material extensions e.g. NI.02 (Nature Inputs: Coking Coal) 215 | - resource extension e.g. L_1.1 (Land use - Arable Land - Rice) 216 | 217 | Furthemore, from the analysis sheet you can set the following variables to be compared in the analysis: 218 | 219 | - product categories 220 | - primary input categories 221 | - emissions extensions 222 | - material extensions 223 | - resource extensions 224 | - region of interest 225 | - impact categories # Please see the data_validation_list sheet in the scenarios.xls file for the comprehensive list 226 | 227 | 228 | 229 | ========== 230 | 6. Credits 231 | ========== 232 | 233 | Thanks to dr. Arnold Tukker, dr. Joao Dias Rodrigues for the supervision 234 | dr. Arjan de Koning for knowledge support in exiobase 235 | dr. Glenn Auguilar Hernandez for testing 236 | 237 | This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. 238 | 239 | .. _Cookiecutter: https://github.com/audreyr/cookiecutter 240 | .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage 241 | -------------------------------------------------------------------------------- /bitbucket-pipelines.yml: -------------------------------------------------------------------------------- 1 | # This is a sample build configuration for Python. 2 | # Check our guides at https://confluence.atlassian.com/x/x4UWN for more examples. 3 | # Only use spaces to indent your .yml configuration. 4 | # ----- 5 | # You can specify a custom docker image from Docker Hub as your build environment. 6 | image: python:3.5.1 7 | 8 | pipelines: 9 | default: 10 | - step: 11 | caches: 12 | - pip 13 | script: # Modify the commands below to build your repository. 14 | - pip install -r requirements.txt 15 | - step: 16 | name: Deploy to test 17 | deployment: test # can be test, staging or production 18 | # trigger: manual # uncomment to make manual deployment 19 | script: 20 | - echo "Deploying to test environment" 21 | -------------------------------------------------------------------------------- /conftest.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/conftest.py -------------------------------------------------------------------------------- /description.txt: -------------------------------------------------------------------------------- 1 | A software to model Circular Economy policy and technological interventions in Environmentally Extended Input-Output Analysis starting from SUTs (EXIOBASE V3.3) 2 | 3 | [License: GPL v3] 4 | [Contributions welcome] 5 | DOI: 10.5281/zenodo.1492957 6 | 7 | Documentation: https://cmlplatform.github.io/pycirk/ 8 | 9 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = python -msphinx 7 | SPHINXPROJ = pycirk 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/_build/doctrees/authors.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/doctrees/authors.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/contributing.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/doctrees/contributing.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/doctrees/environment.pickle -------------------------------------------------------------------------------- /docs/_build/doctrees/history.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/doctrees/history.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/doctrees/index.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/installation.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/doctrees/installation.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/modules.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/doctrees/modules.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/pycirk.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/doctrees/pycirk.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/readme.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/doctrees/readme.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/usage.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/doctrees/usage.doctree -------------------------------------------------------------------------------- /docs/_build/html/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 01296ca3e3f8b63c7a687e2e1ed41295 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /docs/_build/html/_modules/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Overview: module code — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 |
28 |
29 | 30 | 31 | 48 | 49 |
50 |
51 | 101 |
102 |
103 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /docs/_build/html/_modules/pycirk/organize_io.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | pycirk.organize_io — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 |
28 |
29 | 30 | 31 |
32 | 33 |

Source code for pycirk.organize_io

 34 | # -*- coding: utf-8 -*-
 35 | """
 36 | Created on Tue Feb 7 16:29:23 2017
 37 | 
 38 | Description: Organize essential tables for saving
 39 | 
 40 | Scope: Modelling the Circular economy in EEIO
 41 | 
 42 | 
 43 | @author: Franco Donati
 44 | @institution: Leiden University CML
 45 | """
 46 | 
 47 | import numpy as np
 48 | 
 49 | 
[docs]def organizer(data): 50 | 51 | return {"Z": np.array(data["Z"]), 52 | "Y": np.array(data["Y"]), 53 | "W": np.array(data["W"]), 54 | "E": np.array(data["E"]), 55 | "R": np.array(data["R"]), 56 | "M": np.array(data["M"]), 57 | "EY": np.array(data["EY"]), 58 | "RY": np.array(data["RY"]), 59 | "MY": np.array(data["MY"]), 60 | "Cr_E_k": np.array(data["Cr_E_k"]), 61 | "Cr_M_k": np.array(data["Cr_M_k"]), 62 | "Cr_R_k": np.array(data["Cr_R_k"]), 63 | "Cr_W_k": np.array(data["Cr_W_k"]) 64 | }
65 |
66 | 67 |
68 | 69 |
70 |
71 | 123 |
124 |
125 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/authors.rst.txt: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/contributing.rst.txt: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/history.rst.txt: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/index.rst.txt: -------------------------------------------------------------------------------- 1 | Welcome to pycirk's documentation! 2 | ====================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :caption: Contents: 7 | 8 | readme 9 | installation 10 | usage 11 | modules 12 | contributing 13 | authors 14 | history 15 | 16 | Indices and tables 17 | ================== 18 | * :ref:`genindex` 19 | * :ref:`modindex` 20 | * :ref:`search` 21 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/installation.rst.txt: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Installation 5 | ============ 6 | 7 | 8 | Stable release 9 | -------------- 10 | 11 | To install pycirk, run this command in your terminal: 12 | 13 | .. code-block:: console 14 | 15 | $ pip install pycirk 16 | 17 | This is the preferred method to install pycirk, as it will always install the most recent stable release. 18 | 19 | If you don't have `pip`_ installed, this `Python installation guide`_ can guide 20 | you through the process. 21 | 22 | .. _pip: https://pip.pypa.io 23 | .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ 24 | 25 | 26 | From sources 27 | ------------ 28 | 29 | The sources for pycirk can be downloaded from the `Github repo`_. 30 | 31 | You can either clone the public repository: 32 | 33 | .. code-block:: console 34 | 35 | $ git clone git://github.com/FDonati/pycirk 36 | 37 | Or download the `tarball`_: 38 | 39 | .. code-block:: console 40 | 41 | $ curl -OL https://github.com/FDonati/pycirk/tarball/master 42 | 43 | Once you have a copy of the source, you can install it with: 44 | 45 | .. code-block:: console 46 | 47 | $ python setup.py install 48 | 49 | 50 | .. _Github repo: https://github.com/FDonati/pycirk 51 | .. _tarball: https://github.com/FDonati/pycirk/tarball/master 52 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/modules.rst.txt: -------------------------------------------------------------------------------- 1 | pycirk 2 | ====== 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | pycirk 8 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/pycirk.rst.txt: -------------------------------------------------------------------------------- 1 | pycirk package 2 | ============== 3 | 4 | Submodules 5 | ---------- 6 | 7 | pycirk.cli module 8 | ----------------- 9 | 10 | .. automodule:: pycirk.cli 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | pycirk.fundamental\_operations module 16 | ------------------------------------- 17 | 18 | .. automodule:: pycirk.fundamental_operations 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | pycirk.labels module 24 | -------------------- 25 | 26 | .. automodule:: pycirk.labels 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | pycirk.make\_scenarios module 32 | ----------------------------- 33 | 34 | .. automodule:: pycirk.make_scenarios 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | pycirk.make\_secondary\_flows module 40 | ------------------------------------ 41 | 42 | .. automodule:: pycirk.make_secondary_flows 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | 47 | pycirk.organize\_io module 48 | -------------------------- 49 | 50 | .. automodule:: pycirk.organize_io 51 | :members: 52 | :undoc-members: 53 | :show-inheritance: 54 | 55 | pycirk.positions module 56 | ----------------------- 57 | 58 | .. automodule:: pycirk.positions 59 | :members: 60 | :undoc-members: 61 | :show-inheritance: 62 | 63 | pycirk.pycirk module 64 | -------------------- 65 | 66 | .. automodule:: pycirk.pycirk 67 | :members: 68 | :undoc-members: 69 | :show-inheritance: 70 | 71 | pycirk.pycirk\_settings module 72 | ------------------------------ 73 | 74 | .. automodule:: pycirk.pycirk_settings 75 | :members: 76 | :undoc-members: 77 | :show-inheritance: 78 | 79 | pycirk.results module 80 | --------------------- 81 | 82 | .. automodule:: pycirk.results 83 | :members: 84 | :undoc-members: 85 | :show-inheritance: 86 | 87 | pycirk.save\_utils module 88 | ------------------------- 89 | 90 | .. automodule:: pycirk.save_utils 91 | :members: 92 | :undoc-members: 93 | :show-inheritance: 94 | 95 | pycirk.transformation\_methods module 96 | ------------------------------------- 97 | 98 | .. automodule:: pycirk.transformation_methods 99 | :members: 100 | :undoc-members: 101 | :show-inheritance: 102 | 103 | Module contents 104 | --------------- 105 | 106 | .. automodule:: pycirk 107 | :members: 108 | :undoc-members: 109 | :show-inheritance: 110 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/readme.rst.txt: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/usage.rst.txt: -------------------------------------------------------------------------------- 1 | ===== 2 | Usage 3 | ===== 4 | 5 | To use pycirk in a project:: 6 | 7 | import pycirk 8 | -------------------------------------------------------------------------------- /docs/_build/html/_static/custom.css: -------------------------------------------------------------------------------- 1 | /* This file intentionally left blank. */ 2 | -------------------------------------------------------------------------------- /docs/_build/html/_static/doctools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * doctools.js 3 | * ~~~~~~~~~~~ 4 | * 5 | * Sphinx JavaScript utilities for all documentation. 6 | * 7 | * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /** 13 | * select a different prefix for underscore 14 | */ 15 | $u = _.noConflict(); 16 | 17 | /** 18 | * make the code below compatible with browsers without 19 | * an installed firebug like debugger 20 | if (!window.console || !console.firebug) { 21 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir", 22 | "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", 23 | "profile", "profileEnd"]; 24 | window.console = {}; 25 | for (var i = 0; i < names.length; ++i) 26 | window.console[names[i]] = function() {}; 27 | } 28 | */ 29 | 30 | /** 31 | * small helper function to urldecode strings 32 | * 33 | * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL 34 | */ 35 | jQuery.urldecode = function(x) { 36 | if (!x) { 37 | return x 38 | } 39 | return decodeURIComponent(x.replace(/\+/g, ' ')); 40 | }; 41 | 42 | /** 43 | * small helper function to urlencode strings 44 | */ 45 | jQuery.urlencode = encodeURIComponent; 46 | 47 | /** 48 | * This function returns the parsed url parameters of the 49 | * current request. Multiple values per key are supported, 50 | * it will always return arrays of strings for the value parts. 51 | */ 52 | jQuery.getQueryParameters = function(s) { 53 | if (typeof s === 'undefined') 54 | s = document.location.search; 55 | var parts = s.substr(s.indexOf('?') + 1).split('&'); 56 | var result = {}; 57 | for (var i = 0; i < parts.length; i++) { 58 | var tmp = parts[i].split('=', 2); 59 | var key = jQuery.urldecode(tmp[0]); 60 | var value = jQuery.urldecode(tmp[1]); 61 | if (key in result) 62 | result[key].push(value); 63 | else 64 | result[key] = [value]; 65 | } 66 | return result; 67 | }; 68 | 69 | /** 70 | * highlight a given string on a jquery object by wrapping it in 71 | * span elements with the given class name. 72 | */ 73 | jQuery.fn.highlightText = function(text, className) { 74 | function highlight(node, addItems) { 75 | if (node.nodeType === 3) { 76 | var val = node.nodeValue; 77 | var pos = val.toLowerCase().indexOf(text); 78 | if (pos >= 0 && 79 | !jQuery(node.parentNode).hasClass(className) && 80 | !jQuery(node.parentNode).hasClass("nohighlight")) { 81 | var span; 82 | var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg"); 83 | if (isInSVG) { 84 | span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); 85 | } else { 86 | span = document.createElement("span"); 87 | span.className = className; 88 | } 89 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 90 | node.parentNode.insertBefore(span, node.parentNode.insertBefore( 91 | document.createTextNode(val.substr(pos + text.length)), 92 | node.nextSibling)); 93 | node.nodeValue = val.substr(0, pos); 94 | if (isInSVG) { 95 | var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); 96 | var bbox = node.parentElement.getBBox(); 97 | rect.x.baseVal.value = bbox.x; 98 | rect.y.baseVal.value = bbox.y; 99 | rect.width.baseVal.value = bbox.width; 100 | rect.height.baseVal.value = bbox.height; 101 | rect.setAttribute('class', className); 102 | addItems.push({ 103 | "parent": node.parentNode, 104 | "target": rect}); 105 | } 106 | } 107 | } 108 | else if (!jQuery(node).is("button, select, textarea")) { 109 | jQuery.each(node.childNodes, function() { 110 | highlight(this, addItems); 111 | }); 112 | } 113 | } 114 | var addItems = []; 115 | var result = this.each(function() { 116 | highlight(this, addItems); 117 | }); 118 | for (var i = 0; i < addItems.length; ++i) { 119 | jQuery(addItems[i].parent).before(addItems[i].target); 120 | } 121 | return result; 122 | }; 123 | 124 | /* 125 | * backward compatibility for jQuery.browser 126 | * This will be supported until firefox bug is fixed. 127 | */ 128 | if (!jQuery.browser) { 129 | jQuery.uaMatch = function(ua) { 130 | ua = ua.toLowerCase(); 131 | 132 | var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || 133 | /(webkit)[ \/]([\w.]+)/.exec(ua) || 134 | /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || 135 | /(msie) ([\w.]+)/.exec(ua) || 136 | ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || 137 | []; 138 | 139 | return { 140 | browser: match[ 1 ] || "", 141 | version: match[ 2 ] || "0" 142 | }; 143 | }; 144 | jQuery.browser = {}; 145 | jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; 146 | } 147 | 148 | /** 149 | * Small JavaScript module for the documentation. 150 | */ 151 | var Documentation = { 152 | 153 | init : function() { 154 | this.fixFirefoxAnchorBug(); 155 | this.highlightSearchWords(); 156 | this.initIndexTable(); 157 | if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) { 158 | this.initOnKeyListeners(); 159 | } 160 | }, 161 | 162 | /** 163 | * i18n support 164 | */ 165 | TRANSLATIONS : {}, 166 | PLURAL_EXPR : function(n) { return n === 1 ? 0 : 1; }, 167 | LOCALE : 'unknown', 168 | 169 | // gettext and ngettext don't access this so that the functions 170 | // can safely bound to a different name (_ = Documentation.gettext) 171 | gettext : function(string) { 172 | var translated = Documentation.TRANSLATIONS[string]; 173 | if (typeof translated === 'undefined') 174 | return string; 175 | return (typeof translated === 'string') ? translated : translated[0]; 176 | }, 177 | 178 | ngettext : function(singular, plural, n) { 179 | var translated = Documentation.TRANSLATIONS[singular]; 180 | if (typeof translated === 'undefined') 181 | return (n == 1) ? singular : plural; 182 | return translated[Documentation.PLURALEXPR(n)]; 183 | }, 184 | 185 | addTranslations : function(catalog) { 186 | for (var key in catalog.messages) 187 | this.TRANSLATIONS[key] = catalog.messages[key]; 188 | this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); 189 | this.LOCALE = catalog.locale; 190 | }, 191 | 192 | /** 193 | * add context elements like header anchor links 194 | */ 195 | addContextElements : function() { 196 | $('div[id] > :header:first').each(function() { 197 | $('\u00B6'). 198 | attr('href', '#' + this.id). 199 | attr('title', _('Permalink to this headline')). 200 | appendTo(this); 201 | }); 202 | $('dt[id]').each(function() { 203 | $('\u00B6'). 204 | attr('href', '#' + this.id). 205 | attr('title', _('Permalink to this definition')). 206 | appendTo(this); 207 | }); 208 | }, 209 | 210 | /** 211 | * workaround a firefox stupidity 212 | * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075 213 | */ 214 | fixFirefoxAnchorBug : function() { 215 | if (document.location.hash && $.browser.mozilla) 216 | window.setTimeout(function() { 217 | document.location.href += ''; 218 | }, 10); 219 | }, 220 | 221 | /** 222 | * highlight the search words provided in the url in the text 223 | */ 224 | highlightSearchWords : function() { 225 | var params = $.getQueryParameters(); 226 | var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; 227 | if (terms.length) { 228 | var body = $('div.body'); 229 | if (!body.length) { 230 | body = $('body'); 231 | } 232 | window.setTimeout(function() { 233 | $.each(terms, function() { 234 | body.highlightText(this.toLowerCase(), 'highlighted'); 235 | }); 236 | }, 10); 237 | $('') 239 | .appendTo($('#searchbox')); 240 | } 241 | }, 242 | 243 | /** 244 | * init the domain index toggle buttons 245 | */ 246 | initIndexTable : function() { 247 | var togglers = $('img.toggler').click(function() { 248 | var src = $(this).attr('src'); 249 | var idnum = $(this).attr('id').substr(7); 250 | $('tr.cg-' + idnum).toggle(); 251 | if (src.substr(-9) === 'minus.png') 252 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); 253 | else 254 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); 255 | }).css('display', ''); 256 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { 257 | togglers.click(); 258 | } 259 | }, 260 | 261 | /** 262 | * helper function to hide the search marks again 263 | */ 264 | hideSearchWords : function() { 265 | $('#searchbox .highlight-link').fadeOut(300); 266 | $('span.highlighted').removeClass('highlighted'); 267 | }, 268 | 269 | /** 270 | * make the url absolute 271 | */ 272 | makeURL : function(relativeURL) { 273 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; 274 | }, 275 | 276 | /** 277 | * get the current relative url 278 | */ 279 | getCurrentURL : function() { 280 | var path = document.location.pathname; 281 | var parts = path.split(/\//); 282 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { 283 | if (this === '..') 284 | parts.pop(); 285 | }); 286 | var url = parts.join('/'); 287 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1); 288 | }, 289 | 290 | initOnKeyListeners: function() { 291 | $(document).keydown(function(event) { 292 | var activeElementType = document.activeElement.tagName; 293 | // don't navigate when in search box, textarea, dropdown or button 294 | if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT' 295 | && activeElementType !== 'BUTTON' && !event.altKey && !event.ctrlKey && !event.metaKey 296 | && !event.shiftKey) { 297 | switch (event.keyCode) { 298 | case 37: // left 299 | var prevHref = $('link[rel="prev"]').prop('href'); 300 | if (prevHref) { 301 | window.location.href = prevHref; 302 | return false; 303 | } 304 | case 39: // right 305 | var nextHref = $('link[rel="next"]').prop('href'); 306 | if (nextHref) { 307 | window.location.href = nextHref; 308 | return false; 309 | } 310 | } 311 | } 312 | }); 313 | } 314 | }; 315 | 316 | // quick alias for translations 317 | _ = Documentation.gettext; 318 | 319 | $(document).ready(function() { 320 | Documentation.init(); 321 | }); 322 | -------------------------------------------------------------------------------- /docs/_build/html/_static/documentation_options.js: -------------------------------------------------------------------------------- 1 | var DOCUMENTATION_OPTIONS = { 2 | URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), 3 | VERSION: '1.5.5', 4 | LANGUAGE: 'None', 5 | COLLAPSE_INDEX: false, 6 | BUILDER: 'html', 7 | FILE_SUFFIX: '.html', 8 | LINK_SUFFIX: '.html', 9 | HAS_SOURCE: true, 10 | SOURCELINK_SUFFIX: '.txt', 11 | NAVIGATION_WITH_KEYS: false 12 | }; -------------------------------------------------------------------------------- /docs/_build/html/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/html/_static/file.png -------------------------------------------------------------------------------- /docs/_build/html/_static/language_data.js: -------------------------------------------------------------------------------- 1 | /* 2 | * language_data.js 3 | * ~~~~~~~~~~~~~~~~ 4 | * 5 | * This script contains the language-specific data used by searchtools.js, 6 | * namely the list of stopwords, stemmer, scorer and splitter. 7 | * 8 | * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. 9 | * :license: BSD, see LICENSE for details. 10 | * 11 | */ 12 | 13 | var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]; 14 | 15 | 16 | /* Non-minified version is copied as a separate JS file, is available */ 17 | 18 | /** 19 | * Porter Stemmer 20 | */ 21 | var Stemmer = function() { 22 | 23 | var step2list = { 24 | ational: 'ate', 25 | tional: 'tion', 26 | enci: 'ence', 27 | anci: 'ance', 28 | izer: 'ize', 29 | bli: 'ble', 30 | alli: 'al', 31 | entli: 'ent', 32 | eli: 'e', 33 | ousli: 'ous', 34 | ization: 'ize', 35 | ation: 'ate', 36 | ator: 'ate', 37 | alism: 'al', 38 | iveness: 'ive', 39 | fulness: 'ful', 40 | ousness: 'ous', 41 | aliti: 'al', 42 | iviti: 'ive', 43 | biliti: 'ble', 44 | logi: 'log' 45 | }; 46 | 47 | var step3list = { 48 | icate: 'ic', 49 | ative: '', 50 | alize: 'al', 51 | iciti: 'ic', 52 | ical: 'ic', 53 | ful: '', 54 | ness: '' 55 | }; 56 | 57 | var c = "[^aeiou]"; // consonant 58 | var v = "[aeiouy]"; // vowel 59 | var C = c + "[^aeiouy]*"; // consonant sequence 60 | var V = v + "[aeiou]*"; // vowel sequence 61 | 62 | var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 63 | var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 64 | var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 65 | var s_v = "^(" + C + ")?" + v; // vowel in stem 66 | 67 | this.stemWord = function (w) { 68 | var stem; 69 | var suffix; 70 | var firstch; 71 | var origword = w; 72 | 73 | if (w.length < 3) 74 | return w; 75 | 76 | var re; 77 | var re2; 78 | var re3; 79 | var re4; 80 | 81 | firstch = w.substr(0,1); 82 | if (firstch == "y") 83 | w = firstch.toUpperCase() + w.substr(1); 84 | 85 | // Step 1a 86 | re = /^(.+?)(ss|i)es$/; 87 | re2 = /^(.+?)([^s])s$/; 88 | 89 | if (re.test(w)) 90 | w = w.replace(re,"$1$2"); 91 | else if (re2.test(w)) 92 | w = w.replace(re2,"$1$2"); 93 | 94 | // Step 1b 95 | re = /^(.+?)eed$/; 96 | re2 = /^(.+?)(ed|ing)$/; 97 | if (re.test(w)) { 98 | var fp = re.exec(w); 99 | re = new RegExp(mgr0); 100 | if (re.test(fp[1])) { 101 | re = /.$/; 102 | w = w.replace(re,""); 103 | } 104 | } 105 | else if (re2.test(w)) { 106 | var fp = re2.exec(w); 107 | stem = fp[1]; 108 | re2 = new RegExp(s_v); 109 | if (re2.test(stem)) { 110 | w = stem; 111 | re2 = /(at|bl|iz)$/; 112 | re3 = new RegExp("([^aeiouylsz])\\1$"); 113 | re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); 114 | if (re2.test(w)) 115 | w = w + "e"; 116 | else if (re3.test(w)) { 117 | re = /.$/; 118 | w = w.replace(re,""); 119 | } 120 | else if (re4.test(w)) 121 | w = w + "e"; 122 | } 123 | } 124 | 125 | // Step 1c 126 | re = /^(.+?)y$/; 127 | if (re.test(w)) { 128 | var fp = re.exec(w); 129 | stem = fp[1]; 130 | re = new RegExp(s_v); 131 | if (re.test(stem)) 132 | w = stem + "i"; 133 | } 134 | 135 | // Step 2 136 | re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; 137 | if (re.test(w)) { 138 | var fp = re.exec(w); 139 | stem = fp[1]; 140 | suffix = fp[2]; 141 | re = new RegExp(mgr0); 142 | if (re.test(stem)) 143 | w = stem + step2list[suffix]; 144 | } 145 | 146 | // Step 3 147 | re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; 148 | if (re.test(w)) { 149 | var fp = re.exec(w); 150 | stem = fp[1]; 151 | suffix = fp[2]; 152 | re = new RegExp(mgr0); 153 | if (re.test(stem)) 154 | w = stem + step3list[suffix]; 155 | } 156 | 157 | // Step 4 158 | re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; 159 | re2 = /^(.+?)(s|t)(ion)$/; 160 | if (re.test(w)) { 161 | var fp = re.exec(w); 162 | stem = fp[1]; 163 | re = new RegExp(mgr1); 164 | if (re.test(stem)) 165 | w = stem; 166 | } 167 | else if (re2.test(w)) { 168 | var fp = re2.exec(w); 169 | stem = fp[1] + fp[2]; 170 | re2 = new RegExp(mgr1); 171 | if (re2.test(stem)) 172 | w = stem; 173 | } 174 | 175 | // Step 5 176 | re = /^(.+?)e$/; 177 | if (re.test(w)) { 178 | var fp = re.exec(w); 179 | stem = fp[1]; 180 | re = new RegExp(mgr1); 181 | re2 = new RegExp(meq1); 182 | re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); 183 | if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) 184 | w = stem; 185 | } 186 | re = /ll$/; 187 | re2 = new RegExp(mgr1); 188 | if (re.test(w) && re2.test(w)) { 189 | re = /.$/; 190 | w = w.replace(re,""); 191 | } 192 | 193 | // and turn initial Y back to y 194 | if (firstch == "y") 195 | w = firstch.toLowerCase() + w.substr(1); 196 | return w; 197 | } 198 | } 199 | 200 | 201 | 202 | 203 | var splitChars = (function() { 204 | var result = {}; 205 | var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648, 206 | 1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702, 207 | 2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971, 208 | 2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345, 209 | 3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761, 210 | 3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823, 211 | 4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125, 212 | 8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695, 213 | 11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587, 214 | 43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141]; 215 | var i, j, start, end; 216 | for (i = 0; i < singles.length; i++) { 217 | result[singles[i]] = true; 218 | } 219 | var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709], 220 | [722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161], 221 | [1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568], 222 | [1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807], 223 | [1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047], 224 | [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383], 225 | [2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450], 226 | [2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547], 227 | [2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673], 228 | [2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820], 229 | [2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946], 230 | [2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023], 231 | [3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173], 232 | [3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332], 233 | [3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481], 234 | [3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718], 235 | [3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791], 236 | [3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095], 237 | [4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205], 238 | [4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687], 239 | [4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968], 240 | [4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869], 241 | [5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102], 242 | [6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271], 243 | [6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592], 244 | [6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822], 245 | [6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167], 246 | [7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959], 247 | [7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143], 248 | [8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318], 249 | [8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483], 250 | [8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101], 251 | [10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567], 252 | [11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292], 253 | [12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444], 254 | [12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783], 255 | [12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311], 256 | [19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511], 257 | [42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774], 258 | [42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071], 259 | [43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263], 260 | [43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519], 261 | [43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647], 262 | [43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967], 263 | [44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295], 264 | [57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274], 265 | [64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007], 266 | [65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381], 267 | [65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]]; 268 | for (i = 0; i < ranges.length; i++) { 269 | start = ranges[i][0]; 270 | end = ranges[i][1]; 271 | for (j = start; j <= end; j++) { 272 | result[j] = true; 273 | } 274 | } 275 | return result; 276 | })(); 277 | 278 | function splitQuery(query) { 279 | var result = []; 280 | var start = -1; 281 | for (var i = 0; i < query.length; i++) { 282 | if (splitChars[query.charCodeAt(i)]) { 283 | if (start !== -1) { 284 | result.push(query.slice(start, i)); 285 | start = -1; 286 | } 287 | } else if (start === -1) { 288 | start = i; 289 | } 290 | } 291 | if (start !== -1) { 292 | result.push(query.slice(start)); 293 | } 294 | return result; 295 | } 296 | 297 | 298 | -------------------------------------------------------------------------------- /docs/_build/html/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/html/_static/minus.png -------------------------------------------------------------------------------- /docs/_build/html/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/html/_static/plus.png -------------------------------------------------------------------------------- /docs/_build/html/_static/pygments.css: -------------------------------------------------------------------------------- 1 | pre { line-height: 125%; } 2 | td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } 3 | span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } 4 | td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } 5 | span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } 6 | .highlight .hll { background-color: #ffffcc } 7 | .highlight { background: #eeffcc; } 8 | .highlight .c { color: #408090; font-style: italic } /* Comment */ 9 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 10 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */ 11 | .highlight .o { color: #666666 } /* Operator */ 12 | .highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */ 13 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ 14 | .highlight .cp { color: #007020 } /* Comment.Preproc */ 15 | .highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */ 16 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ 17 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ 18 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 19 | .highlight .ge { font-style: italic } /* Generic.Emph */ 20 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 21 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 22 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 23 | .highlight .go { color: #333333 } /* Generic.Output */ 24 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 25 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 26 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 27 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 28 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 29 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 30 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ 31 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */ 32 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 33 | .highlight .kt { color: #902000 } /* Keyword.Type */ 34 | .highlight .m { color: #208050 } /* Literal.Number */ 35 | .highlight .s { color: #4070a0 } /* Literal.String */ 36 | .highlight .na { color: #4070a0 } /* Name.Attribute */ 37 | .highlight .nb { color: #007020 } /* Name.Builtin */ 38 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 39 | .highlight .no { color: #60add5 } /* Name.Constant */ 40 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 41 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 42 | .highlight .ne { color: #007020 } /* Name.Exception */ 43 | .highlight .nf { color: #06287e } /* Name.Function */ 44 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ 45 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 46 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ 47 | .highlight .nv { color: #bb60d5 } /* Name.Variable */ 48 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ 49 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 50 | .highlight .mb { color: #208050 } /* Literal.Number.Bin */ 51 | .highlight .mf { color: #208050 } /* Literal.Number.Float */ 52 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */ 53 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */ 54 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */ 55 | .highlight .sa { color: #4070a0 } /* Literal.String.Affix */ 56 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ 57 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */ 58 | .highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */ 59 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 60 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */ 61 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 62 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ 63 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 64 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */ 65 | .highlight .sr { color: #235388 } /* Literal.String.Regex */ 66 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */ 67 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */ 68 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ 69 | .highlight .fm { color: #06287e } /* Name.Function.Magic */ 70 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ 71 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ 72 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ 73 | .highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */ 74 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /docs/_build/html/authors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Credits — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |
30 |
31 | 32 | 33 |
34 | 35 |
36 |

Credits

37 |
38 |

Development Lead

39 | 42 |
43 |
44 |

Contributors

45 |

None yet. Why not be the first?

46 |
47 |
48 | 49 | 50 |
51 | 52 |
53 |
54 | 110 |
111 |
112 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /docs/_build/html/contributing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Contributing — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |
30 |
31 | 32 | 33 |
34 | 35 |
36 |

Contributing

37 |

Contributions are welcome, and they are greatly appreciated! Every little bit 38 | helps, and credit will always be given.

39 |

You can contribute in many ways:

40 |
41 |

Types of Contributions

42 |
43 |

Report Bugs

44 |

Report bugs at https://github.com/FDonati/pycirk/issues.

45 |

If you are reporting a bug, please include:

46 |
    47 |
  • Your operating system name and version.

  • 48 |
  • Any details about your local setup that might be helpful in troubleshooting.

  • 49 |
  • Detailed steps to reproduce the bug.

  • 50 |
51 |
52 |
53 |

Fix Bugs

54 |

Look through the GitHub issues for bugs. Anything tagged with “bug” and “help 55 | wanted” is open to whoever wants to implement it.

56 |
57 |
58 |

Implement Features

59 |

Look through the GitHub issues for features. Anything tagged with “enhancement” 60 | and “help wanted” is open to whoever wants to implement it.

61 |
62 |
63 |

Write Documentation

64 |

pycirk could always use more documentation, whether as part of the 65 | official pycirk docs, in docstrings, or even on the web in blog posts, 66 | articles, and such.

67 |
68 |
69 |

Submit Feedback

70 |

The best way to send feedback is to file an issue at https://github.com/FDonati/pycirk/issues.

71 |

If you are proposing a feature:

72 |
    73 |
  • Explain in detail how it would work.

  • 74 |
  • Keep the scope as narrow as possible, to make it easier to implement.

  • 75 |
  • Remember that this is a volunteer-driven project, and that contributions 76 | are welcome :)

  • 77 |
78 |
79 |
80 |
81 |

Get Started!

82 |

Ready to contribute? Here’s how to set up pycirk for local development.

83 |
    84 |
  1. Fork the pycirk repo on GitHub.

  2. 85 |
  3. Clone your fork locally:

    86 |
    $ git clone git@github.com:your_name_here/pycirk.git
     87 | 
    88 |
    89 |
  4. 90 |
  5. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    91 |
    $ mkvirtualenv pycirk
     92 | $ cd pycirk/
     93 | $ python setup.py develop
     94 | 
    95 |
    96 |
  6. 97 |
  7. Create a branch for local development:

    98 |
    $ git checkout -b name-of-your-bugfix-or-feature
     99 | 
    100 |
    101 |

    Now you can make your changes locally.

    102 |
  8. 103 |
  9. When you’re done making changes, check that your changes pass flake8 and the 104 | tests, including testing other Python versions with tox:

    105 |
    $ flake8 pycirk tests
    106 | $ python setup.py test or py.test
    107 | $ tox
    108 | 
    109 |
    110 |

    To get flake8 and tox, just pip install them into your virtualenv.

    111 |
  10. 112 |
  11. Commit your changes and push your branch to GitHub:

    113 |
    $ git add .
    114 | $ git commit -m "Your detailed description of your changes."
    115 | $ git push origin name-of-your-bugfix-or-feature
    116 | 
    117 |
    118 |
  12. 119 |
  13. Submit a pull request through the GitHub website.

  14. 120 |
121 |
122 |
123 |

Pull Request Guidelines

124 |

Before you submit a pull request, check that it meets these guidelines:

125 |
    126 |
  1. The pull request should include tests.

  2. 127 |
  3. If the pull request adds functionality, the docs should be updated. Put 128 | your new functionality into a function with a docstring, and add the 129 | feature to the list in README.rst.

  4. 130 |
  5. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check 131 | https://travis-ci.org/FDonati/pycirk/pull_requests 132 | and make sure that the tests pass for all supported Python versions.

  6. 133 |
134 |
135 |
136 |

Tips

137 |

To run a subset of tests:

138 |
$ py.test tests.test_pycirk
139 | 
140 |
141 |
142 |
143 |

Deploying

144 |

A reminder for the maintainers on how to deploy. 145 | Make sure all your changes are committed (including an entry in HISTORY.rst). 146 | Then run:

147 |
$ bumpversion patch # possible: major / minor / patch
148 | $ git push
149 | $ git push --tags
150 | 
151 |
152 |

Travis will then deploy to PyPI if tests pass.

153 |
154 |
155 | 156 | 157 |
158 | 159 |
160 |
161 | 220 |
221 |
222 | 233 | 234 | 235 | 236 | 237 | 238 | -------------------------------------------------------------------------------- /docs/_build/html/history.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | History — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
30 | 31 | 32 |
33 | 34 |
35 |

History

36 |
37 |

0.1.0 (2018-05-11)

38 |
    39 |
  • First release on PyPI.

  • 40 |
41 |
42 |
43 | 44 | 45 |
46 | 47 |
48 |
49 | 103 |
104 |
105 | 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /docs/_build/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Welcome to pycirk’s documentation! — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
30 | 31 | 32 |
33 | 34 |
35 |

Welcome to pycirk’s documentation!

36 |
37 |

Contents:

38 | 75 |
76 |
77 |
78 |

Indices and tables

79 | 84 |
85 | 86 | 87 |
88 | 89 |
90 |
91 | 142 |
143 |
144 | 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /docs/_build/html/installation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Installation — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |
30 |
31 | 32 | 33 |
34 | 35 |
36 |

Installation

37 |
38 |

Stable release

39 |

To install pycirk, run this command in your terminal:

40 |
$ pip install pycirk
 41 | 
42 |
43 |

This is the preferred method to install pycirk, as it will always install the most recent stable release.

44 |

If you don’t have pip installed, this Python installation guide can guide 45 | you through the process.

46 |
47 |
48 |

From sources

49 |

The sources for pycirk can be downloaded from the Github repo.

50 |

You can either clone the public repository:

51 |
$ git clone git://github.com/FDonati/pycirk
 52 | 
53 |
54 |

Or download the tarball:

55 |
$ curl  -OL https://github.com/FDonati/pycirk/tarball/master
 56 | 
57 |
58 |

Once you have a copy of the source, you can install it with:

59 |
$ python setup.py install
 60 | 
61 |
62 |
63 |
64 | 65 | 66 |
67 | 68 |
69 |
70 | 126 |
127 |
128 | 139 | 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /docs/_build/html/modules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | pycirk — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 65 | 120 |
121 |
122 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /docs/_build/html/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/docs/_build/html/objects.inv -------------------------------------------------------------------------------- /docs/_build/html/py-modindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Python Module Index — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
31 |
32 | 33 | 34 |
35 | 36 | 37 |

Python Module Index

38 | 39 |
40 | p 41 |
42 | 43 | 44 | 45 | 47 | 48 | 50 | 53 | 54 | 55 | 58 | 59 | 60 | 63 | 64 | 65 | 68 | 69 | 70 | 73 | 74 | 75 | 78 | 79 | 80 | 83 | 84 | 85 | 88 | 89 | 90 | 93 | 94 | 95 | 98 | 99 | 100 | 103 | 104 | 105 | 108 |
 
46 | p
51 | pycirk 52 |
    56 | pycirk.fundamental_operations 57 |
    61 | pycirk.labels 62 |
    66 | pycirk.make_scenarios 67 |
    71 | pycirk.make_secondary_flows 72 |
    76 | pycirk.organize_io 77 |
    81 | pycirk.positions 82 |
    86 | pycirk.pycirk 87 |
    91 | pycirk.pycirk_settings 92 |
    96 | pycirk.results 97 |
    101 | pycirk.save_utils 102 |
    106 | pycirk.transformation_methods 107 |
109 | 110 | 111 |
112 | 113 |
114 |
115 | 165 |
166 |
167 | 175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /docs/_build/html/search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Search — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
33 |
34 |
35 | 36 | 37 |
38 | 39 |

Search

40 |
41 | 42 |

43 | Please activate JavaScript to enable the search 44 | functionality. 45 |

46 |
47 |

48 | Searching for multiple words only shows matches that contain 49 | all words. 50 |

51 |
52 | 53 | 54 | 55 |
56 | 57 |
58 | 59 |
60 | 61 |
62 | 63 |
64 |
65 | 105 |
106 |
107 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /docs/_build/html/searchindex.js: -------------------------------------------------------------------------------- 1 | Search.setIndex({docnames:["authors","contributing","history","index","installation","modules","pycirk","readme","usage"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.viewcode":1,sphinx:56},filenames:["authors.rst","contributing.rst","history.rst","index.rst","installation.rst","modules.rst","pycirk.rst","readme.rst","usage.rst"],objects:{"":{pycirk:[6,0,0,"-"]},"pycirk.fundamental_operations":{Operations:[6,1,1,""]},"pycirk.fundamental_operations.Operations":{IOT:[6,1,1,""],PxP_ITA_MSC:[6,1,1,""],PxP_ITA_TC:[6,1,1,""],calculate_characterized:[6,2,1,""],delta_Y:[6,2,1,""],delta_x:[6,2,1,""],inv:[6,2,1,""],verifyIOT:[6,2,1,""]},"pycirk.fundamental_operations.Operations.IOT":{A:[6,2,1,""],B:[6,2,1,""],IOT:[6,2,1,""],L:[6,2,1,""],R:[6,2,1,""],RY:[6,2,1,""],Z:[6,2,1,""],bY:[6,2,1,""],x:[6,2,1,""],x_IAy:[6,2,1,""]},"pycirk.fundamental_operations.Operations.PxP_ITA_MSC":{A:[6,2,1,""],B:[6,2,1,""],D:[6,2,1,""],L:[6,2,1,""],R:[6,2,1,""],S:[6,2,1,""],Z:[6,2,1,""]},"pycirk.fundamental_operations.Operations.PxP_ITA_TC":{B:[6,2,1,""],L:[6,2,1,""],R:[6,2,1,""],T:[6,2,1,""],Z:[6,2,1,""]},"pycirk.labels":{Labels:[6,1,1,""]},"pycirk.labels.Labels":{apply_labels:[6,2,1,""],calc_no_of_something:[6,2,1,""],get_labels:[6,2,1,""],get_unique_labels:[6,2,1,""],identify_labels:[6,2,1,""],list_of_something:[6,2,1,""],load_labels:[6,2,1,""],organize_unique_labels:[6,2,1,""],relabel:[6,2,1,""],relabel_to_save:[6,2,1,""],save_labels:[6,2,1,""]},"pycirk.make_scenarios":{basic_add:[6,3,1,""],basic_mult:[6,3,1,""],counterfactual:[6,3,1,""],counterfactual_engine:[6,3,1,""],make_counterfactuals:[6,3,1,""],make_new:[6,3,1,""],substitution:[6,3,1,""]},"pycirk.make_secondary_flows":{allocate_sec_mat:[6,3,1,""],make_secondary:[6,3,1,""]},"pycirk.organize_io":{organizer:[6,3,1,""]},"pycirk.positions":{make_coord_array:[6,3,1,""],make_coord_array_for_make_sec:[6,3,1,""],single_position:[6,3,1,""]},"pycirk.pycirk":{Launch:[6,1,1,""]},"pycirk.pycirk.Launch":{all_results:[6,2,1,""],delete_previous_IO_builds:[6,2,1,""],save_results:[6,2,1,""],scenario_results:[6,2,1,""]},"pycirk.pycirk_settings":{Settings:[6,1,1,""]},"pycirk.pycirk_settings.Settings":{check_dataset_location:[6,2,1,""],check_expand_directory:[6,2,1,""],create_output_folder:[6,2,1,""],create_scenario_file:[6,2,1,""],load_dataset:[6,2,1,""],load_results_params:[6,2,1,""],number_scenarios:[6,2,1,""],project_specs:[6,2,1,""],scenario_file:[6,2,1,""],set_IO_scenario:[6,2,1,""],set_SUTs:[6,2,1,""],set_save_directory:[6,2,1,""],transform_to_io:[6,2,1,""]},"pycirk.results":{iter_thru_for_results:[6,3,1,""],retrieve_specified_data:[6,3,1,""],rsd_engine:[6,3,1,""]},"pycirk.save_utils":{add_date_to_gen_specs:[6,3,1,""],save_outputs:[6,3,1,""]},"pycirk.transformation_methods":{Transform:[6,1,1,""]},"pycirk.transformation_methods.Transform":{IOTpxpSTA_MSCm:[6,2,1,""],IOTpxpSTA_TCm:[6,2,1,""]},pycirk:{fundamental_operations:[6,0,0,"-"],labels:[6,0,0,"-"],make_scenarios:[6,0,0,"-"],make_secondary_flows:[6,0,0,"-"],organize_io:[6,0,0,"-"],positions:[6,0,0,"-"],pycirk:[6,0,0,"-"],pycirk_settings:[6,0,0,"-"],results:[6,0,0,"-"],save_utils:[6,0,0,"-"],transformation_methods:[6,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:function"},terms:{"100":6,"1016":7,"103":6,"104508":7,"105":6,"107":6,"109":6,"111":6,"112":6,"113":6,"149":6,"1492957":7,"2011":7,"2016":6,"2017":6,"2018":[3,6],"2019":[6,7],"4695823":7,"5281":7,"case":[6,7],"class":6,"default":[6,7],"final":[6,7],"float":6,"function":[1,6],"import":[3,8],"int":6,"new":[1,6],"public":[4,7],"return":6,"true":[6,7],The:[1,4,6,7],Then:1,These:7,Use:7,Uses:6,_name:6,a_alum:6,a_cmnt:6,a_con:6,a_copp:6,a_gla:6,a_lztp:6,a_onfm:6,a_pla:6,a_prem:6,a_pulp:6,a_stel:6,a_wood:6,about:[1,6],absolut:[6,7],accept:7,accord:6,achiev:[6,7],acillari:6,action:6,add:[1,6],add_date_to_gen_spec:6,added:[6,7],addit:7,affect:[6,7],aggreg:[6,7],all:[1,6,7],all_result:[6,7],allign:6,allocate_sec_mat:6,allow:[6,7],alreadi:6,also:6,alwai:[1,4],among:7,analysi:6,analysis_spec:6,analyt:6,ancillari:7,anew:6,ani:[1,6],anoth:6,anyth:1,appar:6,appear:6,appli:[6,7],applic:6,apply_label:6,appreci:1,arabl:7,arjan:[6,7],arnold:7,arrai:6,articl:1,assum:1,assumpt:6,audreyr:7,auguilar:7,author:6,avail:6,axi:6,balanc:6,base:6,baselin:[6,7],basic:[6,7],basic_add:6,basic_mult:6,befor:1,begin:6,being:6,belong:6,best:1,between:7,biregion:7,bit:1,bitbucket:7,black:7,blog:1,bool:6,both:7,branch:1,bugfix:1,bumpvers:1,c_alum:6,c_cmnt:6,c_con:6,c_copp:6,c_gla:6,c_lztp:6,c_onfm:6,c_pla:6,c_prem:6,c_pulp:[6,7],c_stel:[6,7],c_wood:6,caclcul:6,calc_no_of_someth:6,calcual:6,calcul:6,calculate_character:6,call:6,can:[1,4,6,7],cat_coord:6,cat_d:7,cat_o:7,categori:[6,7],cell:6,certain:6,chain:6,chang:[1,6,7],change_typ:7,check:[1,6],check_dataset_loc:6,check_expand_directori:6,checkout:1,chosen:6,circular:[6,7],cite:7,clariti:6,cli:5,clone:[1,4,7],cml:[0,6,7],co2:7,coal:7,coef:6,coeff:6,coeffici:[6,7],coeffient:6,cointain:6,coke:7,collect:6,colum:6,column:[6,7],column_label:6,com:[1,4],combust:7,come:6,command:[4,7],commit:1,compar:7,complet:6,comprehens:7,conceptu:7,concern:6,consid:6,consol:7,contain:6,contan:6,content:5,continu:7,contribut:3,contributor:[3,6],cookiecutt:7,coordin:[6,7],copi:[1,4,6,7],could:1,count:6,counterfactu:6,counterfactual_engin:6,countri:6,creat:[1,6,7],create_output_fold:6,create_scenario_fil:6,creation:7,credit:[1,3],curl:4,data:6,data_validation_list:7,databas:[6,7],datafram:6,dataframe_of_label:6,dataset:6,defin:6,delete_previous_io_build:6,delft:6,delta_i:6,delta_x:6,demand:[6,7],depend:6,deploi:3,descript:[1,6],desir:6,destin:[6,7],detail:1,develop:[1,3],dia:7,diag:6,diag_q:6,diag_x:6,diag_yj:6,dict:6,dictionari:6,differ:[6,7],diplai:6,directori:[6,7],distribut:6,divid:6,doc:1,docstr:1,document:7,doi:7,domest:7,don:[4,6],donati:[0,6],done:[1,6],download:[4,7],driven:1,e_co2_c:7,e_hrh:7,each:6,easier:1,economi:[6,7],eeio:6,eeioa:6,effect:[6,7],effici:7,either:4,element:6,elimin:6,elin:6,emiss:[6,7],employ:7,enhanc:1,ensur:6,enter:6,entri:[1,6],environment:7,equal:6,essenti:6,etc:[6,7],even:1,everi:1,everyth:6,exampl:7,excel:6,exiobas:7,exist:6,exit:7,expan:6,expand:6,expans:6,explain:1,extend:7,extens:[6,7],extent:7,f_gove:7,f_hou:7,factor:7,fals:[6,7],fdonati:[1,4,7],featur:3,feb:6,file:[1,6,7],filter:6,filterd_chang:6,filtered_chang:6,find:6,first:[0,2],flake8:1,flow:6,folder:6,follow:7,for_unit:6,fork:1,form:6,format:6,found:6,franco:[0,6],fri:6,from:[3,6],fundament:6,fundamental_oper:5,furthemor:7,futur:6,fx_kp:6,gather:6,gener:6,get:3,get_label:6,get_unique_label:6,git:[1,4,7],github:[1,4],given:[1,6],glenn:7,good:6,govern:7,greatli:1,guid:4,guidelin:3,handl:6,have:[1,4,6,7],help:[1,7],here:[1,6],hernandez:7,highli:7,histori:[1,3],home:7,household:7,how:[1,7],html:7,http:[1,4,7],ide:6,identif:6,identifi:6,identify_label:6,impact:7,implement:6,includ:1,ind:6,ind_or:6,index:[3,6],index_label:6,industri:6,inf:6,info:6,info_and_result:6,inform:6,initi:6,input:[6,7],insid:7,instal:[1,3,6],instead:6,institut:6,integ:6,intemedi:6,intens:6,inter_coef:6,inter_set:6,interest:7,intermedi:[6,7],intervent:[6,7],inv:6,inv_diag_g:6,inv_diag_q:6,inv_diag_x:6,inv_diag_yj:6,invers:6,iot:[6,7],iotpxpsta_mscm:6,iotpxpsta_tcm:6,iron:7,issu:1,ita:6,ita_msc:7,ita_tc:7,item:6,iter_thru_for_result:6,jan:6,joao:7,jul:6,just:[1,6],keep:1,knowledg:7,kone:[6,7],l_1:7,label:5,labels_directori:6,lalt:6,land:7,latest:7,launch:[6,7],lead:3,left:7,leiden:6,leidenuniv:0,leontief:6,less:7,level:[6,7],lib:7,life:7,line:7,link:7,list:[1,6,7],list_of_someth:6,littl:1,load:6,load_dataset:6,load_label:6,load_results_param:6,loc:6,local:[1,7],locat:6,look:[1,6],m_name:6,mai:6,main:6,maintain:1,major:1,make:[1,6],make_coord_arrai:6,make_coord_array_for_make_sec:6,make_counterfactu:6,make_new:6,make_scenario:5,make_secondari:6,make_secondary_flow:5,mani:1,mar:6,mark:6,market:[6,7],master:4,materi:[6,7],matric:[6,7],matrix:[6,7],max:[6,7],mean:7,meet:1,messag:7,method:[4,6,7],might:1,minor:1,miss:6,mkvirtualenv:1,model:[6,7],modifi:6,modul:[3,5],mofifi:6,mon:6,more:1,most:4,move:6,msc:7,much:7,multi:6,multiindex:6,multipl:6,multipli:6,multiregion:7,munch:6,my_work:7,name:[1,6],nan:6,narrow:1,natur:7,necessari:6,need:7,neg:7,no_categori:6,no_countri:6,nomenclatur:6,none:[0,6,7],note:6,nov:6,now:[1,6],number:6,number_scenario:6,numer:6,numpi:6,obj:6,object:6,obtain:6,offici:1,onc:[4,6,7],one:[6,7],onli:[6,7],onto:6,open:[1,7],oper:[1,6],option:7,order:6,org:[1,7],organ:6,organize_io:5,organize_unique_label:6,origin:[1,6,7],other:[1,6],otherwis:6,ouput:6,output:[6,7],output_datas:6,output_dataset:[6,7],packag:[3,5],page:3,panda:6,paramet:[6,7],part:[1,6],pass:[1,6],past:6,patch:1,penet:6,penetr:[6,7],perform:[6,7],physic:7,pickl:6,pip:[1,4,7],pkl:6,place:[6,7],pleas:[1,6,7],plu:6,point:[6,7],polici:[6,7],pos:6,posit:5,possibl:[1,6,7],post:1,pre:6,prefer:4,presenc:6,present:6,pretti:6,previou:6,previous:6,price:7,primari:[6,7],proccess:6,process:[4,6],prod:6,prod_or:6,product:[6,7],prodxprod:6,programm:6,project:[1,6,7,8],project_spec:6,properti:7,propos:1,proxi:7,pull:3,pull_request:1,pulp:7,push:1,put:[1,6],pxp:[6,7],pxp_ita_msc:6,pxp_ita_tc:6,pycirk:[1,4,8],pycirk_set:5,pypackag:7,pypi:[1,2],python3:7,python:[1,4,7],rang:6,read:6,readi:1,readm:[1,7],readthedoc:7,rebound:[6,7],recent:4,recycl:7,reduct:7,refactor:6,refer:6,reg_coord:6,reg_d:7,reg_o:7,region:[6,7],rel:6,relabel:6,relabel_to_sav:6,releas:[2,3],rememb:1,remind:1,renam:6,repeat:6,repo:[1,4],repositori:[4,7],reproduc:1,request:3,requir:[6,7],resconrec:7,research:7,resourc:7,result:[5,7],retriev:6,retrieve_specified_data:6,rice:7,right:6,rodriguez:7,row:[6,7],rsd_engin:6,rst:1,run:[1,4,6],same:6,sat:6,save:6,save_directori:6,save_label:6,save_output:6,save_result:[6,7],save_util:5,scen_fil:6,scen_no:[6,7],scenario:6,scenario_1:6,scenario_fil:6,scenario_result:[6,7],scope:[1,6],scrap:6,script:7,search:3,secondari:6,sector:6,see:7,select:6,send:1,separ:6,seri:6,set:[1,6],set_io_scenario:6,set_save_directori:6,set_sut:6,setup:[1,4,7],shape:6,share:[6,7],sheet:[6,7],sheet_nam:6,should:[1,6,7],show:7,simpl:6,simul:7,singl:6,single_posit:6,site:7,size:6,skill:7,softwar:7,solut:6,some:6,sourc:[3,6],spead:6,spec:6,spec_row:6,specfic:6,speci:6,specif:[6,7],specifi:[6,7],stabl:3,start:[3,7],step:[1,7],store:6,str:6,studi:7,sub:6,subclass:6,subject:6,submodul:5,subset:1,subsidi:7,subsitut:6,substituion:7,substitut:[6,7],sum:6,supervis:7,suppli:6,support:[1,7],sure:[1,6],sut:[6,7],sutop:6,swk:7,system:[1,6],t_tlsa:7,tabl:[6,7],tag:1,take:6,tarbal:4,tax:7,tech:6,technic:[6,7],technolog:[6,7],tell:7,templat:7,termin:[4,7],test:[1,6,7],test_pycirk:1,text:7,thank:7,thei:[1,6],them:[1,6],thi:[1,4,6,7],through:[1,4,7],time:6,timemark:6,tip:3,togeth:6,top:6,tot:6,total:[6,7],tox:1,tpm:6,trans_method:6,transact:[6,7],transat:7,transf_method:7,transform:6,transform_to_io:6,transformation_method:5,trasform:6,travi:1,troubleshoot:1,tue:6,tukker:7,two:6,type:[3,6,7],under:6,understand:6,uniqu:6,unit:[6,7],univers:6,updat:1,usag:3,use:[1,6,7,8],used:[6,7],useful:7,user:6,usernam:7,uses:6,using:6,valu:[6,7],variabl:7,variou:6,verifi:6,verifyiot:6,version:1,virtualenv:1,virtualenvwrapp:1,volunt:1,wai:[1,6],want:[1,6],web:1,websit:1,wed:6,weigh:7,welcom:1,what:6,when:[1,6],where:6,whether:[1,6,7],which:[6,7],whoever:1,why:0,within:6,work:[1,6],would:[1,6],x_iai:6,xls:6,xlsx:6,xlxl:6,yalt:6,yes:7,yet:0,you:[1,4,6,7],your:[1,4,6],your_name_her:1,zenodo:7},titles:["Credits","Contributing","History","Welcome to pycirk\u2019s documentation!","Installation","pycirk","pycirk package","pycirk","Usage"],titleterms:{"2018":2,"import":7,analysi:7,bug:1,cli:6,content:[3,6],contribut:1,contributor:0,credit:[0,7],data:7,deploi:1,develop:0,document:[1,3],featur:[1,7],feedback:1,fix:1,from:[4,7],fundamental_oper:6,get:1,guidelin:1,histori:2,implement:1,indic:3,initi:7,instal:[4,7],label:6,lead:0,make_scenario:6,make_secondary_flow:6,modul:[6,7],organize_io:6,packag:[6,7],posit:6,pull:1,pycirk:[3,5,6,7],pycirk_set:6,releas:[4,7],report:1,request:1,result:6,run:7,save:7,save_util:6,scenario:7,set:7,sourc:[4,7],stabl:[4,7],start:1,submit:1,submodul:6,tabl:3,tip:1,transformation_method:6,type:1,usag:[7,8],welcom:3,write:1,xls:7,your:7}}) -------------------------------------------------------------------------------- /docs/_build/html/usage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Usage — pycirk 1.5.5 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |
30 |
31 | 32 | 33 |
34 | 35 |
36 |

Usage

37 |

To use pycirk in a project:

38 |
import pycirk
 39 | 
40 |
41 |
42 | 43 | 44 |
45 | 46 |
47 |
48 | 100 |
101 |
102 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # pycirk documentation build configuration file, created by 5 | # sphinx-quickstart on Fri Jun 9 13:47:02 2017. 6 | # 7 | # This file is execfile()d with the current directory set to its 8 | # containing dir. 9 | # 10 | # Note that not all possible configuration values are present in this 11 | # autogenerated file. 12 | # 13 | # All configuration values have a default; values that are commented out 14 | # serve to show the default. 15 | 16 | # If extensions (or modules to document with autodoc) are in another 17 | # directory, add these directories to sys.path here. If the directory is 18 | # relative to the documentation root, use os.path.abspath to make it 19 | # absolute, like shown here. 20 | # 21 | import os 22 | import sys 23 | sys.path.insert(0, os.path.abspath('..')) 24 | 25 | import pycirk 26 | 27 | # -- General configuration --------------------------------------------- 28 | 29 | # If your documentation needs a minimal Sphinx version, state it here. 30 | # 31 | # needs_sphinx = '1.0' 32 | 33 | # Add any Sphinx extension module names here, as strings. They can be 34 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 35 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] 36 | 37 | # Add any paths that contain templates here, relative to this directory. 38 | templates_path = ['_templates'] 39 | 40 | # The suffix(es) of source filenames. 41 | # You can specify multiple suffix as a list of string: 42 | # 43 | # source_suffix = ['.rst', '.md'] 44 | source_suffix = '.rst' 45 | 46 | # The master toctree document. 47 | master_doc = 'index' 48 | 49 | # General information about the project. 50 | project = u'pycirk' 51 | copyright = u"2019, Franco Donati" 52 | author = u"Franco Donati" 53 | 54 | # The version info for the project you're documenting, acts as replacement 55 | # for |version| and |release|, also used in various other places throughout 56 | # the built documents. 57 | # 58 | # The short X.Y version. 59 | version = pycirk.__version__ 60 | # The full version, including alpha/beta/rc tags. 61 | release = pycirk.__version__ 62 | 63 | # The language for content autogenerated by Sphinx. Refer to documentation 64 | # for a list of supported languages. 65 | # 66 | # This is also used if you do content translation via gettext catalogs. 67 | # Usually you set "language" from the command line for these cases. 68 | language = None 69 | 70 | # List of patterns, relative to source directory, that match files and 71 | # directories to ignore when looking for source files. 72 | # This patterns also effect to html_static_path and html_extra_path 73 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 74 | 75 | # The name of the Pygments (syntax highlighting) style to use. 76 | pygments_style = 'sphinx' 77 | 78 | # If true, `todo` and `todoList` produce output, else they produce nothing. 79 | todo_include_todos = False 80 | 81 | 82 | # -- Options for HTML output ------------------------------------------- 83 | 84 | # The theme to use for HTML and HTML Help pages. See the documentation for 85 | # a list of builtin themes. 86 | # 87 | html_theme = 'alabaster' 88 | 89 | # Theme options are theme-specific and customize the look and feel of a 90 | # theme further. For a list of options available for each theme, see the 91 | # documentation. 92 | # 93 | # html_theme_options = {} 94 | 95 | # Add any paths that contain custom static files (such as style sheets) here, 96 | # relative to this directory. They are copied after the builtin static files, 97 | # so a file named "default.css" will overwrite the builtin "default.css". 98 | html_static_path = ['_static'] 99 | 100 | 101 | # -- Options for HTMLHelp output --------------------------------------- 102 | 103 | # Output file base name for HTML help builder. 104 | htmlhelp_basename = 'pycirkdoc' 105 | 106 | 107 | # -- Options for LaTeX output ------------------------------------------ 108 | 109 | latex_elements = { 110 | # The paper size ('letterpaper' or 'a4paper'). 111 | # 112 | # 'papersize': 'letterpaper', 113 | 114 | # The font size ('10pt', '11pt' or '12pt'). 115 | # 116 | # 'pointsize': '10pt', 117 | 118 | # Additional stuff for the LaTeX preamble. 119 | # 120 | # 'preamble': '', 121 | 122 | # Latex figure (float) alignment 123 | # 124 | # 'figure_align': 'htbp', 125 | } 126 | 127 | # Grouping the document tree into LaTeX files. List of tuples 128 | # (source start file, target name, title, author, documentclass 129 | # [howto, manual, or own class]). 130 | latex_documents = [ 131 | (master_doc, 'pycirk.tex', 132 | u'pycirk Documentation', 133 | u'Franco Donati', 'manual'), 134 | ] 135 | 136 | 137 | # -- Options for manual page output ------------------------------------ 138 | 139 | # One entry per manual page. List of tuples 140 | # (source start file, name, description, authors, manual section). 141 | man_pages = [ 142 | (master_doc, 'pycirk', 143 | u'pycirk Documentation', 144 | [author], 1) 145 | ] 146 | 147 | 148 | # -- Options for Texinfo output ---------------------------------------- 149 | 150 | # Grouping the document tree into Texinfo files. List of tuples 151 | # (source start file, target name, title, author, 152 | # dir menu entry, description, category) 153 | texinfo_documents = [ 154 | (master_doc, 'pycirk', 155 | u'pycirk Documentation', 156 | author, 157 | 'pycirk', 158 | 'One line description of project.', 159 | 'Miscellaneous'), 160 | ] 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to pycirk's documentation! 2 | ====================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :caption: Contents: 7 | 8 | readme 9 | installation 10 | usage 11 | modules 12 | contributing 13 | authors 14 | history 15 | 16 | Indices and tables 17 | ================== 18 | * :ref:`genindex` 19 | * :ref:`modindex` 20 | * :ref:`search` 21 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Installation 5 | ============ 6 | 7 | 8 | Stable release 9 | -------------- 10 | 11 | To install pycirk, run this command in your terminal: 12 | 13 | .. code-block:: console 14 | 15 | $ pip install pycirk 16 | 17 | This is the preferred method to install pycirk, as it will always install the most recent stable release. 18 | 19 | If you don't have `pip`_ installed, this `Python installation guide`_ can guide 20 | you through the process. 21 | 22 | .. _pip: https://pip.pypa.io 23 | .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ 24 | 25 | 26 | From sources 27 | ------------ 28 | 29 | The sources for pycirk can be downloaded from the `Github repo`_. 30 | 31 | You can either clone the public repository: 32 | 33 | .. code-block:: console 34 | 35 | $ git clone git://github.com/FDonati/pycirk 36 | 37 | Or download the `tarball`_: 38 | 39 | .. code-block:: console 40 | 41 | $ curl -OL https://github.com/FDonati/pycirk/tarball/master 42 | 43 | Once you have a copy of the source, you can install it with: 44 | 45 | .. code-block:: console 46 | 47 | $ python setup.py install 48 | 49 | 50 | .. _Github repo: https://github.com/FDonati/pycirk 51 | .. _tarball: https://github.com/FDonati/pycirk/tarball/master 52 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=python -msphinx 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | set SPHINXPROJ=pycirk 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The Sphinx module was not found. Make sure you have Sphinx installed, 20 | echo.then set the SPHINXBUILD environment variable to point to the full 21 | echo.path of the 'sphinx-build' executable. Alternatively you may add the 22 | echo.Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /docs/modules.rst: -------------------------------------------------------------------------------- 1 | pycirk 2 | ====== 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | pycirk 8 | -------------------------------------------------------------------------------- /docs/pycirk.rst: -------------------------------------------------------------------------------- 1 | pycirk package 2 | ============== 3 | 4 | Submodules 5 | ---------- 6 | 7 | pycirk.cli module 8 | ----------------- 9 | 10 | .. automodule:: pycirk.cli 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | pycirk.fundamental\_operations module 16 | ------------------------------------- 17 | 18 | .. automodule:: pycirk.fundamental_operations 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | pycirk.labels module 24 | -------------------- 25 | 26 | .. automodule:: pycirk.labels 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | pycirk.make\_scenarios module 32 | ----------------------------- 33 | 34 | .. automodule:: pycirk.make_scenarios 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | pycirk.make\_secondary\_flows module 40 | ------------------------------------ 41 | 42 | .. automodule:: pycirk.make_secondary_flows 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | 47 | pycirk.organize\_io module 48 | -------------------------- 49 | 50 | .. automodule:: pycirk.organize_io 51 | :members: 52 | :undoc-members: 53 | :show-inheritance: 54 | 55 | pycirk.positions module 56 | ----------------------- 57 | 58 | .. automodule:: pycirk.positions 59 | :members: 60 | :undoc-members: 61 | :show-inheritance: 62 | 63 | pycirk.pycirk module 64 | -------------------- 65 | 66 | .. automodule:: pycirk.pycirk 67 | :members: 68 | :undoc-members: 69 | :show-inheritance: 70 | 71 | pycirk.pycirk\_settings module 72 | ------------------------------ 73 | 74 | .. automodule:: pycirk.pycirk_settings 75 | :members: 76 | :undoc-members: 77 | :show-inheritance: 78 | 79 | pycirk.results module 80 | --------------------- 81 | 82 | .. automodule:: pycirk.results 83 | :members: 84 | :undoc-members: 85 | :show-inheritance: 86 | 87 | pycirk.save\_utils module 88 | ------------------------- 89 | 90 | .. automodule:: pycirk.save_utils 91 | :members: 92 | :undoc-members: 93 | :show-inheritance: 94 | 95 | pycirk.transformation\_methods module 96 | ------------------------------------- 97 | 98 | .. automodule:: pycirk.transformation_methods 99 | :members: 100 | :undoc-members: 101 | :show-inheritance: 102 | 103 | Module contents 104 | --------------- 105 | 106 | .. automodule:: pycirk 107 | :members: 108 | :undoc-members: 109 | :show-inheritance: 110 | -------------------------------------------------------------------------------- /docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /docs/usage.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | Usage 3 | ===== 4 | 5 | To use pycirk in a project:: 6 | 7 | import pycirk 8 | -------------------------------------------------------------------------------- /pycirk/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """Top-level package for pycirk.""" 4 | 5 | __author__ = """Franco Donati""" 6 | __email__ = 'f.donati@cml.leidenuniv.nl' 7 | __version__ = '1.5.5' 8 | 9 | from pycirk.pycirk import Launch -------------------------------------------------------------------------------- /pycirk/cli.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import click 3 | from pycirk import Launch 4 | 5 | 6 | @click.command() 7 | @click.option('--transf_method', '-tm', default=0, type=int, help='0 = PXP ITA_TC; 1 = PXP ITA_MSC') 8 | @click.option('--save_directory', '-dr', default="", type=str, help='if left black it will be default') 9 | @click.option('--aggregation', '-ag', default=1, type=int, help='1 = bi-regional (EU-ROW) or 0 = None (49 regions)') 10 | @click.option('--make_secondary', '-ms', default=False, type=bool, help='False=no, True=yes - modifies SUT so that secondary materials are apparent in IOT (False or True)') 11 | @click.option('--scenario', '-sc', default=None, type=int, help='all, 1, 2,...') 12 | @click.option('--save_output', '-s', default=False, type=bool, help='False=no, True=yes') 13 | @click.option('--output_dataset', '-od', default=False, type=bool, help='False=no, True=yes') 14 | def main(transf_method, save_directory, aggregation, make_secondary, scenario, save_output, output_dataset): 15 | """ 16 | Console script for pycirk. A software to model policy and 17 | technological interventions in Environmentally Extended Input-Output 18 | Analysis (EXIOBASE V3.3, 2011) 19 | """ 20 | 21 | initialize = Launch(transf_method, make_secondary, save_directory, aggregation) 22 | input("Once you are ready, press enter to continue. It will confirm that scenario.xlsx is ready to be processed") 23 | 24 | click.echo(scenario) 25 | if scenario is None or scenario is "all": 26 | output = initialize.all_results() 27 | if save_output is True: 28 | initialize.save_results() 29 | else: 30 | try: 31 | output = initialize.scenario_results(scenario) 32 | except Exception: 33 | raise ValueError("The value specified for the scenario is invalid") 34 | 35 | if save_output is True: 36 | try: 37 | initialize.save_results(scenario, output_dataset) 38 | except Exception: 39 | raise ValueError("The value specified for saving is invalid") 40 | 41 | click.echo(output) 42 | 43 | 44 | if __name__ == "__main__": 45 | main() 46 | -------------------------------------------------------------------------------- /pycirk/data/README.txt: -------------------------------------------------------------------------------- 1 | This folder is where you should place your data 2 | 3 | You can download the biregional or multiregional database by following this link 4 | 5 | http://doi.org/10.5281/zenodo.4695823 -------------------------------------------------------------------------------- /pycirk/fundamental_operations.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Nov 2 12:05:08 2016 4 | 5 | Description: Class to perform SUT and IOT transformations and balancing 6 | 7 | Scope: Modelling circular economy policies in EEIOA 8 | 9 | @author:Franco Donati 10 | @institution:Leiden University CML 11 | """ 12 | import numpy as np 13 | from numpy import linalg as ln 14 | 15 | 16 | class Operations: 17 | """ 18 | Contains all basic operations to transform SUTs into IOTs and verify them 19 | It contains two subclasses defining two different trasformation methods 20 | PxP ITA Market share and Technical Coefficient methods 21 | note: It should be expanded to other transformation methods in the future 22 | """ 23 | def inv(x): 24 | """ 25 | Returns inverse by dividing by 1 and eliminating inf and nan values 26 | """ 27 | mask = (x == 0) 28 | x[~mask] = 1/x[~mask] 29 | return x 30 | 31 | def delta_Y(Y, Yalt): 32 | """ 33 | method to calculate difference in Y 34 | Y = final demand baseline 35 | Yalt = final demand scenario 36 | """ 37 | return Y - Yalt 38 | 39 | def delta_x(L, Lalt, y): 40 | """ 41 | method to calculate difference in q 42 | L = Leontief of baseline 43 | Lalt = Leontief of scenario 44 | """ 45 | return (L-Lalt) @ y 46 | 47 | def verifyIOT(S, Y, W): 48 | x_out = np.sum(np.array(S), axis=1) + np.sum(np.array(Y), axis=1) 49 | x_in = np.sum(S, axis=0) + np.sum(W[:9], axis=0) 50 | with np.errstate(divide="ignore", invalid="ignore"): 51 | ver = x_out/x_in * 100 52 | 53 | return np.nan_to_num(ver) 54 | 55 | class PxP_ITA_TC: 56 | """ 57 | Model with Transformation Coefficients 58 | ProdxProd Industry Technology assumption 59 | """ 60 | 61 | def T(V, inv_diag_g): 62 | """ 63 | Transformation matrix 64 | T = inv(diag(g)) * V 65 | """ 66 | # V.transpose because it's in MAKE table instead of SUPPLY 67 | return inv_diag_g @ V.transpose() 68 | 69 | def L(U, T, inv_diag_q): 70 | """ 71 | Input coefficients intermediates 72 | A = U * T * inv[diag (q)] 73 | 74 | Multiplier matrix 75 | L = (I-A)^-1 76 | """ 77 | A = U @ T @ inv_diag_q # technical coefficient matrix 78 | A = np.nan_to_num(A) 79 | IA = np.identity(len(A)) - A 80 | return ln.inv(IA) 81 | 82 | def B(R, T, inv_diag_q): 83 | """ 84 | Calculates extension intensity 85 | """ 86 | RT = R @ T 87 | return RT @ inv_diag_q # Input coefficients 88 | 89 | def R(B, diag_q): 90 | """ 91 | Calculates absolute extensions 92 | """ 93 | return B @ diag_q 94 | 95 | def Z(T, U): 96 | """ 97 | Intemediates 98 | Z = U * T 99 | """ 100 | return U @ T 101 | 102 | class PxP_ITA_MSC: 103 | """ 104 | Model with Market Share Coef. 105 | Prod x Prod Industry Technology assumption 106 | """ 107 | # new update of numpy broke consistency of @ operator 108 | # where the exceptional behaviour appeared I substituted 109 | # @ with np.matmul(), this is to be changed in the future 110 | 111 | def S(U, inv_diag_g): 112 | """ 113 | Intermediate coefficients 114 | Input requirements 115 | Z = U * inv(diag(g)) 116 | """ 117 | return U @ inv_diag_g 118 | 119 | def D(V, inv_diag_q): 120 | """ 121 | Market share coefficients 122 | D = V * inv(diag(q)) 123 | """ 124 | # V.transpose because it's in MAKE table instead of SUPPLY 125 | return V.transpose() @ inv_diag_q 126 | 127 | def A(inter_coef, D): 128 | """ 129 | Total requirement multipliers 130 | A = Z * D 131 | """ 132 | return inter_coef @ D 133 | 134 | def L(A): 135 | """ 136 | Leontief inverse 137 | L = (I-A)^-1 138 | """ 139 | IA = np.identity(len(A)) - A 140 | return ln.inv(IA) 141 | 142 | def B(R, D, inv_diag_g): 143 | """ 144 | Calculates extensions intensities 145 | """ 146 | B_ = R @ inv_diag_g 147 | return np.matmul(B_, D) 148 | 149 | def R(B, diag_q): 150 | """ 151 | Calculates absolute extensions 152 | """ 153 | return B @ diag_q 154 | 155 | def Z(inter_coef, D, diag_q): 156 | """ 157 | Intermediates 158 | Z = inter_coef * D * diag(q) 159 | """ 160 | return inter_coef @ D @ diag_q 161 | 162 | class IOT: 163 | """ 164 | General IOT operations subclass 165 | some methods repeat from other subclasses 166 | but it's good to have them divided for clarity 167 | """ 168 | 169 | def x(Z, Y): 170 | """ 171 | total product output s the sum of Si and y 172 | """ 173 | return np.sum(Z, axis=1) + np.sum(Y, axis=1) 174 | 175 | def B(R, inv_diag_x): 176 | """ 177 | Calculates extensions intensities 178 | """ 179 | return R @ inv_diag_x 180 | 181 | def R(B, diag_x): 182 | """ 183 | Calculates absolute extensions 184 | """ 185 | return B @ diag_x 186 | 187 | def x_IAy(L, y): 188 | """ 189 | Total product ouput 190 | x = inv(I - A) * yi 191 | """ 192 | return L @ y 193 | 194 | def Z(A, diag_x): 195 | """ 196 | Total product ouput 197 | Z = A * diag_x 198 | """ 199 | return A @ diag_x 200 | 201 | def A(Z, inv_diag_x): 202 | """ 203 | Technical coefficient matrix 204 | A = Z * inv(diag(x)) 205 | """ 206 | return Z @ inv_diag_x 207 | 208 | def L(A): 209 | """ 210 | Leontief inverse 211 | L = (I-A)^-1 212 | """ 213 | IA = np.identity(len(A)) - A 214 | return ln.inv(IA) 215 | 216 | def bY(RY, inv_diag_yj): 217 | """ 218 | Calculates intensities of extensions in final demand 219 | Method for transformation matrix of bY 220 | (e.g. final demand emissions) 221 | """ 222 | return RY @ inv_diag_yj 223 | 224 | def RY(bY, diag_yj): 225 | """ 226 | Caclculates absolute extensions in final demand 227 | """ 228 | return bY @ diag_yj 229 | 230 | # is this function really needed? 231 | def IOT(Z, Y, W, E, R, M): 232 | """ 233 | IOT 234 | """ 235 | x = Operations.IOT.x(Z, Y) # total product output 236 | diag_x = np.diag(x) 237 | inv_diag_x = Operations.inv(diag_x) 238 | 239 | y = np.sum(Y, axis=1) 240 | 241 | A = Operations.IOT.A(Z, inv_diag_x) # technical coefficient matrix 242 | L = Operations.IOT.L(A) # leontief inverse 243 | 244 | w = Operations.IOT.B(W, inv_diag_x) # primary inputs coef 245 | W = Operations.IOT.R(w, diag_x) 246 | 247 | e = Operations.IOT.B(E, inv_diag_x) # Be coefficient matrix 248 | E = Operations.IOT.R(e, diag_x) # environmental extensions 249 | 250 | r = Operations.IOT.B(R, inv_diag_x) # Br coefficient matrix 251 | R = Operations.IOT.R(r, diag_x) # resource extensions 252 | 253 | m = Operations.IOT.B(M, inv_diag_x) # Bm coefficient matrix 254 | M = Operations.IOT.R(m, diag_x) # Material extension 255 | 256 | Z = Operations.IOT.Z(A, diag_x) # intermediates 257 | x = Operations.IOT.x_IAy(L, y) 258 | 259 | ver_base = Operations.verifyIOT(Z, Y, E) 260 | 261 | return {"A": A, 262 | "Z": Z, 263 | "L": L, 264 | "Z": Z, 265 | "Y": Y, 266 | "w": w, 267 | "W": W, 268 | "x": x, 269 | "E": E, 270 | "e": e, 271 | "R": R, 272 | "r": r, 273 | "M": M, 274 | "m": m, 275 | "ver_base": ver_base 276 | } 277 | 278 | def calculate_characterized(data): 279 | 280 | data.Cr_E = data.Cr_E_k @ data.E 281 | data.Cr_M = data.Cr_M_k @ data.M 282 | data.Cr_R = data.Cr_R_k @ data.R 283 | data.Cr_W = data.Cr_W_k @ data.W 284 | 285 | data.Cr_EY = data.Cr_E_k @ data.EY 286 | data.Cr_MY = data.Cr_M_k @ data.MY 287 | data.Cr_RY = data.Cr_R_k @ data.RY 288 | 289 | return data 290 | -------------------------------------------------------------------------------- /pycirk/labels.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on sat Jan 28 2017 4 | 5 | Description: Labelling elements for SUTs and IOTs 6 | 7 | Scope: Modelling the Circular Economy in EEIO 8 | 9 | @author:Franco Donati 10 | @institution:Leiden University CML 11 | """ 12 | 13 | from pandas import DataFrame as df 14 | from pandas import MultiIndex as mi 15 | from pandas import read_csv 16 | from munch import Munch 17 | 18 | 19 | class Labels: 20 | def __init__(self): 21 | self.country_labels = None 22 | self.region_labels = None 23 | self.product_labels = None 24 | self.industry_labels = None 25 | self.W_labels = None 26 | self.E_labels = None 27 | self.R_labels = None 28 | self.M_labels = None 29 | self.Y_labels = None 30 | self.Cr_E_labels = None 31 | self.Cr_M_labels = None 32 | self.Cr_R_labels = None 33 | self.Cr_W_labels = None 34 | 35 | def calc_no_of_something(self, labels): 36 | """ 37 | A general method to calculate the number of unique entries contained 38 | in a series 39 | """ 40 | return len(labels.unique()) 41 | 42 | def list_of_something(self, labels): 43 | """ 44 | A general method to return a list of unique entries contained in a series 45 | """ 46 | return labels.unique() 47 | 48 | def get_unique_labels(self, dataframe_of_labels, for_units=True): 49 | """ 50 | Calculates all unique entries (labels) contained in a dataframe and 51 | puts them together with their units and total count of unique entries 52 | 53 | It returns an object... which is munched, not a pretty solution but it 54 | works ok for now. Please consider refactoring in the future 55 | """ 56 | organize = dict() 57 | 58 | for keys, labels in dataframe_of_labels.items(): 59 | if for_units is True: 60 | organize[keys] = self.list_of_something(labels) 61 | elif for_units is False: 62 | if keys == "unit": 63 | organize[keys] = labels 64 | else: 65 | organize[keys] = self.list_of_something(labels) 66 | 67 | try: 68 | organize["count"] = len(organize["synonym"]) 69 | except KeyError: 70 | organize["count"] = len(organize["characterization"]) 71 | 72 | return Munch(organize) 73 | 74 | def organize_unique_labels(self, directory): 75 | 76 | lbl = self.load_labels(directory) 77 | 78 | self.product_labels = self.get_unique_labels(lbl["prod"]) 79 | try: 80 | self.industry_labels = self.get_unique_labels(lbl["ind"]) 81 | except AttributeError: 82 | pass 83 | 84 | try: 85 | self.country_labels = self.product_labels.country_code 86 | except Exception: 87 | pass 88 | 89 | self.region_labels = self.product_labels.region 90 | 91 | self.W_labels = self.get_unique_labels(lbl["primary"]) 92 | self.Y_labels = self.get_unique_labels(lbl["fin_dem"]) 93 | self.E_labels = self.get_unique_labels(lbl["emis"], False) 94 | self.R_labels = self.get_unique_labels(lbl["res"], False) 95 | self.M_labels = self.get_unique_labels(lbl["mat"], False) 96 | self.Cr_E_labels = self.get_unique_labels(lbl["car_emis"], False) 97 | self.Cr_R_labels = self.get_unique_labels(lbl["car_res"], False) 98 | self.Cr_M_labels = self.get_unique_labels(lbl["car_mat"], False) 99 | self.Cr_W_labels = self.get_unique_labels(lbl["car_prim"], False) 100 | 101 | 102 | def load_labels(self, directory): 103 | 104 | try: 105 | ind = read_csv(directory + "/industry.csv") # with unit column 106 | except Exception: 107 | ind = None 108 | 109 | try: 110 | prod = read_csv(directory + "/products.csv") # with unit column 111 | except Exception: 112 | prod = None 113 | 114 | primary = read_csv(directory + "/factor_inputs.csv") 115 | fin_dem = read_csv(directory + "/final_demand.csv") 116 | emis = read_csv(directory + "/emissions.csv") 117 | res = read_csv(directory + "/resources.csv") 118 | mat = read_csv(directory + "/materials.csv") 119 | 120 | car_emis = read_csv(directory + "/charact_emissions.csv") 121 | car_res = read_csv(directory + "/charact_resources.csv") 122 | car_mat = read_csv(directory + "/charact_materials.csv") 123 | car_prim = read_csv(directory + "/charact_factor_inputs.csv") 124 | 125 | return {"ind": ind, 126 | "prod": prod, 127 | "primary": primary, 128 | "fin_dem": fin_dem, 129 | "emis": emis, 130 | "res": res, 131 | "mat": mat, 132 | "car_emis": car_emis, 133 | "car_res": car_res, 134 | "car_mat": car_mat, 135 | "car_prim": car_prim} 136 | 137 | def get_labels(self, matrix): 138 | """ 139 | Collects labels from a dataframe 140 | """ 141 | try: 142 | return matrix.index.to_frame(index=False) 143 | # print("ind",matrix.index[0]) 144 | except Exception: 145 | # this exception is here only in the case the multi-index is 146 | # as a list or flat strings instead of an actual multi-index 147 | # it is not the case with our EXIOBASE database but future 148 | #adaptation to include other databases may require it 149 | return df(list(matrix.index)).copy() 150 | 151 | def save_labels(self, data, directory): 152 | """ 153 | saves the labels of the database in the labels directory 154 | """ 155 | 156 | try: 157 | self.get_labels(data["V"].T).to_csv(directory + "/industry.csv", 158 | index=False) 159 | except Exception: 160 | pass 161 | 162 | self.get_labels(data["Cr_E_k"]).to_csv(directory + "/charact_emissions.csv", index=False) 163 | self.get_labels(data["Cr_R_k"]).to_csv(directory + "/charact_resources.csv", index=False) 164 | self.get_labels(data["Cr_M_k"]).to_csv(directory + "/charact_materials.csv", index=False) 165 | self.get_labels(data["Cr_W_k"]).to_csv(directory + "/charact_factor_inputs.csv", index=False) 166 | self.get_labels(data["Y"]).to_csv(directory + "/products.csv", index=False) # with unit column 167 | self.get_labels(data["Y"].T).to_csv(directory + "/final_demand.csv", index=False) 168 | 169 | try: 170 | self.get_labels(data["W"]).to_csv(directory + "/factor_inputs.csv", index=False) 171 | self.get_labels(data["E"]).to_csv(directory + "/emissions.csv", index=False) 172 | self.get_labels(data["R"]).to_csv(directory + "/resources.csv", index=False) 173 | self.get_labels(data["M"]).to_csv(directory + "/materials.csv", index=False) 174 | except Exception: 175 | self.get_labels(data["w"]).to_csv(directory + "/factor_inputs.csv", index=False) 176 | self.get_labels(data["e"]).to_csv(directory + "/emissions.csv", index=False) 177 | self.get_labels(data["r"]).to_csv(directory + "/resources.csv", index=False) 178 | self.get_labels(data["m"]).to_csv(directory + "/materials.csv", index=False) 179 | 180 | def relabel_to_save(self, data, trans_method, labels_directory): 181 | """ 182 | This function makes sure that everything is labeled in IOT tables 183 | 184 | trans_method = 0 is prod x prod , 1 is ind x ind 185 | """ 186 | lb = Munch(self.load_labels(labels_directory)) 187 | 188 | if trans_method in [0, 1]: 189 | cat = lb.prod 190 | elif trans_method not in [0, 1]: 191 | cat = lb.ind 192 | 193 | data = Munch(data) 194 | 195 | try: 196 | # Relabel Main IOT elements 197 | data.Z = self.relabel(data.Z, cat.iloc[:, :4], cat) 198 | data.Y = self.relabel(data.Y, lb.fin_dem, cat) 199 | data.W = self.relabel(data.W, cat.iloc[:, :4], lb.primary) 200 | except Exception: 201 | cat = lb.ind 202 | prod = lb.prod 203 | data.V = self.relabel(data.V, cat, prod) 204 | 205 | # Labeling final demand extensions' 206 | data.EY = self.relabel(data.EY, lb.fin_dem, lb.emis) 207 | data.RY = self.relabel(data.RY, lb.fin_dem, lb.res) 208 | data.MY = self.relabel(data.MY, lb.fin_dem, lb.mat) 209 | 210 | # Inter-trans extensions' 211 | data.E = self.relabel(data.E, cat, lb.emis) 212 | data.R = self.relabel(data.R, cat, lb.res) 213 | data.M = self.relabel(data.M, cat, lb.mat) 214 | 215 | # Relabel characterization tables 216 | data.Cr_E_k = self.relabel(data.Cr_E_k, lb.emis, lb.car_emis) 217 | data.Cr_R_k = self.relabel(data.Cr_R_k, lb.res, lb.car_res) 218 | data.Cr_M_k = self.relabel(data.Cr_M_k, lb.mat, lb.car_mat) 219 | data.Cr_W_k = self.relabel(data.Cr_W_k, lb.primary, lb.car_prim) 220 | 221 | return data 222 | 223 | def apply_labels(self, matrix, labels, axis=0): 224 | """ 225 | Applies labels to a dataframe 226 | axis = 0 => Index 227 | axis = 1 => columns 228 | """ 229 | if axis == 0: # apply index 230 | matrix.index = mi.from_arrays(labels.values.T) 231 | matrix.index.names = labels.columns 232 | elif axis == 1: # collects columns 233 | matrix.columns = mi.from_arrays(labels.values.T) 234 | matrix.columns.names = labels.columns 235 | 236 | return matrix 237 | 238 | def relabel(self, M, column_labels, index_labels): 239 | """ 240 | Processes apply_labels and apply _names together 241 | """ 242 | M = df(M) 243 | 244 | try: 245 | M = self.apply_labels(M, column_labels, axis=1) # columns 246 | except Exception: 247 | # in case a string is passed for column label for a vector 248 | M.columns = [column_labels] 249 | 250 | return self.apply_labels(M, index_labels, axis=0) # index 251 | 252 | def identify_labels(self, M_name): 253 | """ 254 | A method to understand what type of labels are being handled depending 255 | on the name of the matrix in dataframe type that is being passed 256 | """ 257 | 258 | # identifying colum and index labels 259 | if self.country_labels is None: 260 | reg_labels = self.region_labels 261 | elif self.country_labels is not None: 262 | reg_labels = self.country_labels 263 | 264 | if "Y" in M_name: 265 | column_labels = self.Y_labels 266 | row_labels = self.product_labels 267 | else: 268 | column_labels = self.product_labels 269 | row_labels = self.product_labels 270 | 271 | if M_name in ["V", "U", "S", "D"]: 272 | column_labels = self.industry_labels 273 | 274 | name = "" 275 | 276 | if "Cr" in M_name: 277 | name = "Cr_" 278 | M_name = M_name[2:] 279 | 280 | if any(True for l in M_name.lower() if l in ["e", "m", "r", "w"]): 281 | name_2 = [l for l in ["e", "m", "r", "w"] if l in M_name.lower()][0].upper() 282 | 283 | 284 | attr_name = name + name_2 + "_labels" 285 | row_labels = eval("self." + attr_name) 286 | 287 | no_row_labs = row_labels.count 288 | no_reg_labs = len(reg_labels) 289 | no_col_labs = column_labels.count 290 | 291 | return {"reg_labels": reg_labels, 292 | "g_labels": column_labels, 293 | "i_labels": row_labels, 294 | "no_i": no_row_labs, 295 | "no_g": no_col_labs, 296 | "no_reg": no_reg_labs} -------------------------------------------------------------------------------- /pycirk/labels/charact_factor_inputs.csv: -------------------------------------------------------------------------------- 1 | characterization,unit 2 | Value Added,M.EUR 3 | Employment,1000 p. 4 | Employment hour,M.hr 5 | -------------------------------------------------------------------------------- /pycirk/labels/charact_materials.csv: -------------------------------------------------------------------------------- 1 | characterization,unit 2 | Total Emission relevant energy use,TJ 3 | Total Energy inputs from nature,TJ 4 | Total Energy supply,TJ 5 | Total Energy Use,TJ 6 | Domestic Extraction,kt 7 | Unused Domestic Extraction,kt 8 | Water Consumption Green - Agriculture,Mm3 9 | Water Consumption Blue - Agriculture,Mm3 10 | Water Consumption Blue - Livestock,Mm3 11 | Water Consumption Blue - Manufacturing,Mm3 12 | Water Consumption Blue - Electricity,Mm3 13 | Water Consumption Blue - Domestic,Mm3 14 | Water Consumption Blue - Total,Mm3 15 | Water Withdrawal Blue - Manufacturing,Mm3 16 | Water Withdrawal Blue - Electricity,Mm3 17 | Water Withdrawal Blue - Domestic,Mm3 18 | Water Withdrawal Blue - Total,Mm3 19 | -------------------------------------------------------------------------------- /pycirk/labels/charact_resources.csv: -------------------------------------------------------------------------------- 1 | characterization,unit 2 | Land use,km2 3 | -------------------------------------------------------------------------------- /pycirk/labels/factor_inputs.csv: -------------------------------------------------------------------------------- 1 | code,name,synonym,unit 2 | w01,Taxes less subsidies on products purchased: Total,T_TLSA,M.EUR 3 | w02,Other net taxes on production,V_ONTP,M.EUR 4 | w03.a,"Compensation of employees; wages, salaries, & employers' social contributions: Low-skilled",V_WALS,M.EUR 5 | w03.b,"Compensation of employees; wages, salaries, & employers' social contributions: Medium-skilled",V_WAMS,M.EUR 6 | w03.c,"Compensation of employees; wages, salaries, & employers' social contributions: High-skilled",V_WAHS,M.EUR 7 | w04.a,Operating surplus: Consumption of fixed capital,V_COFC,M.EUR 8 | w04.b,Operating surplus: Rents on land,V_RENL, 9 | w04.c,Operating surplus: Royalties on resources,V_ROYR, 10 | w04.d,Operating surplus: Remaining net operating surplus,V_NOPS,M.EUR 11 | s01.a_m,Employment: Low-skilled male,E_NRLS_m,1000 p 12 | s01.a_f,Employment: Low-skilled female,E_NRLS_f,1000 p 13 | s01.b_m,Employment: Medium-skilled male,E_NRMS_m,1000 p 14 | s01.b_f,Employment: Medium-skilled female,E_NRMS_f,1000 p 15 | s01.c_m,Employment: High-skilled male,E_NRHS_m,1000 p 16 | s01.c_f,Employment: High-skilled female,E_NRHS_f,1000 p 17 | s02.a_m,Employment hours: Low-skilled male,E_HRLS_m,M.hr 18 | s02.a_f,Employment hours: Low-skilled female,E_HRLS_f,M.hr 19 | s02.b_m,Employment hours: Medium-skilled male,E_HRMS_m,M.hr 20 | s02.b_f,Employment hours: Medium-skilled female,E_HRMS_f,M.hr 21 | s02.c_m,Employment hours: High-skilled male,E_HRHS_m,M.hr 22 | s02.c_f,Employment hours: High-skilled female,E_HRHS_f,M.hr 23 | s03,Employment: Vulnerable employment,E_VNR,1000 p 24 | s04,Employment hours: Vulnerable employment,E_VHR,M.hr 25 | -------------------------------------------------------------------------------- /pycirk/labels/resources.csv: -------------------------------------------------------------------------------- 1 | name,synonym,unit 2 | Land use - Arable Land - Rice,L_1.1,km2 3 | Land use - Arable Land - Wheat,L_1.2,km2 4 | Land use - Arable Land - Other cereals,L_1.3,km2 5 | "Land use - Arable Land - Vegetables, fruits, nuts",L_1.4,km2 6 | Land use - Arable Land - Oil crops,L_1.5,km2 7 | Land use - Arable Land - Sugar crops,L_1.6,km2 8 | Land use - Arable Land - Fibres,L_1.7,km2 9 | Land use - Arable Land - Other crops,L_1.8,km2 10 | Land use - Arable Land - Fodder crops,L_1.9,km2 11 | Land use - Permanent pasture,L_2,km2 12 | Used Forest Land - Industrial roundwood,L_3.1,km2 13 | Used Forest Land - Wood fuel,L_3.2,km2 14 | Used Other Land - Wood fuel,L_3.3,km2 15 | Infrastructure Land,L_4, 16 | -------------------------------------------------------------------------------- /pycirk/make_secondary_flows.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Mon Jul 16 15:10:19 2018 5 | Description: Modifying SUT to ensure appearance of secondary material flows in 6 | IOT 7 | 8 | Scope: Modelling the Circular Economy in EEIO 9 | 10 | @author:Franco Donati 11 | @contributor: Arjan de Koning 12 | @institution:Leiden University CML 13 | """ 14 | import numpy as np 15 | import pycirk.positions as pos 16 | 17 | 18 | def make_secondary(data): 19 | """ 20 | This allows to allign secondary flow in such a way that they then 21 | appear in the IOT 22 | 23 | Primary Products' positions 24 | 25 | C_WOOD: 57 26 | C_PULP: 59 27 | C_PLAS: 85 28 | C_GLAS: 96 29 | C_CMNT: 100 30 | C_STEL: 103 31 | C_PREM: 105 32 | C_ALUM: 107 33 | C_LZTP: 109 34 | C_COPP: 111 35 | C_ONFM: 113 36 | C_CONS: 149 37 | 38 | Primary Sectors'positions: 39 | 40 | A_WOOD: 49 41 | A_PULP: 51 42 | A_PLAS: 58 43 | A_GLAS: 64 44 | A_CMNT: 68 45 | A_STEL: 71 46 | A_PREM: 73 47 | A_ALUM: 75 48 | A_LZTP: 77 49 | A_COPP: 79 50 | A_ONFM: 81 51 | A_CONS: 112 52 | 53 | """ 54 | V = data["V"] 55 | U = data["U"] 56 | Y = data["Y"] 57 | 58 | products = np.array([57, 59, 85, 96, 100, 103, 59 | 105, 107, 109, 111, 113, 149]) 60 | 61 | industries = np.array([49, 51, 58, 64, 68, 71, 73, 62 | 75, 77, 79, 81, 112]) 63 | 64 | no_countries = int(len(Y)/200) 65 | 66 | prod_or = pos.make_coord_array_for_make_sec(products, no_countries, 200) 67 | ind_or = pos.make_coord_array_for_make_sec(industries, no_countries, 163) 68 | 69 | moved = allocate_sec_mat(V, U, Y, prod_or, ind_or) 70 | 71 | V = moved["V"] 72 | U = moved["U"] 73 | 74 | data["V"] = V 75 | data["U"] = U 76 | 77 | return data 78 | 79 | 80 | def allocate_sec_mat(V, U, Y, prod_or, ind_or): 81 | """ 82 | This function allows to move the primary material output from the 83 | secondary material industries to the secondary material output. 84 | This allows for the presence of secondary materials in the IOT 85 | once they are transformed from SUTS. 86 | 87 | prod_or = row position of the primary supplied material 88 | ind_or = colum pos. of the primary industry supplying primary material 89 | """ 90 | V = V.copy() 91 | U = U.copy() 92 | Y = Y.copy() 93 | 94 | 95 | # position of the secondary material 96 | des_prod_ix_pos = prod_or + 1 97 | des_ind_col_pos = ind_or + 1 98 | 99 | # getting the value of secondary material from the supply table 100 | # which is placed on the primary material row 101 | misplaced = V.iloc[prod_or, des_ind_col_pos] 102 | 103 | # placing the misplaced value to the secondary material row 104 | V.iloc[des_prod_ix_pos, des_ind_col_pos] = np.array(misplaced) 105 | 106 | # collecting how much of the primary material is consumed by final demand 107 | # to be subtracted from the supply value 108 | 109 | # matrix of primary sectors x all products (588 x 7987) 110 | prim_sec_supply_trans = V.iloc[prod_or] 111 | 112 | # scalar value of sum total primary industry supply 113 | # prim_sec_tot_output = np.sum(prim_sec_supply_trans) 114 | prim_sec_tot_output = prim_sec_supply_trans.sum(axis=1) 115 | 116 | # matrix of secondary product supply by secondary industry (588 x 588) 117 | sec_supply_trans = V.iloc[des_prod_ix_pos, des_ind_col_pos] 118 | 119 | # vector of total secondary industry output (588) 120 | sec_output = sec_supply_trans.sum(axis=1) 121 | # vector of ratios between secondary output per industry and sum total 122 | # industry supply (diagonalised 588 x 588) 123 | ratio_prim_sec = np.zeros((len(sec_output))) 124 | for idx in range(0, len(sec_output)): 125 | if prim_sec_tot_output.iloc[idx] != 0: 126 | ratio_prim_sec[idx] = np.array(sec_output.iloc[idx] / prim_sec_tot_output.iloc[idx]) 127 | ratio_prim_sec = np.diag(ratio_prim_sec) 128 | 129 | prim_sec_use_trans = U.iloc[prod_or] 130 | 131 | prim_sec_fin_dem_trans = Y.iloc[prod_or] 132 | 133 | eye = np.identity(len(ratio_prim_sec)) 134 | 135 | U.iloc[prod_or] = (eye - ratio_prim_sec) @ np.array(prim_sec_use_trans) 136 | 137 | U.iloc[des_prod_ix_pos] = ratio_prim_sec @ np.array(prim_sec_use_trans) 138 | 139 | Y.iloc[prod_or] = (eye - ratio_prim_sec) @ np.array(prim_sec_fin_dem_trans) 140 | 141 | Y.iloc[des_prod_ix_pos] = ratio_prim_sec @ np.array(prim_sec_fin_dem_trans) 142 | 143 | V.iloc[prod_or, des_ind_col_pos] = 0 144 | 145 | print('splitting off secondary materials completed') 146 | 147 | return {"V": V, 148 | "U": U, 149 | "Y": Y} 150 | -------------------------------------------------------------------------------- /pycirk/organize_io.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Tue Feb 7 16:29:23 2017 4 | 5 | Description: Organize essential tables for saving 6 | 7 | Scope: Modelling the Circular economy in EEIO 8 | 9 | 10 | @author: Franco Donati 11 | @institution: Leiden University CML 12 | """ 13 | 14 | import numpy as np 15 | 16 | def organizer(data): 17 | 18 | return {"Z": np.array(data["Z"]), 19 | "Y": np.array(data["Y"]), 20 | "W": np.array(data["W"]), 21 | "E": np.array(data["E"]), 22 | "R": np.array(data["R"]), 23 | "M": np.array(data["M"]), 24 | "EY": np.array(data["EY"]), 25 | "RY": np.array(data["RY"]), 26 | "MY": np.array(data["MY"]), 27 | "Cr_E_k": np.array(data["Cr_E_k"]), 28 | "Cr_M_k": np.array(data["Cr_M_k"]), 29 | "Cr_R_k": np.array(data["Cr_R_k"]), 30 | "Cr_W_k": np.array(data["Cr_W_k"]) 31 | } -------------------------------------------------------------------------------- /pycirk/positions.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Jan 23 10:58:46 2019 4 | 5 | Description: Finding the position of labels 6 | 7 | Scope: Modelling the Circular Economy in EEIO 8 | 9 | @author:Franco Donati 10 | @institution:Leiden University CML 11 | """ 12 | 13 | import numpy as np 14 | 15 | 16 | def single_position(item, labels): 17 | """ 18 | Takes a dataframe of the multiindex and identifies the position 19 | of the specified values 20 | 21 | Parameters 22 | ---------- 23 | 24 | item : str 25 | The label the user is looking for 26 | 27 | labels : obj 28 | An object cointaining a set of labels 29 | (as specified in the labels.py module) 30 | 31 | Output 32 | ------ 33 | An numpy.array containing the coordinate of a specific label 34 | or None in case of there is no specified label 35 | 36 | """ 37 | 38 | if item in ["All", "all", "ALL", np.nan]: 39 | return None 40 | 41 | else: 42 | try: 43 | if item in labels: 44 | ref_labels = labels.copy() 45 | except Exception: 46 | pass 47 | 48 | try: 49 | if item in labels.name: 50 | ref_labels = labels.name.copy() 51 | elif item in labels.synonym: 52 | ref_labels = labels.synonym.copy() 53 | elif item in labels.code: 54 | ref_labels = labels.code.copy() 55 | except Exception: 56 | pass 57 | 58 | try: 59 | if item in labels.characterization: 60 | ref_labels = labels.characterization.copy() 61 | except Exception: 62 | pass 63 | 64 | return np.array([i for i, values in enumerate(ref_labels) 65 | if item in values]) 66 | 67 | def make_coord_array(cat_coord, reg_coord, no_countries, no_categories): 68 | """ 69 | It creates an an array of coordinates based on the specification of the 70 | users. 71 | 72 | Parameters 73 | ---------- 74 | cat_coord : int, numpy.array, bool 75 | the numerical coordinate of a specific category belonging to a matrix 76 | in the IO or SUT system. If None is passed then it will return an 77 | array of all coordinates in range no_categories. 78 | 79 | reg_coord : int, numpy.array, bool 80 | the numerical coordinate of a specific region in the IO or SUT system. 81 | If None is passed then it will return an array of all coordinates in 82 | range no_countries. 83 | 84 | no_countries : int 85 | the total number of countries or regions in the dataset 86 | 87 | no_categories : int 88 | the total number of categories referring one axis in the chosen matrix 89 | 90 | Output 91 | ------ 92 | A numpy.array referring to each coordinate point specified by the user 93 | """ 94 | 95 | if no_categories not in [7, 163, 200]: 96 | no_countries = 1 97 | else: 98 | pass 99 | 100 | if cat_coord is None: 101 | s = np.array(range(no_categories * no_countries)) 102 | else: 103 | n = 0 104 | while n in range(no_countries): 105 | 106 | g = cat_coord[0] + no_categories * n 107 | if "s" not in locals(): 108 | s = np.array([g]) 109 | else: 110 | s = np.append(s, g) 111 | n = n+1 112 | 113 | if reg_coord is None: 114 | return s 115 | else: 116 | s = np.split(s, no_countries) 117 | s = s[reg_coord[0]] 118 | return s 119 | 120 | def make_coord_array_for_make_sec(coordinates, no_countries, no_categories): 121 | """ 122 | It creates an an array of coordinates based on the total location 123 | of secondary materials and processing categories 124 | 125 | Parameters 126 | ---------- 127 | coordinates : int, numpy.array 128 | the numerical coordinate of secondary categories belonging to the SUT system 129 | 130 | no_countries : int 131 | the total number of countries or regions in the dataset 132 | 133 | no_categories : int 134 | the total number of categories referring one axis in the chosen matrix 135 | 136 | Output 137 | ------ 138 | A numpy.array referring to each coordinate point 139 | """ 140 | 141 | n = 0 142 | nn = 0 143 | while n in range(len(coordinates)): 144 | while nn in range(no_countries): 145 | g = coordinates + no_categories * nn 146 | if "s" not in locals(): 147 | s = g 148 | else: 149 | s = np.concatenate([s, g]) 150 | nn = nn+1 151 | n = n+1 152 | 153 | return s 154 | -------------------------------------------------------------------------------- /pycirk/pycirk.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Tue Nov 15 16:29:23 2016 4 | 5 | Description: Outputting scenarios 6 | 7 | Scope: Modelling the Circular Economy in EEIO 8 | 9 | @author:Franco Donati 10 | @institution:Leiden University CML 11 | """ 12 | import pandas as pd 13 | from pycirk.save_utils import save_outputs 14 | from pycirk import results 15 | from pycirk.pycirk_settings import Settings 16 | from pycirk.make_scenarios import make_counterfactuals as mcf 17 | import os, glob 18 | 19 | 20 | class Launch: 21 | """ 22 | Pycirk's main class and methods 23 | 24 | Initialize the pycirk programme to make EEIO scenarios and analysis. 25 | From here, you can launch all the analysis specifications listed under 26 | scenarios.xlsx 27 | 28 | Parameters 29 | ---------- 30 | method : int 31 | SUTs to IO transformation methods 32 | 33 | 0 = Prod X Prod Ind-Tech Assumption Technical Coeff method 34 | 35 | 1 = Prod X Prod Ind-Tech Assumption Market Share Coeff method 36 | 37 | make_secondary : bool 38 | modifies SUT so that secondary technologies which process scrap 39 | materials into primary materials are also available in the IO tables 40 | 41 | False = Don't modify 42 | 43 | True = Modify 44 | 45 | save_directory : str 46 | directory in which you want to work and save your results 47 | 48 | aggregation : int, bool 49 | 50 | 0 = None (multi-regional 49 regions) 51 | 52 | 1 = bi-regional (EU- ROW) 53 | 54 | file : bool, str 55 | allows you to specify where the dataset is placed. None will use the 56 | default location within the installed package 57 | 58 | test : bool 59 | if set to true it will run the test settings under under pycirk//tests 60 | 61 | Methods 62 | ---------- 63 | scenario_results : int 64 | Allows to calculate the results for a given specified scenario 65 | 66 | 0 = baseline data 67 | 68 | all_results : 69 | Retrieves all results for all specified scenarios and baseline 70 | 71 | save_results : int and bool 72 | save all specified analytical results from all scenario and baseline 73 | 74 | 75 | Outputs 76 | ------- 77 | analysis.xlsx : excel file 78 | to be found under the default folder on the specified directory 79 | it allows to specify the parameters for your scenario and analysis 80 | 81 | IO tables : pkl 82 | IO tables of the specified scenarios, these are located in the output 83 | folder in the save directory 84 | 85 | results : DataFrame 86 | results gathered from the processed scenarios and baseline 87 | 88 | """ 89 | def __init__(self, method=0, make_secondary=False, save_directory=None, 90 | aggregation=1, file=None, test=False): 91 | 92 | self.settings = Settings(method, make_secondary, save_directory, 93 | aggregation, file, test) 94 | 95 | self.settings.create_scenario_file() 96 | 97 | self.scen_file = self.settings.scenario_file() 98 | self.analysis_specs = self.settings.load_results_params() 99 | 100 | self.baseline = self.settings.transform_to_io() 101 | 102 | self.labels = self.settings.lb 103 | 104 | self.method = method 105 | 106 | if test is False: 107 | self.specs = None 108 | else: 109 | self.specs = self.settings.project_specs(test=True) 110 | 111 | def scenario_results(self, scen_no, output_dataset=False): 112 | """ 113 | Run to output results of a specified scenario 114 | 115 | Parameters 116 | ---------- 117 | scen_no: int 118 | 0 = baseline 119 | 1-n = specified scenarios 120 | 121 | output_datase: bool 122 | If true it will output a dictionary containing all IOT tables in pd.DataFrames 123 | 124 | Output 125 | ------ 126 | specified results in DataFrame form or a dictionary containing results 127 | and a dictionary of dataframes containing IO matrices 128 | 129 | """ 130 | if scen_no in [0, "baseline", "base", None]: 131 | scen_no = "baseline" 132 | IO = self.baseline 133 | else: 134 | IO = mcf(self.baseline, scen_no, self.scen_file, self.labels) 135 | 136 | output = results.iter_thru_for_results(IO, self.analysis_specs, 137 | scen_no, self.labels) 138 | if output_dataset is True: 139 | output = {"res": output, "data": IO} 140 | 141 | return output 142 | 143 | def all_results(self): 144 | """ 145 | Process all scenarios and collects their results together with 146 | Baseline analysis results 147 | 148 | Output 149 | ------ 150 | It outputs a pandas.DataFrame with all results 151 | """ 152 | 153 | output = self.scenario_results(0) 154 | 155 | for l in range(self.settings.number_scenarios()+1): 156 | if l != 0: 157 | scen_res = self.scenario_results(l) 158 | output = pd.concat([output, scen_res], axis=1) 159 | 160 | return output 161 | 162 | 163 | def save_results(self, scen_no=None, output_dataset=False): 164 | """ 165 | Saves all results in excel format for info and results or in 166 | pickle format for the dataset 167 | 168 | Parameters 169 | ---------- 170 | scen_no: int 171 | 0 = baseline 172 | 173 | 1-n = specified scenarios 174 | 175 | output_datase: bool 176 | If true it will output a dictionary containing all IOT tables in 177 | pd.DataFrames 178 | 179 | Output 180 | ------ 181 | Default values will save all results from the all_results method 182 | and they will output only scenario.xlsx and info_and_results.xlsx 183 | 184 | Output_dataset is only possible when scen_no is specified 185 | in which case it would save also a data.pkl file 186 | 187 | scenarios.xlsx : excel file 188 | scenario settings excel file used for the analysis in the same 189 | output directory with the results 190 | 191 | info_and_results.xlsx : excel file 192 | excel file containing general info about project plus the 193 | results from the analysis 194 | 195 | data.pkl : pickle file 196 | new modified IO dataset in pickle format 197 | This is only possible if outputting single scenario (scen_no != None) 198 | 199 | """ 200 | if self.specs is None: 201 | self.specs = self.settings.project_specs() 202 | else: 203 | pass 204 | 205 | if type(scen_no) is int: 206 | scenario = self.scenario_results(scen_no, output_dataset) 207 | data = None 208 | elif scen_no is None: 209 | scenario = self.all_results() 210 | data = None 211 | if output_dataset is True: 212 | scenario = self.scenario_results(scen_no, output_dataset) 213 | data = scenario["data"] 214 | scenario = scenario["res"] 215 | 216 | 217 | save_outputs(scenario, self.settings.save_directory, self.specs, 218 | scen_no, data) 219 | 220 | def delete_previous_IO_builds(self): 221 | """ 222 | Call this method if you want to elinate all previous 223 | IO databases created by pycirk. SUTs database is not affected. 224 | """ 225 | for filename in glob.glob("pycirk//data//mrIO*"): 226 | os.remove(filename) -------------------------------------------------------------------------------- /pycirk/results.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Feb 27 09:26:43 2017 4 | 5 | Description: module to perform results analysis 6 | 7 | Scope: Modelling the Circular Economy in EEIO 8 | 9 | @author:Franco Donati 10 | @institution:Leiden University CML, TU Delft TPM 11 | """ 12 | import warnings 13 | import pandas as pd 14 | from pandas import DataFrame as df 15 | from pandas import MultiIndex as mi 16 | import numpy as np 17 | from pycirk.positions import make_coord_array as coord 18 | from pycirk.positions import single_position as sing_pos 19 | from pycirk.fundamental_operations import Operations as ops 20 | warnings.simplefilter(action='ignore', category=FutureWarning) 21 | 22 | 23 | def iter_thru_for_results(data, analysis_specs, scen_no, labels): 24 | """ 25 | It uses your analytical specification on scenarios.xlxl 26 | to return a dataframe of the desired results 27 | """ 28 | results = [] 29 | 30 | for l, v in analysis_specs.iterrows(): 31 | res = retrieve_specified_data(data, v, labels) 32 | if len(results) == 0: 33 | results = res 34 | else: 35 | results = pd.concat([results, res], axis=0) 36 | 37 | if scen_no not in [0, "baseline", "base", None]: 38 | results.columns = ["sc_" + str(scen_no)] 39 | else: 40 | results.columns = ["baseline"] 41 | 42 | return results 43 | 44 | def rsd_engine(data, M_name, spec_row, labels): 45 | 46 | 47 | M = np.array(data[M_name]) # Call specific matrix from which to select 48 | 49 | spec_labels = labels.identify_labels(M_name) 50 | 51 | reg_labels = spec_labels["reg_labels"] 52 | row_labels = spec_labels["i_labels"] 53 | column_labels = spec_labels["g_labels"] 54 | no_row_labs = spec_labels["no_i"] 55 | no_col_labs = spec_labels["no_g"] 56 | no_reg_labs = spec_labels["no_reg"] 57 | 58 | i_cat = spec_row.o_p # rows 59 | i_reg = spec_row.o_r 60 | 61 | g_cat = spec_row.d_p # columns 62 | g_reg = spec_row.d_r 63 | 64 | try: 65 | cat_o = sing_pos(i_cat, row_labels) 66 | reg_o = sing_pos(i_reg, reg_labels) 67 | # Column items (g) => Consumption / manufacturing activity 68 | cat_d = sing_pos(g_cat, column_labels) 69 | reg_d = sing_pos(g_reg, reg_labels) 70 | 71 | # Identify coordinates 72 | i = coord(cat_o, reg_o, no_reg_labs, no_row_labs) 73 | 74 | g = coord(cat_d, reg_d, no_reg_labs, no_col_labs) 75 | except UnboundLocalError: 76 | raise ValueError(f"\nThe specified coordinates to retrieve results are wrong.\nPlease check that name and matrix in your scenarios.xlsx file are correct.\nCheck: {M_name, i_cat}") 77 | 78 | 79 | 80 | select = df([M[np.ix_(i, g)].sum()]) 81 | 82 | 83 | key_names = ["matrix", "i_category", "i_region", "g_category", 84 | "g_region", "unit"] 85 | 86 | 87 | try: 88 | unit = str(row_labels.unit[cat_o].iloc[0]) 89 | except Exception: 90 | unit = str(row_labels.unit[0]) 91 | 92 | index_label = [M_name, i_cat, i_reg, g_cat, g_reg, unit] 93 | 94 | select.index = mi.from_tuples([index_label], names=key_names) 95 | 96 | return select 97 | 98 | def retrieve_specified_data(data, spec_row, labels): 99 | """ 100 | Separate, collect and rename results for base and scenarios according 101 | to specifications under th sheet "analysis" in scenarios.xls 102 | 103 | data = any IOT table 104 | spec_row = row in the scenarios sheet specifying settings 105 | """ 106 | 107 | pd.options.display.float_format = '{:,.4f}'.format 108 | 109 | M_name = spec_row.matrix # matrix of reference 110 | 111 | if "Cr" in M_name: 112 | data = ops.calculate_characterized(data) 113 | 114 | if "tot" in M_name: 115 | M_name_1 = M_name[-1] 116 | M_name_2 = M_name[-1] + "Y" 117 | 118 | if "Cr" in M_name: 119 | M_name_1 = "Cr_" + M_name_1 120 | M_name_2 = "Cr_" + M_name_2 121 | 122 | 123 | output = rsd_engine(data, M_name_1, spec_row, labels) 124 | output = output + rsd_engine(data, M_name_2, spec_row, labels).values 125 | index_label = [list(i) for i in output.index][0] 126 | index_label[0] = M_name 127 | key_names = output.index.names 128 | output.index = mi.from_tuples([index_label], names=key_names) 129 | else: 130 | output = rsd_engine(data, M_name, spec_row, labels) 131 | 132 | return output 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /pycirk/save_utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sat Mar 4 11:02:52 2017 4 | 5 | Description: Save data to xls 6 | 7 | Scope: Modelling circular economy policies in EEIOA 8 | 9 | 10 | @author: Franco Donati 11 | @institution: Leiden University CML 12 | """ 13 | import os 14 | import datetime 15 | import pandas as pd 16 | import pickle as pk 17 | from shutil import copyfile 18 | from pandas import DataFrame as df 19 | from openpyxl import load_workbook 20 | now = datetime.datetime.now() 21 | 22 | def save_outputs(results, directory, specs, scen_no, data=None): 23 | """ 24 | It saves results into a previously specified directory 25 | 26 | Parameters 27 | ---------- 28 | 29 | results : pandas.DataFrame 30 | a dataframe containing only selected results 31 | 32 | directory : str 33 | the general location specified for your scenarios.xlsx file 34 | 35 | specs : dict 36 | a dictionary containing general info about the project (e.g. author, institution, etc) 37 | 38 | scen_no : int or None 39 | an integer specifying the scenario number or enter None to save all results 40 | 41 | data : dict of pd.DataFrames 42 | a completely new dataset to be pickled. Default value is None otherwise 43 | pass the dataset 44 | 45 | Output 46 | ------ 47 | scenarios.xlsx : excel file 48 | scenario settings excel file used for the analysis in the same output directory with the results 49 | 50 | info_and_results.xlsx : excel file 51 | excel file containing general info about project plus the results from the analysis 52 | 53 | data.pkl : pickle file 54 | new modified IO dataset in pickle format 55 | 56 | """ 57 | date = "_".join([str(now.year), str(now.month), str(now.day)]) 58 | time = "_".join([str(now.hour), str(now.minute)]) 59 | directory_or = directory 60 | directory_out = os.path.join(directory, "output_" + date) 61 | 62 | if scen_no in ["baseline", 0, "base"]: 63 | scen_no = "baseline" 64 | path = os.path.join(directory_out, "baseline", time) 65 | 66 | elif type(scen_no) is int: 67 | if scen_no > 0: 68 | scen_no = "scenario_" + str(scen_no) 69 | specs["scenario_number"] = scen_no 70 | path = os.path.join(directory_out, "_".join([str(scen_no)]), time) 71 | 72 | elif scen_no is None: 73 | scen_no = "all_results" 74 | specs["scenario_number"] = scen_no 75 | path = os.path.join(directory_out, "all_results", time) 76 | 77 | if not os.path.exists(path): 78 | os.makedirs(path) 79 | 80 | specs = add_date_to_gen_specs(specs) 81 | 82 | copyfile(os.path.join(directory_or, "scenarios.xlsx"), os.path.join(path, "scenarios.xlsx")) 83 | 84 | specs.to_excel(os.path.join(path, "info_and_results.xlsx"), sheet_name="Info", startrow=1, startcol=1) 85 | with pd.ExcelWriter(os.path.join(path, "info_and_results.xlsx"), engine="openpyxl") as writer: 86 | writer.book = load_workbook(os.path.join(path, "info_and_results.xlsx")) 87 | results.to_excel(writer, "Results", startrow=1, startcol=1, merge_cells=False) 88 | 89 | if data is not None: 90 | w = open(path + "/"+ "data.pkl", "wb") 91 | pk.dump(data, w, 2) 92 | 93 | w.close() 94 | 95 | def add_date_to_gen_specs(specs): 96 | """ 97 | Adds timemark to general specifications e.g. authors, institution etc 98 | """ 99 | year, month, day = str(now.date()).split("-") 100 | 101 | timemark = "/".join([day, month, year]) 102 | 103 | specs["timemark"] = timemark 104 | 105 | specs = df([specs]).T 106 | specs.columns = ["General_info"] 107 | 108 | return specs 109 | -------------------------------------------------------------------------------- /pycirk/scenarios.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/pycirk/scenarios.xlsx -------------------------------------------------------------------------------- /pycirk/transformation_methods.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Feb 6 12: 29: 47 2017 4 | 5 | Description: Uses methods within SUTops to calculate IOT and Extensions 6 | 7 | Scope: Modelling the Circular economy in EEIO 8 | 9 | @author: Franco Donati 10 | @institution: Leiden University CML 11 | """ 12 | import numpy as np 13 | from pycirk.fundamental_operations import Operations as ops 14 | 15 | 16 | class Transform: 17 | """ 18 | Transforms SUTs to IOT an calcualate extensions 19 | """ 20 | 21 | def __init__(self, SUTs): 22 | 23 | # Baseline monetary data 24 | self.V = np.array(SUTs["V"]) # Supply matrix 25 | self.U = np.array(SUTs["U"]) # Intermediate use 26 | self.Y = np.array(SUTs["Y"]) # Final demand 27 | self.W = np.array(SUTs["W"]) # Primary input 28 | self.E = np.array(SUTs["E"]) # emissions extension 29 | self.EY = np.array(SUTs["YE"]) # emissions extension final demand 30 | self.R = np.array(SUTs["R"]) # Resources extension 31 | self.RY = np.array(SUTs["YR"]) # Resources extension final demand 32 | self.M = np.array(SUTs["M"]) # Materials extension 33 | self.MY = np.array(SUTs["YM"]) # Materials extension final demand 34 | 35 | self.Cr_E_k = SUTs["Cr_E_k"] # Charact coefficients emissions 36 | self.Cr_R_k = SUTs["Cr_R_k"] # Charact coefficients resources 37 | self.Cr_M_k = SUTs["Cr_M_k"] # Charact coefficients materials 38 | self.Cr_W_k = SUTs["Cr_W_k"] # Charact coefficients factor inputs 39 | 40 | # baseline variables 41 | self.yi = np.array(np.sum(self.Y, axis=1)) # row sum of final demand 42 | self.yj = np.array(np.sum(self.Y, axis=0)) # col sum of final demand 43 | self.q = np.sum(self.V, axis=1) # total product output 44 | self.g = np.sum(self.V, axis=0) # total industry output 45 | 46 | # bv diagonals 47 | self.diag_q = np.diag(self.q) # diagonal of q 48 | self.diag_g = np.diag(self.g) # diagonal of g 49 | self.diag_yi = np.diag(self.yi) # diagonal of yi 50 | self.diag_yj = np.diag(self.yj) # diagonal of yj 51 | 52 | # bv inverses 53 | self.inv_diag_yi = ops.inv(self.diag_yi) 54 | self.inv_diag_yj = ops.inv(self.diag_yj) 55 | self.inv_diag_q = ops.inv(self.diag_q) 56 | self.inv_diag_g = ops.inv(self.diag_g) 57 | 58 | del(SUTs) 59 | 60 | def IOTpxpSTA_TCm(self): 61 | """ 62 | IOT prod x prod Single tech Industry-technology assumption 63 | Technical coef method 64 | """ 65 | met = ops.PxP_ITA_TC 66 | 67 | T = met.T(self.V, self.inv_diag_g) # transformation matrix 68 | L = met.L(self.U, T, self.inv_diag_q) # leontief inverse 69 | 70 | w = met.B(self.W, T, self.inv_diag_q) # primary inp. coef matrix 71 | 72 | Z = met.Z(T, self.U) # intermediates 73 | x = ops.IOT.x_IAy(L, self.yi) 74 | W = ops.IOT.R(w, np.diag(x)) 75 | ver_base = ops.verifyIOT(Z, self.Y, W) 76 | del(self.V) 77 | del(self.U) 78 | del(self.W) 79 | 80 | e = met.B(self.E, T, self.inv_diag_q) # emis coef. matrix 81 | del(self.E) 82 | E = met.R(e, np.diag(x)) 83 | 84 | r = met.B(self.R, T, self.inv_diag_q) # resour coef. matrix 85 | del(self.R) 86 | R = met.R(r, np.diag(x)) 87 | 88 | m = met.B(self.M, T, self.inv_diag_q) # mater coef. matrix 89 | del(self.M) 90 | M = met.R(m, np.diag(x)) 91 | 92 | A = ops.IOT.A(Z, self.inv_diag_q) 93 | 94 | return {"Y": self.Y, 95 | "L": L, 96 | "Z": Z, 97 | "A": A, 98 | "W": W, 99 | "E": E, 100 | "EY": self.EY, 101 | "R": R, 102 | "RY": self.RY, 103 | "M": M, 104 | "MY": self.MY, 105 | "Cr_E_k": self.Cr_E_k, 106 | "Cr_M_k": self.Cr_M_k, 107 | "Cr_R_k": self.Cr_R_k, 108 | "Cr_W_k": self.Cr_W_k, 109 | "ver_base": ver_base 110 | } 111 | 112 | def IOTpxpSTA_MSCm(self): 113 | """ 114 | IOT prod x prod Single tech Industry-technology assumption 115 | Market share coef method 116 | """ 117 | met = ops.PxP_ITA_MSC 118 | 119 | S = met.S(self.U, self.inv_diag_g) # ind. interm. coef. => in EUROSTAT manual shown as S 120 | D = met.D(self.V, self.inv_diag_q) # Market shares 121 | A = met.A(S, D) # technical coefficient matrix 122 | 123 | L = met.L(A) # leontief inverse 124 | w = met.B(self.W, D, self.inv_diag_g) # primary inputs 125 | x = ops.IOT.x_IAy(L, self.yi) 126 | W = ops.IOT.R(w, np.diag(x)) 127 | Z = met.Z(S, D, np.diag(x)) # intermediates 128 | ver_base = ops.verifyIOT(Z, self.Y, W) 129 | del(self.V) 130 | del(self.U) 131 | del(self.W) 132 | 133 | e = met.B(self.E, D, self.inv_diag_g) # emis coef. matrix 134 | del(self.E) 135 | E = met.R(e, np.diag(x)) 136 | 137 | r = met.B(self.R, D, self.inv_diag_g) # resour coef. matrix 138 | del(self.R) 139 | R = met.R(r, np.diag(x)) 140 | 141 | m = met.B(self.M, D, self.inv_diag_g) # mater coef. matrix 142 | del(self.M) 143 | M = met.R(m, np.diag(x)) 144 | 145 | return {"Y": self.Y, 146 | "L": L, 147 | "Z": Z, 148 | "A": A, 149 | "W": W, 150 | "E": E, 151 | "EY": self.EY, 152 | "R": R, 153 | "RY": self.RY, 154 | "M": M, 155 | "MY": self.MY, 156 | "Cr_E_k": self.Cr_E_k, 157 | "Cr_M_k": self.Cr_M_k, 158 | "Cr_R_k": self.Cr_R_k, 159 | "Cr_W_k": self.Cr_W_k, 160 | "ver_base": ver_base 161 | } 162 | 163 | # Add here more transformation methods for industry-by-industry 164 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | appdirs==1.4.3 2 | CacheControl==0.12.6 3 | certifi==2019.11.28 4 | chardet==3.0.4 5 | colorama==0.4.3 6 | contextlib2==0.6.0 7 | distlib==0.3.0 8 | distro==1.4.0 9 | et-xmlfile==1.0.1 10 | html5lib==1.0.1 11 | idna==2.8 12 | ipaddr==2.2.0 13 | lockfile==0.12.2 14 | msgpack==0.6.2 15 | munch==2.5.0 16 | numpy==1.20.2 17 | openpyxl==3.0.7 18 | packaging==20.3 19 | pandas==1.2.4 20 | pep517==0.8.2 21 | progress==1.5 22 | pyparsing==2.4.6 23 | python-dateutil==2.8.1 24 | pytoml==0.1.21 25 | pytz==2021.1 26 | requests==2.22.0 27 | retrying==1.3.3 28 | six==1.14.0 29 | urllib3==1.25.8 30 | webencodings==0.5.1 31 | -------------------------------------------------------------------------------- /requirements_dev.txt: -------------------------------------------------------------------------------- 1 | alabaster==0.7.12 2 | appdirs==1.4.3 3 | Babel==2.9.0 4 | CacheControl==0.12.6 5 | certifi==2019.11.28 6 | chardet==3.0.4 7 | colorama==0.4.3 8 | contextlib2==0.6.0 9 | distlib==0.3.0 10 | distro==1.4.0 11 | docutils==0.16 12 | et-xmlfile==1.0.1 13 | html5lib==1.0.1 14 | idna==2.8 15 | imagesize==1.2.0 16 | ipaddr==2.2.0 17 | Jinja2==2.11.3 18 | lockfile==0.12.2 19 | MarkupSafe==1.1.1 20 | msgpack==0.6.2 21 | munch==2.5.0 22 | numpy==1.20.2 23 | openpyxl==3.0.7 24 | packaging==20.3 25 | pandas==1.2.4 26 | pep517==0.8.2 27 | progress==1.5 28 | Pygments==2.8.1 29 | pyparsing==2.4.6 30 | python-dateutil==2.8.1 31 | pytoml==0.1.21 32 | pytz==2021.1 33 | requests==2.22.0 34 | retrying==1.3.3 35 | six==1.14.0 36 | snowballstemmer==2.1.0 37 | Sphinx==3.5.4 38 | sphinxcontrib-applehelp==1.0.2 39 | sphinxcontrib-devhelp==1.0.2 40 | sphinxcontrib-htmlhelp==1.0.3 41 | sphinxcontrib-jsmath==1.0.1 42 | sphinxcontrib-qthelp==1.0.3 43 | sphinxcontrib-serializinghtml==1.1.4 44 | urllib3==1.25.8 45 | webencodings==0.5.1 46 | -------------------------------------------------------------------------------- /resources/categories.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/resources/categories.ods -------------------------------------------------------------------------------- /resources/classifications3.0.13_3_dec_2016.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/resources/classifications3.0.13_3_dec_2016.xlsx -------------------------------------------------------------------------------- /resources/index.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/resources/index.xls -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 2.0 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:setup.py] 7 | search = version='{current_version}' 8 | replace = version='{new_version}' 9 | 10 | [bumpversion:file:pycirk/__init__.py] 11 | search = __version__ = '{current_version}' 12 | replace = __version__ = '{new_version}' 13 | 14 | [bdist_wheel] 15 | python-tag = py38 16 | 17 | [flake8] 18 | exclude = docs, data 19 | 20 | [aliases] 21 | # Define setup.py command aliases here 22 | test = pytest 23 | 24 | [tool:pytest] 25 | collect_ignore = ['setup.py'] 26 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """The setup script.""" 5 | 6 | from setuptools import setup, find_packages 7 | 8 | with open('README.rst') as readme_file: 9 | readme = readme_file.read() 10 | 11 | with open('HISTORY.rst') as history_file: 12 | history = history_file.read() 13 | 14 | 15 | requirements = [ "appdirs==1.4.3", 16 | "munch==2.5.0", 17 | "openpyxl==3.0.7", 18 | "pandas==1.2.4"] 19 | 20 | setup_requirements = ['pytest-runner', ] 21 | 22 | test_requirements = ['pytest', ] 23 | 24 | setup( 25 | author="Franco Donati", 26 | author_email='f.donati@cml.leidenuniv.nl', 27 | classifiers=[ 28 | 'Development Status :: 4 - Beta', 29 | 'Intended Audience :: Developers', 30 | 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 31 | 'Natural Language :: English', 32 | 'Programming Language :: Python :: 3.5', 33 | 'Programming Language :: Python :: 3.6', 34 | 'Programming Language :: Python :: 3.7', 35 | 'Programming Language :: Python :: 3.8', 36 | 'Programming Language :: Python :: 3 :: Only', 37 | ], 38 | description="A software to model Circular Economy policy and" + 39 | "technological interventions in Environmentally " + 40 | "Extended Input-Output Analysis (EXIOBASE V3.3)", 41 | entry_points={ 42 | 'console_scripts': [ 43 | 'pycirk=pycirk.cli:main', 44 | ], 45 | }, 46 | 47 | 48 | install_requires=requirements, 49 | license="GNU General Public License v3", 50 | long_description=readme + '\n\n' + history, 51 | include_package_data=True, 52 | keywords='pycirk', 53 | name='pycirk', 54 | packages=find_packages(include=['pycirk']), 55 | setup_requires=setup_requirements, 56 | test_suite='tests', 57 | tests_require=test_requirements, 58 | url='https://bitbucket.org/CML-IE/pycirk/src/master/', 59 | version='2.0', 60 | zip_safe=False, 61 | ) 62 | -------------------------------------------------------------------------------- /tests/scenarios.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMLPlatform/pycirk/13285f6635ff6e195228cb85289c06eba1af1c7b/tests/scenarios.xlsx -------------------------------------------------------------------------------- /tests/test_pycirk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """Tests for `pycirk` package.""" 5 | 6 | import pytest 7 | import pycirk 8 | 9 | 10 | 11 | @pytest.fixture 12 | def test(): 13 | t = pycirk.Launch(test=True) 14 | return t 15 | 16 | def results(): 17 | return test().all_results() 18 | 19 | if __name__ == "__main__": 20 | assert(results()) 21 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py34, py35, py36, py37, flake8 3 | 4 | [travis] 5 | python = 6 | 3.7: py37 7 | 3.6: py36 8 | 3.5: py35 9 | 3.4: py34 10 | 11 | [testenv:flake8] 12 | basepython = python 13 | deps = flake8 14 | commands = flake8 pycirk 15 | 16 | [testenv] 17 | setenv = 18 | PYTHONPATH = {toxinidir} 19 | deps = 20 | -r{toxinidir}/requirements_dev.txt 21 | ; If you want to make tox run the tests with the same versions, create a 22 | ; requirements.txt with the pinned versions and uncomment the following line: 23 | -r{toxinidir}/requirements.txt 24 | commands = 25 | pip install -U pip 26 | py.test --basetemp={envtmpdir} 27 | 28 | 29 | --------------------------------------------------------------------------------