Esempio n. 1
0
    def test_pcolormesh(self):
        ''' Should use Nansatmap.pcolormesh '''
        n = Nansat(self.test_file_stere, logLevel=40)
        b1 = n[1]
        nmap = Nansatmap(n)
        nmap.pcolormesh(b1)
        tmpfilename = os.path.join(ntd.tmp_data_path, 'nansatmap_pcolormesh.png')
        nmap.save(tmpfilename)

        self.assertTrue(os.path.exists(tmpfilename))
Esempio n. 2
0
    def test_imshow(self):
        ''' Should use Nansatmap.imshow '''
        n = Nansat(self.test_file_stere, logLevel=40)
        b1 = n[1]
        nmap = Nansatmap(n)
        nmap.imshow(b1, cmap='ak01')
        tmpfilename = os.path.join(ntd.tmp_data_path, 'nansatmap_imshow.png')
        nmap.save(tmpfilename)

        self.assertTrue(os.path.exists(tmpfilename))
Esempio n. 3
0
    def test_imshow_random(self):
        ''' Should use Nansatmap.imshow '''
        n = Nansat(self.test_file_stere, logLevel=40)
        b1 = n[1]
        nmap = Nansatmap(n)
        nmap.imshow(b1 / 5, cmap='random')
        nmap.add_colorbar()
        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'nansatmap_imshow_random.png')
        nmap.save(tmpfilename)

        self.assertTrue(os.path.exists(tmpfilename))
Esempio n. 4
0
    def test_imshow_random(self):
        ''' Should use Nansatmap.imshow '''
        n = Nansat(self.test_file_stere, logLevel=40)
        b1 = n[1]
        nmap = Nansatmap(n)
        nmap.imshow(b1/5, cmap='random')
        nmap.add_colorbar()
        tmpfilename = os.path.join(ntd.tmp_data_path, 'nansatmap_imshow_random.png')
        nmap.save(tmpfilename)

        self.assertTrue(os.path.exists(tmpfilename))
Esempio n. 5
0
    def test_add_labels(self):
        size, npo = 100, 10
        xy = np.random.randint(0, size, npo * 2).reshape(npo, 2)
        z = np.random.randint(0, size, npo)
        xg, yg = np.meshgrid(range(size), range(size))
        zg = griddata(xy, z, np.dstack([xg, yg]), method='nearest')
        dstDomain = Domain(NSR().wkt, '-te -10 -10 10 10 -ts 100 100')

        nmap = Nansatmap(dstDomain)
        nmap.imshow(zg, cmap='random')
        nmap.add_zone_labels(zg, fontsize=10)
        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'nansatmap_zonelables.png')
        nmap.save(tmpfilename)

        self.assertTrue(os.path.exists(tmpfilename))
Esempio n. 6
0
    def test_imshow(self):
        ''' Should use Nansatmap.imshow '''
        n = Nansat(self.test_file_stere, logLevel=40)
        b1 = n[1]
        nmap = Nansatmap(n)
        nmap.imshow(b1, cmap='ak01')
        tmpfilename = os.path.join(ntd.tmp_data_path, 'nansatmap_imshow.png')
        nmap.save(tmpfilename)

        self.assertTrue(os.path.exists(tmpfilename))
Esempio n. 7
0
    def test_pcolormesh(self):
        ''' Should use Nansatmap.pcolormesh '''
        n = Nansat(self.test_file_stere, logLevel=40)
        b1 = n[1]
        nmap = Nansatmap(n)
        nmap.pcolormesh(b1)
        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'nansatmap_pcolormesh.png')
        nmap.save(tmpfilename)

        self.assertTrue(os.path.exists(tmpfilename))
Esempio n. 8
0
    def test_add_labels(self):
        size, npo = 100, 10
        xy = np.random.randint(0, size, npo*2).reshape(npo, 2)
        z = np.random.randint(0, size, npo)
        xg, yg = np.meshgrid(range(size), range(size))
        zg = griddata(xy, z, np.dstack([xg, yg]), method='nearest')
        dstDomain = Domain(NSR().wkt, '-te -10 -10 10 10 -ts 100 100')

        nmap = Nansatmap(dstDomain)
        nmap.imshow(zg, cmap='random')
        nmap.add_zone_labels(zg, fontsize=10)
        tmpfilename = os.path.join(ntd.tmp_data_path, 'nansatmap_zonelables.png')
        nmap.save(tmpfilename)

        self.assertTrue(os.path.exists(tmpfilename))
Esempio n. 9
0
    def test_create_map(self):
        ''' should simply create a Nansatmap instance '''
        n = Nansat(self.test_file_stere, logLevel=40)
        nmap = Nansatmap(n)

        self.assertEqual(type(nmap), Nansatmap)
Esempio n. 10
0
create, add legend and geolocation_grids, save.

The core of Nansatmap is Basemap.
Nansatmap object is created based on Domain object.
This class has methods as: filled contour plot, line contour plot,
pseudo-color plot, quiver plot and save.

'''

# Create a Nansat object (n)
n = Nansat(iFileName)
# Get data from 1st, 2nd and 3rd bands as numpy array (u,v and w)
u = n[1]; v = n[2]; w = n[3]

# Create Nansatmap object from nansat (domain) object
nMap = Nansatmap(n)
# draw filled contour plot
nMap.contourf(w, v=range(4, 22, 2))
# draw black smooth contour plot with labels
nMap.contour(w, smooth=True, fontsize=8, colors='k')
# add colorbar
nMap.add_colorbar(fontsize=10)
# add geocoordinates
nMap.drawgrid()
# save to a file
nMap.save(oFileName + '01_contourf_contour.png', landmask=False)

# Create Nansatmap object from nansat (domain) object
nMap = Nansatmap(n, resolution='l')
# pseudo-color plot over the map
nMap.pcolormesh(w)
Esempio n. 11
0
#from nansat_map import NansatMap

# input and output file names
iPath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
iFileName = os.path.join(iPath, 'map.tif')
print 'Input file: ', iFileName
oFileName = os.path.join(iPath, 'tmpdata', 'outputmap_')
print 'Output file prefix: ', oFileName

# Create a Nansat object (n)
n = Nansat(iFileName)
# Get data from 1st, 2nd and 3rd bands as numpy array (u,v and w)
u = n[1]; v = n[2]; w = n[3]


nMap = Nansatmap(n)
# draw filled contour plot
nMap.contourf(w)
# draw black smooth contour plot with labels
nMap.contour(w, smooth=True, fontsize=8, colors='k')
# add colorbar
nMap.add_colorbar(fontsize=10)
# add geocoordinates
nMap.drawgrid()
# save to a file
nMap.save(oFileName+'contourf_contour.png', landmask=False)


nMap = Nansatmap(n, resolution='h')
# pseudo-color plot over the map
nMap.pcolormesh(w)