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


Python RectangularMesh.get_joyner_boore_distance方法代码示例

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


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

示例1: test_simple

# 需要导入模块: from nhlib.geo.mesh import RectangularMesh [as 别名]
# 或者: from nhlib.geo.mesh.RectangularMesh import get_joyner_boore_distance [as 别名]
    def test_simple(self):
        lons = numpy.array([numpy.arange(-1, 1.2, 0.2)] * 11)
        lats = lons.transpose() + 1
        depths = lats + 10
        mesh = RectangularMesh(lons, lats, depths)

        check = lambda lon, lat, depth, expected_distance, **kwargs: \
            self.assertAlmostEqual(
                mesh.get_joyner_boore_distance(
                    Mesh.from_points_list([Point(lon, lat, depth)])
                )[0],
                expected_distance, **kwargs
            )

        check(lon=0, lat=0.5, depth=0, expected_distance=0)
        check(lon=1, lat=1, depth=0, expected_distance=0)
        check(lon=0.6, lat=-1, depth=0,
              expected_distance=Point(0.6, -1).distance(Point(0.6, 0)),
              delta=0.1)
        check(lon=-0.8, lat=2.1, depth=10,
              expected_distance=Point(-0.8, 2.1).distance(Point(-0.8, 2)),
              delta=0.02)
        check(lon=0.75, lat=2.3, depth=3,
              expected_distance=Point(0.75, 2.3).distance(Point(0.75, 2)),
              delta=0.04)
开发者ID:pslh,项目名称:nhlib,代码行数:27,代码来源:mesh_test.py

示例2: test_mesh_of_one_point

# 需要导入模块: from nhlib.geo.mesh import RectangularMesh [as 别名]
# 或者: from nhlib.geo.mesh.RectangularMesh import get_joyner_boore_distance [as 别名]
 def test_mesh_of_one_point(self):
     lons = numpy.array([[1]])
     lats = numpy.array([[0]])
     depths = numpy.array([[1]])
     mesh = RectangularMesh(lons, lats, depths)
     target_mesh = Mesh.from_points_list([Point(1, 0), Point(0.5, 0)])
     dists = mesh.get_joyner_boore_distance(target_mesh)
     expected_dists = [0, Point(0.5, 0).distance(Point(1, 0))]
     self.assertTrue(numpy.allclose(dists, expected_dists, atol=0.2))
开发者ID:pslh,项目名称:nhlib,代码行数:11,代码来源:mesh_test.py

示例3: test_mesh_of_two_points

# 需要导入模块: from nhlib.geo.mesh import RectangularMesh [as 别名]
# 或者: from nhlib.geo.mesh.RectangularMesh import get_joyner_boore_distance [as 别名]
 def test_mesh_of_two_points(self):
     lons = numpy.array([[0, 0.5, 1]], float)
     lats = numpy.array([[0, 0, 0]], float)
     depths = numpy.array([[1, 0, 1]], float)
     mesh = RectangularMesh(lons, lats, depths)
     target_mesh = Mesh.from_points_list([Point(0.5, 1), Point(0.5, 0)])
     dists = mesh.get_joyner_boore_distance(target_mesh)
     expected_dists = [Point(0.5, 1).distance(Point(0.5, 0)), 0]
     numpy.testing.assert_almost_equal(dists, expected_dists)
开发者ID:gvallarelli,项目名称:nhlib,代码行数:11,代码来源:mesh_test.py

示例4: _test

# 需要导入模块: from nhlib.geo.mesh import RectangularMesh [as 别名]
# 或者: from nhlib.geo.mesh.RectangularMesh import get_joyner_boore_distance [as 别名]
 def _test(self, points, site, expected_distance):
     lons, lats, depths = numpy.array(points).transpose()
     lons = lons.transpose()
     lats = lats.transpose()
     depths = depths.transpose()
     mesh = RectangularMesh(lons, lats, depths)
     distance = mesh.get_joyner_boore_distance(
         Mesh.from_points_list([Point(*site)])
     )[0]
     self.assertAlmostEqual(distance, expected_distance, delta=0.02)
开发者ID:pslh,项目名称:nhlib,代码行数:12,代码来源:mesh_test.py

示例5: test_vertical_mesh

# 需要导入模块: from nhlib.geo.mesh import RectangularMesh [as 别名]
# 或者: from nhlib.geo.mesh.RectangularMesh import get_joyner_boore_distance [as 别名]
 def test_vertical_mesh(self):
     lons = numpy.array([[0, 1, 2], [0, 1, 2]])
     lats = numpy.array([[0, 0, 0], [0, 0, 0]])
     depths = numpy.array([[1, 1, 1], [2, 2, 2]])
     mesh = RectangularMesh(lons, lats, depths)
     target_mesh = Mesh.from_points_list([Point(0.5, 0), Point(0.5, 1),
                                          Point(0.5, 5)])
     dists = mesh.get_joyner_boore_distance(target_mesh)
     expected_dists = [
         0, Point(0.5, 1).distance(Point(0.5, 0)),
         Point(0.5, 5).distance(Point(0.5, 0))
     ]
     self.assertTrue(numpy.allclose(dists, expected_dists, atol=3))
开发者ID:pslh,项目名称:nhlib,代码行数:15,代码来源:mesh_test.py


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