Open npgillett opened 4 years ago
I worked out a way round this - by just guessing the bounds for grid_latitude
and grid_longitude
:
class OceanFixGrid(Fix):
"""Fixes for tos, siconc in FGOALS-g3."""
def fix_data(self, cube):
"""Fix data.
Calculate missing latitude/longitude boundaries using interpolation.
Based on a similar fix for BCC-CSM2-MR
Parameters
----------
cube: iris.cube.Cube
Input cube to fix.
Returns
-------
iris.cube.Cube
"""
rlat = cube.coord('grid_latitude').points
rlon = cube.coord('grid_longitude').points
#Guess coordinate bounds in rlat, rlon (following BCC-CSM2-MR-1).
rlat_idx_bnds = np.zeros((len(rlat),2))
rlat_idx_bnds[:,0]=np.arange(len(rlat))-0.5
rlat_idx_bnds[:,1]=np.arange(len(rlat))+0.5
rlat_idx_bnds[0,0]=0.
rlat_idx_bnds[len(rlat)-1,1]=len(rlat)
rlon_idx_bnds = np.zeros((len(rlon),2))
rlon_idx_bnds[:,0]=np.arange(len(rlon))-0.5
rlon_idx_bnds[:,1]=np.arange(len(rlon))+0.5
# Calculate latitude/longitude vertices by interpolation
lat_vertices = []
lon_vertices = []
for (i, j) in [(0, 0), (0, 1), (1, 1), (1, 0)]:
(rlat_v, rlon_v) = np.meshgrid(rlat_idx_bnds[:, i],
rlon_idx_bnds[:, j],
indexing='ij')
lat_vertices.append(
map_coordinates(cube.coord('latitude').points,
[rlat_v, rlon_v],
mode='nearest'))
lon_vertices.append(
map_coordinates(cube.coord('longitude').points,
[rlat_v, rlon_v],
mode='wrap'))
lat_vertices = np.array(lat_vertices)
lon_vertices = np.array(lon_vertices)
lat_vertices = np.moveaxis(lat_vertices, 0, -1)
lon_vertices = np.moveaxis(lon_vertices, 0, -1)
# Copy vertices to cube
cube.coord('latitude').bounds = lat_vertices
cube.coord('longitude').bounds = lon_vertices
return cube
Once I have checked over my CMIP6 fixes again, I plan to put in a pull request for them.
Coordinate variables
latitude
andlongitude
inFGOALS-g3
tos
data do not have attributebounds
:This causes the following problem when esmvaltool is run:
main_log_debug.txt
I tried using this fix for BCC-CSM1-1: https://github.com/ESMValGroup/ESMValCore/blob/master/esmvalcore/cmor/_fixes/cmip5/bcc_csm1_1.py
But that didn't work because it just interpolates the bounds used for
grid_latitude
andgrid_longitude
, and these bounds aren't set in the case of FGOALS-g3.How should I proceed? Is it possible to guess the bounds in some other way, or is this a case where we just have to ask the modelling centre to fix this and republish the data?
siconc
also seems to have the same problem.Thanks!
Relative path to data: CAS/FGOALS-g3/historical/r1i1p1f1/Omon/tos/gn/v20191107/tos_Omon_FGOALS-g3_historical_r1i1p1f1_gn_185001-201412.nc