:py:mod:`hazimp.jobs.vulnerability_model` ========================================= .. py:module:: hazimp.jobs.vulnerability_model .. autoapi-nested-parse:: Title: vulnerability_model.py Author: Ben Cooper, ben.cooper@ga.gov.au Description: TODO: Copyright 2012 by Geoscience Australia Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: hazimp.jobs.vulnerability_model.VulnerabilitySet hazimp.jobs.vulnerability_model.VulnerabilityFunction hazimp.jobs.vulnerability_model.RealisedVulnerabilityCurves Functions ~~~~~~~~~ .. autoapisummary:: hazimp.jobs.vulnerability_model.vuln_sets_from_xml_file hazimp.jobs.vulnerability_model.vuln_sets_from_xml_node hazimp.jobs.vulnerability_model.ratio_cutoff Attributes ~~~~~~~~~~ .. autoapisummary:: hazimp.jobs.vulnerability_model.LOGGER hazimp.jobs.vulnerability_model.DEFAULTLOSS .. py:data:: LOGGER .. py:data:: DEFAULTLOSS :annotation: = 0 .. py:function:: vuln_sets_from_xml_file(filenames: list) -> dict Load a GEM NRML vulnerability file in the format described in resources/nrml/schema/risk/vulnerability.xsd Args: :param filenames: The names of the xml files. :returns: A dictionary of Vulnerability Sets. .. py:function:: vuln_sets_from_xml_node(xml_node) Load in the vulnerability sets from an xml node. :param vulnerability_models: Dictionary to store vulnerability models. :param xml_node: The root node of the vulnerability xml file. :returns: A dictionary of Vulnerability Sets. .. py:class:: VulnerabilitySet(intensity_measure_level, intensity_measure_type, vulnerability_set_id, asset_category, loss_category, vulnerability_functions, default_loss) Bases: :py:obj:`object` A set of vulnerability functions for a given intensity measure level. All vulnerability functions have the same intensity measure (x-axis) and loss category (y-axis). Each vulnerability function represents a class of assets, such as brick buildings etc. Methods: - calc_mean - return mean loss and sigma for the given function id - sample - return a sample for the given function id Constructor input: - intensity_measure_level - a set of points for the x axis of the mean loss curve (common to all functions) - intensity_measure_type - type of intensity measure that the intensity measure level specifies ('MMI' is the only supported value) - vulnerability_functions - a dictionary of VulnerabilityFunction objects where the function id is the key Class method: - from_xml - construct a Vulnerability_Set object from a NRML vulnerability file .. py:method:: __repr__(self) Return repr(self). .. py:method:: build_realised_vuln_curves(self, vulnerability_function_ids, variability_method=None) Given a list of vulnerability_function_IDs return the actual vulnerability curves, as a realised vulnerabitly curves instance. Currently this just returns a mean curve. :parmas vulnerability_function_IDs: A list of the vuln. functions. The list dimension is asset. :parmas variability_method: How the vulnerability function is sampled. :returns: A realised vulnerabitly curves instance. Use this to calc the loss ratio. .. py:method:: calc_mean(self, func_id, intensity) A wrapper for `VulnerabilityFunction.calc_mean`. Lookup the specified vulnerability function in the set and run `calc_mean` for that function. .. py:method:: sample(self, func_id, mean, sigma) A wrapper for VulnerabilityFunction.sample. Lookup the specified vulnerability function in the set and run sample for that function. :param str func_id: Then name of the vulnerability function set :param float mean: Mean value of the selected vulnerability function :param float sigma: the coefficient of variation of the selected vunlerability function .. py:function:: ratio_cutoff(ratio) As VulnerabilityFunction.sample may return values outside of a ratio, ensure that the given ratio array is between 0 and 1 by setting values outside these bounds to the bounds. :param float ratio: the value to be tested. :returns: 1 if ratio > 1.0, 0 if ratio < 0.0, or the value of ratio otherwise. .. py:class:: VulnerabilityFunction(func_id, mean_loss, coefficient_of_variation, distribution) Bases: :py:obj:`object` A vulnerability function defined by a specified set of points on a curve. Methods: calc_mean - return mean loss and sigma based on the given set of points sample - return a sample based on the specified probabilistic distribution .. py:method:: get_loss(self, variability_method=None) Get the actual loss for a curve. Currently this just returns a mean curve. :param variability_method: How the vulnerability function is sampled. :returns: The loss y-axis values, sampled using the supplied method. .. py:method:: calc_mean(self, intensity) Calculate mean loss ratio and sigma based on the specified points on the curve: | | + | + Mean loss ratio | + | + | + | + | + | + | + | + | + +----------------------------------- Intensity measure level For a given intensity, mean loss and sigma is determined by linearly interpolating the points on the curve. Note that sigma is calculated as cv * mean loss as cv = mean loss/sigma .. py:method:: from_xml_node(cls, xml_node) :classmethod: Load in a vulnerability function from an xml node. :param xml_node: The root node of the vulnerability xml file. :returns: A vulnerability function. .. py:class:: RealisedVulnerabilityCurves(intensity_measure_type, loss_category_type, intensity_measure_level, loss_per_asset, vulnerability_set_id, default_loss) Bases: :py:obj:`object` Respresents a collection of vulnerability curves associated with an exposure set. There is one vulnerability curve per asset .. py:method:: look_up(self, intensity) Given an intensity use the curve to determine the loss ratio. :param intensity: An array intensity measures. Dimensions(asset, ...) :return: A loss value. loss_category_type describes type of loss.