Esempio n. 1
0
def _convert_pes_to_pos(hazard_curve, imls):
    """
        For each IML (Intensity Measure Level) given compute the
        PoOs (Probability of Occurence) from the PoEs
        (Probability of Exceendance) defined in the given hazard curve.
    """
    return collect(loop(_compute_pes_from_imls(hazard_curve, imls),
        lambda x, y: subtract(array(x), array(y))))
def _generate_curve(losses, probs_of_exceedance):
    """Generate a loss ratio (or loss) curve, given a set of losses
    and corresponding PoEs (Probabilities of Exceedance).

    This function is intended to be used internally.
    """

    mean_losses = collect(loop(losses, lambda x, y: mean([x, y])))
    return shapes.Curve(zip(mean_losses, probs_of_exceedance))
Esempio n. 3
0
def _convert_pes_to_pos(hazard_curve, imls):
    """
        For each IML (Intensity Measure Level) given compute the
        PoOs (Probability of Occurence) from the PoEs
        (Probability of Exceendance) defined in the given hazard curve.
    """
    return collect(
        loop(_compute_pes_from_imls(hazard_curve, imls),
             lambda x, y: subtract(array(x), array(y))))
def _compute_imls(vuln_function):
    """
        Computes Intensity Measure Levels considering
        the highest/lowest values a special case
    """

    imls = vuln_function.imls

    # "special" cases for lowest part and highest part of the curve
    lowest_curve_value = imls[0] - ((imls[1] - imls[0]) / 2)
    highest_curve_value = imls[-1] + ((imls[-1] - imls[-2]) / 2)

    between_curve_values = collect(loop(imls, lambda x, y: mean([x, y])))
    
    return [lowest_curve_value] + between_curve_values + [highest_curve_value]
Esempio n. 5
0
def _compute_imls(vuln_function):
    """
        Compute the mean IMLs (Intensity Measure Level)
        for the given vulnerability function.
    """

    imls = vuln_function.imls

    # "special" cases for lowest part and highest part of the curve
    lowest_curve_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_curve_value < 0:
        lowest_curve_value = 0

    highest_curve_value = imls[-1] + ((imls[-1] - imls[-2]) / 2)

    between_curve_values = collect(loop(imls, lambda x, y: mean([x, y])))

    return [lowest_curve_value] + between_curve_values + [highest_curve_value]
Esempio n. 6
0
def _compute_imls(vuln_function):
    """
        Compute the mean IMLs (Intensity Measure Level)
        for the given vulnerability function.
    """

    imls = vuln_function.imls

    # "special" cases for lowest part and highest part of the curve
    lowest_curve_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_curve_value < 0:
        lowest_curve_value = 0

    highest_curve_value = imls[-1] + ((imls[-1] - imls[-2]) / 2)

    between_curve_values = collect(loop(imls, lambda x, y: mean([x, y])))

    return [lowest_curve_value] + between_curve_values + [highest_curve_value]
def _convert_pes_to_pos(hazard_curve, imls):
    """
        Computes the probability occurences from the probability exceedances
    """
    return collect(loop(_compute_pes_from_imls(hazard_curve, imls), 
        lambda x, y: subtract(array(x), array(y))))