Example #1
0
    def intermediate_points(self, numpoints=101, connection="greatcircle"):
        """
        Compute intermediate points between the waypoints.

        See mss_util.path_points() for additional arguments.

        Returns lats, lons.
        """
        return path_points([wp.lat for wp in self.waypoints],
                           [wp.lon for wp in self.waypoints],
                           times=[wp.utc_time for wp in self.waypoints],
                           numpoints=numpoints,
                           connection=connection)
Example #2
0
 def _set_vertical_section_path(self,
                                vsec_path,
                                vsec_numpoints=101,
                                vsec_path_connection='linear'):
     """
     """
     logging.debug("computing %i interpolation points, connection: %s",
                   vsec_numpoints, vsec_path_connection)
     self.lats, self.lons = coordinate.path_points(
         [_x[0] for _x in vsec_path], [_x[1] for _x in vsec_path],
         numpoints=vsec_numpoints,
         connection=vsec_path_connection)
     self.lats, self.lons = np.asarray(self.lats), np.asarray(self.lons)
     self.vsec_path = vsec_path
     self.vsec_numpoints = vsec_numpoints
     self.vsec_path_connection = vsec_path_connection
Example #3
0
 def _set_linear_section_path(self,
                              lsec_path,
                              lsec_numpoints=101,
                              lsec_path_connection='linear'):
     """
     """
     logging.debug("computing %i interpolation points, connection: %s",
                   lsec_numpoints, lsec_path_connection)
     self.lats, self.lons, self.alts = coordinate.path_points(
         [_x[0] for _x in lsec_path], [_x[1] for _x in lsec_path],
         alts=[_x[2] for _x in lsec_path],
         numpoints=lsec_numpoints,
         connection=lsec_path_connection)
     self.lats, self.lons, self.alts = [
         np.asarray(_x) for _x in (self.lats, self.lons, self.alts)
     ]
     self.lsec_path = lsec_path
     self.lsec_numpoints = lsec_numpoints
     self.lsec_path_connection = lsec_path_connection
Example #4
0
def test_pathpoints():
    lats = [0, 10]
    lons = [0, 10]
    times = [
        datetime.datetime(2012, 7, 1, 10, 30),
        datetime.datetime(2012, 7, 1, 10, 40)
    ]
    ref = [lats, lons, times]
    result = coordinate.path_points(lats,
                                    lons,
                                    100,
                                    times=times,
                                    connection="linear")
    assert all(len(_x) == 100 for _x in result)
    for i in range(3):
        assert pytest.approx(result[i][0]) == ref[i][0]
        assert pytest.approx(result[i][-1]) == ref[i][-1]

    result = coordinate.path_points(lats,
                                    lons,
                                    100,
                                    times=times,
                                    connection="greatcircle")
    assert all(len(_x) == 100 for _x in result)
    for i in range(3):
        assert pytest.approx(result[i][0]) == ref[i][0]
        assert pytest.approx(result[i][-1]) == ref[i][-1]

    result = coordinate.path_points(lats,
                                    lons,
                                    200,
                                    times=times,
                                    connection="linear")
    assert all(len(_x) == 200 for _x in result)
    for i in range(3):
        assert pytest.approx(result[i][0]) == ref[i][0]
        assert pytest.approx(result[i][-1]) == ref[i][-1]

    result = coordinate.path_points(lats,
                                    lons,
                                    200,
                                    times=times,
                                    connection="greatcircle")
    assert all(len(_x) == 200 for _x in result)
    for i in range(3):
        assert pytest.approx(result[i][0]) == ref[i][0]
        assert pytest.approx(result[i][-1]) == ref[i][-1]

    lats = [0, 10, -20]
    lons = [0, 10, 20]
    times = [
        datetime.datetime(2012, 7, 1, 10, 30),
        datetime.datetime(2012, 7, 1, 10, 40),
        datetime.datetime(2012, 7, 1, 10, 50)
    ]
    ref = [lats, lons, times]

    result = coordinate.path_points(lats,
                                    lons,
                                    100,
                                    times=times,
                                    connection="linear")
    assert all([len(_x) == 100 for _x in result])
    for i in range(3):
        assert pytest.approx(result[i][0]) == ref[i][0]
        assert pytest.approx(result[i][-1]) == ref[i][-1]

    result = coordinate.path_points(lats,
                                    lons,
                                    100,
                                    times=times,
                                    connection="greatcircle")
    assert all(len(_x) == 100 for _x in result)
    for i in range(3):
        assert pytest.approx(result[i][0]) == ref[i][0]
        assert pytest.approx(result[i][-1]) == ref[i][-1]