Multifunctional Analysis of Regions through Input-Output

Related tags

MiscellaneousMARIO
Overview
https://img.shields.io/gitter/room/SESAM-Polimi/MARIO Documentation Status https://img.shields.io/pypi/v/mariopy https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png

MARIO

Multifunctional Analysis of Regions through Input-Output. (Documents)

What is it

MARIO is a python package for handling input-output tables and models inspired by pymrio. MARIO aims to provide a simple & intuitive API for common IO tasks without needing in-depth programming knowledge. MARIO supporst automatic parsing of different structured tables such EXIOBASE, EORA, EUROSTAT in different formats namely:

  • Single region
  • Multi region
  • Hybrid tables
  • Monetary tables
  • Input-Output tables
  • Supply-Use tables

When databases are not structured, MARIO supports parsing data from xlsx, csv, txt files or pandas.DataFrames.

More than parsing data, MARIO includes some basic functionalities:

  • Aggregation of databases
  • SUT to IOT transformation
  • Modifying database in terms of adding:
    • New sectors, activities or commodities to the database
    • Adding new extensions to the satellite account
  • Scneario and shock analysis
  • Backward and forward linkages analysis
  • Extracting single region database from multi region databases
  • Balance test
  • Productivity test
  • Exporting the databases into different formats for scenarios analyzed
  • Interactive visualization routines

Requirements

MARIO has been tested on macOS and Windows.

To run MARIO, a couple of things are needed:

  1. Being in love with Input-Output :-)
  2. The Python programming language, version 3.7 or higher
  3. A number of Python adds-on packages
  4. For some functionalities a solver may needed (optional)
  5. MARIO software itself

Recommended installation method

The easiest way to make MARIO software working is to use the free conda package manager which can install the current and future MARIO depencies in an easy and user friendly way.

To get conda, download and install "Anaconda Distribution" . Between differnet options for running python codes, we strongly suggest, Spyder, which is a free and open source scientific environment written in Python, for Python, and designed by and for scientists, engineers and data analysts.

You can install mario using pip or from source code. It is suggested to create a new environment by running the following command in the anaconda prompt

conda create -n mario python=3.8

If you create a new environment for mario, to use it, you need to activate the mario environment each time by writing the following line in Anaconda Prompt

conda activate mario

Now you can use pip to install mario on your environment as follow:

pip install mariopy

You can also install from the source code!

Quickstart

A simple test for Input-Output Table (IOT) and Supply-Use Table (SUT) is included in mario.

To use the IOT test, call

import mario
test_iot = mario.load_test('IOT')

and to use the SUT test, call

test_sut = mario.load_test('SUT')

To see the configurations of the data, you can print them:

print(test_iot)
print(test_sut)

To see specific sets of the tables like regions or value added, get_index function can be used:

print(test_iot.get_index('Region'))
print(test_sut.get_index('Factor of production'))

To visualize some data, various plot functions can be used:

test_iot.plot_matrix(....)

Specific modifications on the database can be done, such as SUT to IOT transformation:

reformed_iot = test.sut_to_iot(method='B')

The changes can be tracked by metadata. The history can be checked by calling:

reformed_iot.meta_history

The new database can be saved into excel,txt or csv file:

reformed_iot.to_excel(path='a folder//database.xlsx')

Python module requirements

Some of the key packages the mario relies on are:

Note

  • This project is under active development.
  • More examples will be uploaded through time to the gellery.
  • More parsers will be added to the next version.
  • The next version will cover some optimization models within the IO framework

License

https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png

This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)

