Project

General

Profile

sellonlatbox applied on a tripolar grid (ORCA grid) is wrong

Added by Josué Bock almost 5 years ago

Hello,
When applying cdo sellonlatbox to a CMIP6 file using ORCA grid (tripolar grid), it works but the outfile has not the expected properties: especially, the output longitude range (58.82 to 89.74), in not as requested (70 to 90).

ncdump of initial file:

> ncdump -h fgdms_Omon_CNRM-ESM2-1_historical_r1i1p1f2_gn_185001-201412_seltimestep.nc
netcdf fgdms_Omon_CNRM-ESM2-1_historical_r1i1p1f2_gn_185001-201412_seltimestep {
dimensions:
    time = UNLIMITED ; // (1 currently)
    bnds = 2 ;
    x = 362 ;
    y = 294 ;
    nvertex = 4 ;
variables:
    double time(time) ;
        time:standard_name = "time" ;
        time:long_name = "Time axis" ;
        time:bounds = "time_bnds" ;
        time:units = "days since 1850-01-01 00:00:00" ;
        time:calendar = "gregorian" ;
        time:axis = "T" ;
    double time_bnds(time, bnds) ;
    double lon(y, x) ;
        lon:standard_name = "longitude" ;
        lon:long_name = "Longitude" ;
        lon:units = "degrees_east" ;
        lon:_CoordinateAxisType = "Lon" ;
        lon:bounds = "lon_bnds" ;
    double lon_bnds(y, x, nvertex) ;
    double lat(y, x) ;
        lat:standard_name = "latitude" ;
        lat:long_name = "Latitude" ;
        lat:units = "degrees_north" ;
        lat:_CoordinateAxisType = "Lat" ;
        lat:bounds = "lat_bnds" ;
    double lat_bnds(y, x, nvertex) ;
    double depth ;
        depth:standard_name = "depth" ;
        depth:long_name = "depth" ;
        depth:units = "m" ;
        depth:positive = "down" ;
        depth:axis = "Z" ;
        depth:name = "depth" ;
    float fgdms(time, y, x) ;
        fgdms:standard_name = "surface_upward_mole_flux_of_dimethyl_sulfide" ;
        fgdms:long_name = "Surface Upward Flux of DMS" ;
        fgdms:units = "mol m-2 s-1" ;
        fgdms:coordinates = "depth lat lon" ;
        fgdms:_FillValue = 1.e+20f ;
        fgdms:missing_value = 1.e+20f ;
        fgdms:online_operation = "average" ;
        fgdms:cell_methods = "area: mean where sea time: mean" ;
        fgdms:interval_operation = "1800 s" ;
        fgdms:interval_write = "1 month" ;
        fgdms:description = "Gas exchange flux of DMS (positive into atmosphere)" ;
        fgdms:history = "none" ;
        fgdms:cell_measures = "area: areacello" ;
...

sinfo of original file:
> cdo sinfo fgdms_Omon_CNRM-ESM2-1_historical_r1i1p1f2_gn_185001-201412_seltimestep.nc
   File format : NetCDF4
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter ID
     1 : unknown  CNRM-ESM2-1 v instant       1   1    106428   1  F32  : -1            
   Grid coordinates :
     1 : curvilinear              : points=106428 (362x294)
                              lon : -179.9965 to 179.9903 degrees_east
                              lat : -79.00794 to 89.74177 degrees_north
                        available : cellbounds
...

sellonlatbox and sinfo on the resulting file:
> cdo sellonlatbox,0,360,70,90 fgdms_Omon_CNRM-ESM2-1_historical_r1i1p1f2_gn_185001-201412_seltimestep.nc fgdms_Omon_CNRM-ESM2-1_historical_r1i1p1f2_gn_185001-201412_seltimestep_sellonlatbox.nc

> cdo sinfo fgdms_Omon_CNRM-ESM2-1_historical_r1i1p1f2_gn_185001-201412_seltimestep_sellonlatbox.nc
   File format : NetCDF4
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter ID
     1 : unknown  CNRM-ESM2-1 v instant       1   1     10578   1  F32  : -1            
   Grid coordinates :
     1 : curvilinear              : points=10578 (258x41)
                              lon : -179.9295 to 179.9903 degrees_east
                              lat : 58.82096 to 89.74177 degrees_north
                        available : cellbounds


Is it a bug, and is there another way to obtain the desired result with such a grid?

If there is no solution, is there a way so that cdo detects such grid to abort the process?

The infile is attached.

Kind regards


Replies (2)

RE: sellonlatbox applied on a tripolar grid (ORCA grid) is wrong - Added by Ralf Mueller almost 5 years ago

Hi!

The problem is, that it's not always possible the select a box in all grids, where all location follow the selection. You cannot keep the (possibly arbitrary) gridstructure and limit the locations based on min/max for lon/lat. your grid is curved, so a box along the original coordinates has nothing to do with a box on a lonlat grid.

If you drop the requirement of keeping the base grid and transform the input to an unstructured grid (where the location are the same, but the lon and lat are just long 1D-vectors), the box-selection works:
  1. create mask file that doesn mask anything but marks all points the same
    cdo gtc,-9999999999 fgdms_Omon_CNRM-ESM2-1_historical_r1i1p1f2_gn_185001-201412_seltimestep.nc mask.nc
  2. re-write your input file to a an unstructured grid
    cdo -reducegrid,mask.nc fgdms_Omon_CNRM-ESM2-1_historical_r1i1p1f2_gn_185001-201412_seltimestep.nc fgdms_unstruct.nc
  3. rerun sellonlatbox and check the locations:
    % cdo -sinfov -sellonlatbox,0,360,70,90 fgdms_unstruct.nc 
    cdo(1) sellonlatbox: Process started
       File format : NetCDF4
        -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter name
         1 : unknown  CNRM-ESM2-1 v instant       1   1      6332   1  F32  : fgdms         
       Grid coordinates :
         1 : unstructured             : points=6332  nvertex=4
                                  lon : -179.9295 to 179.9903 degrees_east
                                  lat : 70.00931 to 89.74177 degrees_north
                            available : cellbounds
       Vertical coordinates :
         1 : depth_below_sea          : levels=1  scalar
                                depth : 0 m
       Time coordinate :  1 step
         RefTime =  1850-01-01 00:00:00  Units = days  Calendar = gregorian  Bounds = true
      YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss
      1850-01-16 12:00:00
    cdo(1) sellonlatbox: Processed 1 variable over 1 timestep.
    cdo    sinfon: Processed 1 variable over 1 timestep [0.02s 62MB].

I uploaded the intermediate files. In most cases data analysis and plotting tools do only support a limited number of grid structures and fully unstructured is often skipped. So people try to avoid this and live with the restrictions.

hth
ralf

RE: sellonlatbox applied on a tripolar grid (ORCA grid) is wrong - Added by Josué Bock almost 5 years ago

Dear Ralf,
Thanks a lot for your suggestion of solution.

However, as you pointed out, getting an unstructured grid is not very convenient since it is not supported by many plotting tools.

I just found another solution, which better suits my needs:
- first apply a masklonlatbox, which keeps only the requested values (and only the requested values)
- then apply a sellonlatbox, which will only reduce the grid dimension, where the grid cells whose latitude do not match the request have been set to missing by the previous command.

I uploaded the resulting file

Kind regard,
Josué

    (1-2/2)