diff --git a/esmvalcore/cmor/_fixes/cmip5/ec_earth.py b/esmvalcore/cmor/_fixes/cmip5/ec_earth.py index 6830092698..212a43f61c 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ec_earth.py +++ b/esmvalcore/cmor/_fixes/cmip5/ec_earth.py @@ -1,5 +1,7 @@ """Fixes for EC-Earth model.""" +from collections.abc import Iterable + import iris import numpy as np from dask import array as da @@ -132,7 +134,9 @@ def fix_metadata(self, cubes): class Pr(Fix): """Fixes for pr.""" - def fix_metadata(self, cubes): + def fix_metadata( + self, cubes: Iterable[iris.cube.Cube] + ) -> iris.cube.CubeList: """Fix time coordinate. Last file (2000-2009) has erroneously duplicated points @@ -160,6 +164,8 @@ def fix_metadata(self, cubes): else: # erase erroneously copy-pasted points select = np.unique(time_coord.points, return_index=True)[1] - new_list.append(cube[select]) + new_cube = cube[select] + iris.util.promote_aux_coord_to_dim_coord(new_cube, "time") + new_list.append(new_cube) return new_list diff --git a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py index 8390e9385b..14dacf4d68 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py +++ b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py @@ -187,7 +187,7 @@ def setUp(self): units="days since 1850-01-01", ) - correct_time_coord = AuxCoord( + correct_time_coord = DimCoord( points=[1.0, 2.0, 3.0], var_name="time", standard_name="time", @@ -216,7 +216,7 @@ def setUp(self): self.correct_cube = CubeList( [Cube(np.ones(3), var_name="pr", units="kg m-2 s-1")] ) - self.correct_cube[0].add_aux_coord(correct_time_coord, 0) + self.correct_cube[0].add_dim_coord(correct_time_coord, 0) self.fix = Pr(None) @@ -232,10 +232,10 @@ def test_pr_fix_metadata(self): out_wrong_cube = self.fix.fix_metadata(self.wrong_cube) out_correct_cube = self.fix.fix_metadata(self.correct_cube) - time = out_wrong_cube[0].coord("time") + time = out_wrong_cube[0].coord("time", dim_coords=True) assert time == self.time_coord - time = out_correct_cube[0].coord("time") + time = out_correct_cube[0].coord("time", dim_coords=True) assert time == self.time_coord def test_pr_fix_metadata_no_time(self):