Ejemplo n.º 1
0
    def test_median(self):
        mo = Mosaic(domain=self.domain)
        mo.median([self.test_file_gcps, self.test_file_stere],
                  bands=['L_645', 'L_555', 'L_469'])

        mask = mo['mask']
        L_645 = mo['L_645']
        L_555 = mo['L_555']
        L_469 = mo['L_469']

        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'mosaic_median_export.nc')
        bands = {
            'mask': {
                'type': '>i1'
            },
            'L_645': {
                'type': '>i1'
            },
            'L_555': {
                'type': '>i1'
            },
            'L_469': {
                'type': '>i1'
            },
        }
        mo.set_metadata('time_coverage_start', '2016-01-19')
        mo.export2thredds(tmpfilename, bands)
Ejemplo n.º 2
0
    def test_average(self):
        mo = Mosaic(domain=self.domain)
        mo.average([self.test_file_gcps, self.test_file_stere],
                    bands=['L_645', 'L_555', 'L_469'])

        mask = mo['mask']
        L_645 = mo['L_645']
        L_555 = mo['L_555']
        L_469 = mo['L_469']

        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'mosaic_export.nc')
        bands = {
            'L_645' : {'type': '>i1'},
            'L_555' : {'type': '>i1'},
            'L_469' : {'type': '>i1'},
        }
        mo.export2thredds(tmpfilename, bands)
Ejemplo n.º 3
0
    def test_median(self):
        mo = Mosaic(domain=self.domain)
        mo.median([self.test_file_gcps, self.test_file_stere],
                    bands=['L_645', 'L_555', 'L_469'])

        mask = mo['mask']
        L_645 = mo['L_645']
        L_555 = mo['L_555']
        L_469 = mo['L_469']

        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'mosaic_median_export.nc')
        bands = {
            'mask'  : {'type': '>i1'},
            'L_645' : {'type': '>i1'},
            'L_555' : {'type': '>i1'},
            'L_469' : {'type': '>i1'},
        }
        mo.set_metadata('time_coverage_start', '2016-01-19')
        mo.export2thredds(tmpfilename, bands)
Ejemplo n.º 4
0
    def test_average(self):
        mo = Mosaic(domain=self.domain)
        mo.average([self.test_file_gcps, self.test_file_stere],
                   bands=['L_645', 'L_555', 'L_469'])

        mask = mo['mask']
        L_645 = mo['L_645']
        L_555 = mo['L_555']
        L_469 = mo['L_469']

        tmpfilename = os.path.join(ntd.tmp_data_path, 'mosaic_export.nc')
        bands = {
            'L_645': {
                'type': '>i1'
            },
            'L_555': {
                'type': '>i1'
            },
            'L_469': {
                'type': '>i1'
            },
        }
        mo.export2thredds(tmpfilename, bands)
Ejemplo n.º 5
0
''' Mosaic class includes mosaicing methods

mosaicing methods:
1. average
2. median
3. latest (add the latest image on top)

'''

# Create target domain
domain = Domain(4326, '-lle 27 70 31 72 -ts 1400 1300')

# A. Perform averaging of several files
# 1. Create destination Nansat object with desired projection
nMosaic = Mosaic(domain=domain)
# 2. Perfom averaging
nMosaic.average(iFileNames, bands=['L_645', 'L_555', 'L_469'])
# 3. Get mask of valid pixels
mask = nMosaic['mask']
# 4. Output averaged data using the mask
nMosaic.write_figure(fileName=oFileName + '.png',
                     bands=['L_645', 'L_555', 'L_469'],
                     clim='hist',
                     mask_array=mask,
                     mask_lut={0: [128,128,128]})
# 5. Get values of standard deviation from averaging of input files
L_469_std = nMosaic['L_469_std']

# B. calculate median from the first band (very slow thus comented)
#nMosaic.median(['gcps.tif', 'stere.tif'])
Ejemplo n.º 6
0
    def test_init(self):
        mo = Mosaic(domain=self.domain)

        self.assertEqual(type(mo), Mosaic)
Ejemplo n.º 7
0
# 6. Get Nansat object with watermask
# 7. Get array from Nansat object. 0 - land, 1 - water
wm = n.watermask()                                                  # 6.
wmArray = wm[1]                                                     # 7.

# 8. Write the projected image with transparent land mask and image background
# transparentMask: boolean, defult = False
# If True, the masked pixels will be transparent when saving to png
#transparency: int
#transparency of the image background, set for PIL in Figure.save()
#default transparent color is [0,0,0]
n.write_figure(fileName=oFileName + '_proj.png', bands=[1,2,3],
               mask_array=wmArray, mask_lut={0: [128, 128, 128]},
               clim='hist', transparency=[128, 128, 128])           # 8.

# make KML file for the exported image
n.write_kml_image(kmlFileName=oFileName + '.kml', kmlFigureName=oFileName + '_proj.png')

# Perform batch averaging of several files
# 1. Create destination Nansat object with desired projection
nMosaic = Mosaic(domain=dStereo)
# 2. Perfom averaging
nMosaic.average(['gcps.tif', 'stere.tif'], bands=['L_645', 'L_555', 'L_469'])
# 3. Get mask of non-valid pixels
mask = nMosaic['mask']
# 4. Output averaged data using the mask
nMosaic.write_figure(fileName=oFileName + '_mosaic.png', bands=['L_645', 'L_555', 'L_469'], clim='hist',
                        mask_array=mask, mask_lut={0:[128,128,128]})

print 'Tutorial completed successfully. Output files are found here:' + oFileName