SUT to IOT#
This notebook transforms the embedded test SUT table into an IOT according to any of the embedded transformation models (A, B, C, D).
Core method#
The relevant entry point is Database.to_iot.
[1]:
import mario
db_sut = mario.load_test("SUT")
INFO Parser: excel reading SUT flows from /Users/lorenzorinaldi/Documents/GitHub/MARIO/mario/test/tables/test_SUT_standard.xlsx.
INFO Parser: state payload ready with 10 canonical blocks.
INFO Parser: excel state ready for SUT.
INFO Metadata: initialized.
Inspect the starting SUT#
[2]:
db_sut.table_type
[2]:
'SUT'
[3]:
db_sut.get_index("all")
[3]:
{'Activity': ['Manufacturing', 'Services'],
'Commodity': ['Goods', 'Services'],
'Factor of production': ['Taxes', 'Wages', 'Capital'],
'Satellite account': ['Employment', 'CO2'],
'Consumption category': ['Final demand'],
'Region': ['Region 1', 'Region 2']}
Transform to IOT#
[4]:
db_iot = db_sut.to_iot(
method="A", # method can be "A", "B", "C" or "D" according to documentation
inplace=False
)
db_iot.table_type
INFO Database: Transforming the database from SUT to IOT via method A
INFO Resolver: resolving Z for baseline.
INFO Resolver: trying Z via concat.
INFO Resolver: resolved Z via concat.
INFO Resolver: resolving V for baseline.
INFO Resolver: trying V via concat.
INFO Resolver: resolved V via concat.
INFO Resolver: resolving E for baseline.
INFO Resolver: trying E via concat.
INFO Resolver: resolved E via concat.
INFO Resolver: resolving X for baseline.
INFO Resolver: trying X via concat.
INFO Resolver: resolved X via concat.
INFO Resolver: resolving Y for baseline.
INFO Resolver: trying Y via concat.
INFO Resolver: resolved Y via concat.
WARNING baseline deleted from the database
INFO Transformation of the database from SUT to IOT via method A
[4]:
'IOT'
Inspect the resulting IOT compared with previous SUT#
This is a structural transformation, not a local matrix edit. After the operation:
the table type becomes
IOTthe baseline matrices are rebuilt accordingly
non-baseline scenarios are discarded
[5]:
db_iot.table_type
[5]:
'IOT'
[6]:
db_iot.get_index("all")
[6]:
{'Factor of production': ['Taxes', 'Wages', 'Capital'],
'Satellite account': ['Employment', 'CO2'],
'Consumption category': ['Final demand'],
'Region': ['Region 1', 'Region 2'],
'Sector': ['Goods', 'Services']}
[7]:
db_sut.Z
INFO Resolver: resolving Z for baseline.
INFO Resolver: trying Z via concat.
INFO Resolver: resolved Z via concat.
[7]:
| Region | Region 1 | Region 2 | Region 1 | Region 2 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Level | Activity | Activity | Commodity | Commodity | ||||||
| Item | Manufacturing | Services | Manufacturing | Services | Goods | Services | Goods | Services | ||
| Region | Level | Item | ||||||||
| Region 1 | Activity | Manufacturing | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 1.240653e+12 | 3.487923e+10 | 0.000000e+00 | 0.000000e+00 |
| Services | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 7.077650e+10 | 2.347886e+12 | 0.000000e+00 | 0.000000e+00 | ||
| Region 2 | Activity | Manufacturing | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 6.243698e+13 | 6.506942e+11 |
| Services | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 5.907938e+11 | 1.039044e+14 | ||
| Region 1 | Commodity | Goods | 3.334903e+11 | 1.657755e+11 | 1.487965e+11 | 6.895332e+10 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 |
| Services | 3.261811e+11 | 7.254021e+11 | 1.176727e+10 | 3.588505e+10 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | ||
| Region 2 | Commodity | Goods | 1.922623e+11 | 4.099986e+10 | 3.038628e+13 | 1.157115e+13 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 |
| Services | 2.614852e+10 | 5.823465e+10 | 1.154871e+13 | 3.075294e+13 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | ||
[8]:
db_iot.Z
[8]:
| Region | Region 1 | Region 2 | ||||
|---|---|---|---|---|---|---|
| Level | Sector | Sector | ||||
| Item | Goods | Services | Goods | Services | ||
| Region | Level | Item | ||||
| Region 1 | Sector | Goods | 3.502087e+11 | 1.490571e+11 | 1.497774e+11 | 6.797240e+10 |
| Services | 3.336807e+11 | 7.179024e+11 | 1.165245e+10 | 3.599987e+10 | ||
| Region 2 | Sector | Goods | 2.027584e+11 | 3.050372e+10 | 3.060247e+13 | 1.135496e+13 |
| Services | 2.674844e+10 | 5.763473e+10 | 1.146426e+13 | 3.083740e+13 | ||