def test_double(self): fname = gettemp(double_ampl_func) aw = read_csv(fname, {'ampcode': ampcode_dt, None: numpy.float64}) a = Amplifier(self.imtls, aw) poes = a.amplify_one(b'A', 'SA(0.1)', self.hcurve[1]).flatten() numpy.testing.assert_allclose(poes, [ 0.989, 0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69, 0.09, 0.09 ], atol=1E-6) poes = a.amplify_one(b'A', 'SA(0.2)', self.hcurve[2]).flatten() numpy.testing.assert_allclose(poes, [ 0.989, 0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69, 0.09, 0.09 ], atol=1E-6) poes = a.amplify_one(b'A', 'SA(0.5)', self.hcurve[3]).flatten() numpy.testing.assert_allclose(poes, [ 0.989, 0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69, 0.09, 0.09 ], atol=1E-6) # amplify GMFs gmvs = a.amplify_gmvs(b'A', numpy.array([.1, .2, .3]), 'SA(0.5)') numpy.testing.assert_allclose(gmvs, [.2, .4, .6])
def test_simple(self): fname = gettemp(simple_ampl_func) aw = read_csv(fname, {'ampcode': ampcode_dt, None: numpy.float64}) a = Amplifier(self.imtls, aw, self.soil_levels) a.check(self.vs30, vs30_tolerance=1) poes = a.amplify_one(b'A', 'SA(0.1)', self.hcurve[1]).flatten() numpy.testing.assert_allclose( poes, [0.985002, 0.979997, 0.970004, 0.940069, 0.889961, 0.79, 0.690037], atol=1E-6) poes = a.amplify_one(b'A', 'SA(0.2)', self.hcurve[2]).flatten() numpy.testing.assert_allclose( poes, [0.985002, 0.979997, 0.970004, 0.940069, 0.889961, 0.79, 0.690037], atol=1E-6) poes = a.amplify_one(b'A', 'SA(0.5)', self.hcurve[3]).flatten() numpy.testing.assert_allclose( poes, [0.985002, 0.979996, 0.969991, 0.940012, 0.889958, 0.79, 0.690037], atol=1E-6) # amplify GMFs gmvs = a.amplify_gmvs(b'A', numpy.array([.005, .010, .015]), 'PGA') numpy.testing.assert_allclose(gmvs, [0.00505, 0.010233, 0.01575], atol=1E-5)