mario.Database.calc_spa#

db.calc_spa(...) runs a first demand-driven structural path analysis for one indicator, one scenario, and one selected bundle of final demand.

The method is currently available only for IOT tables. It combines the direct coefficient row for indicator with the z coefficient matrix and the selected columns of Y to enumerate ordered upstream paths up to a chosen depth.

Use item to focus the final-demand bundle on one sector, and final_demand_region or final_demand_category to keep only the relevant final-demand columns. The output is a dataframe sorted by absolute contribution and includes path shares relative to the full footprint of the selected bundle.

Like db.calc_trades(...), db.calc_spa(...) can also render one built-in plot with show_plot=True and export it with save_plot=... or path=.... Use plot="paths" for the default horizontal bar chart of the reported paths, plot="sankey" for a network-style view of the same ranked paths, or plot="depth" for an integrated summary of the footprint by upstream depth.

Database.calc_spa(indicator, scenario='baseline', item=None, final_demand_region=None, final_demand_category=None, max_depth=5, cutoff=0.0, top_n=200, plot='paths', show_plot=False, save_plot=None, path=False, auto_open=False, title=None)#

Run a first structural path analysis on one IOT scenario.

This v1 implementation is currently limited to IOT databases. It expands the demand-driven footprint identity into ordered supply-chain paths using the direct coefficient row for indicator, the z coefficient matrix, and one selected final-demand bundle from Y.

Parameters:
  • indicator – Satellite-account row, factor-of-production row, or "total value added".

  • scenario – Scenario to analyse. v1 accepts one scenario at a time.

  • item – Optional sector selector applied to the rows of Y. When omitted, MARIO requires homogeneous sector units.

  • final_demand_region – Optional Region label or labels used to filter the final-demand columns of Y.

  • final_demand_category – Optional final-demand category label or labels used to filter the final-demand columns of Y.

  • max_depth – Maximum number of upstream z rounds included in the reported paths. 0 keeps only direct final-demand paths.

  • cutoff – Minimum absolute contribution required for one path to be kept and expanded.

  • top_n – Optional cap on the number of returned paths after sorting by the absolute contribution magnitude. Pass None to keep all paths.

  • plot – Integrated plotting mode used when show_plot=True or when save_plot/path request output. Use "paths" for the default ranked-path view, "sankey" for a network-style view of the reported paths, or "depth" for a depth summary.

  • show_plot – When True, build and display the selected integrated SPA plot.

  • save_plot – Optional output path for the SPA plot. When provided, MARIO writes the plot to this path.

  • path – Backward-compatible alias for save_plot. Ignored when neither show_plot nor save_plot are requested.

  • auto_open – When True, automatically open the saved plot.

  • title – Optional title for the SPA plot. When omitted, MARIO uses a title based on the selected item and indicator.

Returns:

One path table sorted by absolute contribution. The dataframe keeps path metadata in columns and summary metadata in .attrs.

Return type:

pandas.DataFrame