예제 #1
0
 def test_instantiation(self):
     """ Tests the instantiation """
     mgmpe = NRCan15SiteTerm(gmpe_name='BooreEtAl2014')
     #
     # Check the assigned IMTs
     expected = set([PGA, SA, PGV])
     self.assertTrue(mgmpe.DEFINED_FOR_INTENSITY_MEASURE_TYPES == expected,
                     msg='The assigned IMTs are incorrect')
     # Check the TR
     expected = TRT.ACTIVE_SHALLOW_CRUST
     self.assertTrue(mgmpe.DEFINED_FOR_TECTONIC_REGION_TYPE == expected,
                     msg='The assigned TRT is incorrect')
     # Check the IM component
     expected = IMC.RotD50
     self.assertTrue(
         mgmpe.DEFINED_FOR_INTENSITY_MEASURE_COMPONENT == expected,
         msg='The IM component is wrong')
     # Check the standard deviations
     expected = set(['Intra event', 'Total', 'Inter event'])
     self.assertTrue(mgmpe.DEFINED_FOR_STANDARD_DEVIATION_TYPES == expected,
                     msg='The standard deviations assigned are wrong')
     # Check the required distances
     expected = set(['rjb'])
     self.assertTrue(mgmpe.REQUIRES_DISTANCES == expected,
                     msg='The assigned distance types are wrong')
예제 #2
0
 def test_gm_calculationAB06(self):
     # Modified gmpe
     mgmpe = NRCan15SiteTerm(gmpe_name='AtkinsonBoore2006')
     ctx = self.ctx(4, [1000., 1500., 1000., 1500.])
     ctx.rrup = np.array([10., 10., 40., 40.])
     imt = PGA()
     stdt = [const.StdDev.TOTAL]
     # Computes results
     mean, stds = mgmpe.get_mean_and_stddevs(ctx, ctx, ctx, imt, stdt)
     # Compute the expected results
     gmpe = AtkinsonBoore2006()
     mean_expected, stds_expected = gmpe.get_mean_and_stddevs(
         ctx, ctx, ctx, imt, stdt)
     # Test that for reference soil conditions the modified GMPE gives the
     # same results of the original gmpe
     np.testing.assert_almost_equal(mean, mean_expected)
     np.testing.assert_almost_equal(stds, stds_expected)
예제 #3
0
 def test_gm_calculationBA08_vs30variable(self):
     # Modified gmpe
     mgmpe = NRCan15SiteTerm(gmpe_name='BooreAtkinson2008')
     # Set parameters
     ctx = self.ctx(3, vs30=[400., 600, 1000])
     ctx.rjb = np.array([10., 10., 10.])
     imt = PGA()
     stdt = [const.StdDev.TOTAL]
     # Computes results
     mean, stds = mgmpe.get_mean_and_stddevs(ctx, ctx, ctx, imt, stdt)
     # Compute the expected results
     gmpe = BooreAtkinson2008()
     mean_expected, stds_expected = gmpe.get_mean_and_stddevs(
         ctx, ctx, ctx, imt, stdt)
     # Test that for reference soil conditions the modified GMPE gives the
     # same results of the original gmpe
     np.testing.assert_almost_equal(mean[:-1], mean_expected[:-1])
     np.testing.assert_almost_equal(stds[:-1], stds_expected[:-1])
예제 #4
0
    def test_instantiation(self):
        mgmpe = NRCan15SiteTerm(gmpe_name='BooreEtAl2014')

        # Check the assigned IMTs
        expected = {PGA, SA, PGV}
        self.assertTrue(mgmpe.DEFINED_FOR_INTENSITY_MEASURE_TYPES == expected,
                        msg='The assigned IMTs are incorrect')
        # Check the TR
        expected = TRT.ACTIVE_SHALLOW_CRUST
        self.assertTrue(mgmpe.DEFINED_FOR_TECTONIC_REGION_TYPE == expected,
                        msg='The assigned TRT is incorrect')
        # Check the IM component
        expected = IMC.RotD50
        self.assertTrue(
            mgmpe.DEFINED_FOR_INTENSITY_MEASURE_COMPONENT == expected,
            msg='The IM component is wrong')
        # Check the required distances
        expected = {'rjb'}
        self.assertTrue(mgmpe.REQUIRES_DISTANCES == expected,
                        msg='The assigned distance types are wrong')
예제 #5
0
 def test_gm_calculationAB06_hard_bedrock(self):
     """ Test mean and std calculation - AB06 on vs30 hard bedrock"""
     # Modified gmpe
     mgmpe = NRCan15SiteTerm(gmpe_name='AtkinsonBoore2006')
     # Set parameters
     sites = Dummy.get_site_collection(4, vs30=1999.0)
     rup = Dummy.get_rupture(mag=6.0)
     dists = DistancesContext()
     dists.rrup = np.array([10., 20., 30., 40.])
     imt = PGA()
     stdt = [const.StdDev.TOTAL]
     # Computes results
     mean, stds = mgmpe.get_mean_and_stddevs(sites, rup, dists, imt, stdt)
     # Compute the expected results
     gmpe = AtkinsonBoore2006()
     mean_expected, stds_expected = gmpe.get_mean_and_stddevs(
         sites, rup, dists, imt, stdt)
     # Test that for reference soil conditions the modified GMPE gives the
     # same results of the original gmpe
     np.testing.assert_almost_equal(mean, mean_expected)
     np.testing.assert_almost_equal(stds, stds_expected)
예제 #6
0
 def test_gm_calculationBA08_vs30variable(self):
     """ Test mean and std calculation - BA08 - Vs30 variable"""
     # Modified gmpe
     mgmpe = NRCan15SiteTerm(gmpe_name='BooreAtkinson2008')
     # Set parameters
     sites = Dummy.get_site_collection(3, vs30=[400., 600, 1000])
     rup = Dummy.get_rupture(mag=6.0)
     dists = DistancesContext()
     dists.rjb = np.array([10., 10., 10.])
     imt = PGA()
     stdt = [const.StdDev.TOTAL]
     # Computes results
     mean, stds = mgmpe.get_mean_and_stddevs(sites, rup, dists, imt, stdt)
     # Compute the expected results
     gmpe = BooreAtkinson2008()
     mean_expected, stds_expected = gmpe.get_mean_and_stddevs(
         sites, rup, dists, imt, stdt)
     # Test that for reference soil conditions the modified GMPE gives the
     # same results of the original gmpe
     np.testing.assert_almost_equal(mean[:-1], mean_expected[:-1])
     np.testing.assert_almost_equal(stds[:-1], stds_expected[:-1])
예제 #7
0
 def test_set_vs30_attribute(self):
     mgmpe = NRCan15SiteTerm(gmpe_name='Campbell2003SHARE')
     msg = '{:s} does not have vs30 in the required site parameters'
     self.assertTrue('vs30' in mgmpe.REQUIRES_SITES_PARAMETERS, msg=msg)
예제 #8
0
 def test_raise_error(self):
     """ Tests that exception is raised """
     with self.assertRaises(AttributeError):
         mgmpe = NRCan15SiteTerm(gmpe_name='FukushimaTanaka1990')
예제 #9
0
 def test_raise_error(self):
     with self.assertRaises(AttributeError):
         NRCan15SiteTerm(gmpe_name='FukushimaTanaka1990')