예제 #1
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))
예제 #2
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))
예제 #3
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))
예제 #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))
예제 #5
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))
예제 #6
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))
예제 #7
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))
예제 #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))
예제 #9
0
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)
# quiver plot
nMap.quiver(v, u, quivectors=20)
# save to a file
nMap.save(oFileName + '02_pcolormesh_quiver.png')

# use Nansatmap for converting lon/lat into x/y
# 1. Create domain over the area of interest in stereographic projection
extentString = '-lle -10 50 20 70 -tr 1000 1000'
srsString = '+proj=stere +lon_0=10 +lat_0=60 +k=1 +ellps=WGS84 +datum=WGS84 +no_defs'
d = Domain(srsString, extentString)
예제 #10
0
# 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)
# quiver plot
nMap.quiver(u, v, quivectors=20)
nMap.save(oFileName+'pcolormesh_quiver.png')




#n.write_map(grid='w', contour='w', smooth=true, quiver=('u','v'), step=5)