Skip to content

Commit

Permalink
#2572: Emma Hogans fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SophieHall2024 committed Nov 15, 2024
1 parent dfdb904 commit 14787d2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
17 changes: 17 additions & 0 deletions esmvalcore/cmor/_fixes/nemo/gc3p1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,20 @@ def fix_metadata(self, cubes):
break

return cubes

# def remove_extra_time_axis(cube):
# count_time_axes = 0
# time_axes_names = []
# for coord in cube.coords():
# if iris.util.guess_coord_axis(coord) == 'T':
# count_time_axes += 1
# time_axes_names.append(coord.standard_name)
#
# if count_time_axes >= 2 and len(set(time_axes_names)) == 1:
# for aux_coord in cube.coords(dim_coords=False):
# if iris.util.guess_coord_axis(aux_coord) == 'T':
# cube.remove_coord(aux_coord)
# else:
# for coord in cube.coords():
# if coord.var_name == 'time_counter':
# cube.remove_coord(coord)
23 changes: 18 additions & 5 deletions esmvalcore/cmor/_fixes/nemo/gc5.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
from iris.util import promote_aux_coord_to_dim_coord



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

def fix_metadata(self, cubes):
""""""
# Correct variable name
# Replace time_counter with time_centered/time_instant
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)
Expand All @@ -23,4 +21,19 @@ def fix_metadata(self, cubes):

return cubes

#check with emma about adding in the fix
# def remove_extra_time_axis(cube):
# count_time_axes = 0
# time_axes_names = []
# for coord in cube.coords():
# if iris.util.guess_coord_axis(coord) == 'T':
# count_time_axes += 1
# time_axes_names.append(coord.standard_name)
#
# if count_time_axes >= 2 and len(set(time_axes_names)) == 1:
# for aux_coord in cube.coords(dim_coords=False):
# if iris.util.guess_coord_axis(aux_coord) == 'T':
# cube.remove_coord(aux_coord)
# else:
# for coord in cube.coords():
# if coord.var_name == 'time_counter':
# cube.remove_coord(coord)

0 comments on commit 14787d2

Please sign in to comment.