API Reference
API references for all modules
Data input and output
Test system
Return a small test MRIO. |
Download MRIO databases
Download publicly EE MRIO databases from the web. This is currently implemented for the WIOD and OECD_ICIO database (EXIOBASE and EORA26 require registration before downloading).
|
Download EXIOBASE 3 files from Zenodo. |
|
Download the 2013 wiod release. |
|
Download the OECD ICIO tables. |
Raw data
|
Parse the exiobase1 raw data files. |
|
Parse the exiobase 2.2.2 source files for the IOSystem. |
|
Parse the public EXIOBASE 3 system. |
|
Parse EXIOBASE version 1 and 2. |
|
Parse the wiod source files for the IOSystem. |
|
Parse the Eora26 database. |
|
Parse the OECD ICIO tables. |
Save data
Currently, the full MRIO system can be saved in txt or the python specific binary format (‘pickle’). Both formats work with the same API interface:
|
Save the system to path. |
|
Save the system and all extensions. |
Already saved MRIO databases can be archived with
|
Archive a MRIO database as zip file. |
Load processed data
This functions load IOSystems or individual extensions which have been saved with pymrio before.
|
Load a IOSystem or Extension previously saved with pymrio. |
|
Load a full IO system with all extension from path. |
Accessing
pymrio stores all tables as pandas DataFrames. This data can be accessed with the usual pandas methods. On top of that, the following functions return (in fact yield) several tables at once:
|
Yield all panda.DataFrames or there names. |
|
Yield the extensions or their names. |
For the extensions, it is also possible to receive all data (F, S, M, D_cba, …) for one specified row.
|
Return a dict with all available data for a row in the extension. |
Exploring and Search
Structure
The following functions provide informations about the structure of the IO System and the extensions. The methods work on the IOSystem as well as directly on the Extensions.
|
Return the names of regions in the IOSystem as unique names in order. |
|
Return names of sectors in the IOSystem as unique names in order. |
|
Return names of y cat. |
|
Return the index of the DataFrames in the system. |
|
Set the pd dataframe index of all dataframes in the system to index. |
Return the gross bilateral trade flows and totals. |
|
Return the name of the rows of the extension. |
Finding accounts
|
Look for term in index, sectors, regions, Y_categories. |
|
Check if index of the system contains the regex pattern. |
|
Check if index of the system match the regex pattern. |
|
Check if a index row of the system is a full match to the regex pattern. |
|
Check if index of the system contains the regex pattern. |
|
Check if index of the system match the regex pattern. |
|
Check if a index row of the system is a full match to the regex pattern. |
|
Get a dict of extension index dicts which contains a search pattern. |
|
Get a dict of extension index dicts with full match of a search pattern. |
|
Get a dict of extension index dicts which match a search pattern. |
|
Check if index contains a regex pattern. |
Calculations
Top level methods
The top level level function calc_all checks the IO System and its extensions for missing parts and calculate these. This function calls the specific calculation method for the core system and for the extensions.
|
Calculate missing parts of the IOSystem and all extensions. |
|
Calculate the missing part of the core IOSystem. |
|
Calculate the missing part of the extension plus accounts. |
Low level matrix calculations
The top level functions work by calling the following low level functions. These can also be used independently from the IO System for pandas DataFrames and numpy array.
|
Calculate the industry output x from the Z and Y matrix. |
|
Calculate the Z matrix (flows) from A and x. |
|
Calculate the A matrix (coefficients) from Z and x. |
|
Calculate the B matrix (coefficients) from Z and x. |
|
Calculate the Leontief L from A. |
|
Calculate the Ghosh inverse matrix G. |
|
Calculate extensions/factor inputs coefficients. |
|
Calculate total direct impacts from the impact coefficients. |
|
Calculate multipliers of the extensions. |
|
Calculate downstream multipliers of the extensions. |
|
Calculate total impacts (footprints of consumption Y). |
|
Calculate sector specific cba and pba based accounts, imp and exp accounts. |
Metadata and history recording
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’.
|
MRIO Meta Data class. |
|
Add the passed string as note to the history. |
Return all recorded history. |
|
Return all modification history entries. |
|
Return all note history entries. |
|
Return all fileio history entries. |
|
|
Save the current status of the metadata. |
Modifiying the IO System and its Extensions
Aggregation
The IO System method ‘aggregate’ accepts concordance matrices and/or aggregation vectors. The latter can be generated automatically for various aggregation levels for the test system and EXIOBASE 2.
|
Aggregate the IO system. |
|
Build an combined aggregation vector considering diff classifications. |
Characterizing stressors
|
Characterize stressors. |
Analysing the source of impacts
|
Diagonalize one row of the stressor matrix for a flow analysis. |
Changing extensions
Remove extension from IOSystem. |
|
|
Concatenate extensions. |
|
Characterize stressors across different extensions. |
|
Apply the convert function to a list of extensions. |
|
Parse an EXIOBASE version 1 or 2 like extension file into pymrio.Extension. |
Adjusting and Renaming
|
Set new names for the regions. |
|
Set new names for the sectors. |
|
Set new names for the Y_categories. |
Getting predefined Classifications of MRIOs
|
Get predefined classifications included in pymrio. |
|
Classification data for MRIOs. |
Report
The following method works on the IO System (generating reports for every extension available) or at individual extensions.
|
Generate a report to the given path for all extension. |
Visualization
|
Plot D_pba, D_cba, D_imp and D_exp for the specified row (account). |
Utility
Routines developed for pymrio which can also be used independently.
|
Match regex on index of df_ix. |
|
Check if index contains a regex pattern. |
|
Fullmatch regex on index of df_ix. |
|
Aggregate based on mapping given in input as numerical or str vector. |
|
Build an combined aggregation vector considering diff classifications. |
Miscellaneous
|
Keep only the absolute values. |
Keep only the coefficient. |
|
|
Return a deep copy of the system. |