Comments
  • Misleading error message for `parse_eurostat`

    Misleading error message for `parse_eurostat`

    Following the documentation for the Eurostat-parsing functionality, I ran into below error ("non-corresponding years"). This is unexpected since I was strictly following the documentation, i.e. did everything as described there. Any ideas why that happens and how to get my SUTs?

    `--------------------------------------------------------------------------- WrongInput Traceback (most recent call last) c:\Users\maximiko\IO-testbed\Eurostat_MARIO.py in ----> 18 italy_sut = parse_eurostat( 19 supply_path = supply_path, 20 use_path = use_path, 21 region = "Italy", 22 year = 2011

    ~\Anaconda3\envs\pymrio\lib\site-packages\mario\tools\parsersclass.py in parse_eurostat(supply_path, use_path, region, year, consumption_categories, factors_of_production, imports, model, name, calc_all, **kwargs) 432 table = "SUT" 433 if table == "SUT": --> 434 matrices, indeces, units = eurostat_sut( 435 supply_path, 436 use_path,

    ~\Anaconda3\envs\pymrio\lib\site-packages\mario\tools\tableparser.py in eurostat_sut(supply_path, use_path, region, selected_year, consumption_categories, factors_of_production, imports) 992 years = supply_years 993 else: --> 994 raise WrongInput("No correspondance between years of use and supply tables") 995 996 "Warning on supply in IxP format, Use in PxI format"

    WrongInput: No correspondance between years of use and supply tables`

    enhancement 
    opened by maximikos 4
  • New parse hybrid Exiobase from Zenodo

    New parse hybrid Exiobase from Zenodo

    Now the Hybrid version of EXIOBASE is available on Zenodo at https://zenodo.org/record/7244919#.Y6Lr0NXMIQ8

    A new parse function is needed in order to take advantage of a lighter format.

    enhancement 
    opened by nigolred 1
  • calc all keyerror management

    calc all keyerror management

    In the calc_all function, we should check at the beginning of the function whether the scenario exists or not so the keyerror won't be about the missing scenario.

    opened by LorenzoRinaldi 1
  • search function minor improvement

    search function minor improvement

    The search function should not be case sensitive. For instance, if the user run this command:

    db.search("Sector","electricity")

    he will not be able to track for sectors named "Electricity..." with capital "E". It would be super-useful to improve this making the function not case-sensitive

    opened by LorenzoRinaldi 1
  • Pymrio integration

    Pymrio integration

    pull request for merging the functions and methods added for mario vs pymrio integration.

    Changes:

    • Adding a new method for converting mario.Database to pymrio.IOSystem in Database class
    • Adding the parser function to parsers that reshapes the pymrio.IOSystem and pymrio.Extensions to mario.Database
    • miscellaneous changes in tools and constants to map the differences in two libraries
    opened by mohammadamint 1
  • There should be a way to store the metadata that generated a new database

    There should be a way to store the metadata that generated a new database

    Every time a new database is printed-out there should be a way to access information on the:

    • year
    • table version
    • added extensions
    • ...

    Printing out the metadata (as a txt file in case .to_txt or .to_csv is used; as an additional sheet in case .to_excel is used) can do the job

    opened by nigolred 1
  • Add a Gitter chat badge to README.rst

    Add a Gitter chat badge to README.rst

    SESAM-Polimi/MARIO now has a Chat Room on Gitter

    @LorenzoRinaldi has just created a chat room. You can visit it here: https://gitter.im/SESAM-Polimi/MARIO.

    This pull-request adds this badge to your README.rst:

    Gitter

    If my aim is a little off, please let me know.

    Happy chatting.

    PS: Click here if you would prefer not to receive automatic pull-requests from Gitter in future.

    opened by gitter-badger 1
  • Add pymrio package to requirements

    Add pymrio package to requirements

    TLDR I tried to follow the Mario set up instruction and I believe the pymrio package is missing from requirements.txt. I am using this as an opportunity to try my first pull request on the MARIO repo just to make sure everything works properly.

    REPRO

    i tried to install MARIO and then run a simple script using it. Here is the script I tried: https://gist.github.com/AAmedeo/fdeb1f74413d109d3f2727fa1116e687

    This is what happened before adding pymrio to requirements.txt

    [email protected] MARIO % rm -r venv
    [email protected] MARIO % python3 -m venv venv
    [email protected] MARIO % source ./venv/bin/activate
    (venv) [email protected] MARIO % pip3 install -r requirements.txt
    (venv) [email protected] MARIO % python3 mario_hello_world.py
    Traceback (most recent call last):
      File "mario_hello_world.py", line 1, in <module>
        import mario
      File "/Users/afa/Desktop/MARIO/mario/__init__.py", line 48, in <module>
        from mario.core.AttrData import Database
      File "/Users/afa/Desktop/MARIO/mario/core/AttrData.py", line 91, in <module>
        from mario.core.CoreIO import CoreModel
      File "/Users/afa/Desktop/MARIO/mario/core/CoreIO.py", line 15, in <module>
        from mario.tools.tableparser import dataframe_parser
      File "/Users/afa/Desktop/MARIO/mario/tools/tableparser.py", line 48, in <module>
        import pymrio
    ModuleNotFoundError: No module named 'pymrio'
    

    This is what happened after adding pymrio to requirements.txt

    [email protected] MARIO % rm -r venv
    [email protected] MARIO % python3 -m venv venv
    [email protected] MARIO % source ./venv/bin/activate
    (venv) [email protected] MARIO % pip3 install -r requirements.txt
    (venv) [email protected] MARIO % python3 mario_hello_world.py
    cvxpy module is not installed in your system. This will raise problems in some of the abilities of MARIO
    name = IOT test
    table = IOT
    scenarios = ['baseline']
    Factor of production = 3
    Satellite account = 4
    Consumption category = 1
    Region = 2
    Sector = 6
    
    name = SUT test
    table = SUT
    scenarios = ['baseline']
    Activity = 6
    Commodity = 6
    Factor of production = 3
    Satellite account = 1
    Consumption category = 1
    Region = 2
    
    ['RoW', 'Italy']
    ['Taxes', 'Wages', 'Capital']
    
    opened by AAmedeo 0
  • Add sectors conflict with pandas 1.4.4. version

    Add sectors conflict with pandas 1.4.4. version

    Using add_sectors function with pandas version 1.4.4 lead to the following error:

    ValueError: Length of new names must be 1, got 3

    The function works with pandas 1.3.3

    dependencies 
    opened by LorenzoRinaldi 1
  • Adding parsing function for Exiobase 3.3.18 (hybrid) version

    Adding parsing function for Exiobase 3.3.18 (hybrid) version

    I am requesting to merge these changes to main branch. The changes implement a new parser function for exiobase database, in particular referring to version 3.3.18, downloadable at this link

    In particular, the new feature have been implemented by updating the already present function parse_exiobase_sut, by adding the unit, version and extensions attributes.

    The unit attribute can be selected among the _acceptable_units list, saved in the parserid.py file, and is by default set to "monetary". In the default case, the function is run exactly in the same way as the one in the main branch. The version attribute is by default set to None and must be provided in case unit="hybrid" The extensions attribute is by default set to None and can be provided as a list including any of the keys of the _acceptable_extensions dictionay saved in the parserid.py file.

    Regarding the case when unit="hybrid", then the new hybrid_sut_parser function (in tableparser.py) will be invoked (see commit 799443fd5b3e0944894238b0d4c5861fe8e18640).

    Initially, this function was developed to parse an old version of the database, downloadable from the official exiobase website, which was saved as a zip file. This version had supply, use and final demand matrices saved into separate .xlsb files therefore the parser was significantly slower than other ones for other exiobase versions. The function was then modified in order to parse the database as the one available on zenodo (link reported previously), where the same matrices are available by default in .csv formats (much faster to be read).

    Another improvement brought by this merge would be the fact that the aggregation excel file template obtained by the get_aggregation_excel function, automatically prints a new sheet showing the units of each entry of each set. This would ease the process of aggregation in case of hybrid databases.

    enhancement 
    opened by LorenzoRinaldi 0
  • Obsolete xlsxwriter dependency

    Obsolete xlsxwriter dependency

    I see the package depency states "xlsxwriter <= 1.3.7", whereas the current version is 3.0.3... Is this really required? When installing the package, it downgraded my package version, and broke functionnalities with other Python scripts I'm running. Thanks in advance...

    enhancement 
    opened by adrienjacob 1
  • Get_data function

    Get_data function

    The function "get_data" is not working if the user provide an integer as "scenarios" parameter. Not even if it is provided within a list. Moreover, the documentation for this function seems missing.

    bug documentation 
    opened by LorenzoRinaldi 0
  • Activity units

    Activity units

    Check if actvity units is making sense, in general: do they need to be provided with units? Especially in hybrid database the answer is probably no, while for economic databases it is the opposite.

    Also, hybrid database need for further checks when dealing with aggregation of activities due to the fact activities may produce commodities with different units

    opened by LorenzoRinaldi 0
