当前位置: 首页>>代码示例>>Python>>正文


Python Catalogue.hypocentres_as_mesh方法代码示例

本文整理汇总了Python中openquake.hmtk.seismicity.catalogue.Catalogue.hypocentres_as_mesh方法的典型用法代码示例。如果您正苦于以下问题:Python Catalogue.hypocentres_as_mesh方法的具体用法?Python Catalogue.hypocentres_as_mesh怎么用?Python Catalogue.hypocentres_as_mesh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openquake.hmtk.seismicity.catalogue.Catalogue的用法示例。


在下文中一共展示了Catalogue.hypocentres_as_mesh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_hypocentres_as_mesh

# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import hypocentres_as_mesh [as 别名]
 def test_hypocentres_as_mesh(self):
     # Tests the function to render the hypocentres to a
     # hazardlib.geo.mesh.Mesh object.
     cat = Catalogue()
     cat.data['longitude'] = np.array([2., 3.])
     cat.data['latitude'] = np.array([2., 3.])
     cat.data['depth'] = np.array([2., 3.])
     self.assertTrue(isinstance(cat.hypocentres_as_mesh(), Mesh))
开发者ID:gem,项目名称:oq-hazardlib,代码行数:10,代码来源:catalogue_test.py

示例2: TestSelector

# 需要导入模块: from openquake.hmtk.seismicity.catalogue import Catalogue [as 别名]
# 或者: from openquake.hmtk.seismicity.catalogue.Catalogue import hypocentres_as_mesh [as 别名]

#.........这里部分代码省略.........
                            for iloc in range(0, 4)])
        self.catalogue.data['longitude'] = np.arange(4.0, 7.5, 0.5)
        self.catalogue.data['latitude'] = np.arange(4.0, 7.5, 0.5)
        self.catalogue.data['depth'] = np.ones(7, dtype=float)
        # Simple case with nodes inside, outside and on the border of polygon
        selector0 = CatalogueSelector(self.catalogue)
        test_cat1 = selector0.within_polygon(polygon0)
        self.assertTrue(np.allclose(test_cat1.data['longitude'],
                                    np.array([5.0, 5.5, 6.0])))
        self.assertTrue(np.allclose(test_cat1.data['latitude'],
                                    np.array([5.0, 5.5, 6.0])))
        self.assertTrue(np.allclose(test_cat1.data['depth'],
                                    np.array([1.0, 1.0, 1.0])))
        # CASE 2: As case 1 with one of the inside nodes outside of the depths
        self.catalogue.data['depth'] = \
            np.array([1.0, 1.0, 1.0, 50.0, 1.0, 1.0, 1.0], dtype=float)
        selector0 = CatalogueSelector(self.catalogue)
        test_cat1 = selector0.within_polygon(polygon0, upper_depth=0.0,
                                             lower_depth=10.0)
        self.assertTrue(np.allclose(test_cat1.data['longitude'],
                                    np.array([5.0, 6.0])))
        self.assertTrue(np.allclose(test_cat1.data['latitude'],
                                    np.array([5.0, 6.0])))
        self.assertTrue(np.allclose(test_cat1.data['depth'],
                                    np.array([1.0])))

    def test_point_in_circular_distance(self):
        # Tests point in circular distance

        self.catalogue.data['longitude'] = np.arange(4.0, 7.5, 0.5)
        self.catalogue.data['latitude'] = np.arange(4.0, 7.5, 0.5)
        self.catalogue.data['depth'] = np.ones(7, dtype=float)
        test_point = Point(5.5, 5.5)
        test_mesh = self.catalogue.hypocentres_as_mesh()
        selector0 = CatalogueSelector(self.catalogue)
        # Within 10 km
        test_cat_10 = selector0.circular_distance_from_point(
            test_point, 10., distance_type='epicentral')
        np.testing.assert_array_equal(test_cat_10.data['longitude'],
                                      np.array([5.5]))
        np.testing.assert_array_equal(test_cat_10.data['latitude'],
                                      np.array([5.5]))
        np.testing.assert_array_equal(test_cat_10.data['depth'],
                                      np.array([1.0]))

        # Within 100 km
        test_cat_100 = selector0.circular_distance_from_point(
            test_point, 100., distance_type='epicentral')
        np.testing.assert_array_equal(test_cat_100.data['longitude'],
                                      np.array([5.0, 5.5, 6.0]))
        np.testing.assert_array_equal(test_cat_100.data['latitude'],
                                      np.array([5.0, 5.5, 6.0]))
        np.testing.assert_array_equal(test_cat_100.data['depth'],
                                      np.array([1.0, 1.0, 1.0]))

        # Within 1000 km
        test_cat_1000 = selector0.circular_distance_from_point(
            test_point, 1000., distance_type='epicentral')
        np.testing.assert_array_equal(test_cat_1000.data['longitude'],
                                      self.catalogue.data['longitude'])
        np.testing.assert_array_equal(test_cat_1000.data['latitude'],
                                      self.catalogue.data['latitude'])
        np.testing.assert_array_equal(test_cat_1000.data['depth'],
                                      self.catalogue.data['depth'])

    def test_cartesian_square_on_point(self):
开发者ID:gem,项目名称:oq-hazardlib,代码行数:70,代码来源:test_selector.py


注:本文中的openquake.hmtk.seismicity.catalogue.Catalogue.hypocentres_as_mesh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。