In [1]:
import numpy as np
import matplotlib.pyplot as plt

from sea_ice_drift import SeaIceDrift

%matplotlib inline

In [3]:
# set names of files
f1 = 'S1B_EW_GRDM_1SDH_20200123T120618.tif'
f2 = 'S1B_EW_GRDM_1SDH_20200125T114955.tif'
# create SeaIceDrift object
sid = SeaIceDrift(f1, f2)


VMIN:  -22.70601463317871
VMAX:  -12.372260780334472
VMIN:  -23.11758918762207
VMAX:  -12.701321620941169

In [4]:
# run Feature Tracking
uft, vft, lon1ft, lat1ft, lon2ft, lat2ft = sid.get_drift_FT()


ORB detector initiated
Key points found: 24255
ORB detector initiated
Key points found: 23285
Domain filter: 24255 -> 24183
Domain filter: 23285 -> 22694
Keypoints matched 3.8641562461853027
Ratio test 0.700000 found 2301 keypoints
MaxDrift filter: 2301 -> 2301
LSTSQ filter: 2301 -> 2299

In [5]:
# plot identified and matched keypoints
plt.plot(lon1ft, lat1ft, '.')
plt.plot(lon2ft, lat2ft, '.')


Out[5]:
[<matplotlib.lines.Line2D at 0x7f4c8fe2df90>]

In [6]:
# plot ice drift vectors calculated from the keypoints
plt.quiver(lon1ft, lat1ft, uft, vft, color='r',
           angles='xy', scale_units='xy', scale=1)


Out[6]:
<matplotlib.quiver.Quiver at 0x7f4c8fda4e90>

In [7]:
# create longitude and latitude grids at satellite projection
step = 10
lon1pm, lat1pm = sid.n1.get_geolocation_grids(stepSize=step)
plt.subplot(1,2,1);plt.imshow(lon1pm);plt.colorbar(shrink=0.5);plt.title('Longitude grid')
plt.subplot(1,2,2);plt.imshow(lat1pm);plt.colorbar(shrink=0.5);plt.title('Latitude grid')


Out[7]:
Text(0.5, 1.0, 'Latitude grid')

In [8]:
# run pattern matching
upm, vpm, apm, rpm, hpm, lon2pm, lat2pm = sid.get_drift_PM(
                                    lon1pm, lat1pm,
                                    lon1ft, lat1ft,
                                    lon2ft, lat2ft)


 Pattern matching - OK! (  1 sec)

In [9]:
# plot results of pattern matching

# find cells with correlation over 0.4
gpi = hpm*rpm > 4

# convert lon/lat into cartesian coordinates (only valid)
x1pm, y1pm = sid.n1.transform_points(lon1pm[gpi], lat1pm[gpi], DstToSrc=1)
x2pm, y2pm = sid.n1.transform_points(lon2pm[gpi], lat2pm[gpi], DstToSrc=1)

# compute ice drift speed in cartesian coordinates
dx_pm = x2pm - x1pm
dy_pm = y2pm - y1pm

# plot vectors of sea ice drift from Feature Tracking, color by MCC
plt.figure(figsize=(10,10))
plt.imshow(sid.n1[1], cmap='gray')
plt.quiver(x1pm, y1pm, dx_pm, dy_pm, rpm[gpi],
           angles='xy', scale_units='xy', scale=0.2, cmap='jet')
plt.colorbar(shrink=0.7)


/opt/conda/lib/python3.7/site-packages/ipykernel_launcher.py:4: RuntimeWarning: invalid value encountered in greater
  after removing the cwd from sys.path.
Out[9]:
<matplotlib.colorbar.Colorbar at 0x7f4c8f7a7fd0>

In [ ]: