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
outandcache(overlaid on the same axes if more than one key is present – e.g. to compare twoslfgeneratorruns side by side):A scatter cloud of the per-realization storey loss RATIO (
cache[key]['total_loss_storey_ratio']) vs. EDP.A shaded band spanning the empirical 16th-84th percentile of the loss ratio (
out[key]['slf_16th']/out[key]['slf_84th']).The empirical median loss-ratio curve (
out[key]['slf']) – this IS the Storey Loss Function; no fitted/regression curve is plotted, sinceslfgenerator.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.figsizewithconstrained_layoutand is saved withoutbbox_inches='tight'so that every output image has identical, deterministic pixel dimensions.- Parameters:
out (dict) –
{group_key: slf_dict}as returned byopenquake.vmtk.slfgenerator.slfgenerator.generate(). Eachslf_dictmust 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 byopenquake.vmtk.slfgenerator.slfgenerator.generate(). Eachcache_dictmust 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
Truethe plot is displayed or saved. Default isTrue.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",
)