本文整理汇总了Python中nansat.Nansat.transform_points方法的典型用法代码示例。如果您正苦于以下问题:Python Nansat.transform_points方法的具体用法?Python Nansat.transform_points怎么用?Python Nansat.transform_points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nansat.Nansat
的用法示例。
在下文中一共展示了Nansat.transform_points方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SeaIceDriftFuncTests
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import transform_points [as 别名]
class SeaIceDriftFuncTests(unittest.TestCase):
def setUp(self):
''' Load test data '''
testDir = os.getenv('ICE_DRIFT_TEST_DATA_DIR')
if testDir is None:
sys.exit('ICE_DRIFT_TEST_DATA_DIR is not defined')
testFiles = sorted(glob.glob(os.path.join(testDir, 'S1A_*tif')))
if len(testFiles) < 2:
sys.exit('Not enough test files in %s' % testDir)
self.n1 = Nansat(testFiles[0])
self.n2 = Nansat(testFiles[1])
self.img1 = self.n1['sigma0_HV']
self.img2 = self.n2['sigma0_HV']
self.imgMin = 0.001
self.imgMax = 0.013
self.nFeatures = 10000
def test_reproject_gcp_to_stere(self):
''' Shall change projection of GCPs to stere '''
n1pro = reproject_gcp_to_stere(self.n1)
self.assertTrue(n1pro.vrt.tps)
self.assertTrue(len(n1pro.vrt.dataset.GetGCPs()) > 0)
self.assertTrue((NSR(n1pro.vrt.dataset.GetGCPProjection())
.ExportToProj4().startswith('+proj=stere')))
def test_get_uint8_image(self):
''' Shall scale image values from float (or any) to 0 - 255 [uint8] '''
imageUint8 = get_uint8_image(self.img1, self.imgMin, self.imgMax)
plt.imsave('sea_ice_drift_tests_00_imgUint8.png',
imageUint8, vmin=0, vmax=255)
self.assertEqual(imageUint8.dtype, np.uint8)
self.assertEqual(imageUint8.min(), 0)
self.assertEqual(imageUint8.max(), 255)
def test_find_key_points(self):
''' Shall find key points using default values '''
img1 = get_uint8_image(self.img1, self.imgMin, self.imgMax)
keyPoints1, descr1 = find_key_points(img1)
self.assertTrue(len(keyPoints1) > 1000)
def test_get_match_coords(self):
''' Shall find matching coordinates '''
img1 = get_uint8_image(self.img1, self.imgMin, self.imgMax)
img2 = get_uint8_image(self.img2, self.imgMin, self.imgMax)
keyPoints1, descr1 = find_key_points(img1, nFeatures=self.nFeatures)
keyPoints2, descr2 = find_key_points(img2, nFeatures=self.nFeatures)
x1, y1, x2, y2 = get_match_coords(keyPoints1, descr1,
keyPoints2, descr2)
self.assertTrue(len(keyPoints1) > len(x1))
self.assertTrue(len(keyPoints2) > len(x2))
def test_get_displacement_km(self):
''' Shall find matching coordinates and plot quiver in lon/lat'''
img1 = get_uint8_image(self.img1, self.imgMin, self.imgMax)
img2 = get_uint8_image(self.img2, self.imgMin, self.imgMax)
keyPoints1, descr1 = find_key_points(img1, nFeatures=self.nFeatures)
keyPoints2, descr2 = find_key_points(img2, nFeatures=self.nFeatures)
x1, y1, x2, y2 = get_match_coords(keyPoints1, descr1,
keyPoints2, descr2)
u, v = get_displacement_km(self.n1, x1, y1, self.n2, x2, y2)
lon1, lat1 = self.n1.transform_points(x1, y1)
plt.quiver(lon1, lat1, u, v)
plt.savefig('sea_ice_drift_tests_01_quiver_lonlat.png')
plt.close('all')
self.assertTrue(len(u) == len(x1))
def test_get_displacement_pix(self):
''' Shall find matching coordinates and plot quiver in pixel/line'''
img1 = get_uint8_image(self.img1, self.imgMin, self.imgMax)
img2 = get_uint8_image(self.img2, self.imgMin, self.imgMax)
keyPoints1, descr1 = find_key_points(img1, nFeatures=self.nFeatures)
keyPoints2, descr2 = find_key_points(img2, nFeatures=self.nFeatures)
x1, y1, x2, y2 = get_match_coords(keyPoints1, descr1,
keyPoints2, descr2)
u, v = get_displacement_pix(self.n1, x1, y1, self.n2, x2, y2)
plt.quiver(x1, y1, u, v)
plt.savefig('sea_ice_drift_tests_02_quiver_pixlin.png')
plt.close('all')
self.assertTrue(len(u) == len(x1))
def test_domain_filter(self):
''' Shall leave keypoints from second image withn domain of the first '''
img1 = get_uint8_image(self.img1, self.imgMin, self.imgMax)
img2 = get_uint8_image(self.img2, self.imgMin, self.imgMax)
keyPoints1, descr1 = find_key_points(img1, nFeatures=self.nFeatures)
keyPoints2, descr2 = find_key_points(img2, nFeatures=self.nFeatures)
keyPoints2f, descr2f = domain_filter(self.n2, keyPoints2, descr2,
self.n1, domainMargin=100)
# plot dots
cols1 = [kp.pt[0] for kp in keyPoints1]
rows1 = [kp.pt[1] for kp in keyPoints1]
lon1, lat1 = self.n1.transform_points(cols1, rows1, 0)
#.........这里部分代码省略.........