API Reference¶
API references for all modules
Data input and output¶
Download MRIO databases¶
Download publicly EE MRIO databases from the web. This is currently implemented for the WIOD and EORA26 database (EXIOBASE requires registration before downloading).
download_wiod2013 (storage_folder[, years, …]) |
Downloads the 2013 wiod release |
download_eora26 (storage_folder[, years, …]) |
Downloads Eora 26 |
Raw data¶
parse_exiobase2 (path[, charact, popvector]) |
Parse the exiobase 2.2.2 source files for the IOSystem |
parse_wiod (path[, year, names, popvector]) |
Parse the wiod source files for the IOSystem |
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:
IOSystem.save (path[, table_format, sep, …]) |
Developing version for saving with json instead of ini for meta |
IOSystem.save_all (path[, table_format, sep, …]) |
Saves the system and all extensions |
Load processed data¶
This functions load IOSystems or individual extensions which have been saved with pymrio before.
load (path[, include_core]) |
Loads a IOSystem or Extension previously saved with pymrio |
load_all (path[, include_core, subfolders]) |
Loads a full IO system with all extension in 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:
IOSystem.get_DataFrame ([data, with_unit, …]) |
Yields all panda.DataFrames or there names |
IOSystem.get_extensions ([data]) |
Yields 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.
Extension.get_row_data (row[, name]) |
Returns a dict with all available data for a row in the extension |
Exploring the IO System¶
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.
IOSystem.get_regions ([entries]) |
Returns the names of regions in the IOSystem as unique names in order |
IOSystem.get_sectors ([entries]) |
Names of sectors in the IOSystem as unique names in order |
IOSystem.get_Y_categories ([entries]) |
Returns names of y cat. |
IOSystem.get_index ([as_dict, grouping_pattern]) |
Returns the index of the DataFrames in the system |
IOSystem.set_index (index) |
Sets the pd dataframe index of all dataframes in the system to index |
Extension.get_rows () |
Returns the name of the rows of the extension |
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.
IOSystem.calc_all () |
Calculates missing parts of the IOSystem and all extensions. |
IOSystem.calc_system () |
Calculates the missing part of the core IOSystem |
Extension.calc_system (x, Y_agg[, L, population]) |
Calculates 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.
calc_x (Z, Y) |
Calculate the industry output x from the Z and Y matrix |
calc_Z (A, x) |
calculate the Z matrix (flows) from A and x |
calc_A (Z, x) |
Calculate the A matrix (coefficients) from Z and x |
calc_L (A) |
Calculate the Leontief L from A |
calc_S (F, x) |
Calculate extensions/factor inputs coefficients |
calc_F (S, x) |
Calculate total direct impacts from the impact coefficients |
calc_M (S, L) |
Calculate multipliers of the extensions |
calc_e (M, Y) |
Calculate total impacts (footprints of consumption Y) |
calc_accounts (S, L, Y, nr_sectors) |
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’.
MRIOMetaData ([location, description, name, …]) |
|
MRIOMetaData.note (entry) |
Add the passed string as note to the history |
MRIOMetaData.history |
All recorded history |
MRIOMetaData.modification_history |
All modification history entries |
MRIOMetaData.note_history |
All note history entries |
MRIOMetaData.file_io_history |
All fileio history entries |
MRIOMetaData.save ([location]) |
Saves 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.
IOSystem.aggregate ([region_agg, sector_agg, …]) |
Aggregates the IO system. |
build_agg_vec (agg_vec, **source) |
Builds an combined aggregation vector based on various classifications |
Analysing the source of impacts¶
Extension.diag_stressor (stressor[, name]) |
Diagonalize one row of the stressor matrix for a flow analysis. |
Changing extensions¶
IOSystem.remove_extension ([ext]) |
Remove extension from IOSystem |
parse_exio_ext (ext_file, index_col, name[, …]) |
Parse an EXIOBASE like extension file into pymrio.Extension |
Renaming¶
IOSystem.rename_regions (regions) |
Sets new names for the regions |
IOSystem.rename_sectors (sectors) |
Sets new names for the sectors |
IOSystem.rename_Y_categories (Y_categories) |
Sets new names for the Y_categories |
Report¶
The following method works on the IO System (generating reports for every extension available) or at individual extensions.
IOSystem.report_accounts (path[, per_region, …]) |
Generates a report to the given path for all extension |
Visualization¶
Extension.plot_account (row[, per_capita, …]) |
Plots D_pba, D_cba, D_imp and D_exp for the specified row (account) |
Miscellaneous¶
IOSystem.reset_to_flows () |
Keeps only the absolute values. |
IOSystem.reset_to_coefficients () |
Keeps only the coefficient. |
IOSystem.copy ([new_name]) |
Returns a deep copy of the system |