Exemplo n.º 1
0
 def _create_mesh(self):
     """
     See :meth:`nhlib.geo.surface.base.BaseSurface._create_mesh`.
     """
     llons, llats, ldepths = geodetic.intervals_between(
         self.top_left.longitude, self.top_left.latitude,
         self.top_left.depth,
         self.bottom_left.longitude, self.bottom_left.latitude,
         self.bottom_left.depth,
         self.mesh_spacing
     )
     rlons, rlats, rdepths = geodetic.intervals_between(
         self.top_right.longitude, self.top_right.latitude,
         self.top_right.depth,
         self.bottom_right.longitude, self.bottom_right.latitude,
         self.bottom_right.depth,
         self.mesh_spacing
     )
     mlons, mlats, mdepths = [], [], []
     for i in xrange(len(llons)):
         lons, lats, depths = geodetic.intervals_between(
             llons[i], llats[i], ldepths[i], rlons[i], rlats[i], rdepths[i],
             self.mesh_spacing
         )
         mlons.append(lons)
         mlats.append(lats)
         mdepths.append(depths)
     return RectangularMesh(numpy.array(mlons), numpy.array(mlats),
                            numpy.array(mdepths))
Exemplo n.º 2
0
 def _create_mesh(self):
     """
     See :meth:`nhlib.geo.surface.base.BaseSurface._create_mesh`.
     """
     llons, llats, ldepths = geodetic.intervals_between(
         self.top_left.longitude, self.top_left.latitude,
         self.top_left.depth,
         self.bottom_left.longitude, self.bottom_left.latitude,
         self.bottom_left.depth,
         self.mesh_spacing
     )
     rlons, rlats, rdepths = geodetic.intervals_between(
         self.top_right.longitude, self.top_right.latitude,
         self.top_right.depth,
         self.bottom_right.longitude, self.bottom_right.latitude,
         self.bottom_right.depth,
         self.mesh_spacing
     )
     mlons, mlats, mdepths = [], [], []
     for i in xrange(len(llons)):
         lons, lats, depths = geodetic.intervals_between(
             llons[i], llats[i], ldepths[i], rlons[i], rlats[i], rdepths[i],
             self.mesh_spacing
         )
         mlons.append(lons)
         mlats.append(lats)
         mdepths.append(depths)
     return RectangularMesh(numpy.array(mlons), numpy.array(mlats),
                            numpy.array(mdepths))
Exemplo n.º 3
0
 def test_zero_intervals(self):
     lons, lats, depths = geodetic.intervals_between(
         lon1=10, lat1=1, depth1=100, lon2=10.04, lat2=1.5, depth2=90,
         length=140
     )
     expected_lons = [10]
     expected_lats = [1]
     expected_depths = [100]
     self.assertTrue(numpy.allclose(lons, expected_lons))
     self.assertTrue(numpy.allclose(lats, expected_lats))
     self.assertTrue(numpy.allclose(depths, expected_depths))
Exemplo n.º 4
0
 def test_round_up(self):
     lons, lats, depths = geodetic.intervals_between(
         lon1=10, lat1=-4, depth1=100,
         lon2=12, lat2=4, depth2=60,
         length=350
     )
     expected_lons = [10., 10.76308634, 11.52482625, 12.28955192]
     expected_lats = [-4, -0.94915589, 2.10185625, 5.15249576]
     expected_depths = [100, 84.74555236, 69.49110472, 54.23665708]
     self.assertTrue(numpy.allclose(lons, expected_lons))
     self.assertTrue(numpy.allclose(lats, expected_lats))
     self.assertTrue(numpy.allclose(depths, expected_depths))
Exemplo n.º 5
0
 def test_round_down(self):
     lons, lats, depths = geodetic.intervals_between(
         lon1=10, lat1=-4, depth1=100,
         lon2=12, lat2=4, depth2=60,
         length=380
     )
     expected_lons = [10., 10.82836972, 11.65558943]
     expected_lats = [-4, -0.68763949, 2.62486454]
     expected_depths = [100, 83.43802828, 66.87605655]
     self.assertTrue(numpy.allclose(lons, expected_lons))
     self.assertTrue(numpy.allclose(lats, expected_lats))
     self.assertTrue(numpy.allclose(depths, expected_depths))
Exemplo n.º 6
0
 def test_zero_intervals(self):
     lons, lats, depths = geodetic.intervals_between(lon1=10,
                                                     lat1=1,
                                                     depth1=100,
                                                     lon2=10.04,
                                                     lat2=1.5,
                                                     depth2=90,
                                                     length=140)
     expected_lons = [10]
     expected_lats = [1]
     expected_depths = [100]
     self.assertTrue(numpy.allclose(lons, expected_lons))
     self.assertTrue(numpy.allclose(lats, expected_lats))
     self.assertTrue(numpy.allclose(depths, expected_depths))
Exemplo n.º 7
0
 def test_round_up(self):
     lons, lats, depths = geodetic.intervals_between(lon1=10,
                                                     lat1=-4,
                                                     depth1=100,
                                                     lon2=12,
                                                     lat2=4,
                                                     depth2=60,
                                                     length=350)
     expected_lons = [10., 10.76308634, 11.52482625, 12.28955192]
     expected_lats = [-4, -0.94915589, 2.10185625, 5.15249576]
     expected_depths = [100, 84.74555236, 69.49110472, 54.23665708]
     self.assertTrue(numpy.allclose(lons, expected_lons))
     self.assertTrue(numpy.allclose(lats, expected_lats))
     self.assertTrue(numpy.allclose(depths, expected_depths))
Exemplo n.º 8
0
 def test_round_down(self):
     lons, lats, depths = geodetic.intervals_between(lon1=10,
                                                     lat1=-4,
                                                     depth1=100,
                                                     lon2=12,
                                                     lat2=4,
                                                     depth2=60,
                                                     length=380)
     expected_lons = [10., 10.82836972, 11.65558943]
     expected_lats = [-4, -0.68763949, 2.62486454]
     expected_depths = [100, 83.43802828, 66.87605655]
     self.assertTrue(numpy.allclose(lons, expected_lons))
     self.assertTrue(numpy.allclose(lats, expected_lats))
     self.assertTrue(numpy.allclose(depths, expected_depths))
Exemplo n.º 9
0
    def equally_spaced_points(self, point, distance):
        """
        Compute the set of points equally spaced between this point
        and the given point.

        :param point:
            Destination point.
        :type point:
            Instance of :class:`Point`
        :param distance:
            Distance between points (in km).
        :type distance:
            float
        :returns:
            The list of equally spaced points.
        :rtype:
            list of :class:`Point` instances
        """
        lons, lats, depths = geodetic.intervals_between(
            self.longitude, self.latitude, self.depth, point.longitude,
            point.latitude, point.depth, distance)
        return [Point(lons[i], lats[i], depths[i]) for i in xrange(len(lons))]
Exemplo n.º 10
0
Arquivo: point.py Projeto: angri/nhlib
    def equally_spaced_points(self, point, distance):
        """
        Compute the set of points equally spaced between this point
        and the given point.

        :param point:
            Destination point.
        :type point:
            Instance of :class:`Point`
        :param distance:
            Distance between points (in km).
        :type distance:
            float
        :returns:
            The list of equally spaced points.
        :rtype:
            list of :class:`Point` instances
        """
        lons, lats, depths = geodetic.intervals_between(
            self.longitude, self.latitude, self.depth,
            point.longitude, point.latitude, point.depth,
            distance
        )
        return [Point(lons[i], lats[i], depths[i]) for i in xrange(len(lons))]