9.11. Storey Loss Functions

plotter.plot_slf_model(out, cache, edp_label, loss_label, xlims, ylims, title=None, pFlag=True, export_path=None)[source]

Generate a plot to visualize the Storey Loss Function (SLF) model output.

Visualises, for every performance-group key shared by out and cache (overlaid on the same axes if more than one key is present – e.g. to compare two slfgenerator runs side by side):

  1. A scatter cloud of the per-realization storey loss RATIO (cache[key]['total_loss_storey_ratio']) vs. EDP.

  2. A shaded band spanning the empirical 16th-84th percentile of the loss ratio (out[key]['slf_16th'] / out[key]['slf_84th']).

  3. The empirical median loss-ratio curve (out[key]['slf']) – this IS the Storey Loss Function; no fitted/regression curve is plotted, since slfgenerator.generate() no longer fits one.

All three are expressed as loss RATIO (loss / replacement cost), the conventional, dimensionless definition of a Storey Loss Function, so the scatter, band, and median line share consistent units on a single set of axes.

The figure uses self.figsize with constrained_layout and is saved without bbox_inches='tight' so that every output image has identical, deterministic pixel dimensions.

Parameters:
  • out (dict) – {group_key: slf_dict} as returned by openquake.vmtk.slfgenerator.slfgenerator.generate(). Each slf_dict must provide 'edp_range', 'slf_16th', 'slf' (median), and 'slf_84th' (all loss-ratio values). Pass a dict with more than one key (e.g. {'Example A': out_a[...], 'Example B': out_b[...]}) to overlay several SLF results on one figure.

  • cache (dict) – {group_key: cache_dict} as returned by openquake.vmtk.slfgenerator.slfgenerator.generate(). Each cache_dict must provide 'total_loss_storey_ratio' ({realization: array}).

  • edp_label (str) – Label for the x-axis (Engineering Demand Parameter).

  • loss_label (str) – Label for the y-axis. Typically 'Storey Loss Ratio [-]'.

  • xlims (tuple of float) – (min, max) limits for the X-axis (EDP axis).

  • ylims (tuple of float) – (min, max) limits for the Y-axis (loss-ratio axis).

  • title (str, optional) – Custom plot title.

  • pFlag (bool, optional) – If True the plot is displayed or saved. Default is True.

  • export_path (str, optional) – Full path including filename to save the plot. Directories are created if missing.

Return type:

None

Example

from openquake.vmtk.plotter import plotter

pl = plotter()
# out, cache from slfgenerator.generate()
pl.plot_slf_model(
    out=out,
    cache=cache,
    edp_label="Interstorey Drift Ratio [-]",
    loss_label="Storey Loss Ratio [-]",
    xlims=[0, 0.05],
    ylims=[0, 1],
    export_path="slf_model.png",
)