本文整理匯總了Python中openquake.hazardlib.gsim.base.DistancesContext.rjb方法的典型用法代碼示例。如果您正苦於以下問題:Python DistancesContext.rjb方法的具體用法?Python DistancesContext.rjb怎麽用?Python DistancesContext.rjb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類openquake.hazardlib.gsim.base.DistancesContext
的用法示例。
在下文中一共展示了DistancesContext.rjb方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_mean_and_stddevs
# 需要導入模塊: from openquake.hazardlib.gsim.base import DistancesContext [as 別名]
# 或者: from openquake.hazardlib.gsim.base.DistancesContext import rjb [as 別名]
def test_get_mean_and_stddevs(self):
"""
Tests mean and standard deviations without amplification
"""
gsim = GMPETable(gmpe_table=self.TABLE_FILE)
rctx = RuptureContext()
rctx.mag = 6.0
dctx = DistancesContext()
# Test values at the given distances and those outside range
dctx.rjb = np.array([0.5, 1.0, 10.0, 100.0, 500.0])
sctx = SitesContext()
stddevs = [const.StdDev.TOTAL]
expected_mean = np.array([2.0, 2.0, 1.0, 0.5, 1.0E-20])
# PGA
mean, sigma = gsim.get_mean_and_stddevs(sctx, rctx, dctx,
imt_module.PGA(),
stddevs)
np.testing.assert_array_almost_equal(np.exp(mean), expected_mean, 5)
np.testing.assert_array_almost_equal(sigma[0], 0.5 * np.ones(5), 5)
# SA
mean, sigma = gsim.get_mean_and_stddevs(sctx, rctx, dctx,
imt_module.SA(1.0),
stddevs)
np.testing.assert_array_almost_equal(np.exp(mean), expected_mean, 5)
np.testing.assert_array_almost_equal(sigma[0], 0.8 * np.ones(5), 5)
# PGV
mean, sigma = gsim.get_mean_and_stddevs(sctx, rctx, dctx,
imt_module.PGV(),
stddevs)
np.testing.assert_array_almost_equal(np.exp(mean),
10. * expected_mean,
5)
np.testing.assert_array_almost_equal(sigma[0], 0.5 * np.ones(5), 5)
示例2: test_get_mean_and_stddevs_good
# 需要導入模塊: from openquake.hazardlib.gsim.base import DistancesContext [as 別名]
# 或者: from openquake.hazardlib.gsim.base.DistancesContext import rjb [as 別名]
def test_get_mean_and_stddevs_good(self):
"""
Tests the full execution of the GMPE tables for valid data
"""
gsim = GMPETable(gmpe_table=self.TABLE_FILE)
rctx = RuptureContext()
rctx.mag = 6.0
rctx.rake = 90.0
dctx = DistancesContext()
# Test values at the given distances and those outside range
dctx.rjb = np.array([0.5, 1.0, 10.0, 100.0, 500.0])
sctx = SitesContext()
stddevs = [const.StdDev.TOTAL]
expected_mean = np.array([20.0, 20.0, 10.0, 5.0, 1.0E-19])
# PGA
mean, sigma = gsim.get_mean_and_stddevs(sctx, rctx, dctx,
imt_module.PGA(),
stddevs)
np.testing.assert_array_almost_equal(np.exp(mean), expected_mean, 5)
np.testing.assert_array_almost_equal(sigma[0], 0.25 * np.ones(5), 5)
# SA
mean, sigma = gsim.get_mean_and_stddevs(sctx, rctx, dctx,
imt_module.SA(1.0),
stddevs)
np.testing.assert_array_almost_equal(np.exp(mean), expected_mean, 5)
np.testing.assert_array_almost_equal(sigma[0], 0.4 * np.ones(5), 5)
示例3: test_get_mean_stddevs_unsupported_stddev
# 需要導入模塊: from openquake.hazardlib.gsim.base import DistancesContext [as 別名]
# 或者: from openquake.hazardlib.gsim.base.DistancesContext import rjb [as 別名]
def test_get_mean_stddevs_unsupported_stddev(self):
"""
Tests the execution of the GMPE with an unsupported standard deviation
type
"""
gsim = GMPETable(gmpe_table=self.TABLE_FILE)
rctx = RuptureContext()
rctx.mag = 6.0
dctx = DistancesContext()
# Test values at the given distances and those outside range
dctx.rjb = np.array([0.5, 1.0, 10.0, 100.0, 500.0])
sctx = SitesContext()
sctx.vs30 = 1000. * np.ones(5)
stddevs = [const.StdDev.TOTAL, const.StdDev.INTER_EVENT]
with self.assertRaises(ValueError) as ve:
gsim.get_mean_and_stddevs(sctx, rctx, dctx, imt_module.PGA(),
stddevs)
self.assertEqual(str(ve.exception),
"Standard Deviation type Inter event not supported")
示例4: test_get_amplification_factors
# 需要導入模塊: from openquake.hazardlib.gsim.base import DistancesContext [as 別名]
# 或者: from openquake.hazardlib.gsim.base.DistancesContext import rjb [as 別名]
def test_get_amplification_factors(self):
"""
Tests the amplification tables
"""
rctx = RuptureContext()
rctx.mag = 6.0
dctx = DistancesContext()
# Takes distances at the values found in the table (not checking
# distance interpolation)
dctx.rjb = np.copy(self.amp_table.distances[:, 0, 0])
# Test Vs30 is 700.0 m/s midpoint between the 400 m/s and 1000 m/s
# specified in the table
sctx = SitesContext()
sctx.vs30 = 700.0 * np.ones_like(dctx.rjb)
stddevs = [const.StdDev.TOTAL]
expected_mean = np.ones_like(dctx.rjb)
expected_sigma = np.ones_like(dctx.rjb)
# Check PGA and PGV
mean_amp, sigma_amp = self.amp_table.get_amplification_factors(
imt_module.PGA(), sctx, rctx, dctx.rjb, stddevs)
np.testing.assert_array_almost_equal(
mean_amp,
midpoint(1.0, 1.5) * expected_mean)
np.testing.assert_array_almost_equal(
sigma_amp[0],
0.9 * expected_mean)
mean_amp, sigma_amp = self.amp_table.get_amplification_factors(
imt_module.PGV(), sctx, rctx, dctx.rjb, stddevs)
np.testing.assert_array_almost_equal(
mean_amp,
midpoint(1.0, 0.5) * expected_mean)
np.testing.assert_array_almost_equal(
sigma_amp[0],
0.9 * expected_mean)
# Sa (0.5)
mean_amp, sigma_amp = self.amp_table.get_amplification_factors(
imt_module.SA(0.5), sctx, rctx, dctx.rjb, stddevs)
np.testing.assert_array_almost_equal(
mean_amp,
midpoint(1.0, 2.0) * expected_mean)
np.testing.assert_array_almost_equal(
sigma_amp[0],
0.9 * expected_mean)
示例5: get_response_spectrum
# 需要導入模塊: from openquake.hazardlib.gsim.base import DistancesContext [as 別名]
# 或者: from openquake.hazardlib.gsim.base.DistancesContext import rjb [as 別名]
def get_response_spectrum(self, magnitude, distance, periods, rake=90, vs30=800, damping=0.05):
"""
"""
responses = np.zeros((len(periods),))
p_damping = damping * 100
rup = RuptureContext()
rup.mag = magnitude
rup.rake = rake
dists = DistancesContext()
dists.rjb = np.array([distance])
sites = SitesContext()
sites.vs30 = np.array([vs30])
stddev_types = [StdDev.TOTAL]
for i, period in enumerate(periods):
if period == 0:
imt = _PGA()
else:
imt = _SA(period, p_damping)
responses[i] = np.exp(self._gmpe.get_mean_and_stddevs(sites, rup, dists, imt, stddev_types)[0][0])
return ResponseSpectrum(periods, responses, unit='g', damping=damping)
示例6: SitesContext
# 需要導入模塊: from openquake.hazardlib.gsim.base import DistancesContext [as 別名]
# 或者: from openquake.hazardlib.gsim.base.DistancesContext import rjb [as 別名]
sctx_rock = SitesContext()
rctx.rake = 0.0
rctx.dip = 90.0
rctx.ztor = 7.13
rctx.mag = 3.0
#rctx.mag = np.linspace(0.1,5.)
rctx.width = 10.0
rctx.hypo_depth = 8.0
#dctx.rrup = np.logspace(1,np.log10(200),100)
dctx.rrup = np.logspace(np.log10(10),np.log10(10.0),1)
# Assuming average ztor, get rjb:
dctx.rjb = np.sqrt(dctx.rrup**2 - rctx.ztor**2)
dctx.rhypo = dctx.rrup
dctx.rx = dctx.rjb
dctx.ry0 = dctx.rx
sctx.vs30 = np.ones_like(dctx.rrup) * 760.0
sctx.vs30measured = np.full_like(dctx.rrup, False, dtype='bool')
sctx.z1pt0 = np.ones_like(dctx.rrup) * 0.05
lmean_ask14, sd_ask14 = ASK14.get_mean_and_stddevs(
sctx, rctx, dctx, IMT, [const.StdDev.TOTAL])