def test_pga(self): sa = SA(period=1e-50, damping=5) pga = PGA() cormo = JB2009CorrelationModel(vs30_clustering=False) corma = cormo.get_correlation_matrix(self.SITECOL, sa) corma2 = cormo.get_correlation_matrix(self.SITECOL, pga) self.assertTrue((corma == corma2).all()) cormo = JB2009CorrelationModel(vs30_clustering=True) corma = cormo.get_correlation_matrix(self.SITECOL, sa) corma2 = cormo.get_correlation_matrix(self.SITECOL, pga) self.assertTrue((corma == corma2).all())
def test_no_correlation_mean_and_intra_respected(self): mean1 = 10 mean2 = 14 inter = 1e-300 intra1 = 0.2 intra2 = 1.6 p1 = Point(0, 0) p2 = Point(0, 0.3) sites = [Site(p1, mean1, False, inter, intra1), Site(p2, mean2, False, inter, intra2)] self.sites = SiteCollection(sites) numpy.random.seed(41) cormo = JB2009CorrelationModel(vs30_clustering=False) lt_corma = cormo.get_lower_triangle_correlation_matrix(self.sites, self.imt1) s1_intensity, s2_intensity = ground_motion_fields( self.rupture, self.sites, [self.imt1], self.gsim, truncation_level=None, realizations=6000, lt_correlation_matrices={self.imt1: lt_corma} )[self.imt1] self.assertAlmostEqual(s1_intensity.mean(), mean1, delta=1e-3) self.assertAlmostEqual(s2_intensity.mean(), mean2, delta=1e-3) self.assertAlmostEqual(s1_intensity.std(), intra1, delta=2e-3) self.assertAlmostEqual(s2_intensity.std(), intra2, delta=1e-2)
def test_period_one_and_above(self): cormo = JB2009CorrelationModel(vs30_clustering=False) cormo2 = JB2009CorrelationModel(vs30_clustering=True) imt = SA(period=1.0, damping=5) corma = cormo.get_correlation_matrix(self.SITECOL, imt) aaae(corma, [[1, 0.2730787, 1, 0.2730787], [0.2730787, 1, 0.2730787, 0.07457198], [1, 0.2730787, 1, 0.2730787], [0.2730787, 0.07457198, 0.2730787, 1]]) corma2 = cormo2.get_correlation_matrix(self.SITECOL, imt) self.assertTrue((corma == corma2).all()) imt = SA(period=10.0, damping=5) corma = cormo.get_correlation_matrix(self.SITECOL, imt) aaae(corma, [[1, 0.56813402, 1, 0.56813402], [0.56813402, 1, 0.56813402, 0.32277627], [1, 0.56813402, 1, 0.56813402], [0.56813402, 0.32277627, 0.56813402, 1]]) corma2 = cormo2.get_correlation_matrix(self.SITECOL, imt) self.assertTrue((corma == corma2).all())
def test_clustered(self): cormo = JB2009CorrelationModel(vs30_clustering=True) imt = SA(period=0.001, damping=5) corma = cormo.get_correlation_matrix(self.SITECOL, imt) aaae(corma, [[1, 0.44046654, 1, 0.44046654], [0.44046654, 1, 0.44046654, 0.19401077], [1, 0.44046654, 1, 0.44046654], [0.44046654, 0.19401077, 0.44046654, 1]]) imt = SA(period=0.5, damping=5) corma = cormo.get_correlation_matrix(self.SITECOL, imt) aaae(corma, [[1, 0.36612758, 1, 0.36612758], [0.36612758, 1, 0.36612758, 0.1340494], [1, 0.36612758, 1, 0.36612758], [0.36612758, 0.1340494, 0.36612758, 1]])
def test_no_clustering(self): cormo = JB2009CorrelationModel(vs30_clustering=False) imt = SA(period=0.1, damping=5) corma = cormo.get_correlation_matrix(self.SITECOL, imt) aaae(corma, [[1, 0.03823366, 1, 0.03823366], [0.03823366, 1, 0.03823366, 0.00146181], [1, 0.03823366, 1, 0.03823366], [0.03823366, 0.00146181, 0.03823366, 1]]) imt = SA(period=0.95, damping=5) corma = cormo.get_correlation_matrix(self.SITECOL, imt) aaae(corma, [[1, 0.26107857, 1, 0.26107857], [0.26107857, 1, 0.26107857, 0.06816202], [1, 0.26107857, 1, 0.26107857], [0.26107857, 0.06816202, 0.26107857, 1]])
def test_array_instead_of_matrix(self): mean = 10 inter = 1e-300 intra = 1 points = [Point(0, 0), Point(0, 0.23)] sites = [Site(point, mean, False, inter, intra) for point in points] self.sites = SiteCollection(sites) numpy.random.seed(43) cormo = JB2009CorrelationModel(vs30_clustering=False) corma = cormo.get_correlation_matrix(self.sites, self.imt1) lt_corma = cormo.get_lower_triangle_correlation_matrix(self.sites, self.imt1) gmfs = ground_motion_fields( self.rupture, self.sites, [self.imt1], self.gsim, truncation_level=None, realizations=6000, lt_correlation_matrices={self.imt1: lt_corma.A} ) sampled_corma = numpy.corrcoef(gmfs[self.imt1]) assert_allclose(corma, sampled_corma, rtol=0, atol=0.02)
def test(self): cormo = JB2009CorrelationModel(vs30_clustering=False) lt = cormo.get_lower_triangle_correlation_matrix(self.SITECOL, PGA()) aaae(lt, [[1.0, 0.0, 0.0], [1.97514806e-02, 9.99804920e-01, 0.0], [1.97514806e-02, 5.42206860e-20, 9.99804920e-01]])