• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mesh.Mesh类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_nine_positions

    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))
开发者ID:pslh,项目名称:nhlib,代码行数:31,代码来源:planar_test.py


示例2: _test

 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)
开发者ID:pslh,项目名称:nhlib,代码行数:7,代码来源:mesh_test.py


示例3: test_many_points

 def test_many_points(self):
     lons = numpy.array([0.7, 0.6, 0.4, 0.6, 0.3, 0.9, 0.5, 0.4])
     lats = numpy.array([0.8, 0.5, 0.2, 0.7, 0.2, 0.4, 0.9, 0.4])
     mesh = Mesh(lons, lats, None)
     polygon = mesh.get_convex_hull()
     elons = [0.4, 0.3, 0.5, 0.7, 0.9]
     elats = [0.2, 0.2, 0.9, 0.8, 0.4]
     numpy.testing.assert_allclose(polygon.lons, elons)
     numpy.testing.assert_allclose(polygon.lats, elats)
开发者ID:pslh,项目名称:nhlib,代码行数:9,代码来源:mesh_test.py


示例4: test_two_points

 def test_two_points(self):
     mesh = Mesh(numpy.array([-10., -11.]), numpy.array([-12., -13.]), None)
     polygon = mesh.get_convex_hull()
     self.assertIsInstance(polygon, Polygon)
     elons = [-10.99996704, -11.0000323, -11.00003296, -10.00003295,
              -9.99996795, -9.99996705]
     elats = [-13.00003147, -13.00003212, -12.99996853, -11.99996865,
              -11.99996776, -12.00003135]
     numpy.testing.assert_allclose(polygon.lons, elons)
     numpy.testing.assert_allclose(polygon.lats, elats)
开发者ID:pslh,项目名称:nhlib,代码行数:10,代码来源:mesh_test.py


示例5: test

 def test(self):
     mesh = Mesh(numpy.array([0., 1., 2., 3.]), numpy.zeros(4), None)
     matrix = mesh.get_distance_matrix()
     aaae = numpy.testing.assert_array_almost_equal
     aaae(matrix[0], [[0, 111.2, 222.4, 333.6]], decimal=1)
     aaae(matrix[1], [[111.2, 0, 111.2, 222.4]], decimal=1)
     aaae(matrix[2], [[222.4, 111.2, 0, 111.2]], decimal=1)
     aaae(matrix[3], [[333.6, 222.4, 111.2, 0]], decimal=1)
     for i in xrange(4):
         for j in xrange(i, 4):
             self.assertEqual(matrix[i, j], matrix[j, i])
开发者ID:gvallarelli,项目名称:nhlib,代码行数:11,代码来源:mesh_test.py


示例6: test_point_on_the_border

 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))
开发者ID:GEMStudents,项目名称:nhlib,代码行数:7,代码来源:base_surface_test.py


示例7: test_point_inside

 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))
开发者ID:GEMStudents,项目名称:nhlib,代码行数:7,代码来源:base_surface_test.py


示例8: test_left_or_right_edge_is_closest

 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])
开发者ID:angri,项目名称:nhlib,代码行数:7,代码来源:planar_test.py


示例9: test_top_or_bottom_edge_is_closest

 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)
开发者ID:angri,项目名称:nhlib,代码行数:7,代码来源:planar_test.py


示例10: test_point_outside

 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))
开发者ID:angri,项目名称:nhlib,代码行数:29,代码来源:planar_test.py


示例11: test_point_on_the_border

 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))
开发者ID:angri,项目名称:nhlib,代码行数:7,代码来源:planar_test.py


示例12: test4_site_along_strike

 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))
开发者ID:pslh,项目名称:nhlib,代码行数:7,代码来源:planar_test.py


示例13: test_one_point

 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)
开发者ID:pslh,项目名称:nhlib,代码行数:7,代码来源:mesh_test.py


示例14: test_simple

    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,代码行数:25,代码来源:mesh_test.py


示例15: test8_strike_of_45_degrees

 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)
开发者ID:pslh,项目名称:nhlib,代码行数:7,代码来源:planar_test.py


示例16: test5_site_opposite_to_strike_direction

 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))
开发者ID:pslh,项目名称:nhlib,代码行数:7,代码来源:planar_test.py


示例17: test_point_above_surface

 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])
开发者ID:gvallarelli,项目名称:nhlib,代码行数:8,代码来源:planar_test.py


示例18: test_from_points_list_no_depth

 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)
开发者ID:pslh,项目名称:nhlib,代码行数:8,代码来源:mesh_test.py


示例19: test_mesh_of_one_point

 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,代码行数:9,代码来源:mesh_test.py


示例20: test_corner_is_closest

 def test_corner_is_closest(self):
     sites = Mesh.from_points_list(
         [Point(-0.11, 0.11), Point(0.14, -0.12, 10), Point(0.3, 0.2, 0.5), Point(-0.6, -0.6, 0.3)]
     )
     res = self.surface.get_closest_points(sites)
     aae = numpy.testing.assert_almost_equal
     aae(res.lons, [-0.1, 0.1, 0.1, -0.1], decimal=4)
     aae(res.lats, [0.1, -0.1, 0.1, -0.1])
     aae(res.depths, [2, 0, 2, 0], decimal=5)
开发者ID:angri,项目名称:nhlib,代码行数:9,代码来源:planar_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mesh.RectangularMesh类代码示例发布时间:2022-05-27
下一篇:
Python ngs.NGS类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap