当前位置: 首页>>代码示例>>Python>>正文


Python Nansat.write_figure方法代码示例

本文整理汇总了Python中nansat.Nansat.write_figure方法的典型用法代码示例。如果您正苦于以下问题:Python Nansat.write_figure方法的具体用法?Python Nansat.write_figure怎么用?Python Nansat.write_figure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nansat.Nansat的用法示例。


在下文中一共展示了Nansat.write_figure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_write_figure_clim

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
    def test_write_figure_clim(self):
        n1 = Nansat(self.test_file_stere, logLevel=40)
        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'nansat_write_figure_legend.png')
        n1.write_figure(tmpfilename, 3, clim='hist', legend=True)

        self.assertTrue(os.path.exists(tmpfilename))
开发者ID:WYC19910220,项目名称:nansat,代码行数:9,代码来源:test_nansat.py

示例2: test_write_figure_band

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
    def test_write_figure_band(self):
        n1 = Nansat(self.test_file_stere, logLevel=40)
        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'nansat_write_figure_band.png')
        n1.write_figure(tmpfilename, 2)

        self.assertTrue(os.path.exists(tmpfilename))
开发者ID:WYC19910220,项目名称:nansat,代码行数:9,代码来源:test_nansat.py

示例3: test_resize_resize

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [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)
开发者ID:WYC19910220,项目名称:nansat,代码行数:11,代码来源:test_nansat.py

示例4: test_write_fig_tif

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
 def test_write_fig_tif(self):
     n = Nansat(self.test_file_arctic)
     tmpfilename = os.path.join(ntd.tmp_data_path,
                                'nansat_write_fig_tif.tif')
     n.write_figure(tmpfilename)
     nn = Nansat(tmpfilename)
     # Asserts that the basic georeference (corners in this case) is still
     # present after opening the image
     self.assertTrue(np.allclose(n.get_corners(), nn.get_corners()))
开发者ID:,项目名称:,代码行数:11,代码来源:

示例5: test_reproject_gcps

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
    def test_reproject_gcps(self):
        n1 = Nansat(self.test_file_stere, logLevel=40)
        n2 = Nansat(self.test_file_gcps, logLevel=40)
        n1.reproject(n2)
        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'nansat_reproject_gcps.png')
        n1.write_figure(tmpfilename, 2, clim='hist')

        self.assertEqual(n1.shape(), n2.shape())
        self.assertEqual(type(n1[1]), np.ndarray)
开发者ID:WYC19910220,项目名称:nansat,代码行数:12,代码来源:test_nansat.py

示例6: test_reproject_domain

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
    def test_reproject_domain(self):
        n = Nansat(self.test_file_gcps, logLevel=40)
        d = Domain(4326, "-te 27 70 30 72 -ts 500 500")
        n.reproject(d)
        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'nansat_reproject_domain.png')
        n.write_figure(tmpfilename, 2, clim='hist')

        self.assertEqual(n.shape(), (500, 500))
        self.assertEqual(type(n[1]), np.ndarray)
开发者ID:WYC19910220,项目名称:nansat,代码行数:12,代码来源:test_nansat.py

示例7: boreali_processing

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
def boreali_processing(obj,  final_path):
    wavelen = [412, 443, 469, 488, 531, 547, 555, 645, 667, 678]
    cpa_limits = [0.01, 2,
                  0.01, 1,
                  0.01, 1, 10]
    b = Boreali('michigan', wavelen)

    n = Nansat(obj)
    dom = Domain('+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs', '-lle -86.3 44.6 -85.2 45.3 -ts 300 200')
    n.reproject(dom)
    theta = numpy.zeros_like(n[2])
    custom_n = Nansat(domain=n)
    band_rrs_numbers = list(map(lambda x: n._get_band_number('Rrs_' + str(x)),
                                wavelen))

    for index in range(0, len(wavelen)):
        # Преобразуем в Rrsw
        rrsw = n[band_rrs_numbers[index]] / (0.52 + 1.7 * n[band_rrs_numbers[index]])
        custom_n.add_band(rrsw, parameters={'name': 'Rrsw_' + str(wavelen[index]),
                                            'units': 'sr-1',
                                            'wavelength': wavelen[index]})

    custom_n = create_mask(custom_n)
    cpa = b.process(custom_n, cpa_limits, mask=custom_n['mask'], theta=theta, threads=4)

    custom_n.add_band(array=cpa[0], parameters={'name': 'chl',
                                                'long_name': 'Chlorophyl-a',
                                                'units': 'mg m-3'})
    custom_n.add_band(array=cpa[1], parameters={'name': 'tsm',
                                                'long_name': 'Total suspended matter',
                                                'units': 'g m-3'})
    custom_n.add_band(array=cpa[2], parameters={'name': 'doc',
                                                'long_name': 'Dissolved organic carbon',
                                                'units': 'gC m-3'})
    custom_n.add_band(array=cpa[3], parameters={'name': 'mse',
                                                'long_name': 'Root Mean Square Error',
                                                'units': 'sr-1'})
    custom_n.add_band(array=cpa[4], parameters={'name': 'mask',
                                                'long_name': 'L2 Boreali mask',
                                                'units': '1'})

    custom_n.export(final_path + obj.split('/')[-1] + 'cpa_deep.nc')

    fig_params = {'legend': True,
                  'LEGEND_HEIGHT': 0.5,
                  'NAME_LOCATION_Y': 0,
                  'mask_array': cpa[4],
                  'mask_lut': {1: [255, 255, 255], 2: [128, 128, 128], 4: [200, 200, 255]}}
    custom_n.write_figure(final_path + obj.split('/')[-1] + 'chl_deep.png', 'chl', clim=[0, 1.], **fig_params)
    custom_n.write_figure(final_path + obj.split('/')[-1] + 'tsm_deep.png', 'tsm', clim=[0, 1.], **fig_params)
    custom_n.write_figure(final_path + obj.split('/')[-1] + 'doc_deep.png', 'doc', clim=[0, .2], **fig_params)
    custom_n.write_figure(final_path + obj.split('/')[-1] + 'mse_deep.png', 'mse', clim=[1e-5, 1e-2], logarithm=True, **fig_params)
    n.write_figure(final_path + obj.split('/')[-1] + 'rgb_deep.png',
                   [16, 14, 6],
                   clim=[[0, 0, 0], [0.006, 0.04, 0.024]],
                   mask_array=cpa[4],
                   mask_lut={2: [128, 128, 128]})
开发者ID:korvinos,项目名称:work,代码行数:59,代码来源:custrepr.py

示例8: test_write_fig_wrong_type_filename

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
 def test_write_fig_wrong_type_filename(self):
     n = Nansat(self.test_file_arctic)
     with self.assertRaises(OptionError):
         n.write_figure(1.2)
     with self.assertRaises(OptionError):
         n.write_figure(['filename'])
     with self.assertRaises(OptionError):
         n.write_figure({'name': 'filename'})
开发者ID:,项目名称:,代码行数:10,代码来源:

示例9: array

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
# 5. Write image
n.reproject() # 1.
lons, lats = n.get_corners() # 2.
pxlRes = distancelib.getPixelResolution(array(lats), array(lons), n[1])
pxlRes = array(pxlRes)*360/40000 # great circle distance
srsString = "+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs"
#~ extentString = '-lle %f %f %f %f -ts 3000 3000' % (min(lons), min(lats), max(lons), max(lats))
extentString = '-lle %f %f %f %f -tr %f %f' % (min(lons), min(lats), \
                max(lons), max(lats), pxlRes[1], pxlRes[0])
d = Domain(srs=srsString, ext=extentString) # 3.
print d
n.reproject(d) # 4.

# get array with watermask (landmask) b 
# it must be done after reprojection!
# 1. Get Nansat object with watermask
# 2. Get array from Nansat object. 0 - land, 1 - water
#wm = n.watermask(mod44path='/media/magDesk/media/SOLabNFS/store/auxdata/coastline/mod44w/')
wm = n.watermask(mod44path='/media/data/data/auxdata/coastline/mod44w/')
wmArray = wm[1]

figureName = oPath + fileName + '_proj.png'
n.write_figure(fileName=figureName, clim=[3,133], \
               mask_array=wmArray, mask_lut={0: [204, 153, 25]}) # 5.

#~ # make KML file with image borders (to be opened in Googe Earth)
#~ n.write_kml(kmlFileName=oPath + fileName + '_preview.kml')

# make KML image file with image borders (to be opened in Googe Earth)
n.write_image_kml(kmlFileName=oPath + fileName + '.kml', kmlFigureName=figureName)
开发者ID:lelou6666,项目名称:PySOL,代码行数:32,代码来源:nansatExampleNetCDF.py

示例10: testio

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
# Set input and output file names
iPath, oPath = testio()
iFileName = os.path.join(iPath, 'gcps.tif')
oFileName = os.path.join(oPath, 'tutor_')

# Open an input satellite image with Nansat
n = Nansat(iFileName)

# List bands and georeference of the object
print n

# Write picture with map of the file location
n.write_map(oFileName + 'map.png')

# Write indexed picture with data from the first band
n.write_figure(oFileName + '.png', clim='hist')

# Reproject input image onto map of Norwegian Coast
# 1. Create domain describing the desired map
# 2. Transform the original satellite image
# 3. Write the transfromed image into RGB picture
dLatlong = Domain("+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs",
                  "-te 27 70.2 31 71.5 -ts 500 500")
n.reproject(dLatlong)
n.write_figure(oFileName + 'pro.png', bands=[1, 2, 3], clim=[0, 100])

# Export projected satelite image into NetCDF format
n.export(oFileName + '.nc')

# Collect values from interactively drawn transect
# 1. draw transect interactively
开发者ID:yuxiaobu,项目名称:nansat,代码行数:33,代码来源:tutorial.py

示例11: process_boreali

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
    def process_boreali(self, opts):
        '''Advanced processing of MODIS images:
        retrieve chl, tsm, doc with boreali
        generate images
        '''

        pnDefaults = {
            'lmchl': [0, 5, False],
            'lmtsm': [0, 3, False],
            'lmdoc': [0, 2, False],
            'lmmse': [1e-8, 1e-5, True]}

        borMinMax = [[pnDefaults['lmchl'][0], pnDefaults['lmchl'][1]],
                     [pnDefaults['lmtsm'][0], pnDefaults['lmtsm'][1]],
                     [pnDefaults['lmdoc'][0], pnDefaults['lmdoc'][1]]]

        dtsDomain = Domain(opts['srs'], opts['ext'])

        fileName = self.get_metadata('name')
        oBaseFileName = self.get_metadata('name').strip('"').strip("'")
        ncName = opts['oDir'] + oBaseFileName + '.nc'
        print ncName
        prodFileNames = {}
        for pn in opts['prods']:
            prodFileNames[pn] = '%s/%s.%s.png' % (opts['oDir'], oBaseFileName, pn)

        if os.path.exists(ncName):
            print '%s already exist!' % ncName
        else:
            # good bits for NRT
            #self.add_mask(cloudBits=[1, 4, 5, 6, 9, 10, 13, 15, 20, 21, 23, 28, 29, 30])

            try:
                self.reproject(dtsDomain)
            except:
                print 'Cannot reproject %s. Skipping' % fileName
                return 1
            else:
                Rrsw_412 = self['Rrsw_412']
                if Rrsw_412 is None:
                    return 1
                # process input with BOREALI
                b = Boreali(model='northsea', zone='northsea')
                cImg = b.process_lm(self, wavelen=[412, 443, 488, 531, 555, 667],
                                          start=opts['start'],
                                          minmax=borMinMax)

                # generate Nansat with results
                img2 = Nansat(domain=self)
                for i, pn in enumerate(opts['prods']):
                    img2.add_band(array=cImg[i, :, :], parameters={'name': pn})
                img2.add_band(array=self['mask'], parameters={'name': 'mask'})

                # export results into NC-file
                img2.export(ncName)

                # write images with concentrations
                for pn in opts['prods']:
                    pnd = pnDefaults[pn]
                    img2.write_figure(prodFileNames[pn], pn, clim=[pnd[0], pnd[1]], legend=True, logarithm=pnd[2])

        return 0
开发者ID:nansencenter,项目名称:nansen-cloud,代码行数:64,代码来源:modis_l2_image.py

示例12: main

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]

#.........这里部分代码省略.........
            # try to create Nansat object
            try:
                n = Nansat(iPath + dirName + '/' + fileName, mapperName='asar', logLevel=27)
            except Exception as e:
                print "Failed to create Nansat object:"
                print str(e)
                os.rmdir(oPath + fileName[0:27] + '/' )
                continue
                

            #~ Get the bands
            raw_counts = n[1]
            inc_angle = n[2]

            #~ NICE image (roughness)
            pol = n.bands()[3]['polarization']
            if pol == 'HH':
                ph = (2.20495, -14.3561e-2, 11.28e-4)
                sigma0_hh_ref = exp( ( ph[0]+inc_angle*ph[1]+inc_angle**2*ph[2])*log(10) )
                roughness = n[3]/sigma0_hh_ref
            elif pol == 'VV':
                pv = (2.29373, -15.393e-2, 15.1762e-4)
                sigma0_vv_ref = exp( ( pv[0]+inc_angle*pv[1]+inc_angle**2*pv[2])*log(10) )
                roughness = n[3]/sigma0_vv_ref

            #~ Create new band
            n.add_band(bandID=4, array=roughness, \
               parameters={'name':'roughness', \
               'wkv': 'surface_backwards_scattering_coefficient_of_radar_wave', \
               'dataType': 6})

            # Reproject image into Lat/Lon WGS84 (Simple Cylindrical) projection
            # 1. Cancel previous reprojection
            # 2. Get corners of the image and the pixel resolution
            # 3. Create Domain with stereographic projection, corner coordinates 1000m
            # 4. Reproject
            # 5. Write image
            n.reproject() # 1.
            lons, lats = n.get_corners() # 2.
            # Pixel resolution
            #~ pxlRes = distancelib.getPixelResolution(array(lats), array(lons), n.shape())
            #~ pxlRes = array(pxlRes)*360/40000 # great circle distance
            pxlRes = array(distancelib.getPixelResolution(array(lats), array(lons), n.shape(), 'deg'))
            
            
            ipdb.set_trace()
            
            
            if min(lats) >= 65 and max(lats) >= 75 and max(lats)-min(lats) >= 13:
               pxlRes = array([0.00065, 0.00065])*2 # make the resolution 150x150m
            #~ pxlRes = pxlRes*7 # make the resolution worser
            srsString = "+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs"
            #~ extentString = '-lle %f %f %f %f -ts 3000 3000' % (min(lons), min(lats), max(lons), max(lats))
            extentString = '-lle %f %f %f %f -tr %f %f' % (min(lons), min(lats), \
                            max(lons), max(lats), pxlRes[1], pxlRes[0])
            d = Domain(srs=srsString, ext=extentString) # 3.
            n.reproject(d) # 4.

            if useMask:
               # get array with watermask (landmask) b
               # it must be done after reprojection!
               # 1. Get Nansat object with watermask
               # 2. Get array from Nansat object. 0 - land, 1 - water
               #wm = n.watermask(mod44path='/media/magDesk/media/SOLabNFS/store/auxdata/coastline/mod44w/')
               wm = n.watermask(mod44path='/media/data/data/auxdata/coastline/mod44w/')
               wmArray = wm[1]

               #~ ОШИБКА numOfColor=255 не маскирует, потому что в figure.apply_mask: availIndeces = range(self.d['numOfColor'], 255 - 1)
               #~ n.write_figure(fileName=figureName, bands=[3], \
                            #~ numOfColor=255, mask_array=wmArray, mask_lut={0: 0},
                            #~ clim=[0,0.15], cmapName='gray', transparency=0) # 5.
               n.write_figure(fileName=figureName, bands=[4], \
                                 mask_array=wmArray, mask_lut={0: [0,0,0]},
                                 clim=[0,2], cmapName='gray', transparency=[0,0,0]) # 5.
            else:
               n.write_figure(fileName=figureName, bands=[1], \
                              clim=[0,2], cmapName='gray', transparency=[0,0,0]) # 5.

            # open the input image and convert to RGBA for further tiling with slbtiles
            input_img = Image.open(figureName)
            output_img = input_img.convert("RGBA")
            output_img.save(figureName)

            # make KML image
            n.write_kml_image(kmlFileName=kmlName, kmlFigureName=figureName)

            #~ Change the file permissions
            os.chmod(oPath, 0777)
            os.chmod(oPath + fileName[0:27] + '/', 0777)
            os.chmod(kmlName, 0777)
            os.chmod(figureName, 0777)

            #~ Change the owner and group
            #~ os.chown(oPath, 1111, 1111)
            #~ os.chown(oPath + fileName[0:27] + '/', 1111, 1111)
            #~ os.chown(kmlName, 1111, 1111)
            #~ os.chown(figureName, 1111, 1111)
            
            #~ garbage collection
            gc.collect()
开发者ID:lelou6666,项目名称:PySOL,代码行数:104,代码来源:readASAR.py

示例13: Nansat

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
# create Nansat object
n = Nansat(iPath + fileName, mapperName="radarsat2")

# list bands and georeference of the object
print n

# Get band data and do some operations
# 1. Get data from 1st band as numpy array
# 2. Plot the array (NB: close the shown image to continue processing)
# 3. Save as Matlab file
a = n[1]
plt.imshow(a);plt.colorbar();plt.show()
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()
开发者ID:lelou6666,项目名称:PySOL,代码行数:32,代码来源:nansatExample.py

示例14: band

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
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')

# Writes an 8-bit GeoTiff image for a given band
开发者ID:yuxiaobu,项目名称:nansat,代码行数:33,代码来源:test_nansat.py

示例15: min

# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import write_figure [as 别名]
srsString = "+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs"
#~ extentString = '-lle %f %f %f %f -ts 3000 3000' % (min(lons), min(lats), max(lons), max(lats))
extentString = '-lle %f %f %f %f -tr %f %f' % (min(lons), min(lats), \
                max(lons), max(lats), pxlRes[1], pxlRes[0])
d = Domain(srs=srsString, ext=extentString) # 3.
n.reproject(d) # 4.

# get array with watermask (landmask) b 
# it must be done after reprojection!
# 1. Get Nansat object with watermask
# 2. Get array from Nansat object. 0 - land, 1 - water
#wm = n.watermask(mod44path='/media/magDesk/media/SOLabNFS/store/auxdata/coastline/mod44w/')
wm = n.watermask(mod44path='/media/data/data/auxdata/coastline/mod44w/')
wmArray = wm[1]

n.write_figure(oFileName + '_proj.png', clim='hist', bands=[3], \
               mask_array=wmArray, mask_lut={0: [204, 153, 25]}) # 5.

# write figure with lat/lon grid
# 1. Get lat/lon arrays from Nansat object (may take some time)
# 2. Make figure with lat/lon grids
lonGrid, latGrid = n.get_geolocation_grids()
n.write_figure(oFileName + '_latlon.png', bands=[1], \
               latGrid=latGrid, lonGrid=lonGrid, \
               latlonGridSpacing=10, latlonLabels=10, \
               mask_array=wmArray, mask_lut={0: [0, 0, 0]})

# make KML file with image borders (to be opened in Googe Earth)
n.write_kml(kmlFileName=oFileName + '_preview.kml')

# make image with map of the file location
n.write_map(oFileName + '_map.png')
开发者ID:lelou6666,项目名称:PySOL,代码行数:34,代码来源:nansatExampleASAR.py


注:本文中的nansat.Nansat.write_figure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。