def test_recarray_conversion(self): # automatic recarray conversion for backward compatibility imt = PGA() gsim = AbrahamsonGulerce2020SInter() ctx = RuptureContext() ctx.mag = 5. ctx.sids = [0, 1] ctx.vs30 = [760., 760.] ctx.rrup = [100., 110.] ctx.occurrence_rate = .000001 mean, _stddevs = gsim.get_mean_and_stddevs(ctx, ctx, ctx, imt, []) numpy.testing.assert_allclose(mean, [-5.81116004, -6.00192455])
def test_rhypo_smaller_than_15(self): # test the calculation in case of rhypo distances less than 15 km # (for rhypo=0 the distance term has a singularity). In this case the # method should return values equal to the ones obtained by clipping # distances at 15 km. ctx = RuptureContext() ctx.sids = [0, 1, 2] ctx.vs30 = numpy.array([800.0, 800.0, 800.0]) ctx.mag = 5.0 ctx.rake = 0 ctx.occurrence_rate = .0001 ctx.rhypo = numpy.array([0.0, 10.0, 16.0]) ctx.rhypo.flags.writeable = False mean_0, stds_0 = self.GSIM_CLASS().get_mean_and_stddevs( ctx, ctx, ctx, PGA(), [StdDev.TOTAL]) mean_15, stds_15 = self.GSIM_CLASS().get_mean_and_stddevs( ctx, ctx, ctx, PGA(), [StdDev.TOTAL]) numpy.testing.assert_array_equal(mean_0, mean_15) numpy.testing.assert_array_equal(stds_0, stds_15)
def test_zero_distance(self): # test the calculation in case of zero rrup distance (for rrup=0 # the slab correction term has a singularity). In this case the # method should return values equal to the ones obtained by # replacing 0 values with 0.1 ctx = RuptureContext() ctx.sids = [0, 1] ctx.vs30 = numpy.array([800.0, 800.0]) ctx.mag = 5.0 ctx.rake = 0.0 ctx.hypo_depth = 0.0 ctx.rrup = numpy.array([0.0, 0.2]) ctx.occurrence_rate = .0001 mean_0, stds_0 = self.GSIM_CLASS().get_mean_and_stddevs( ctx, ctx, ctx, PGA(), [StdDev.TOTAL]) ctx.rrup = numpy.array([0.1, 0.2]) mean_01, stds_01 = self.GSIM_CLASS().get_mean_and_stddevs( ctx, ctx, ctx, PGA(), [StdDev.TOTAL]) numpy.testing.assert_array_equal(mean_0, mean_01) numpy.testing.assert_array_equal(stds_0, stds_01)