-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2572: Adding fixes to combat the issue of having two time coordinate…
…s time_counter and time_centered.
- Loading branch information
1 parent
314cdfa
commit c2f4488
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |