diff --git a/esmvalcore/preprocessor/_regrid.py b/esmvalcore/preprocessor/_regrid.py index 7077ea0bfe..ad5d8b9b39 100644 --- a/esmvalcore/preprocessor/_regrid.py +++ b/esmvalcore/preprocessor/_regrid.py @@ -647,6 +647,11 @@ def regrid(cube, target_grid, scheme, lat_offset=True, lon_offset=True): "'%s': %s", original_dtype, cube.core_data().dtype, str(exc)) cube.data = da.ma.masked_equal(cube.core_data(), fill_value) + else: + # force target coordinates + for coord in ['latitude', 'longitude']: + cube.coord(coord).points = target_grid.coord(coord).points + cube.coord(coord).bounds = target_grid.coord(coord).bounds return cube diff --git a/tests/integration/preprocessor/_regrid/test_regrid.py b/tests/integration/preprocessor/_regrid/test_regrid.py index 7a6b87e1a3..a6ba8b95b5 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid.py +++ b/tests/integration/preprocessor/_regrid/test_regrid.py @@ -92,6 +92,23 @@ def test_regrid__linear(self): expected = np.array([[[1.5]], [[5.5]], [[9.5]]]) self.assert_array_equal(result.data, expected) + def test_regrid__regular_coordinates(self): + data = np.ones((1, 1)) + lons = iris.coords.DimCoord([1.50000000000001], + standard_name='longitude', + bounds=[[1, 2]], + units='degrees_east', + coord_system=self.cs) + lats = iris.coords.DimCoord([1.50000000000001], + standard_name='latitude', + bounds=[[1, 2]], + units='degrees_north', + coord_system=self.cs) + coords_spec = [(lats, 0), (lons, 1)] + regular_grid = iris.cube.Cube(data, dim_coords_and_dims=coords_spec) + result = regrid(regular_grid, self.grid_for_linear, 'linear') + iris.common.resolve.Resolve(result, self.grid_for_linear) + def test_regrid__linear_do_not_preserve_dtype(self): self.cube.data = self.cube.data.astype(int) result = regrid(self.cube, self.grid_for_linear, 'linear')