Project

General

Profile

Limited precision on x/y increments for interpolation

Added by Jordi Mercader over 5 years ago

Dear all,

So far, I've been using an old version of CDO (1.5.4) to perform a bilinear interpolation between lat-lon grids. It allowed me to set an X,Y increment on the grid description file with up to 8 decimals places that were taken into account:

[meteo@recercam1 opt]$ cat pdc.09.grid
[..]
gridtype = lonlat
gridsize = 68120
xname = lon
xlongname = longitude
xunits = degrees_east
yname = lat
ylongname = latitude
yunits = degrees_north
xsize = 260
ysize = 262
xfirst = 0.147870
xinc = 0.012324000
yfirst = 40.512275
yinc = 0.009114000

So, when we ran

cdo remapbil,pdc.09.grid out.grib pdc.grib

the output grib had effectively this X/Y increment. We checked it with grib_dump:

/opt/eccodes-2.12.0/bin/grib_dump pdc.grib
[...]
jDirectionIncrementInDegrees = 0.00911494;
iDirectionIncrementInDegrees = 0.0123243;
[...]

However, when using CDO v1.9.5, we can still use the same descriptor file but only 3 decimal places are considered:

/opt/eccodes-2.12.0/bin/grib_dump pdc.grib
[...]
jDirectionIncrementInDegrees = 0.009;
iDirectionIncrementInDegrees = 0.012;
[...]

and, consequently, the new grid has different interpolated values when compared to the old version.

Do you know if there is a way to take into account more than 3 decimal places for X/Y increments when performing an interpolation? Thank you very much!


Replies (3)

RE: Limited precision on x/y increments for interpolation - Added by Ralf Mueller over 5 years ago

grib encodes double values with lossy compression. Avoid lengthy floating point numbers when working with grib1. You could use grib2, this works better:

<ram@melian:~/Downloads>
% cdo -f grb2 -setname,orog -topo,target.grid t.grib2
cdo(2) topo: Process started
cdo(2) topo: 
cdo setname: Processed 68120 values from 1 variable [0.06s 50MB]
<ram@melian:~/Downloads>
% cdo griddes t.grib2
#
# gridID 1
#
gridtype  = lonlat
gridsize  = 68120
xsize     = 260
ysize     = 262
xname     = lon
xlongname = "longitude" 
xunits    = "degrees_east" 
yname     = lat
ylongname = "latitude" 
yunits    = "degrees_north" 
xfirst    = 0.14787
xinc      = 0.012324
yfirst    = 40.512275
yinc      = 0.009114
cdo griddes: Processed 1 variable [0.12s 66MB]
For the target grid I used your input
% cat target.grid
gridtype = lonlat
gridsize = 68120
xname = lon
xlongname = longitude
xunits = degrees_east
yname = lat
ylongname = latitude
yunits = degrees_north
xsize = 260
ysize = 262
xfirst = 0.147870
xinc = 0.012324000
yfirst = 40.512275
yinc = 0.009114000

Whereas when I use grib1:

% cdo griddes t.grib
#
# gridID 1
#
gridtype  = lonlat
gridsize  = 68120
xsize     = 260
ysize     = 262
xname     = lon
xlongname = "longitude" 
xunits    = "degrees_east" 
yname     = lat
ylongname = "latitude" 
yunits    = "degrees_north" 
xfirst    = 0.148
xinc      = 0.0123243243243243
yfirst    = 40.512
yinc      = 0.00911494252873563

hth
ralf

RE: Limited precision on x/y increments for interpolation - Added by Ralf Mueller over 5 years ago

I use cdo-1.9.6 compiled with eccodes for grib2 support

RE: Limited precision on x/y increments for interpolation - Added by Jordi Mercader over 5 years ago

Thank you Ralf for your advice. I've tried it with grib2 and, as you commented, it keeps all the decimal places.

    (1-3/3)