Example #1
0
    def test_return_type(self):
        """Test that an iris cubelist is returned."""

        plugin = TemporalInterpolation(interpolation_method='daynight',
                                       times=[self.time_mid])
        result = plugin.daynight_interpolate(self.interpolated_cube)
        self.assertIsInstance(result, iris.cube.CubeList)
Example #2
0
    def test_daynight_interpolation(self):
        """Test interpolating to the a point where the daynight
           mask is not all zero."""

        expected_data = np.ones((self.npoints, self.npoints)) * 4
        index = np.where(self.daynight_mask == 0)
        expected_data[index] = 0.0
        expected_time = [1509523200]
        expected_fp = 2 * 3600
        plugin = TemporalInterpolation(interpolation_method='daynight',
                                       times=[self.time_mid])
        result, = plugin.daynight_interpolate(self.interpolated_cube)
        self.assertArrayAlmostEqual(expected_data, result.data)
        self.assertArrayAlmostEqual(result.coord('time').points, expected_time)
        self.assertAlmostEqual(
            result.coord('forecast_period').points[0], expected_fp)
Example #3
0
    def test_daynight_interpolation_ens(self):
        """Test interpolating to the a point where the daynight
        mask is not all zero and the len(shape) of the cube > 2."""

        expected_data_grid = np.ones((self.npoints, self.npoints)) * 4
        index = np.where(self.daynight_mask == 0)
        expected_data_grid[index] = 0.0
        expected_data = np.repeat(expected_data_grid[np.newaxis, :, :], 3, axis=0)
        expected_time = [1509523200]
        expected_fp = 2 * 3600
        plugin = TemporalInterpolation(
            interpolation_method="daynight", times=[self.time_mid]
        )
        (result,) = plugin.daynight_interpolate(self.interpolated_cube_ens)
        self.assertArrayAlmostEqual(expected_data, result.data)
        self.assertArrayAlmostEqual(result.coord("time").points, expected_time)
        self.assertAlmostEqual(result.coord("forecast_period").points[0], expected_fp)