Releases(v0.1.0)
Shell Trality API for local development.

Trality Simulator Intro This package is a work in progress. It allows local development of Trality bots in an IDE such as VS Code. The package provide

CrypTrality 1 Nov 17, 2021
A maubot plugin to invite users to Matrix rooms according to LDAP groups

LDAP Inviter Bot This is a maubot plugin that invites users to Matrix rooms according to their membership in LDAP groups.

David Mehren 14 Dec 09, 2022
Snek-test - An operating system kernel made in python and assembly

pythonOS An operating system kernel made in python and assembly Wait what? It us

TechStudent10 2 Jan 25, 2022
A simple API to upload notes or files to KBFS

This API can be used to upload either secure notes or files to a secure KeybaseFS folder.

Dakota Brown 1 Oct 08, 2021
script to analyze EQ decay using python

pyq_decay script to analyze EQ decay using python PyQ Decay ver 1.0 A pythonic script to analyze EQ aftershock decay using method of Omori (1894), Mog

1 Nov 04, 2021
A slapdash script to solve Wordle or Absurdle automatically

A slapdash script to solve Wordle or Absurdle automatically

Michael Anthony 1 Jan 19, 2022
SMS-b0mber VANDALIZM developed for VK group

VANDALIZM SMS-b0mber VANDALIZM developed for VK group https://vk.com/dark__code if you come across this code, you can use it for your own purposes) ус

