def test_spec_accels(params, expected): m = DBC14(Scenario(**params)) np.testing.assert_allclose( m.interp_spec_accels(expected['periods']), # Need to convert from m/sec to g np.array(expected['spec_accels']) / m.GRAVITY, rtol=RTOL, err_msg='Spectral accelerations')
def test_im_values(params, expected, key): m = DBC14(Scenario(**params)) # PGA needs to be converted from m/sec² to g, and PGV need to be # converted from m/sec into cm/sec scale = m.GRAVITY if key == "pga" else 0.01 np.testing.assert_allclose( getattr(m, key), expected[key] / scale, rtol=RTOL, )
def test_model(event, prediction, indices, attr): m = HKR13(Scenario(**dict(zip(names, event)))) prediction = np.asarray(prediction) if 'ln_' in attr: # Convert from variance to standard deviation prediction = np.sqrt(prediction[indices]) else: # Convert from log to natural space. prediction = np.exp(prediction[indices]) np.testing.assert_allclose( getattr(m, attr), prediction, rtol=RTOL, )
def model(): """Instance of the DBC13 model.""" return DBC14(Scenario(dist_jb=10, mag=6, v_s30=600, depth_hyp=10, mechanism="SS"))
def test_scenario(): s = Scenario(mag=6, dist_jb=20) assert_allclose(s.mag, s["mag"]) assert_allclose(s.dist_jb, s["dist_jb"])
def model(): return C03(Scenario(mag=6.5, dist_rup=20))
def test_scenario(): s = Scenario(mag=6, dist_jb=20) assert_allclose(s.mag, s['mag']) assert_allclose(s.dist_jb, s['dist_jb'])
def create_model(params): s = Scenario(**params) m = Model(s) return m
def create_model(params, dist): params = dict(params) params[dist] = params.pop("dist") s = Scenario(**params) m = ASB14(s) return m