Ejemplo n.º 1
0
 def _create_mesh(self):
     """
     See
     :meth:`openquake.hazardlib.geo.surface.base.BaseQuadrilateralSurface._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))
Ejemplo n.º 2
0
 def _create_mesh(self):
     """
     See
     :meth:`openquake.hazardlib.geo.surface.base.BaseQuadrilateralSurface._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 range(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))
Ejemplo n.º 3
0
    def test_same_number_of_intervals(self):
        # these two set of points are separated by a distance of 65 km. By
        # discretizing the line every 2 km, the number of expected points for
        # both sets (after rounding) must be 34
        lons_1, lats_1, depths_1 = geodetic.intervals_between(
            lon1=132.2272081355264675, lat1=31.0552366690758639,
            depth1=7.7000000000000002,
            lon2=131.6030780890111203, lat2=31.1968015468782589,
            depth2=28.8619300397151832,
            length=2.0
        )

        lons_2, lats_2, depths_2 = geodetic.intervals_between(
            lon1=132.2218096511129488, lat1=31.0378653652772165,
            depth1=7.7000000000000002,
            lon2=131.5977943677305859, lat2=31.1794320218608547,
            depth2=28.8619300397151832,
            length=2.0
        )

        self.assertTrue(34, lons_1.shape[0])
        self.assertTrue(34, lons_2.shape[0])
        self.assertTrue(34, lats_1.shape[0])
        self.assertTrue(34, lats_2.shape[0])
        self.assertTrue(34, depths_1.shape[0])
        self.assertTrue(34, depths_2.shape[0])
Ejemplo n.º 4
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))
Ejemplo n.º 5
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]
     assert_aeq(lons, expected_lons)
     assert_aeq(lats, expected_lats)
     assert_aeq(depths, expected_depths)
Ejemplo 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]
     assert_aeq(lons, expected_lons)
     assert_aeq(lats, expected_lats)
     assert_aeq(depths, expected_depths)
Ejemplo 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))
Ejemplo 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))
Ejemplo n.º 9
0
 def test_round_up_topo(self):
     lons, lats, depths = geodetic.intervals_between(
         lon1=0, lat1=0, depth1=0,
         lon2=0, lat2=0, depth2=-3,
         length=2
     )
     expected_lons = [0, 0, 0]
     expected_lats = [0, 0, 0]
     expected_depths = [0, -2, -4]
     assert_aeq(lons, expected_lons)
     assert_aeq(lats, expected_lats)
     assert_aeq(depths, expected_depths)
Ejemplo n.º 10
0
 def test_round_up_topo(self):
     lons, lats, depths = geodetic.intervals_between(
         lon1=0, lat1=0, depth1=0,
         lon2=0, lat2=0, depth2=-3,
         length=2
     )
     expected_lons = [0, 0, 0]
     expected_lats = [0, 0, 0]
     expected_depths = [0, -2, -4]
     assert_aeq(lons, expected_lons)
     assert_aeq(lats, expected_lats)
     assert_aeq(depths, expected_depths)
Ejemplo n.º 11
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 range(len(lons))]
Ejemplo n.º 12
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 range(len(lons))]