Example #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)
Example #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)
Example #3
0
    def test_init(self):
        mo = Mosaic(domain=self.domain)

        self.assertEqual(type(mo), Mosaic)
Example #4
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