Skip to content
Open
Changes from 18 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions esmvalcore/cmor/_fixes/native6/era5.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,10 @@ def _fix_coordinates( # noqa: C901
):
coord.guess_bounds()

self._fix_monthly_time_coord(cube)
frequency = (
get_frequency(cube) if self.frequency is None else self.frequency
)
self._fix_monthly_time_coord(cube, frequency)

# Fix coordinate increasing direction
if cube.coords("latitude") and not has_unstructured_grid(cube):
Expand All @@ -582,9 +585,9 @@ def _fix_coordinates( # noqa: C901
return cube

@staticmethod
def _fix_monthly_time_coord(cube):
def _fix_monthly_time_coord(cube, frequency):
"""Set the monthly time coordinates to the middle of the month."""
if get_frequency(cube) == "monthly":
if frequency in ("monthly", "mon", "mo"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "mo" is not needed, as it looks like monthly frequency will be either "monthly" as returned by the get_frequency function or "mon" from the CMOR table:

"frequency":{
"1hr":"sampled hourly",
"1hrCM":"monthly-mean diurnal cycle resolving each day into 1-hour means",
"1hrPt":"sampled hourly, at specified time point within an hour",
"3hr":"sampled every 3 hours",
"3hrPt":"sampled 3 hourly, at specified time point within the time period",
"6hr":"sampled every 6 hours",
"6hrPt":"sampled 6 hourly, at specified time point within the time period",
"day":"daily mean samples",
"dec":"decadal mean samples",
"fx":"fixed (time invariant) field",
"mon":"monthly mean samples",
"monC":"monthly climatology computed from monthly mean samples",
"monPt":"sampled monthly, at specified time point within the time period",
"subhrPt":"sampled sub-hourly, at specified time point within an hour",
"yr":"annual mean samples",
"yrPt":"sampled yearly, at specified time point within the time period"
},

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bouweandela, I'm not sure I can speak to the get_frequency function.. it was added for some use cases?
I have added a test for "mon" frequency repeating one for "monthly"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a test for "mon" frequency repeating one for "monthly"

Great!

Thanks @bouweandela, I'm not sure I can speak to the get_frequency function.. it was added for some use cases?

It was added before we passed all the facets and their values from the recipe to the fix functions. I've thought about it some more, and it can be removed. In rare cases where the frequency is wrongly inferred from the mip, the user can specify the right frequency value in the recipe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, should I create a new issue/PR to discuss specifically or I can just change here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just change it here

coord = cube.coord(axis="T")
end = []
for cell in coord.cells():
Expand Down