def test_return_type(self): """Test that an iris cubelist is returned.""" plugin = TemporalInterpolation(interpolation_method='solar', times=[self.time_mid]) result = plugin.solar_interpolate(self.cube, self.interpolated_cube) self.assertIsInstance(result, iris.cube.CubeList)
def test_solar_interpolation(self): """Test interpolating using solar method works correctly.""" expected_time = [1509523200] expected_fp = 2 * 3600 plugin = TemporalInterpolation(interpolation_method='solar', times=[self.time_mid]) result, = plugin.solar_interpolate(self.cube, self.interpolated_cube) self.assertArrayAlmostEqual(result.data, self.expected) self.assertArrayAlmostEqual(result.coord('time').points, expected_time) self.assertAlmostEqual( result.coord('forecast_period').points[0], expected_fp)
def test_solar_interpolation_shape(self): """Test interpolating using solar method with len(shape) >= 3 works correctly.""" expected_time = [1509523200] expected_fp = 2 * 3600 plugin = TemporalInterpolation( interpolation_method="solar", times=[self.time_mid] ) (result,) = plugin.solar_interpolate(self.cube_ens, self.interpolated_cube_ens) self.assertArrayEqual(result.data.shape, (3, 5, 5)) self.assertArrayAlmostEqual(result.data[0], self.expected) self.assertArrayAlmostEqual(result.coord("time").points, expected_time) self.assertAlmostEqual(result.coord("forecast_period").points[0], expected_fp)
def test_solar_interpolation_shape(self): """Test interpolating using solar method with len(shape) >= 3 works correctly.""" expected_time = (self.time_0 + timedelta(hours=2)).timestamp() expected_fp = 2 * 3600 plugin = TemporalInterpolation(interpolation_method='solar', times=[self.time_mid]) result, = plugin.solar_interpolate(self.cube_ens, self.interpolated_cube_ens) self.assertArrayEqual(result.data.shape, (3, 5, 5)) self.assertArrayAlmostEqual(result.data[0], self.expected) self.assertArrayAlmostEqual(result.coord('time').points, expected_time) self.assertAlmostEqual( result.coord('forecast_period').points[0], expected_fp)