-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started with docs for exploring mrios
- Loading branch information
1 parent
74eb4ce
commit 0c58262
Showing
8 changed files
with
269 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "444a77e7-8a6f-44c1-bdac-b7f1e0b052e8", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"# Exploring MRIOs with Pymrio" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "7a8d7b7a-1d21-4cea-b7bf-578ac1b40679", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import pymrio" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5ac4addd-0a85-4b49-8f95-48bc25a24366", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# --- | ||
# jupyter: | ||
# jupytext: | ||
# text_representation: | ||
# extension: .py | ||
# format_name: percent | ||
# format_version: '1.3' | ||
# jupytext_version: 1.15.0 | ||
# kernelspec: | ||
# display_name: Python 3 (ipykernel) | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% [markdown] | ||
# # Exploring MRIOs with Pymrio | ||
|
||
# %% [markdown] | ||
# The first step when working with a new MRIO data set is to familiarize yourself with the data. | ||
# This notebook shows how to use the `pymrio` package to explore the data. | ||
# We use the test data set that is included in the `pymrio` package. | ||
# This is a completely artificial, very small MRIO. | ||
# It is not meant to be realistic, but it is useful for developing, testing and learning. | ||
|
||
|
||
# %% [markdown] | ||
# First we import the required packages: | ||
|
||
# %% | ||
import pymrio | ||
|
||
# %% [markdown] | ||
# We can now load the test data set with the `load_test` function. We can call | ||
# the MRIO whatever we want, here we use mrio. | ||
|
||
# %% | ||
mrio = pymrio.load_test() | ||
|
||
# %% [markdown] | ||
# We can get some first information about the MRIO by printing it. | ||
|
||
# %% | ||
print(mrio) | ||
|
||
# %% [markdown] | ||
# This tells us what the MRIO data we just loaded contains. | ||
# We find a Z and Y matrix, some unit information and two satellite accounts, factor_inputs and emissions. | ||
|
||
# %% [markdown] | ||
# To get more specific data we can ask pymrio for regions, sectors, products, etc. | ||
|
||
# %% | ||
mrio.name | ||
|
||
# %% | ||
mrio.get_regions() | ||
|
||
# %% | ||
mrio.get_sectors() | ||
|
||
# %% | ||
mrio.get_Y_categories() | ||
|
||
# %% [markdown] | ||
# The same methods can be used to explore one of the satellite accounts. | ||
|
||
# %% | ||
print(mrio.emissions) | ||
|
||
# %% | ||
mrio.emissions.name | ||
# %% | ||
mrio.emissions.get_regions() | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Pair ipynb notebooks to py:percent text notebooks | ||
formats = "ipynb,py:percent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# --- | ||
# jupyter: | ||
# jupytext: | ||
# text_representation: | ||
# extension: .py | ||
# format_name: percent | ||
# format_version: '1.3' | ||
# jupytext_version: 1.15.0 | ||
# kernelspec: | ||
# display_name: Python 3 (ipykernel) | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% [markdown] | ||
# # Metadata and change recording | ||
|
||
# %% [markdown] | ||
# **DEPRECATED**: this will be removed and changed to loguru soon | ||
|
||
# %% [markdown] | ||
# Each pymrio core system object contains a field 'meta' which stores meta data as well as changes to the MRIO system. This data is stored as json file in the root of a saved MRIO data and accessible through the attribute '.meta': | ||
|
||
# %% | ||
import pymrio | ||
|
||
io = pymrio.load_test() | ||
|
||
# %% | ||
io.meta | ||
|
||
# %% | ||
io.meta("Loaded the pymrio test system") | ||
|
||
# %% [markdown] | ||
# We can now do several steps to modify the system, for example: | ||
|
||
# %% | ||
io.calc_all() | ||
io.aggregate(region_agg="global") | ||
|
||
# %% | ||
io.meta | ||
|
||
# %% [markdown] | ||
# Notes can added at any time: | ||
|
||
# %% | ||
io.meta.note("First round of calculations finished") | ||
|
||
# %% | ||
io.meta | ||
|
||
# %% [markdown] | ||
# In addition, all file io operations are recorde in the meta data: | ||
|
||
# %% | ||
io.save_all("/tmp/foo") | ||
|
||
# %% | ||
io_new = pymrio.load_all("/tmp/foo") | ||
|
||
# %% | ||
io_new.meta | ||
|
||
# %% [markdown] | ||
# The top level meta data can be changed as well. These changes will also be recorded in the history: | ||
|
||
# %% | ||
io_new.meta.change_meta("Version", "v2") | ||
|
||
# %% | ||
io_new.meta | ||
|
||
# %% [markdown] | ||
# To get the full history list, use: | ||
|
||
# %% | ||
io_new.meta.history | ||
|
||
# %% [markdown] | ||
# This can be restricted to one of the history types by: | ||
|
||
# %% | ||
io_new.meta.modification_history | ||
|
||
# %% [markdown] | ||
# or | ||
|
||
# %% | ||
io_new.meta.note_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.