本文整理汇总了Python中openquake.hmtk.seismicity.catalogue.Catalogue.get_magnitude_time_distribution方法的典型用法代码示例。如果您正苦于以下问题:Python Catalogue.get_magnitude_time_distribution方法的具体用法?Python Catalogue.get_magnitude_time_distribution怎么用?Python Catalogue.get_magnitude_time_distribution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openquake.hmtk.seismicity.catalogue.Catalogue
的用法示例。
在下文中一共展示了Catalogue.get_magnitude_time_distribution方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestMagnitudeTimeDistribution
# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import get_magnitude_time_distribution [as 别名]
class TestMagnitudeTimeDistribution(unittest.TestCase):
"""
Simple class to test the magnitude time density distribution
"""
def setUp(self):
self.catalogue = Catalogue()
x, y = np.meshgrid(np.arange(1915., 2010., 10.),
np.arange(5.5, 9.0, 1.0))
nx, ny = np.shape(x)
self.catalogue.data['magnitude'] = (y.reshape([nx * ny, 1])).flatten()
x = (x.reshape([nx * ny, 1])).flatten()
self.catalogue.data['year'] = x.astype(int)
self.catalogue.data['month'] = np.ones_like(x, dtype=int)
self.catalogue.data['day'] = np.ones_like(x, dtype=int)
self.catalogue.data['hour'] = np.ones_like(x, dtype=int)
self.catalogue.data['minute'] = np.ones_like(x, dtype=int)
self.catalogue.data['second'] = np.ones_like(x, dtype=float)
def test_magnitude_time_distribution_no_uncertainties(self):
# Tests the magnitude-depth distribution without uncertainties
mag_range = np.arange(5., 10., 1.)
time_range = np.arange(1910., 2020., 10.)
# Without normalisation
expected_array = np.ones([len(time_range) - 1, len(mag_range) - 1],
dtype=float)
np.testing.assert_array_almost_equal(
expected_array,
self.catalogue.get_magnitude_time_distribution(
mag_range, time_range))
# With Normalisation
np.testing.assert_array_almost_equal(
expected_array / np.sum(expected_array),
self.catalogue.get_magnitude_time_distribution(
mag_range, time_range, normalisation=True))