Пример #1
0
    def test_gm_calculation_hard_rock(self):
        """ Test mean and std calculation - on hard rock using AB06"""
        # Modified gmpe
        mgmpe = NRCan15SiteTermLinear(gmpe_name='AtkinsonBoore2006')
        # Set parameters
        sites = Dummy.get_site_collection(2, vs30=[760, 2010])
        rup = Dummy.get_rupture(mag=7.0)
        dists = DistancesContext()
        dists.rrup = np.array([15., 15.])
        stdt = [const.StdDev.TOTAL]
        gmpe = AtkinsonBoore2006()

        for imt in [PGA(), SA(1.0), SA(5.0)]:
            #
            # Computes results
            mean, stds = mgmpe.get_mean_and_stddevs(sites, rup, dists, imt,
                                                    stdt)
            # Compute the expected results
            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_allclose(np.exp(mean),
                                       np.exp(mean_expected),
                                       rtol=1.0e-1)
            np.testing.assert_allclose(stds, stds_expected)
Пример #2
0
    def test_gm_calculation_soil_reference(self):
        """ Test mean and std calculation - CY14 on reference rock"""

        # Modified gmpe
        mgmpe = CY14SiteTerm(gmpe_name='ChiouYoungs2014')

        # Set parameters
        sites = Dummy.get_site_collection(4,
                                          vs30=1130.,
                                          vs30measured=True,
                                          z1pt0=0.)
        rup = Dummy.get_rupture(mag=6.0)
        rup.dip = 90.
        rup.ztor = 0.
        dists = DistancesContext()
        dists.rrup = np.array([1., 10., 30., 70.])
        dists.rx = np.array([1., 10., 30., 70.])
        dists.rjb = np.array([1., 10., 30., 70.])
        imt = PGA()
        stdt = [const.StdDev.TOTAL]

        # Compute results
        mean, stds = mgmpe.get_mean_and_stddevs(sites, rup, dists, imt, stdt)

        # Compute the expected results
        gmpe = ChiouYoungs2014()
        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)
    def test_gm_calculation_hard_rock(self):
        """ Test mean and std calculation - on hard rock using AB06"""
        # Modified gmpe
        mgmpe = NRCan15SiteTermLinear(gmpe_name='AtkinsonBoore2006')
        # Set parameters
        sites = Dummy.get_site_collection(2, vs30=[760, 2010])
        rup = Dummy.get_rupture(mag=7.0)
        dists = DistancesContext()
        dists.rrup = np.array([15., 15.])
        stdt = [const.StdDev.TOTAL]
        gmpe = AtkinsonBoore2006()

        for imt in [PGA(), SA(1.0), SA(5.0)]:
            #
            # Computes results
            mean, stds = mgmpe.get_mean_and_stddevs(sites, rup, dists, imt,
                                                    stdt)
            # Compute the expected results
            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_allclose(np.exp(mean), np.exp(mean_expected),
                                 rtol=1.0e-1)
            np.testing.assert_allclose(stds, stds_expected)
Пример #4
0
    def test02(self):
        # checks if gmpe is always being evaluated at vs30=760
        # see HID 2.6.2
        filename = os.path.join(DATA_PATH, 'kappa.txt')
        gmm = AlAtikSigmaModel(gmpe_name='YenierAtkinson2015ACME2019',
                               kappa_file=filename,
                               kappa_val='high')
        sites = Dummy.get_site_collection(4, vs30=760.)
        rup = Dummy.get_rupture(mag=6.0)
        dists = DistancesContext()
        dists.rjb = np.array([1., 10., 30., 70.])
        dists.rrup = np.array([1., 10., 30., 70.])
        imt = SA(0.1)
        stdt = [const.StdDev.TOTAL]
        mean_760, _ = gmm.get_mean_and_stddevs(sites, rup, dists, imt, stdt)

        sites2 = Dummy.get_site_collection(4, vs30=1500.)
        mean_1500, _ = gmm.get_mean_and_stddevs(sites2, rup, dists, imt, stdt)

        self.assertAlmostEqual(mean_760[-1], mean_1500[-1], 4)
