Exemplo n.º 1
0
def get_drift_vectors(n1, x1, y1, n2, x2, y2, nsr=NSR(), **kwargs):
    ''' Find ice drift speed m/s
    Parameters
    ----------
        n1 : First Nansat object
        x1 : 1D vector - X coordinates of keypoints on image 1
        y1 : 1D vector - Y coordinates of keypoints on image 1
        n2 : Second Nansat object
        x1 : 1D vector - X coordinates of keypoints on image 2
        y1 : 1D vector - Y coordinates of keypoints on image 2
        nsr: Nansat.NSR(), projection that defines the grid
    Returns
    -------
        u : 1D vector - eastward ice drift speed
        v : 1D vector - northward ice drift speed
        lon1 : 1D vector - longitudes of source points
        lat1 : 1D vector - latitudes of source points
        lon2 : 1D vector - longitudes of destination points
        lat2 : 1D vector - latitudes of destination points
    '''
    # convert x,y to lon, lat
    lon1, lat1 = n1.transform_points(x1, y1)
    lon2, lat2 = n2.transform_points(x2, y2)

    # create domain that converts lon/lat to units of the projection
    d = Domain(nsr, '-te -10 -10 10 10 -tr 1 1')

    # find displacement in needed units
    x1, y1 = d.transform_points(lon1, lat1, 1)
    x2, y2 = d.transform_points(lon2, lat2, 1)

    return x2 - x1, y1 - y2, lon1, lat1, lon2, lat2
Exemplo n.º 2
0
def get_displacement_km(n1, x1, y1, n2, x2, y2, ll2km='domain'):
    ''' Find displacement in kilometers using Domain'''
    lon1, lat1 = n1.transform_points(x1, y1)
    lon2, lat2 = n2.transform_points(x2, y2)

    d = Domain(
        '+proj=stere +lon_0=%f +lat_0=%f +no_defs' %
        (lon1.mean(), lat1.mean()),
        '-te -100000 -100000 100000 100000 -tr 1000 1000')

    x1d, y1d = d.transform_points(lon1, lat1, 1)
    x2d, y2d = d.transform_points(lon2, lat2, 1)

    return x2d - x1d, y1d - y2d
Exemplo n.º 3
0
    def test_transform_points_inverse(self):
        d = Domain(4326, "-te 25 70 35 72 -ts 500 500")
        x, y = d.transform_points([25, 26, 27], [70, 71, 72], 1)

        self.assertTrue(all(np.round(x) == [0, 50, 100]))
        self.assertTrue(all(np.round(y) == [500, 250, 0]))
Exemplo n.º 4
0
    def test_transform_points(self):
        d = Domain(4326, "-te 25 70 35 72 -ts 500 500")
        lon, lat = d.transform_points([1, 2, 3], [1, 2, 3])

        self.assertEqual(type(lon), np.ndarray)
        self.assertEqual(type(lat), np.ndarray)
Exemplo n.º 5
0
    def test_transform_points_inverse(self):
        d = Domain(4326, "-te 25 70 35 72 -ts 500 500")
        x, y = d.transform_points([25, 26, 27], [70, 71, 72], 1)

        self.assertTrue(all(np.round(x) == [0, 50, 100]))
        self.assertTrue(all(np.round(y) == [500, 250, 0]))
Exemplo n.º 6
0
    def test_transform_points(self):
        d = Domain(4326, "-te 25 70 35 72 -ts 500 500")
        lon, lat = d.transform_points([1, 2, 3], [1, 2, 3])

        self.assertEqual(type(lon), np.ndarray)
        self.assertEqual(type(lat), np.ndarray)