Example #1
0
 def test_modify_mfd(self):
     mfd = ArbitraryMFD(magnitudes=(4., 5., 6.),
                        occurrence_rates=(1., 2., 3.))
     mfd.modify(
         "set_mfd",
         {"magnitudes": [7, 8, 9], "occurrence_rates": [0, 2, 1]})
     self.assertListEqual(mfd.magnitudes, [7, 8, 9])
     self.assertListEqual(mfd.occurrence_rates, [0, 2, 1])
Example #2
0
 def test_modify_mfd(self):
     mfd = ArbitraryMFD(magnitudes=(4., 5., 6.),
                        occurrence_rates=(1., 2., 3.))
     mfd.modify(
         "set_mfd",
         {"magnitudes": [7, 8, 9], "occurrence_rates": [0, 2, 1]})
     self.assertListEqual(mfd.magnitudes, [7, 8, 9])
     self.assertListEqual(mfd.occurrence_rates, [0, 2, 1])
 def test(self):
     sitecol = SiteCollection([Site(Point(-65.13490, 0.0),
                               vs30=760., z1pt0=48.0, z2pt5=0.607,
                               vs30measured=True)])
     mfd = ArbitraryMFD([6.0], [0.01604252])
     trace = Line([Point(-65.0000, -0.11240), Point(-65.000, 0.11240)])
     # 1.0 km Mesh Spacing
     mesh_spacing = 1.0
     msr = PeerMSR()
     sources = [SimpleFaultSource("001", "PEER Fault Set 2.5",
                                  "Active Shallow Crust", mfd,
                                  mesh_spacing,  msr, 2.0, PoissonTOM(1.0),
                                  0.0, 12., trace, 90., 0.)]
     imtls = {"PGA": [0.001, 0.01, 0.05, 0.1, 0.2, 0.4, 0.6, 0.8, 1.0,
                      1.25, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 7.0]}
     gmpe = ChiouYoungs2014PEER()
     gmpe.mixture_model = {"factors": [0.8, 1.2], "weights": [0.5, 0.5]}
     hcm = calc_hazard_curves(sources, sitecol, imtls,
                              {"Active Shallow Crust": gmpe})
     # Match against the benchmark is not exact - but differences in the
     # log space should be on the order of less than 0.04%
     expected = numpy.array([-4.140470001, -4.140913368, -4.259457496,
                             -4.724733842, -5.900747959, -7.734816415,
                             -9.019329629, -10.03864778, -10.90333404,
                             -11.83885783, -12.65826442, -14.05429951,
                             -15.22535996, -16.23988897, -17.94685518,
                             -19.36079032, -20.57460101, -21.64201335])
     expected = numpy.around(expected, 5)
     hcm_lnpga = numpy.around(numpy.log(hcm["PGA"].flatten()), 5)
     perc_diff = 100.0 * ((hcm_lnpga / expected) - 1.0)
     numpy.testing.assert_allclose(perc_diff, numpy.zeros(len(perc_diff)),
                                   atol=0.04)
Example #4
0
    def test_point_surface(self):

        sid = 0
        name = 'test'
        trt = TRT.ACTIVE_SHALLOW_CRUST
        mfd = ArbitraryMFD([7.0], [1.])
        rms = 2.5
        msr = WC1994()
        rar = 1.0
        tom = PoissonTOM(1.)
        usd = 0.0
        lsd = 20.0
        loc = Point(0.0, 0.0)
        npd = PMF([(1.0, NodalPlane(90., 90., 90.))])
        hyd = PMF([(1.0, 10.)])
        src = PointSource(sid, name, trt, mfd, rms, msr, rar, tom, usd, lsd,
                          loc, npd, hyd)
        rups = [r for r in src.iter_ruptures()]

        # Compute distances
        param = 'closest_point'
        sites = SiteCollection(
            [Site(Point(0.0, 0.0, 0.0)),
             Site(Point(-0.2, 0.0, 0.0))])
        dsts = get_distances(rups[0], sites, param)

        # Check first point
        msg = 'The longitude of the first point is wrong'
        self.assertTrue(abs(dsts[0, 0] - 0.0) < 1e-2, msg)
        msg = 'The latitude of the first point is wrong'
        self.assertTrue(abs(dsts[0, 1] - 0.0) < 1e-2, msg)

        # Check second point
        msg = 'The longitude of the second point is wrong'
        self.assertTrue(abs(dsts[1, 0] + 0.1666) < 1e-2, msg)
        msg = 'The latitude of the second point is wrong'
        self.assertTrue(abs(dsts[1, 1] - 0.0) < 1e-2, msg)
Example #5
0
 def test_get_min_max(self):
     mfd = ArbitraryMFD(magnitudes=[4, 5, 6], occurrence_rates=[1, 2, 3])
     self.assertEqual(mfd.get_min_max_mag(), (4, 6))
Example #6
0
 def test_get_annual_occurrence_rates(self):
     mfd = ArbitraryMFD(magnitudes=[4, 5, 6], occurrence_rates=[1, 2, 3])
     self.assertEqual(mfd.get_annual_occurrence_rates(), [(4, 1), (5, 2),
                                                          (6, 3)])
Example #7
0
 def test_get_min_max(self):
     mfd = ArbitraryMFD(magnitudes=[4, 5, 6], occurrence_rates=[1, 2, 3])
     self.assertEqual(mfd.get_min_max_mag(), (4, 6))
Example #8
0
 def test_get_annual_occurrence_rates(self):
     mfd = ArbitraryMFD(magnitudes=[4, 5, 6], occurrence_rates=[1, 2, 3])
     self.assertEqual(mfd.get_annual_occurrence_rates(),
                      [(4, 1), (5, 2), (6, 3)])