From 14787d2afbb6a21d5055defd29256aae8cc8fb9a Mon Sep 17 00:00:00 2001 From: Sophie Hall Date: Fri, 15 Nov 2024 16:25:48 +0000 Subject: [PATCH] #2572: Emma Hogans fix --- esmvalcore/cmor/_fixes/nemo/gc3p1.py | 17 +++++++++++++++++ esmvalcore/cmor/_fixes/nemo/gc5.py | 23 ++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/esmvalcore/cmor/_fixes/nemo/gc3p1.py b/esmvalcore/cmor/_fixes/nemo/gc3p1.py index 643b7d3492..08a0d50c3f 100644 --- a/esmvalcore/cmor/_fixes/nemo/gc3p1.py +++ b/esmvalcore/cmor/_fixes/nemo/gc3p1.py @@ -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) diff --git a/esmvalcore/cmor/_fixes/nemo/gc5.py b/esmvalcore/cmor/_fixes/nemo/gc5.py index df770296b9..3698907f82 100644 --- a/esmvalcore/cmor/_fixes/nemo/gc5.py +++ b/esmvalcore/cmor/_fixes/nemo/gc5.py @@ -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) @@ -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)