示例#1
0
    def test_SingleMap_Init(self):
        try:
            import cartopy.crs as ccrs
        except:
            return True  #no testing if cartopy not installed

        # just test if things pass
        SM1 = mapping.SingleMap(self.D)
        SM2 = mapping.SingleMap(self.D, stat_type='sum')
        proj_prop = {'projection': 'robin'}
        SM3 = mapping.SingleMap(self.D, backend='basemap', stat_type='median')
        SM4 = mapping.SingleMap(self.D, backend='cartopy')
        SM1.plot(show_zonal=True)
        SM2.plot(show_zonal=True, colorbar_orientation='horizontal')
        SM3.plot(show_zonal=True,
                 colorbar_orientation='horizontal',
                 proj_prop=proj_prop)
        SM4.plot(show_zonal=True,
                 colorbar_orientation='horizontal',
                 proj_prop=proj_prop)
示例#2
0
 def test_SingleMap_Save(self):
     SM = mapping.SingleMap(self.D,
                            savefile=self._tmpdir + os.sep +
                            'my_test_save_file.nc')
     SM.save(save_mean=True, save_all=True)
     self.assertTrue(
         os.path.exists(self._tmpdir + os.sep +
                        'my_test_save_file.nc_timmean.nc'))
     self.assertTrue(
         os.path.exists(self._tmpdir + os.sep +
                        'my_test_save_file.nc_timmean.nc_all.nc'))
     if os.path.exists(self._tmpdir + os.sep +
                       'my_test_save_file.nc_timmean.nc'):
         os.remove(self._tmpdir + os.sep +
                   'my_test_save_file.nc_timmean.nc')
     if os.path.exists(self._tmpdir + os.sep +
                       'my_test_save_file.nc_timmean.nc_all.nc'):
         os.remove(self._tmpdir + os.sep +
                   'my_test_save_file.nc_timmean.nc_all.nc')
示例#3
0
 def test_SingleMap_InitWithMissingProjectionProperties(self):
     # just test if things pass
     with self.assertRaises(ValueError):
         SM = mapping.SingleMap(self.D, backend='cartopy')
         SM.plot()
示例#4
0
 def test_SingleMap_InitWithInvalidBackend(self):
     # just test if things pass
     with self.assertRaises(ValueError):
         SM = mapping.SingleMap(self.D, backend='some_invalid_backend')
示例#5
0
 def test_SingleMap_WithPredefinedAxisButWhichIsNone(self):
     ax = None
     SM1 = mapping.SingleMap(self.D, ax=ax)
示例#6
0
 def test_SingleMap_WithPredefinedAxis(self):
     f = plt.figure()
     ax = f.add_subplot(2, 1, 1)
     SM1 = mapping.SingleMap(self.D, ax=ax)
示例#7
0
 def test_invalid_colorbar_orientation(self):
     SM = mapping.SingleMap(self.D)
     with self.assertRaises(ValueError):
         SM.plot(colorbar_orientation='something')
示例#8
0
 def test_SingleMap_WithoutColorbar(self):
     SM = mapping.SingleMap(self.D)
     SM.plot(show_colorbar=False)