コード例 #1
0
ファイル: test_plot.py プロジェクト: cedadev/cis
 def test_get_axis_ungridded(self):
     from cis.plotting.plot import get_axis
     from cis.test.util.mock import make_dummy_2d_ungridded_data
     d = make_dummy_2d_ungridded_data()
     assert get_axis(d, "x").name() == 'latitude'
     assert get_axis(d, "x", 'latitude').name() == 'latitude'
     assert get_axis(d, "x", 'bad_name').name() == 'latitude'  # Falls back on axis name
     assert get_axis(d, "y").name() == 'longitude'
     assert get_axis(d, "y", 'longitude').name() == 'longitude'
     assert get_axis(d, "y", 'bad_name').name() == 'longitude'  # Falls back on axis name
コード例 #2
0
 def test_ungridded_write_attributes(self):
     data = make_dummy_2d_ungridded_data()
     attrs = {'attr_name': 'attr_val',
              'standard_name': 'std_val',
              'long_name': 'lg_val',
              'units': 'units'}
     data.add_attributes(attrs)
     write(data, tmp_file)
     self.d = Dataset(tmp_file)
     for key, val in attrs.items():
         assert getattr(self.d.variables['rain'], key) == val
コード例 #3
0
 def test_get_axis_ungridded(self):
     from cis.plotting.plot import get_axis
     from cis.test.util.mock import make_dummy_2d_ungridded_data
     d = make_dummy_2d_ungridded_data()
     assert get_axis(d, "x").name() == 'latitude'
     assert get_axis(d, "x", 'latitude').name() == 'latitude'
     assert get_axis(
         d, "x", 'bad_name').name() == 'latitude'  # Falls back on axis name
     assert get_axis(d, "y").name() == 'longitude'
     assert get_axis(d, "y", 'longitude').name() == 'longitude'
     assert get_axis(
         d, "y",
         'bad_name').name() == 'longitude'  # Falls back on axis name
コード例 #4
0
 def test_ungridded_write_attributes(self):
     data = make_dummy_2d_ungridded_data()
     attrs = {
         'attr_name': 'attr_val',
         'standard_name': 'std_val',
         'long_name': 'lg_val',
         'units': 'units'
     }
     data.add_attributes(attrs)
     write(data, tmp_file)
     self.d = Dataset(tmp_file)
     for key, val in attrs.items():
         assert getattr(self.d.variables['rainfall_flux'], key) == val
コード例 #5
0
 def test_ungridded_write_units(self):
     data = make_dummy_2d_ungridded_data()
     data.units = 'kg'
     write(data, tmp_file)
     self.d = Dataset(tmp_file)
     assert self.d.variables['rainfall_flux'].units == 'kg'
コード例 #6
0
 def test_write_netcdf(self):
     data_object = make_dummy_2d_ungridded_data()
     write(data_object, tmp_file)
コード例 #7
0
 def test_ungridded_write_units(self):
     data = make_dummy_2d_ungridded_data()
     data.units = 'kg'
     write(data, tmp_file)
     self.d = Dataset(tmp_file)
     assert self.d.variables['rain'].units == 'kg'
コード例 #8
0
 def test_write_netcdf(self):
     data_object = make_dummy_2d_ungridded_data()
     write(data_object, tmp_file)