Skip to content

Commit

Permalink
tests: fill_gpi; examples: scale for quiver
Browse files Browse the repository at this point in the history
  • Loading branch information
akorosov committed Aug 3, 2017
1 parent 28c4f89 commit a056573
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
Binary file modified examples/sea_ice_drift_FT_img1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/sea_ice_drift_PM_img2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,27 @@
# plot the projected image from the first SAR scene
plt.imshow(s01, extent=[-3, 2, 86.4, 86.8], cmap='gray', aspect=12)
# plot vectors of sea ice drift from Feature Tracking
plt.quiver(lon1ft, lat1ft, uft, vft, color='r', scale=0.7)
plt.quiver(lon1ft, lat1ft, uft, vft, color='r',
angles='xy', scale_units='xy', scale=0.5)
# plot border of the second SAR scene
plt.plot(lon2, lat2, '.-r')
# set X/Y limits of figure
plt.xlim([-3, 2])
plt.ylim([86.4, 86.8])
plt.savefig('sea_ice_drift_FT_img1.png', dpi=75, bbox_inches='tight', pad_inches=0)
plt.savefig('sea_ice_drift_FT_img1.png', dpi=150, bbox_inches='tight', pad_inches=0)
plt.close('all')

# plot the projected image from the second SAR scene
plt.imshow(s02, extent=[-3, 2, 86.4, 86.8], cmap='gray', aspect=12)
# filter only high quality pixels
gpi = rpm > 0.4
# plot vectors of sea ice drift from Feature Tracking, color by MCC
plt.quiver(lon1pm[gpi], lat1pm[gpi], upm[gpi], vpm[gpi], rpm[gpi], scale=0.7)
plt.quiver(lon1pm[gpi], lat1pm[gpi], upm[gpi], vpm[gpi], rpm[gpi],
angles='xy', scale_units='xy', scale=0.5)
# plot border of the first SAR scene
plt.plot(lon1, lat1, '.-r')
# set X/Y limits of figure
plt.xlim([-3, 2])
plt.ylim([86.4, 86.8])
plt.savefig('sea_ice_drift_PM_img2.png', dpi=75, bbox_inches='tight', pad_inches=0)
plt.savefig('sea_ice_drift_PM_img2.png', dpi=150, bbox_inches='tight', pad_inches=0)
plt.close('all')
2 changes: 1 addition & 1 deletion sea_ice_drift/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def get_drift_vectors(n1, x1, y1, n2, x2, y2, nsr=NSR(), **kwargs):
lon2, lat2 = n2.transform_points(x2, y2)

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

# find displacement in needed units
x1, y1 = d.transform_points(lon1, lat1, 1)
Expand Down
8 changes: 5 additions & 3 deletions sea_ice_drift/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_get_drift_vectors(self):
def test_fill_gpi(self):
a = np.array([[1,2,3],[1,2,3],[1,2,3]])
gpi = (a > 2)
b = _fill_gpi(a.shape, a[gpi].flatten(), gpi.flatten())
b = _fill_gpi(a.shape, gpi.flatten(), a[gpi].flatten())
self.assertEqual(a.shape, b.shape)


Expand Down Expand Up @@ -340,7 +340,8 @@ def test_integrated(self):
s02 = sid.n2['sigma0_HV']

plt.imshow(s01, extent=[-3, 2, 86.4, 86.8], cmap='gray', aspect=12)
plt.quiver(lon1ft, lat1ft, uft, vft, color='r')
plt.quiver(lon1ft, lat1ft, uft, vft, color='r',
angles='xy', scale_units='xy', scale=0.5)
plt.plot(lon2, lat2, '.-r')
plt.xlim([-3, 2])
plt.ylim([86.4, 86.8])
Expand All @@ -350,7 +351,8 @@ def test_integrated(self):

plt.imshow(s02, extent=[-3, 2, 86.4, 86.8], cmap='gray', aspect=12)
gpi = rpm > 0.4
plt.quiver(lon1pm[gpi], lat1pm[gpi], upm[gpi], vpm[gpi], rpm[gpi])
plt.quiver(lon1pm[gpi], lat1pm[gpi], upm[gpi], vpm[gpi], rpm[gpi],
angles='xy', scale_units='xy', scale=0.5)
plt.plot(lon1, lat1, '.-r')
plt.xlim([-3, 2])
plt.ylim([86.4, 86.8])
Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
from setuptools import setup

import_error_msg = "Sea Ice Drift requires %s, which should be installed separately"

setup(
name = "sea_ice_drift",
version = "0.4",
version = "0.5",
author = ('Anton Korosov', 'Stefan Muckenhuber'),
author_email = "anton.korosov@nersc.no",
description = ("Drift of sea ice from satellite data using feature tracking and pattern matching methods"),
long_description = ("Drift of sea ice from satellite data using feature tracking and pattern matching methods"),
license = "GNU General Public License v3",
keywords = "sar, feature tracking, pattern matching, ice drift",
url = "https://github.com/nansencenter/sea_ice_drift",
download_url='https://github.com/nansencenter/sea_ice_drift/archive/v0.4.tar.gz',
download_url='https://github.com/nansencenter/sea_ice_drift/archive/v0.5.tar.gz',
packages=['sea_ice_drift'],
test_suite="sea_ice_drift.tests",
classifiers=[
Expand Down

0 comments on commit a056573

Please sign in to comment.