本文整理汇总了Python中nhlib.geo.mesh.Mesh.from_points_list方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.from_points_list方法的具体用法?Python Mesh.from_points_list怎么用?Python Mesh.from_points_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nhlib.geo.mesh.Mesh
的用法示例。
在下文中一共展示了Mesh.from_points_list方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def _test(self, mesh_points, target_points, expected_distance_indexes):
mesh = Mesh.from_points_list(mesh_points)
target_mesh = Mesh.from_points_list(target_points)
dists = mesh.get_min_distance(target_mesh)
expected_dists = [mesh_points[mi].distance(target_points[ti])
for ti, mi in enumerate(expected_distance_indexes)]
self.assertEqual(list(dists), expected_dists)
示例2: test_nine_positions
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test_nine_positions(self):
def v2p(*vectors): # "vectors to points"
return [Point(*coords)
for coords in zip(*geo_utils.cartesian_to_spherical(
numpy.array(vectors, dtype=float)
))]
corners = v2p([6370, 0, -0.5], [6370, 0, 0.5],
[6369, 2, 0.5], [6369, 2, -0.5])
surface = PlanarSurface(1, 2, 3, *corners)
# first three positions: point projection is above the top edge
dists = surface.get_min_distance(Mesh.from_points_list(
v2p([6371, 0, -1.5], [6371, 0, 1.5], [6371, 0, 0.33])
))
self.assertTrue(numpy.allclose(dists, [2 ** 0.5, 2 ** 0.5, 1.0],
atol=1e-4))
# next three positions: point projection is below the bottom edge
dists = surface.get_min_distance(Mesh.from_points_list(
v2p([6368, 2, -1.5], [6368, 2, 1.5], [6368, 2, -0.45])
))
self.assertTrue(numpy.allclose(dists, [2 ** 0.5, 2 ** 0.5, 1.0],
atol=1e-4))
# next three positions: point projection is left to rectangle,
# right to it or lies inside
dists = surface.get_min_distance(Mesh.from_points_list(
v2p([6369.5, 1, -1.5], [6369.5, 1, 1.5], [6369.5, 1, -0.1])
))
self.assertTrue(numpy.allclose(dists, [1, 1, 0], atol=1e-4))
示例3: test_point_on_the_border
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test_point_on_the_border(self):
corners = [Point(0.1, -0.1, 1), Point(-0.1, -0.1, 1), Point(-0.1, 0.1, 2), Point(0.1, 0.1, 2)]
surface = PlanarSurface(1, 270, 45, *corners)
sites = Mesh.from_points_list([Point(-0.1, 0.04), Point(0.1, 0.03)])
dists = surface.get_joyner_boore_distance(sites)
expected_dists = [0] * 2
self.assertTrue(numpy.allclose(dists, expected_dists))
示例4: test5_site_opposite_to_strike_direction
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test5_site_opposite_to_strike_direction(self):
surface = self._test1to7surface()
sites = Mesh.from_points_list([Point(-0.2, 0), Point(-67.6, 0),
Point(-90.33, 0)])
dists = surface.get_rx_distance(sites)
expected_dists = [0] * 3
self.assertTrue(numpy.allclose(dists, expected_dists))
示例5: test8_strike_of_45_degrees
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test8_strike_of_45_degrees(self):
corners = [Point(-0.05, -0.05, 8), Point(0.05, 0.05, 8),
Point(0.05, 0.05, 9), Point(-0.05, -0.05, 9)]
surface = PlanarSurface(1, 45, 60, *corners)
sites = Mesh.from_points_list([Point(0.05, 0)])
self.assertAlmostEqual(surface.get_rx_distance(sites)[0],
3.9313415355436705, places=4)
示例6: test_one_point
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test_one_point(self):
mesh = Mesh.from_points_list([Point(7, 7)])
polygon = mesh.get_convex_hull()
elons = [7.0000453, 7., 6.9999547, 7]
elats = [7., 6.99995503, 7., 7.00004497]
numpy.testing.assert_allclose(polygon.lons, elons)
numpy.testing.assert_allclose(polygon.lats, elats)
示例7: test_point_on_the_border
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test_point_on_the_border(self):
corners = [[(0.1, -0.1, 1), (-0.1, -0.1, 1)], [(0.1, 0.1, 2), (-0.1, 0.1, 2)]]
surface = DummySurface(corners)
sites = Mesh.from_points_list([Point(-0.1, 0.04), Point(0.1, 0.03)])
dists = surface.get_joyner_boore_distance(sites)
expected_dists = [0] * 2
self.assertTrue(numpy.allclose(dists, expected_dists, atol=1e-4))
示例8: test_point_inside
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test_point_inside(self):
corners = [[(-1, -1, 1), (1, -1, 1)], [(-1, 1, 2), (1, 1, 2)]]
surface = DummySurface(corners)
sites = Mesh.from_points_list([Point(0, 0), Point(0, 0, 20), Point(0.1, 0.3)])
dists = surface.get_joyner_boore_distance(sites)
expected_dists = [0] * 3
self.assertTrue(numpy.allclose(dists, expected_dists))
示例9: test_simple
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [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)
示例10: test_left_or_right_edge_is_closest
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test_left_or_right_edge_is_closest(self):
sites = Mesh.from_points_list([Point(-0.24, -0.08, 0.55), Point(0.17, 0.07, 0)])
res = self.surface.get_closest_points(sites)
aae = numpy.testing.assert_almost_equal
aae(res.lons, [-0.1, 0.1], decimal=5)
aae(res.lats, [-0.08, 0.07], decimal=3)
aae(res.depths, [0.20679306, 1.69185737])
示例11: test_top_or_bottom_edge_is_closest
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test_top_or_bottom_edge_is_closest(self):
sites = Mesh.from_points_list([Point(-0.04, -0.28, 0), Point(0.033, 0.15, 0)])
res = self.surface.get_closest_points(sites)
aae = numpy.testing.assert_almost_equal
aae(res.lons, [-0.04, 0.033], decimal=5)
aae(res.lats, [-0.1, 0.1], decimal=5)
aae(res.depths, [0, 2], decimal=2)
示例12: test_point_outside
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test_point_outside(self):
corners = [Point(0.1, -0.1, 1), Point(-0.1, -0.1, 1), Point(-0.1, 0.1, 2), Point(0.1, 0.1, 2)]
surface = PlanarSurface(1, 270, 45, *corners)
sites = Mesh.from_points_list(
[
Point(-0.2, -0.2),
Point(1, 1, 1),
Point(4, 5),
Point(0.8, 0.01),
Point(0.2, -0.15),
Point(0.02, -0.12),
Point(-0.14, 0),
Point(-3, 3),
Point(0.05, 0.15, 10),
]
)
dists = surface.get_joyner_boore_distance(sites)
expected_dists = [
Point(-0.2, -0.2).distance(Point(-0.1, -0.1)),
Point(1, 1).distance(Point(0.1, 0.1)),
Point(4, 5).distance(Point(0.1, 0.1)),
Point(0.8, 0.01).distance(Point(0.1, 0.01)),
Point(0.2, -0.15).distance(Point(0.1, -0.1)),
Point(0.02, -0.12).distance(Point(0.02, -0.1)),
Point(-0.14, 0).distance(Point(-0.1, 0)),
Point(-3, 3).distance(Point(-0.1, 0.1)),
Point(0.05, 0.15).distance(Point(0.05, 0.1)),
]
self.assertTrue(numpy.allclose(dists, expected_dists, atol=0.05))
示例13: test4_site_along_strike
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test4_site_along_strike(self):
surface = self._test1to7surface()
sites = Mesh.from_points_list([Point(0.2, 0), Point(67.6, 0),
Point(90.33, 0)])
dists = surface.get_rx_distance(sites)
expected_dists = [0] * 3
self.assertTrue(numpy.allclose(dists, expected_dists))
示例14: test_from_points_list_no_depth
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test_from_points_list_no_depth(self):
points = [Point(0, 1), Point(2, 3), Point(5, 7)]
mesh = Mesh.from_points_list(points)
self.assertTrue((mesh.lons == [0, 2, 5]).all())
self.assertTrue((mesh.lats == [1, 3, 7]).all())
self.assertEqual(mesh.lons.dtype, numpy.float)
self.assertEqual(mesh.lats.dtype, numpy.float)
self.assertIs(mesh.depths, None)
示例15: test_point_above_surface
# 需要导入模块: from nhlib.geo.mesh import Mesh [as 别名]
# 或者: from nhlib.geo.mesh.Mesh import from_points_list [as 别名]
def test_point_above_surface(self):
sites = Mesh.from_points_list([Point(0, 0), Point(-0.03, 0.05, 0.5)])
res = self.surface.get_closest_points(sites)
self.assertIsInstance(res, Mesh)
aae = numpy.testing.assert_almost_equal
aae(res.lons, [0, -0.03], decimal=4)
aae(res.lats, [-0.00081824, 0.04919223])
aae(res.depths, [1.0113781, 1.50822185])