hazimp.jobs.vulnerability_model
¶
Title: vulnerability_model.py
Author: Ben Cooper, ben.cooper@ga.gov.au
Description: TODO:
Copyright 2012 by Geoscience Australia
Module Contents¶
Classes¶
A set of vulnerability functions for a given intensity measure |
|
A vulnerability function defined by a specified set of points on a curve. |
|
Respresents a collection of vulnerability curves associated with an |
Functions¶
|
Load a GEM NRML vulnerability file in the format described in |
|
Load in the vulnerability sets from an xml node. |
|
As VulnerabilityFunction.sample may return values outside of a ratio, |
Attributes¶
- hazimp.jobs.vulnerability_model.LOGGER¶
- hazimp.jobs.vulnerability_model.DEFAULTLOSS = 0¶
- hazimp.jobs.vulnerability_model.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.
- hazimp.jobs.vulnerability_model.vuln_sets_from_xml_node(xml_node)¶
Load in the vulnerability sets from an xml node.
- Parameters:
vulnerability_models – Dictionary to store vulnerability models.
xml_node – The root node of the vulnerability xml file.
- Returns:
A dictionary of Vulnerability Sets.
- class hazimp.jobs.vulnerability_model.VulnerabilitySet(intensity_measure_level, intensity_measure_type, vulnerability_set_id, asset_category, loss_category, vulnerability_functions, default_loss)¶
Bases:
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
- __repr__(self)¶
Return repr(self).
- 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.
- 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.
- 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.
- Parameters:
func_id (str) – Then name of the vulnerability function set
mean (float) – Mean value of the selected vulnerability function
sigma (float) – the coefficient of variation of the selected vunlerability function
- hazimp.jobs.vulnerability_model.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.
- Parameters:
ratio (float) – the value to be tested.
- Returns:
1 if ratio > 1.0, 0 if ratio < 0.0, or the value of ratio otherwise.
- class hazimp.jobs.vulnerability_model.VulnerabilityFunction(func_id, mean_loss, coefficient_of_variation, distribution)¶
Bases:
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
- get_loss(self, variability_method=None)¶
Get the actual loss for a curve.
Currently this just returns a mean curve.
- Parameters:
variability_method – How the vulnerability function is sampled.
- Returns:
The loss y-axis values, sampled using the supplied 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
- classmethod from_xml_node(cls, xml_node)¶
Load in a vulnerability function from an xml node.
- Parameters:
xml_node – The root node of the vulnerability xml file.
- Returns:
A vulnerability function.
- class hazimp.jobs.vulnerability_model.RealisedVulnerabilityCurves(intensity_measure_type, loss_category_type, intensity_measure_level, loss_per_asset, vulnerability_set_id, default_loss)¶
Bases:
object
Respresents a collection of vulnerability curves associated with an exposure set.
There is one vulnerability curve per asset
- look_up(self, intensity)¶
Given an intensity use the curve to determine the loss ratio.
- Parameters:
intensity – An array intensity measures. Dimensions(asset, …)
- Returns:
A loss value. loss_category_type describes type of loss.