Add extensions#
This notebook adds one satellite account row to the packaged IOT test table using an Excel extension workbook.
[ ]:
import mario
[2]:
db = mario.load_test("IOT")
INFO Parser: excel reading IOT flows from /Users/lorenzorinaldi/Documents/GitHub/MARIO/mario/test/tables/test_IOT_standard.xlsx.
INFO Parser: state payload ready with 6 canonical blocks.
INFO Parser: excel state ready for IOT.
INFO Metadata: initialized.
Generate an empty extension template#
[ ]:
db.get_extensions_excel(
path="/path/to/add_extensions_template.xlsx",
matrix="E",
)
Prepare the unit for the new row#
add_extensions reads the numeric row from Excel and receives the unit table separately.
[4]:
new_units = db.units["Satellite account"].iloc[:1].copy()
new_units.index = ["CH4"]
new_units.loc["CH4", "unit"] = "kg"
new_units
[4]:
| unit | |
|---|---|
| CH4 | kg |
Download the packaged example workbooks#
The exact workbooks used in this example are available here:
[ ]:
extended_db = db.add_extensions(
io="/path/to/add_extensions_filled.xlsx",
matrix="E",
units=new_units,
inplace=False,
)
extended_db.get_index("Satellite account")
INFO Resolver: resolving v for baseline.
INFO Resolver: trying v via formula build_iot_v_from_V_X.
INFO Resolver: resolved v via formula build_iot_v_from_V_X.
WARNING Using add extensions will rewrite the new results on the baseline and delete other scenarios
WARNING baseline deleted from the database
INFO Resolver: resolving z for baseline.
INFO Resolver: trying z via formula build_iot_z_from_Z_X.
INFO Resolver: resolved z via formula build_iot_z_from_Z_X.
INFO Resolver: resolving e for baseline.
INFO Resolver: trying e via formula build_iot_e_from_E_X.
INFO Resolver: resolved e via formula build_iot_e_from_E_X.
['Employment', 'CO2', 'CH4']
Inspect the new extension row#
[6]:
extended_db.E.loc[["CH4"]]
[6]:
| Region | Reg1 | Reg2 | ||||
|---|---|---|---|---|---|---|
| Level | Sector | Sector | ||||
| Item | Agriculture | Industry | Services | Agriculture | Industry | Services |
| CH4 | 1.0 | 2.0 | 3.0 | 4.0 | 5.0 | 6.0 |