Exemplo n.º 1
0
 def test_check_points(self):
     """Test that a cube is returned with the desired types for the points
     of the time, forecast_reference_time and forecast_period
     coordinates."""
     plugin = TemporalInterpolation(interval_in_minutes=60)
     result = plugin.enforce_time_coords_dtype(self.cube.copy())
     self.assertIsInstance(result, iris.cube.Cube)
     # All coordinates converted to the desired units and datatypes.
     # Check time coordinate.
     self.assertEqual(
         result.coord('time').points.dtype, self.coord_dtypes['time'])
     self.assertEqual(result.coord('time').units, self.coord_units['time'])
     # Check forecast_reference_time.
     self.assertEqual(
         result.coord('forecast_reference_time').points.dtype,
         self.coord_dtypes["forecast_reference_time"])
     self.assertEqual(
         result.coord('forecast_reference_time').units,
         self.coord_units["forecast_reference_time"])
     # Check forecast_period.
     self.assertEqual(
         result.coord('forecast_period').points.dtype,
         self.coord_dtypes['forecast_period'])
     self.assertEqual(
         result.coord('forecast_period').units,
         self.coord_units['forecast_period'])
Exemplo n.º 2
0
    def test_check_bounds(self):
        """Test that a cube is returned with the desired types when
        the time and forecast_period coordinates have bounds."""
        plugin = TemporalInterpolation(interval_in_minutes=60)
        cube = self.cube
        # Use of guess_bounds converts datatype to float64.
        cube.coord("time").guess_bounds()
        cube.coord("forecast_period").guess_bounds()

        result = plugin.enforce_time_coords_dtype(cube.copy())
        self.assertIsInstance(result, iris.cube.Cube)
        # All coordinates including bounds converted to the
        # desired units and datatypes.
        # Check time coordinate.
        self.assertEqual(result.coord('time').points.dtype,
                         self.coord_dtypes['time'])
        self.assertEqual(result.coord('time').bounds.dtype,
                         self.coord_dtypes['time'])
        self.assertEqual(result.coord('time').units, self.coord_units['time'])
        # Check forecast_reference_time coordinate.
        self.assertEqual(
            result.coord('forecast_reference_time').points.dtype,
            self.coord_dtypes["forecast_reference_time"])
        self.assertEqual(
            result.coord('forecast_reference_time').units,
            self.coord_units["forecast_reference_time"])
        # Check forecast_period coordinate.
        self.assertEqual(result.coord('forecast_period').points.dtype,
                         self.coord_dtypes["forecast_period"])
        self.assertEqual(result.coord('forecast_period').bounds.dtype,
                         self.coord_dtypes["forecast_period"])
        self.assertEqual(result.coord('forecast_period').units,
                         self.coord_units['forecast_period'])