diff --git a/doc/esmvalcore/preprocessor.rst b/doc/esmvalcore/preprocessor.rst index a92b6c4cb5..3b6866f063 100644 --- a/doc/esmvalcore/preprocessor.rst +++ b/doc/esmvalcore/preprocessor.rst @@ -675,7 +675,8 @@ The ``_time.py`` module contains the following preprocessor functions: Statistics functions are applied by default in the order they appear in the list. For example, the following example applied to hourly data will retrieve the minimum values for the full period (by season) of the monthly mean of the -daily maximum of any given variable. +daily maximum of any given variable. The representative time for statistics +is (hour=12:00) in daily periods and (day=15, hour=12:00) in monthly periods. .. code-block:: yaml diff --git a/esmvalcore/preprocessor/_time.py b/esmvalcore/preprocessor/_time.py index 020d0d0347..8f4d643b6f 100644 --- a/esmvalcore/preprocessor/_time.py +++ b/esmvalcore/preprocessor/_time.py @@ -184,7 +184,9 @@ def daily_statistics(cube, operator='mean'): """ Compute daily statistics. - Chunks time in daily periods and computes statistics over them; + Chunks time in daily periods and computes statistics over them. + The statistics are assigned to a specific time (hour=12:00) in + daily period; Parameters ---------- @@ -207,6 +209,14 @@ def daily_statistics(cube, operator='mean'): operator = get_iris_analysis_operation(operator) cube = cube.aggregated_by(['day_of_year', 'year'], operator) + + # Correct the time coordinate + cube.coord('time').points = cube.coord('time').units.date2num([ + cell.point.replace(hour=12, minute=0) + for cell in cube.coord('time').cells()]) + + cube.coord('time').bounds = None + cube.coord('time').guess_bounds() return cube @@ -214,7 +224,9 @@ def monthly_statistics(cube, operator='mean'): """ Compute monthly statistics. - Chunks time in monthly periods and computes statistics over them; + Chunks time in monthly periods and computes statistics over them. + The statistics are assigned to a specific time (day=15, hour=12:00) + in monthly period; Parameters ---------- @@ -237,6 +249,14 @@ def monthly_statistics(cube, operator='mean'): operator = get_iris_analysis_operation(operator) cube = cube.aggregated_by(['month_number', 'year'], operator) + + # Correct the time coordinate + cube.coord('time').points = cube.coord('time').units.date2num([ + cell.point.replace(day=15, hour=12, minute=0) + for cell in cube.coord('time').cells()]) + + cube.coord('time').bounds = None + cube.coord('time').guess_bounds() return cube