5 Jun 24, 2022
A tool for study using pomodoro methodology, while study mode spotify or any other .exe app is opened and while resting is closed.

Pomodoro-Timer-With-Spotify-Connection A tool for study using pomodoro methodology, while study mode spotify or any other .exe app is opened and while

2 Oct 23, 2022
Create beautiful diagrams just by typing mathematical notation in plain text.

Penrose Penrose is an early-stage system that is still in development. Our system is not ready for contributions or public use yet, but hopefully will

Penrose 5.6k Jan 08, 2023
Placeholders is a single-unit storage solution for your Frontend.

Placeholder Placeholders is a single-unit file storage solution for your Frontend. Why Placeholder? Generally, when a website/service requests for fil

Tanmoy Sen Gupta 1 Nov 09, 2021
Python-Kite: Simple python code to make kite pattern

Python-Kite Simple python code to make kite pattern. Getting Started These instr

Anoint 0 Mar 22, 2022
A tool to flash .ofp files in bootloader mode without needing MSM Tool, an alternative to official realme tool

Oppo/Realme Flash .OFP File on Bootloader A tool to flash .ofp files in bootloader mode without needing MSM Tool, an alternative to official realme to

Italo Almeida 70 Jan 02, 2023
Hopefully it'll become a very annoying desktop pet

AnnoyingPet Basic Tutorial: https://seebass22.github.io/python-desktop-pet-tutorial/ Handling Mouse Input: https://pythonhosted.org/pynput/mouse.html

1 Jun 08, 2022
A very small (15 lines of code) and beautiful fetch script (exclusively for Arch Linux).

minifetch A very small (15 lines of code) and beautiful fetch script (exclusively for Arch Linux). There are many fetch scripts out there but I wanted

16 Jul 11, 2022
Code emulator plugin for IDA Pro

emu_ida Code emulator plugin for IDA Pro (v 0.0.6) The plugin is designed for simple data decryption and getting stack strings. Requirements Emulator

Andrey Zhdanov 11 Jul 06, 2022
Discover and load entry points from installed packages

Entry points are a way for Python packages to advertise objects with some common interface. The most common examples are console_scripts entry points,

Thomas Kluyver 69 Jul 05, 2022
A country information finder module

A country information finder module

Fayas Noushad 3 Nov 28, 2021
Beginner Projects A couple of beginner projects here

Beginner Projects A couple of beginner projects here, listed from easiest to hardest :) selector.py: simply a random selector to tell me who to faceti

Kylie 272 Jan 07, 2023
The third home of the bare Programming Language (1st there's my heart, the forest came second and then there's Github :)

The third home of the bare Programming Language (1st there's my heart, the forest came second and then there's Github :)

Garren Souza 7 Dec 24, 2022
Powerful virtual assistant in python

Virtual assistant in python Powerful virtual assistant in python Set up Step 1: download repo and unzip Step 2: pip install requirements.txt (if py au

Arkal 3 Jan 23, 2022