Пример #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)
 def _get_stds(self, within_absolute=None, between_absolute=None):
     if within_absolute is not None:
         gmm = SplitSigmaGMPE(gmpe_name='Campbell2003',
                              within_absolute=within_absolute)
     elif between_absolute is not None:
         gmm = SplitSigmaGMPE(gmpe_name='Campbell2003',
                              between_absolute=between_absolute)
     else:
         raise ValueError('Unknown option')
     # Set parameters
     sites = Dummy.get_site_collection(4, vs30=760.)
     rup = Dummy.get_rupture(mag=6.0)
     dists = DistancesContext()
     dists.rrup = np.array([1., 10., 30., 70.])
     imt = PGA()
     stds_types = [const.StdDev.TOTAL, const.StdDev.INTER_EVENT,
                   const.StdDev.INTRA_EVENT]
     # Compute results
     mean, stds = gmm.get_mean_and_stddevs(sites, rup, dists, imt,
                                           stds_types)
     return stds, stds_types
Пример #7
0
    def test01(self):
        avg_periods = [0.05, 0.15, 1.0, 2.0, 4.0]
        gmm = gsim.mgmpe.generic_gmpe_avgsa.GenericGmpeAvgSA(
            gmpe_name='ZhaoEtAl2006Asc',
            avg_periods=avg_periods,
            corr_func='akkar')
        msg = 'The class name is incorrect'
        self.assertTrue(gmm.__class__.__name__ == 'GenericGmpeAvgSA', msg=msg)

        sites = Dummy.get_site_collection(4, vs30=760.)
        rup = Dummy.get_rupture(mag=6.0)
        rup.hypo_depth = 10.
        dists = DistancesContext()
        dists.rrup = np.array([1., 10., 30., 70.])
        imtype = PGA()
        stdt = [const.StdDev.TOTAL]
        # Computes results
        mean, _ = gmm.get_mean_and_stddevs(sites, rup, dists, imtype, stdt)
        expected = np.array(
            [-1.33735637, -2.62649473, -3.64500654, -4.60067093])
        np.testing.assert_almost_equal(mean, expected)
 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)
Пример #9
0
    def setUp(self):

        # Set parameters - Setting z1pt0 does not make sense but here we
        # want to make sure that the modified gmm provided GM amplified
        # by the site term exactly as the original model.
        sites = Dummy.get_site_collection(4,
                                          vs30=400.,
                                          vs30measured=True,
                                          z1pt0=0.)
        rup = Dummy.get_rupture(mag=6.0)
        rup.dip = 90.
        rup.ztor = 0.
        dists = DistancesContext()
        dists.rrup = np.array([1., 10., 30., 70.])
        dists.rx = np.array([1., 10., 30., 70.])
        dists.rjb = np.array([1., 10., 30., 70.])
        stdt = [const.StdDev.TOTAL]

        self.rup = rup
        self.dists = dists
        self.stdt = stdt
        self.sites = sites
Пример #10
0
 def _get_stds(self, within_absolute=None, between_absolute=None):
     if within_absolute is not None:
         gmm = SplitSigmaGMPE(gmpe_name='Campbell2003',
                              within_absolute=within_absolute)
     elif between_absolute is not None:
         gmm = SplitSigmaGMPE(gmpe_name='Campbell2003',
                              between_absolute=between_absolute)
     else:
         raise ValueError('Unknown option')
     # Set parameters
     sites = Dummy.get_site_collection(4, vs30=760.)
     rup = Dummy.get_rupture(mag=6.0)
     dists = DistancesContext()
     dists.rrup = np.array([1., 10., 30., 70.])
     imt = PGA()
     stds_types = [
         const.StdDev.TOTAL, const.StdDev.INTER_EVENT,
         const.StdDev.INTRA_EVENT
     ]
     # Compute results
     mean, stds = gmm.get_mean_and_stddevs(sites, rup, dists, imt,
                                           stds_types)
     return stds, stds_types
Пример #11
0
    def extrapolate_in_PSA(self, sites, rup, dists, imt_high, set_imt,
                           stds_types, imt):

        extrap_mean = []
        t_log10 = np.log10([im for im in set_imt])
        for d in np.arange(0, len(dists.rjb)):
            dist = DistancesContext()
            if hasattr(dists, 'rjb'):
                dist.rjb = np.array([dists.rjb[d]])
            if hasattr(dists, 'rrup'):
                dist.rrup = np.array([dists.rrup[d]])
            means_log10 = []
            for im in set_imt:
                mean_ln, _ = self.gmpe.get_mean_and_stddevs(
                    sites, rup, dist, SA(im), stds_types)
                mean = np.exp(mean_ln[0])
                means_log10.append(np.log10(mean))

            mb = np.polyfit(t_log10, means_log10, 1)
            mean_imt_log10 = mb[0] * np.log10(imt) + mb[1]
            extrap_mean.append(np.log(10**mean_imt_log10))

        return extrap_mean