Esempio n. 1
0
 def test_exception_raised(self):
     """
     Test that a CoordinateNotFoundError exception is raised if the
     forecast_period, or the time and forecast_reference_time,
     are not present.
     """
     cube = set_up_cube()
     msg = "The forecast period coordinate is not available"
     with self.assertRaisesRegexp(CoordinateNotFoundError, msg):
         Utilities.find_required_lead_times(cube)
Esempio n. 2
0
 def test_check_forecast_period_unit_conversion_exception(self):
     """
     Test that an exception is raised, when the input cube has a
     forecast_period coordinate with units that can not be converted
     into hours.
     """
     cube = add_forecast_reference_time_and_forecast_period(set_up_cube())
     cube.coord("forecast_period").units = Unit("Celsius")
     msg = "For forecast_period"
     with self.assertRaisesRegexp(ValueError, msg):
         Utilities.find_required_lead_times(cube)
Esempio n. 3
0
 def test_check_coordinate(self):
     """
     Test that the data within the numpy array is as expected, when
     the input cube has a forecast_period coordinate.
     """
     cube = add_forecast_reference_time_and_forecast_period(set_up_cube())
     expected_result = cube.coord("forecast_period").points
     result = Utilities.find_required_lead_times(cube)
     self.assertArrayAlmostEqual(result, expected_result)
Esempio n. 4
0
 def test_check_forecast_period_unit_conversion(self):
     """
     Test that the data within the numpy array is as expected, when
     the input cube has a forecast_period coordinate with units
     other than the desired units of hours.
     """
     cube = add_forecast_reference_time_and_forecast_period(set_up_cube())
     expected_result = cube.coord("forecast_period").points.copy()
     cube.coord("forecast_period").convert_units("seconds")
     result = Utilities.find_required_lead_times(cube)
     self.assertArrayAlmostEqual(result, expected_result)
Esempio n. 5
0
 def test_basic(self):
     """Test that a numpy array is returned."""
     cube = add_forecast_reference_time_and_forecast_period(set_up_cube())
     result = Utilities.find_required_lead_times(cube)
     self.assertIsInstance(result, np.ndarray)