本文整理汇总了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)
示例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))
示例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)
示例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)
示例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))