API Reference

Analyzing database

CoreModel.is_balanced(method[, data_set, ...])

Checks if a specific data_set in the database is balance or not

CoreModel.is_productive(method[, data_set])

Checks the productivity of the system

CoreModel.is_multi_region

Defines if a database is single region or multi-region

CoreModel.is_hybrid

checks if the database is hybrid or monetary

CoreModel.sets

Returns a list of levels of info in the model

CoreModel.scenarios

Returns all the scenarios existed in the model

CoreModel.table_type

Returns the type of the database

CoreModel.get_index(index[, level])

Returns a list or a DataFrame of different levels of indeces in the database.

Database modification

Database.aggregate(io[, drop, levels, ...])

This function is in charge of reading data regarding the aggregation

Database.add_sectors(io, new_sectors, ...[, ...])

Adds a Sector/Activity/Commodity to the database

Database.to_single_region(region[, backup, ...])

Extracts a single region from multi-region databases

Database.to_iot(method[, inplace])

The function will transform a SUT table to a IOT table

Database.add_extensions(io, matrix, units[, ...])

Adding a new extension [Factor of production or Satellite account] to the database passing the coefficients or the absolute values.

Database.update_scenarios(scenario, **matrices)

Updates the matrices for a specific scenario.

Database.reset_to_flows(scenario[, backup])

Deletes the coefficients of a scenario and keeps only flows

Database.reset_to_coefficients(scenario[, ...])

Deletes the flows of a scenario and keeps only coefficients

Database.clone_scenario(scenario, name)

Creates a new scenario by cloning an existing scenario

Database.copy()

Returns a deepcopy of the instance

Database.backup()

The function creates a backup of the last configuration of database to be returned in case needed.

Database.reset_to_backup()

This function is in charge of reseting back the database to the last back-up.

Shock analysis

Database.shock_calc(io[, z, e, v, Y, notes, ...])

Implements shocks on different matrices with the possibility of defining clusters on every level of information.

Data visualization

mario.set_palette([mario_palettes, user_palette])

Sets the default palette of plots

Database.plot_gdp([path, plot, scenario, ...])

Plots sectoral GDP with additional info

Database.plot_bubble(x, y, size[, path, ...])

Creates bubble plots

Database.plot_linkages([scenarios, ...])

Plots linkages in different modes

Database.plot_matrix(matrix, x, color[, y, ...])

Generates a general html barplot giving the user certain degrees of freedom such as:

Get excels

mario has some functions providing automatic excel file generations for easing some of the functionalities such as aggrgeaton and adding sectors.

Database.get_aggregation_excel([path, levels])

Generates the Excel file for aggregation of the database

Database.get_extensions_excel(matrix[, path])

Generates an Excel file for easing the add extension functionality

Database.get_add_sectors_excel(new_sectors, ...)

Generates an Excel file to add a sector/activity/commodity to the database

Database.get_shock_excel([path, num_shock])

Creates an Excel file based on the shape and the format

Save data

Database.to_excel([path, flows, ...])

Saves the database into an Excel file

Database.to_txt([path, flows, coefficients, ...])

Saves the database multiple text file based on given inputs

Database.to_pymrio([satellite_account, ...])

Returns a pymrio.IOSystem from a mario.Database

Database parsers

Structured Databases

mario supports automatic parsing of following database:

  • Exiobase

  • Eurostat Supply and Use

  • Eora26

  • Eora single region

mario.parse_exiobase_3(path[, calc_all, ...])

Parsing exiobase3

mario.parse_exiobase_sut(path[, calc_all, ...])

Parsing exiobase mrsut

mario.parse_eurostat_sut(supply_path, use_path)

Parsing Eurostat databases

mario.parse_eora(path, multi_region, table)

Parsing eora databases

mario.parse_from_pymrio(io, value_added, ...)

Parsing a pymrio database

mario.hybrid_sut_exiobase(path[, ...])

reads hybrid supply and use exiobase

mario.parse_exiobase(table, unit, path[, ...])

A unique function for parsing all exiobase databases

Non-Structured Databases

When databases are not structured (coming from abovementioned sources), excel or text parsers can be used. The databases in this case, should follow specific rules:

mario.parse_from_excel(path, table, mode[, ...])

Parsing database from excel file

mario.parse_from_txt(path, table, mode[, ...])

Parsing database from text files

Calculations

High level matrix calculations

This function can be called inside a mario.Database object to call missing matrices for different scenarios.

CoreModel.calc_all([matrices, scenario, ...])

Calculates the input-output matrices for different scenarios.

CoreModel.GDP([exclude, scenario, total, share])

Return the value of the GDP based scenario.

Database.calc_linkages([scenario, ...])

Calculates the linkages in different modes

Low level matrix calculations

This functions are used to calculate the matrices in mario.Database while they can be used independently outside a mario.Databases object.

calc_X(Z, Y)

Calculates the production vector

calc_X_from_w(w, Y)

Calculates Production vector from Leontief coefficients matrix

calc_X_from_z(z, Y)

Calculates Production vector from Intersectoral transaction coefficients matrix

calc_Z(z, X)

Calculates Intersectoral transaction flows matrix

calc_E(e, X)

Calculates satellite transaction flows matrix

calc_V(v, X)

Calculates Factor of production transaction flows matrix

calc_M(m, Y)

Calculates Economic impact matrix

calc_F(f, Y)

Calculates Footprint flows matrix

calc_z(Z, X)

Calculates Intersectoral transaction coefficients matrix

calc_v(V, X)

Calculates Factor of production transaction coefficients matrix

calc_e(E, X)

Calculates Satellite transaction coefficients matrix

calc_m(v, w)

Calculates Multipliers coefficients matrix

calc_f(e, w)

Calculates Footprint coefficients matrix

calc_w(z)

Calculates Leontief coefficients matrix

calc_g(b)

Calculates Ghosh coefficients matrix

calc_b(X, Z)

Calculates Intersectoral transaction direct-output coefficients matrix (for Ghosh model)

calc_p(v, w)

Calculating Price index coefficients vector

calc_y(Y)

Calculates Final demand share coefficients matrix

Metadata

CoreModel.save_meta(path[, format])

Saves the metadata in different formats

CoreModel.meta_history

Returns the whole history of the metadata

CoreModel.add_note(notes)

Adds notes to the meta history

Test

For having a simple exmaple of mario, load_test can be used.

mario.load_test(table)

Loads an example of mario.Database

Directory

When mario needs to save an output of the model, if no path is given, files wil be saved in a default directory with subfolders based on the type of the output. By default, the directory is the working directory but user can change the default directory.

CoreModel.directory

The defualt directory of the database

Utilities

There are some useful functions in mario that may help the user for different purposes.

CoreModel.search(item, search[, ignore_case])

Searches for specific keywords in a given item

mario.slicer(matrix, axis, **levels)

Helps to slice the matrices

Logging

In case that logging is useful for the user, the following function can be used to set the level of verbosity.

mario.set_log_verbosity([verbosity, ...])

Sets the formatted logging level