本文整理汇总了Python中openquake.hazardlib.mfd.TruncatedGRMFD类的典型用法代码示例。如果您正苦于以下问题:Python TruncatedGRMFD类的具体用法?Python TruncatedGRMFD怎么用?Python TruncatedGRMFD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TruncatedGRMFD类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_a_and_get_total_moment_rate_when_b_equal_to_1_5
def test_set_a_and_get_total_moment_rate_when_b_equal_to_1_5(self):
mfd = TruncatedGRMFD(min_mag=2.4, max_mag=5.6, bin_width=0.4,
a_val=-0.44, b_val=1.5)
tmr = mfd._get_total_moment_rate()
mfd._set_a(tmr)
self.assertAlmostEqual(mfd.a_val, -0.44)
self.assertEqual(mfd._get_total_moment_rate(), tmr)
示例2: test_set_a_and_get_total_moment_rate
def test_set_a_and_get_total_moment_rate(self):
mfd = TruncatedGRMFD(min_mag=3.0, max_mag=4.0, bin_width=0.1,
a_val=4.4, b_val=0.5)
tmr = mfd._get_total_moment_rate()
mfd._set_a(tmr)
self.assertAlmostEqual(mfd.a_val, 4.4)
self.assertEqual(mfd._get_total_moment_rate(), tmr)
示例3: test_set_ab
def test_set_ab(self):
mfd = TruncatedGRMFD(min_mag=2.5, max_mag=3.5, bin_width=0.25,
a_val=1, b_val=1.3)
mfd.modify('set_ab', {'a_val': -4.2, 'b_val': 1.45})
self.assertEqual(mfd.max_mag, 3.5)
self.assertEqual(mfd.a_val, -4.2)
self.assertEqual(mfd.b_val, 1.45)
self.assertEqual(mfd.min_mag, 2.5)
示例4: test_set_max_mag
def test_set_max_mag(self):
mfd = TruncatedGRMFD(min_mag=3.5, max_mag=5.5, bin_width=0.5,
a_val=1, b_val=1.3)
mfd.modify('set_max_mag', {'value': 4.2})
self.assertEqual(mfd.max_mag, 4.2)
self.assertEqual(mfd.a_val, 1)
self.assertEqual(mfd.b_val, 1.3)
self.assertEqual(mfd.min_mag, 3.5)
示例5: test
def test(self):
mfd = TruncatedGRMFD(min_mag=0.61, max_mag=0.94, bin_width=0.1,
a_val=1, b_val=0.2)
# mag values should be rounded to 0.6 and 0.9 and there
# should be three bins with the first having center at 0.65
min_mag, num_bins = mfd._get_min_mag_and_num_bins()
self.assertAlmostEqual(min_mag, 0.65)
self.assertEqual(mfd.get_min_max_mag(), (min_mag, min_mag + 0.2))
self.assertEqual(num_bins, 3)
示例6: _test
def _test(self, expected_rates, rate_tolerance, **kwargs):
mfd = TruncatedGRMFD(**kwargs)
actual_rates = mfd.get_annual_occurrence_rates()
self.assertEqual(len(actual_rates), len(expected_rates))
for i, (mag, rate) in enumerate(actual_rates):
expected_mag, expected_rate = expected_rates[i]
self.assertAlmostEqual(mag, expected_mag, delta=1e-14)
self.assertAlmostEqual(rate, expected_rate, delta=rate_tolerance)
if i == 0:
self.assertEqual((mag, mag + 2), mfd.get_min_max_mag())
示例7: _get_mfds
def _get_mfds(srcs):
"""
Return sources' magnitude frequency distributions.
"""
mfds = {}
tot_occur_rate = 0
for src in srcs:
mfd = {}
if isinstance(src.mfd, IncrementalMFD):
mfd['min_mag'] = float(src.mfd.min_mag)
mfd['bin_width'] = float(src.mfd.bin_width)
mfd['occur_rates'] = map(float, src.mfd.occur_rates)
elif isinstance(src.mfd, TGRMFD):
bin_width = 0.1
mfd = TruncatedGRMFD(
src.mfd.min_mag,
src.mfd.max_mag,
bin_width,
src.mfd.a_val,
src.mfd.b_val
)
mags_rates = mfd.get_annual_occurrence_rates()
mags = [m for m, _ in mags_rates]
occur_rates = [r for _, r in mags_rates]
mfd['min_mag'] = mags[0]
mfd['bin_width'] = bin_width
mfd['occur_rates'] = occur_rates
else:
raise ValueError(
'MFD %s not recognized' % src.mfd.__class__.__name__
)
tot_occur_rate += sum(mfd['occur_rates'])
assert src.id not in mfds
mfds[src.id] = mfd
return mfds, tot_occur_rate
示例8: test_increment_b
def test_increment_b(self):
mfd = TruncatedGRMFD(min_mag=4.2, max_mag=6.6, bin_width=0.2,
a_val=-20.5, b_val=0.51)
old_tmr = mfd._get_total_moment_rate()
mfd.modify('increment_b', {'value': 1.46})
self.assertEqual(mfd.max_mag, 6.6)
self.assertEqual(mfd.b_val, 0.51 + 1.46)
self.assertEqual(mfd.min_mag, 4.2)
self.assertAlmostEqual(mfd._get_total_moment_rate(), old_tmr)
mfd.modify('increment_b', {'value': -1.46})
self.assertAlmostEqual(mfd._get_total_moment_rate(), old_tmr)
self.assertEqual(mfd.b_val, 0.51)
self.assertAlmostEqual(mfd.a_val, -20.5)
示例9: test_increment_max_mag
def test_increment_max_mag(self):
mfd = TruncatedGRMFD(min_mag=6.0, max_mag=7.0, bin_width=0.1,
a_val=-18.2, b_val=0.41)
old_tmr = mfd._get_total_moment_rate()
mfd.modify('increment_max_mag', {'value': 1})
self.assertEqual(mfd.max_mag, 8.0)
self.assertEqual(mfd.b_val, 0.41)
self.assertEqual(mfd.min_mag, 6.0)
self.assertAlmostEqual(mfd._get_total_moment_rate(), old_tmr)
mfd.modify('increment_max_mag', {'value': -1})
self.assertAlmostEqual(mfd._get_total_moment_rate(), old_tmr)
self.assertEqual(mfd.max_mag, 7.0)
self.assertAlmostEqual(mfd.a_val, -18.2)
示例10: test_set_a_when_b_equal_to_1_5
def test_set_a_when_b_equal_to_1_5(self):
mfd = TruncatedGRMFD(min_mag=6.0, max_mag=8.0, bin_width=0.1,
a_val=1.5, b_val=1.5)
mfd._set_a(12.45)
self.assertAlmostEqual(mfd.a_val, -8.4319519)
示例11: test_set_a
def test_set_a(self):
mfd = TruncatedGRMFD(min_mag=6.0, max_mag=8.0, bin_width=0.1,
a_val=1.5, b_val=0.5)
mfd._set_a(123.45)
self.assertAlmostEqual(mfd.a_val, -14.6531141)
示例12: test_get_total_moment_rate_when_b_equal_to_1_5
def test_get_total_moment_rate_when_b_equal_to_1_5(self):
# pylint: disable=invalid-name
mfd = TruncatedGRMFD(min_mag=6.0, max_mag=8.0, bin_width=0.1,
a_val=-9.4, b_val=1.5)
self.assertAlmostEqual(mfd._get_total_moment_rate(), 1.3400508)
示例13: test_get_total_moment_rate
def test_get_total_moment_rate(self):
mfd = TruncatedGRMFD(min_mag=6.0, max_mag=8.0, bin_width=0.1,
a_val=-17.2, b_val=0.4)
self.assertAlmostEqual(mfd._get_total_moment_rate(), 1.6140553)