def test_prob_failure_given_displacement(self): Dn_ = np.array([ 0.000000e00, 0.000000e00, 0.000000e00, 0.000000e00, 0.000000e00, 6.006612e-05, 6.681122e-04, 1.929713e-03, 3.775745e-03, 6.137864e-03, ]) pf = prob_failure_given_displacement(Dn_) pf_ = np.array([ 0.0, 0.0, 0.0, 0.0, 0.0, 5.368313e-06, 2.328222e-04, 1.222611e-03, 3.483592e-03, 7.407753e-03, ]) np.testing.assert_allclose(pf, pf_, atol=1e-9)
def compute(self, mag, imt, gmf, sites): if imt.name == 'PGA': nd = newmark_displ_from_pga_M( gmf, sites.crit_accel, mag, self.c1, self.c2, self.c3, self.c4, self.crit_accel_threshold) return nd, prob_failure_given_displacement(nd) else: raise NotImplementedError('NewmarkDisplacement for %s' % imt)
def test_newmark_prob_displacement(self): self.sites["newmark_disp"] = newmark_displ_from_pga_M( pga=self.pga, critical_accel=self.sites['crit_accel'], M=7.5) self.sites["prob_disp"] = prob_failure_given_displacement( self.sites["newmark_disp"]) prob_d = np.array([0., 0., 0., 0.335, 0., 0., 0., 0., 0., 0.]) np.testing.assert_array_almost_equal(self.sites["prob_disp"], prob_d)
def compute(self, mag, imt_gmf, sites): out = [] for imt, gmf in imt_gmf: if imt.name == 'PGA': nd = newmark_displ_from_pga_M(gmf, sites.crit_accel, mag, self.c1, self.c2, self.c3, self.c4, self.crit_accel_threshold) out.append(nd) out.append(prob_failure_given_displacement(nd)) return out
def test_newmark_prob_displacement(self): self.sites["newmark_disp"] = newmark_displ_from_pga_M(pga=self.pga, critical_accel=self.sites['crit_accel'], M=7.5) self.sites["prob_disp"] = prob_failure_given_displacement( self.sites["newmark_disp"] ) prob_d = np.array([0.00000000e+00, 3.02568994e-04, 0.00000000e+00, 3.35000000e-01, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 2.82209270e-07, 1.12933769e-05]) np.testing.assert_array_almost_equal(self.sites["prob_disp"], prob_d)