Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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()
Exemplo n.º 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')
Exemplo n.º 5
0
 def test_SingleMap_WithPredefinedAxisButWhichIsNone(self):
     ax = None
     SM1 = mapping.SingleMap(self.D, ax=ax)
Exemplo n.º 6
0
 def test_SingleMap_WithPredefinedAxis(self):
     f = plt.figure()
     ax = f.add_subplot(2, 1, 1)
     SM1 = mapping.SingleMap(self.D, ax=ax)
Exemplo n.º 7
0
 def test_invalid_colorbar_orientation(self):
     SM = mapping.SingleMap(self.D)
     with self.assertRaises(ValueError):
         SM.plot(colorbar_orientation='something')
Exemplo n.º 8
0
 def test_SingleMap_WithoutColorbar(self):
     SM = mapping.SingleMap(self.D)
     SM.plot(show_colorbar=False)