Project

General

Profile

Difficulty remapping data on MPI-ESM1-2-LR grid

Added by Brendan DeTracey almost 3 years ago

Hi all, (cdo 1.9.9, but I do not believe the remap code has been changed for more recent cdo versions.)
I am having problems doing a conservative remap on data on the MPI-ESM1-2-LR ocean model grid, because the grid is.. well.. not a properly defined grid. My code is as follows:

cdo -O --reduce_dim setattribute,mask@long_name='T-grid CDO Grid Reduction Mask' -chname,zos,mask -select,name=zos -setmisstoc,0 -eq zos_Omon_MPI-ESM1-2-LR_historical_r1i1p1f1_gn_195001.nc zos_Omon_MPI-ESM1-2-LR_historical_r1i1p1f1_gn_195001.nc mask_Omon_MPI-ESM1-2-LR_t-grid.nc
cdo -O remapcon,cdo_scrip_grid_nwa-gt-600.nc -reducegrid,mask_Omon_MPI-ESM1-2-LR_t-grid.nc mask_Omon_MPI-ESM1-2-LR_t-grid.nc grid_Omon_MPI-ESM1-2-LR_t-grid_nwa-gt-600.nc
Do you have any advice on how to get this bad grid to behave? Or how to get cdo to ignore the bad grid points and continue with the conservative remap?


Replies (3)

RE: Difficulty remapping data on MPI-ESM1-2-LR grid - Added by Uwe Schulzweida almost 3 years ago

Hi Brendan,

The MPI-ESM1-2 ocean data is unfortunately raw model data. I have no idea why the data was published in this state in CMIP6. The first and last column must be removed before use. These columns are redundant and contain unusable coordinates. This leads to problems when interpolating. With sethalo,-1,-1 these columns can be easily removed:

cdo remapcon,cdo_scrip_grid_nwa-gt-600.nc -sethalo,-1,-1 zos_Omon_MPI-ESM1-2-LR_historical_r1i1p1f1_gn_195001.nc grid_Omon_MPI-ESM1-2-LR_t-grid_nwa-gt-600.nc
Cheers,
Uwe

RE: Difficulty remapping data on MPI-ESM1-2-LR grid - Added by Uwe Schulzweida almost 3 years ago

Hi Brendan,

I was surprised that the conservative remapping works at all with this target cell. That's why I talked to the author of the code, Moritz Hanke. Unfortunately, I have to inform you that the result is not correct! For remapcon, the cells must be convex in the broadest sense. That is definitely not the case here. In the next version, the shape of the cells will be checked and an error message will be issued if necessary.

In CDO version 2.0.4 there is a new function selregion. With this function you can select all source cells within a region and then calculate the mean value with fldmean. Only the source cells whose centre lies within the region are taken into account. Maybe this will help you. Here is an example:

# create a CDO region file from the target cell:
cdo -s gmtcells -random,cdo_scrip_grid_nwa-gt-600.nc > region.txt
cdo fldmean -selregion,region.txt -sethalo,-1,-1 zos_Omon_MPI-ESM1-2-LR_historical_r1i1p1f1_gn_195001.nc result.nc

Cheers,
Uwe

RE: Difficulty remapping data on MPI-ESM1-2-LR grid - Added by Brendan DeTracey almost 3 years ago

Thanks Uwe! Another solution is to change the grid type to unstructured and then select a lon lat box that is slightly bigger than the polygon in question. I will compare the results to your fldmean method:

$ cdo -O sellonlatbox,-100,0,25,77 -setgridtype,unstructured zos_Omon_MPI-ESM1-2-LR_historical_r1i1p1f1_gn_195001.nc tmp.nc
cdo(1) setgridtype: Process started
cdo(1) setgridtype: Processed 56320 values from 1 variable over 1 timestep.
cdo    sellonlatbox: Processed 56320 values from 1 variable over 1 timestep [0.25s 38MB].
$ cdo verifygrid tmp.nc
cdo    verifygrid: Grid consists of 15461 cells (type: unstructured), of which
cdo    verifygrid:     15461 cells have 4 vertices
cdo    verifygrid:         7 cells have duplicate vertices
cdo    verifygrid:        13 cells are not unique
cdo    verifygrid:         3 cells are non-convex
cdo    verifygrid:        10 cells have their center point located outside their boundaries
cdo    verifygrid:  longitude : 260.001 to 359.9904 degrees
cdo    verifygrid:   latitude : 25.00098 to 76.99862 degrees
cdo    verifygrid: Processed 1 variable [0.02s 25MB].
$ cdo -O --reduce_dim setattribute,mask@long_name='T-grid CDO Grid Reduction Mask' -chname,zos,mask -select,name=zos -setmisstoc,0 -eq tmp.nc tmp.nc mask_Omon_MPI-ESM1-2-LR_t-grid.nc                                                       cdo(1) chname: Process started
cdo(2) select: Process started
cdo(3) setmisstoc: Process started
cdo(4) eq: Process started
cdo(4) eq: Processed 30922 values from 2 variables over 2 timesteps.
cdo(3) setmisstoc: Processed 15461 values from 1 variable over 1 timestep.
cdo(2) select: Processed 15461 values from 1 variable over 1 timestep.
cdo(1) chname: Processed 15461 values from 1 variable over 1 timestep.
cdo    setattribute: Processed 15461 values from 1 variable over 1 timestep [0.23s 26MB].
$ cdo -O remapcon,cdo_scrip_grid_nwa-gt-600.nc -reducegrid,mask_Omon_MPI-ESM1-2-LR_t-grid.nc mask_Omon_MPI-ESM1-2-LR_t-grid.nc grid_Omon_MPI-ESM1-2-LR_t-grid_nwa-gt-600.nc
cdo(1) reducegrid: Process started
cdo    remapcon: YAC first order conservative weights from unstructured (10168) to unstructured (1) grid
cdo(1) reducegrid: Processed 15461 values from 1 variable over 1 timestep.
cdo    remapcon: Processed 10168 values from 1 variable over 1 timestep [1.32s 36MB].
I think I will have to add model specific code to my workflow. Many modeling groups published data on ESGF that did not conform to CF and CMIP6 standards, but passed all the automated software checks. Since the data is free, I suppose it is a question of "buyer beware", as Americans like to say. A terrible saying, that. I have tried to write a work flow such that all CMIP6 ocean model data can pass through the same code. However, I have come to believe that this is clearly impossible. :)
A cdo tool that can reduce a grid by rejecting bad cells would be very useful. A lot of the CMIP ocean model grids need masking to remove bad cells so the good cells can still be used.

    (1-3/3)