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)
def test_gm_calculation_soilBC(self): """ Test mean and std calculation - AB06 on BC soil""" # Modified gmpe mgmpe = NRCan15SiteTermLinear(gmpe_name='AtkinsonBoore2006') # 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() 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 test_gm_calculationBA08_vs30variable(self): """ Test mean and std calculation - BA08 - Vs30 variable""" # Modified gmpe mgmpe = NRCan15SiteTermLinear(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])
def test_instantiation(self): """ Tests the instantiation """ mgmpe = NRCan15SiteTermLinear(gmpe_name='BooreEtAl2014') # # Check the assigned IMTs expected = set([PGA, SA, PGV]) self.assertEqual(mgmpe.DEFINED_FOR_INTENSITY_MEASURE_TYPES, expected) # Check the TR expected = TRT.ACTIVE_SHALLOW_CRUST self.assertEqual(mgmpe.DEFINED_FOR_TECTONIC_REGION_TYPE, expected) # Check the IM component expected = IMC.RotD50 self.assertEqual(mgmpe.DEFINED_FOR_INTENSITY_MEASURE_COMPONENT, expected) # Check the standard deviations expected = set(['Intra event', 'Total', 'Inter event']) self.assertEqual(mgmpe.DEFINED_FOR_STANDARD_DEVIATION_TYPES, expected) # Check the required distances expected = set(['rjb']) self.assertEqual(mgmpe.REQUIRES_DISTANCES, expected)
def test_set_vs30_attribute(self): mgmpe = NRCan15SiteTermLinear(gmpe_name='Campbell2003SHARE') msg = '{:s} does not have vs30 in the required site parameters' self.assertTrue('vs30' in mgmpe.REQUIRES_SITES_PARAMETERS, msg=msg)
def test_raise_error(self): """ Tests that exception is raised """ with self.assertRaises(AttributeError): NRCan15SiteTermLinear(gmpe_name='FukushimaTanaka1990')