Apply shocks and compare scenarios
Create an alternative scenario from specified changes to a baseline.
Baseline → Specified changes → Alternative → Comparison
Use a filled shock workbook#
The packaged example changes technical and satellite coefficients in the test IOT.
Download the filled workbook
and save it beside your script.
import mario
db = mario.load_test("IOT")
db.shock_calc(
io="shock_IOT_filled.xlsx", z=True, e=True,
scenario="alternative",
)
change = db.query(
"z", scenarios="alternative",
base_scenario="baseline", type="relative",
)
Result · A new scenario and a DataFrame of relative changes against the baseline. Inspect both the changed inputs and the resulting outputs.
Prepare your own workbook#
db.get_shock_excel(path="my_shocks.xlsx")
Fill the relevant sheets, then enable those blocks in shock_calc().
For a SUT, generate the template from that SUT to obtain its activity and
commodity labels.
Plot the result
fig = db.plot(
matrix="Z", scenarios=["alternative"],
base_scenario="baseline", difference="relative",
preset="heatmap", auto_open=False, path=False,
)
fig.show()
Chain changes or edit inputs programmatically
shock_calc(..., base_scenario="alternative", scenario="step 2")
applies a second change to an existing scenario. The
API reference describes
selectors and coefficient changes.
If you edit matrices directly, reset stale calculated quantities before recalculating. Follow the complete code and reset sequence in the companion notebook; editing an input does not make cached results valid automatically.
For generation or trade shares, use Update electricity mixes.