예제 #1
0
    def test_lrem_po_computation(self):
        hazard_curve = shapes.Curve([
              (0.01, 0.99), (0.08, 0.96),
              (0.17, 0.89), (0.26, 0.82),
              (0.36, 0.70), (0.55, 0.40),
              (0.70, 0.01)])

        # pre computed values just use one intermediate
        # values between the imls
        psha.STEPS_PER_INTERVAL = 2

        imls = [0.1, 0.2, 0.4, 0.6]
        loss_ratios = [0.05, 0.08, 0.2, 0.4]
        covs = [0.5, 0.3, 0.2, 0.1]
        vuln_function = shapes.VulnerabilityFunction(imls, loss_ratios, covs)

        lrem = psha._compute_lrem(vuln_function)

        lrem_po = psha._compute_lrem_po(vuln_function,
                lrem, hazard_curve)

        self.assertTrue(numpy.allclose(0.07, lrem_po[0][0], atol=0.005))
        self.assertTrue(numpy.allclose(0.06, lrem_po[1][0], atol=0.005))
        self.assertTrue(numpy.allclose(0.13, lrem_po[0][1], atol=0.005))
        self.assertTrue(numpy.allclose(0.47, lrem_po[5][3], atol=0.005))
        self.assertTrue(numpy.allclose(0.23, lrem_po[8][3], atol=0.005))
        self.assertTrue(numpy.allclose(0.00, lrem_po[10][0], atol=0.005))
예제 #2
0
    def test_lrem_po_computation(self):
        hazard_curve = shapes.Curve([
              (0.01, 0.99), (0.08, 0.96),
              (0.17, 0.89), (0.26, 0.82),
              (0.36, 0.70), (0.55, 0.40),
              (0.70, 0.01)])

        # pre computed values just use one intermediate
        # values between the imls
        psha.STEPS_PER_INTERVAL = 2

        vuln_function = shapes.VulnerabilityFunction([(0.1, (0.05, 0.5)),
              (0.2, (0.08, 0.3)), (0.4, (0.2, 0.2)), (0.6, (0.4, 0.1))])

        lrem = psha._compute_lrem(vuln_function)

        lrem_po = psha._compute_lrem_po(vuln_function,
                lrem, hazard_curve)

        self.assertTrue(numpy.allclose(0.07, lrem_po[0][0], atol=0.005))
        self.assertTrue(numpy.allclose(0.06, lrem_po[1][0], atol=0.005))
        self.assertTrue(numpy.allclose(0.13, lrem_po[0][1], atol=0.005))
        self.assertTrue(numpy.allclose(0.47, lrem_po[5][3], atol=0.005))
        self.assertTrue(numpy.allclose(0.23, lrem_po[8][3], atol=0.005))
        self.assertTrue(numpy.allclose(0.00, lrem_po[10][0], atol=0.005))
예제 #3
0
    def test_lrem_po_computation(self):
        lrem_po = psha._compute_lrem_po(shapes.Curve.from_json(
                self.vulnerability_curves[self.vuln_curve_code_test]), 
                LOSS_RATIO_EXCEEDANCE_MATRIX, HAZARD_CURVE)

        self.assertAlmostEquals(0.0959, lrem_po[0][0], 4)
        self.assertAlmostEquals(0.0367, lrem_po[1][0], 4)
        self.assertAlmostEquals(0.0849, lrem_po[0][1], 4)
        self.assertAlmostEquals(0.05049, lrem_po[1][1], 4)
        self.assertAlmostEquals(0.0673, lrem_po[0][2], 4)
        self.assertAlmostEquals(0.05718, lrem_po[1][2], 4)
예제 #4
0
 def test_empty_lrem_po(self):
     self.assertEqual([], psha._compute_lrem_po(
             shapes.EMPTY_CURVE, [], None))