Exemple #1
0
 def test_phenom_known_long_name(self, mock_set_long):
     grib = None
     cube = iris.cube.Cube(np.array([1.0]), long_name='cloud_mixing_ratio')
     grib_save_rules.param_code(cube, grib)
     mock_set_long.assert_any_call(grib, "discipline", 0)
     mock_set_long.assert_any_call(grib, "parameterCategory", 1)
     mock_set_long.assert_any_call(grib, "parameterNumber", 22)
Exemple #2
0
 def test_phenom_known_long_name(self, mock_set_long):
     grib = None
     cube = iris.cube.Cube(np.array([1.0]),
                           long_name='cloud_mixing_ratio')
     grib_save_rules.param_code(cube, grib)
     mock_set_long.assert_any_call(grib, "discipline", 0)
     mock_set_long.assert_any_call(grib, "parameterCategory", 1)
     mock_set_long.assert_any_call(grib, "parameterNumber", 22)
Exemple #3
0
 def test_phenom_known_standard_name(self, mock_set_long):
     grib = None
     cube = iris.cube.Cube(np.array([1.0]),
                           standard_name='sea_surface_temperature')
     grib_save_rules.param_code(cube, grib)
     mock_set_long.assert_any_call(grib, "discipline", 10)
     mock_set_long.assert_any_call(grib, "parameterCategory", 3)
     mock_set_long.assert_any_call(grib, "parameterNumber", 0)
Exemple #4
0
 def test_phenom_known_standard_name(self, mock_set_long):
     grib = None
     cube = iris.cube.Cube(np.array([1.0]),
                           standard_name='sea_surface_temperature')
     grib_save_rules.param_code(cube, grib)
     mock_set_long.assert_any_call(grib, "discipline", 10)
     mock_set_long.assert_any_call(grib, "parameterCategory", 3)
     mock_set_long.assert_any_call(grib, "parameterNumber", 0)
Exemple #5
0
 def test_phenom_unknown(self, mock_set_long):
     grib = None
     cube = iris.cube.Cube(np.array([1.0]))
     with warnings.catch_warnings():
         # This should issue a warning about unrecognised data
         warnings.simplefilter("error")
         with self.assertRaises(UserWarning):
             grib_save_rules.param_code(cube, grib)
     # do it all again, and this time check the results
     grib = None
     cube = iris.cube.Cube(np.array([1.0]))
     grib_save_rules.param_code(cube, grib)
     mock_set_long.assert_any_call(grib, "discipline", 0)
     mock_set_long.assert_any_call(grib, "parameterCategory", 0)
     mock_set_long.assert_any_call(grib, "parameterNumber", 0)
Exemple #6
0
 def test_phenom_unknown(self, mock_set_long):
     grib = None
     cube = iris.cube.Cube(np.array([1.0]))
     with warnings.catch_warnings():
         # This should issue a warning about unrecognised data
         warnings.simplefilter("error")
         with self.assertRaises(UserWarning):
             grib_save_rules.param_code(cube, grib)
     # do it all again, and this time check the results
     grib = None
     cube = iris.cube.Cube(np.array([1.0]))
     grib_save_rules.param_code(cube, grib)
     mock_set_long.assert_any_call(grib, "discipline", 0)
     mock_set_long.assert_any_call(grib, "parameterCategory", 0)
     mock_set_long.assert_any_call(grib, "parameterNumber", 0)
Exemple #7
0
 def test_phenom_unknown(self, mock_set_long):
     grib = None
     cube = iris.cube.Cube(np.array([1.0]))
     # Force reset of warnings registry to avoid suppression of
     # repeated warnings. warnings.resetwarnings() does not do this.
     if hasattr(grib_save_rules, '__warningregistry__'):
         grib_save_rules.__warningregistry__.clear()
     with warnings.catch_warnings():
         # This should issue a warning about unrecognised data
         warnings.simplefilter("error")
         with self.assertRaises(UserWarning):
             grib_save_rules.param_code(cube, grib)
     # do it all again, and this time check the results
     grib = None
     cube = iris.cube.Cube(np.array([1.0]))
     grib_save_rules.param_code(cube, grib)
     mock_set_long.assert_any_call(grib, "discipline", 255)
     mock_set_long.assert_any_call(grib, "parameterCategory", 255)
     mock_set_long.assert_any_call(grib, "parameterNumber", 255)
Exemple #8
0
 def test_phenom_unknown(self, mock_set_long):
     grib = None
     cube = iris.cube.Cube(np.array([1.0]))
     # Force reset of warnings registry to avoid suppression of
     # repeated warnings. warnings.resetwarnings() does not do this.
     if hasattr(grib_save_rules, '__warningregistry__'):
         grib_save_rules.__warningregistry__.clear()
     with warnings.catch_warnings():
         # This should issue a warning about unrecognised data
         warnings.simplefilter("error")
         with self.assertRaises(UserWarning):
             grib_save_rules.param_code(cube, grib)
     # do it all again, and this time check the results
     grib = None
     cube = iris.cube.Cube(np.array([1.0]))
     grib_save_rules.param_code(cube, grib)
     mock_set_long.assert_any_call(grib, "discipline", 255)
     mock_set_long.assert_any_call(grib, "parameterCategory", 255)
     mock_set_long.assert_any_call(grib, "parameterNumber", 255)