diff --git a/esmvalcore/preprocessor/_time.py b/esmvalcore/preprocessor/_time.py index 1890e9739c..2466e5a064 100644 --- a/esmvalcore/preprocessor/_time.py +++ b/esmvalcore/preprocessor/_time.py @@ -1233,7 +1233,7 @@ def resample_hours(cube: Cube, interval: int, offset: int = 0) -> Cube: f'the interval ({interval})') time = cube.coord('time') cube_period = time.cell(1).point - time.cell(0).point - if cube_period.total_seconds() / 3600 >= interval: + if cube_period.total_seconds() / 3600 > interval: raise ValueError(f"Data period ({cube_period}) should be lower than " f"the interval ({interval})") hours = [PartialDateTime(hour=h) for h in range(0 + offset, 24, interval)] diff --git a/tests/unit/preprocessor/_time/test_time.py b/tests/unit/preprocessor/_time/test_time.py index a1ae135c25..03ca53dd24 100644 --- a/tests/unit/preprocessor/_time/test_time.py +++ b/tests/unit/preprocessor/_time/test_time.py @@ -2082,8 +2082,9 @@ def test_resample_same_interval(self): times = np.arange(0, 48, 12) cube = self._create_cube(data, times) - with self.assertRaises(ValueError): - resample_hours(cube, interval=12) + result = resample_hours(cube, interval=12) + expected = np.arange(0, 48, 12) + assert_array_equal(result.data, expected) def test_resample_nodata(self): """Test average of a 1D field."""