def _convert_pes_to_pos(hazard_curve, imls): """For each IML (Intensity Measure Level) compute the PoOs (Probability of Occurence) from the PoEs (Probability of Exceendance) defined in the given hazard curve. :param hazard_curve: the hazard curve used to compute the PoOs. :type hazard_curve: :py:class:`openquake.shapes.Curve` :param imls: the IMLs (Intensity Measure Level) of the vulnerability function used to interpolate the hazard curve. :type imls: :py:class:`list` """ return collect(loop(_compute_pes_from_imls(hazard_curve, imls), lambda x, y: subtract(array(x), array(y))))
def _convert_pes_to_pos(hazard_curve, imls): """For each IML (Intensity Measure Level) compute the PoOs (Probability of Occurence) from the PoEs (Probability of Exceendance) defined in the given hazard curve. :param hazard_curve: the hazard curve used to compute the PoOs. :type hazard_curve: :py:class:`openquake.shapes.Curve` :param imls: the IMLs (Intensity Measure Level) of the vulnerability function used to interpolate the hazard curve. :type imls: :py:class:`list` """ return collect( loop(_compute_pes_from_imls(hazard_curve, imls), lambda x, y: subtract(array(x), array(y))))
def _compute_imls(vuln_function): """Compute the mean IMLs (Intensity Measure Level) for the given vulnerability function. :param vuln_function: the vulnerability function where the IMLs (Intensity Measure Level) are taken from. :type vuln_function: :py:class:`openquake.shapes.VulnerabilityFunction` """ imls = vuln_function.imls # "special" cases for lowest part and highest part of the curve lowest_iml_value = imls[0] - ((imls[1] - imls[0]) / 2) # if the calculated lowest_curve_value goes < 0 we have to force the 0 # IMLs have to be >= 0 if lowest_iml_value < 0: lowest_iml_value = 0 highest_iml_value = imls[-1] + ((imls[-1] - imls[-2]) / 2) between_iml_values = collect(loop(imls, lambda x, y: mean([x, y]))) return [lowest_iml_value] + between_iml_values + [highest_iml_value]