本文整理汇总了Python中nansat.Nansat.resize方法的典型用法代码示例。如果您正苦于以下问题:Python Nansat.resize方法的具体用法?Python Nansat.resize怎么用?Python Nansat.resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nansat.Nansat
的用法示例。
在下文中一共展示了Nansat.resize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_undo
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
def test_undo(self):
n1 = Nansat(self.test_file_stere, logLevel=40)
shape1 = n1.shape()
n1.resize(10)
n1.undo()
shape2 = n1.shape()
self.assertEqual(shape1, shape2)
示例2: test_resize_resize
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
def test_resize_resize(self):
n = Nansat(self.test_file_gcps, logLevel=40)
n.resize(0.1)
n.resize(10)
tmpfilename = os.path.join(ntd.tmp_data_path,
'nansat_resize_resize.png')
n.write_figure(tmpfilename, 2, clim='hist')
self.assertEqual(type(n[1]), np.ndarray)
示例3: test_reproject_gcps_resize
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
def test_reproject_gcps_resize(self):
n1 = Nansat(self.test_file_stere, logLevel=40)
n2 = Nansat(self.test_file_gcps, logLevel=40)
n1.reproject(n2)
n1.resize(2)
tmpfilename = os.path.join(ntd.tmp_data_path,
'nansat_reproject_gcps_resize.png')
n1.write_figure(tmpfilename, 2, clim='hist')
self.assertEqual(n1.shape()[0], n2.shape()[0]*2)
self.assertEqual(n1.shape()[1], n2.shape()[1]*2)
self.assertEqual(type(n1[1]), np.ndarray)
示例4: test_resize_complex_algAverage
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
def test_resize_complex_algAverage(self):
n = Nansat(self.test_file_complex, logLevel=40)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
n.resize(0.5, eResampleAlg=-1)
self.assertTrue(len(w)==1)
self.assertTrue(issubclass(w[-1].category, UserWarning))
self.assertTrue(
'The imaginary parts of complex numbers ' \
'are lost when resampling by averaging '
in str(w[-1].message))
示例5: test_add_latlon_grids_number
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
def test_add_latlon_grids_number(self):
''' Should create figure with lon/lat gridlines given manually '''
tmpfilename = os.path.join(self.tmp_data_path, 'figure_latlon_grids_number.png')
n = Nansat(self.test_file_gcps, mapper=self.default_mapper)
n.resize(3)
b = n[1]
lon, lat = n.get_geolocation_grids()
f = Figure(b)
f.process(cmax=100, lonGrid=lon,
latGrid=lat,
lonTicks=7,
latTicks=7)
f.save(tmpfilename)
self.assertEqual(type(f), Figure)
self.assertTrue(os.path.exists(tmpfilename))
示例6: test_resize_complex_alg4
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
def test_resize_complex_alg4(self):
n = Nansat(self.test_file_complex, logLevel=40)
n.resize(0.5, eResampleAlg=4)
self.assertTrue(np.any(n[1].imag!=0))
示例7: test_resize_by_height
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
def test_resize_by_height(self):
n = Nansat(self.test_file_gcps, logLevel=40)
n.resize(height=500, eResampleAlg=1)
self.assertEqual(type(n[1]), np.ndarray)
示例8: test_resize_by_factor
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
def test_resize_by_factor(self):
n = Nansat(self.test_file_gcps, logLevel=40)
n.resize(0.5, eResampleAlg=1)
self.assertEqual(type(n[1]), np.ndarray)
示例9: savemat
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
savemat(oPath + fileName + '.mat', {'band_1': a})
# make simple indexed image from 1st band
n.write_figure(oPath + fileName + '.png')
# make RGB image from bands 6,5,2 with brightness correction
n.write_figure(oPath + fileName + '_rgb.png', bands=[6,5,2], clim='hist', ratio=0.7, logarithm=True, gamma=3)
# make indexed image with legend
n.write_figure(oPath + fileName + '_legend.png', bands='radiance_900', clim='hist', ratio=0.7, legend=True, titleString='NANSAT Tutorial', fontSize=40)
# make small preview in three steps:
# 1. Reduce size of the Nansat object ten times
# 2. Make simple grayscaled image with brightness correction
# 3. Resize back to original resolution
n.resize(0.1)
n.write_figure(oPath + fileName + '_preview.png', clim='hist', ratio=0.7, cmapName='gray')
n.resize()
# make KML file with image borders (to be opened in Googe Earth)
n.write_kml(kmlFileName=oPath + fileName + '_preview.kml')
# make image with map of the file location
n.write_map(oPath + fileName + '_map.png')
# Make image, reprojected onto map of Northern Europe in three steps:
# 1. Create Domain object. It describes the desired grid of reprojected image:
# projection, resolution, size, etc. In this case it is geographic projection;
# -10 - 30 E, 50 - 70 W; 2000 x 2000 pixels
# 2. Reproject the Nansat object
# 3. Make simple image
示例10: band
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
'info': 'copy from the 1st band array'})
# print band list
n.list_bands()
# get GDAL raster band (2nd band)
band = n.get_GDALRasterBand(bandID=2)
# Get band data and do some operations
# -- Get data from 1st band as numpy array
a = n[1]
# -- Plot the array (pyplot image is save to a PNG file)
plt.imshow(a);plt.colorbar();plt.savefig(oFileName + '01_imshow.png');plt.close()
# -- Save as Matlab file
savemat(oFileName + '01.mat', {'band_1': a})
# Resize the data to 50%
n.resize(0.5)
# make simple indexed image from 1st band with default colormap
n.write_figure(oFileName + '02.png', clim='hist')
# undo resize
n.resize()
# Resize the data to 50% using CubicSpline
n.resize_lite(0.5, eResampleAlg=3)
# make simple indexed image from 1st band with default colormap
n.write_figure(oFileName + '02CubicSpline.png', clim='hist')
# undo resize
n.resize()
# make image with map of the file location
n.write_map(oFileName + '04_map.png')
示例11: Nansat
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import resize [as 别名]
# Fill gaps: extrapolate valid values into 2 pixels border using nearest neighbour
# get distance and indices of nearest neighbours
dst, ind = nd.distance_transform_edt(np.isnan(sssOrig),
return_distances=True,
return_indices=True)
# erase row,col indeces further than 2 pixels
ind[0][dst > 2] = 0
ind[1][dst > 2] = 0
# fill gaps
sssExtra = sssOrig[tuple(ind)]
# Create a Nansat object from matrix with extrapolated product
nExtra = Nansat(domain=nOrig, array=sssExtra)
# Increase resolution
nExtra.resize(10, eResampleAlg=1)
# Get upscaled SSS
sssUpscaled = nExtra[1]
# Plot all SSS for comparison
for sss, sssName in [(sssOrig, 'sss0.png'),
(sssExtra, 'sss1.png'),
(sssUpscaled, 'sss2.png')]:
f = plt.figure(figsize=(10,5))
plt.imshow(sss, vmin=20, vmax=38, interpolation='nearest')
plt.gca().get_xaxis().set_visible(False)
plt.gca().get_yaxis().set_visible(False)
plt.savefig(sssName, bbox_inches='tight', pad_inches=0.0, dpi=300)
plt.close('all')