Skip to content

Commit

Permalink
#2572: Adding fixes to combat the issue of having two time coordinate…
Browse files Browse the repository at this point in the history
…s time_counter and time_centered.
  • Loading branch information
SophieHall2024 committed Nov 6, 2024
1 parent 314cdfa commit c2f4488
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
21 changes: 21 additions & 0 deletions esmvalcore/cmor/_fixes/nemo/gc3p1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Fixes for GC3.1 data"""

from esmvalcore.cmor.fix import Fix
from iris.util import promote_aux_coord_to_dim_coord


class AllVars(Fix):
""""""

def fix_metadata(self, cubes):
""""""
# Replace time_counter with time_centered/time_instant
for cube in cubes:
for coordinate in cube.coords(dim_coords=True):
if coordinate.var_name == 'time_counter':
cube.remove_coord(coordinate)
promote_aux_coord_to_dim_coord(cube, 'time')
cube.coord('time').var_name = 'time'
break

return cubes
26 changes: 26 additions & 0 deletions esmvalcore/cmor/_fixes/nemo/gc5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Fixes for GC5 data"""

from esmvalcore.cmor.fix import Fix
from iris.util import promote_aux_coord_to_dim_coord


class AllVars(Fix):
""""""

def fix_metadata(self, cubes):
""""""
# Correct variable name
for cube in cubes:
if cube.var_name.endswith('_con'):
cube.var_name = cube.var_name[:-4]

for coordinate in cube.coords(dim_coords=True):
if coordinate.var_name == 'time_counter':
cube.remove_coord(coordinate)
promote_aux_coord_to_dim_coord(cube, 'time')
cube.coord('time').var_name = 'time'
break

return cubes

#check with emma about adding in the fix

0 comments on commit c2f4488

Please sign in to comment.