Override the grid description for a grib file
Added by Jia Wang 5 months ago
I have a grib file, 1.grb (attached), which has the grid description (cdo griddes 1.grb):
gridtype = generic
gridsize = 987601
Because the grid type is generic, each time I do some operation on 1.grb, I got this message:
cdi decodeGDS_double : GRIB gridtype 5 unsupported
I know that 1.grb is on a projection, and its grid description is supposed to be:
gridtype = projection
gridsize = 987601
xsize = 1121
ysize = 881
xname = x
xunits = "m"
yname = y
yunits = "m"
xfirst = 0
xinc = 4762.5
yfirst = 0
yinc = 4762.5
grid_mapping = Polar_Stereographic
grid_mapping_name = polar_stereographic
standard_parallel = 60.
straight_vertical_longitude_from_pole = 255.
latitude_of_projection_origin = 90.
earth_radius = 6371200.
false_easting = 1902531.67435698
false_northing = 7617604.93005048
longitudeOfFirstGridPointInDegrees = 240.976992
latitudeOfFirstGridPointInDegrees = 23.117
How could I set the grid description for this grib file to be correct?
Replies (4)
RE: Override the grid description for a grib file - Added by Uwe Schulzweida 5 months ago
Add the CDO option --eccodes to decode GRIB1 records with the EcCodes library:
cdo --eccodes -sinfon 1.grb File format : GRIB -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name 1 : unknown unknown v accum 1 1 987601 1 P13 : tp Grid coordinates : 1 : projection : points=987601 (1121x881) mapping : polar_stereographic x : 0 to 5334560 by 4763 m y : 0 to 4191440 by 4763 m Vertical coordinates : 1 : surface : levels=1 Time coordinate : time : 1 step RefTime = 2009-12-01 12:00:00 Units = hours Calendar = proleptic_gregorian YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss 2009-12-01 18:00:00
RE: Override the grid description for a grib file - Added by Jia Wang 5 months ago
Use the "--eccodes" option can give the correct projection. But another problem came up.
What I want to do is to combine the stage IV precipitation within a day. And these are my steps:
1. Put four files of 6-hour precipitation into one file: 2009120200.grb
grib_copy ST4.2009120106.06h ST4.2009120112.06h ST4.2009120118.06h ST4.2009120200.06h 2009120200.grb
2. Sum up the precipitation within the file
cdo --eccodes --timestat_date last timselsum,4 2009120200.grb new.grb
I got the error message:
!!! failed call to grib_set_double( grib_handle* h, "LaDInDegrees", 60.000000) !!!
/tmp/deploy//eci-builds/cdo-2.4.0-build-GNU13.2/cdo-2.4.0/libcdi/src/stream_gribapi.c at line 2392: my_grib_set_double(gh, "LaDInDegrees", gpp.lat_1) failed: Value is read only
ST4.2009120118.06h (1.23 MB) ST4.2009120118.06h | |||
ST4.2009120200.06h (1.23 MB) ST4.2009120200.06h | |||
ST4.2009120106.06h (1.23 MB) ST4.2009120106.06h | |||
ST4.2009120112.06h (1.32 MB) ST4.2009120112.06h | |||
2009120200.grb (0 Bytes) 2009120200.grb |
RE: Override the grid description for a grib file - Added by Uwe Schulzweida 5 months ago
This seems to be a bug in the GRIB1 ecCodes interface of CDO. We will fix it in the next release.
Could you work with GRIB2:
cdo -f grb2 --eccodes --timestat_date last timselsum,4 2009120200.grb new.grb
RE: Override the grid description for a grib file - Added by Jia Wang 5 months ago
It is also I am currently doing.
I use "grib_set -s edition=2" from eccodes to convert the files, such as ST4.2009120112.06h, into a grb2 file.
One thing is that, after the "grid_set", the time information in the new grb2 file is not correct (for some files, it is correct. I suspect it is an issue related to the stageIV precipitation file itself). So I need to use something like "grib_set -s dataDate=${date_now_beg_YMD},dataTime=${date_now_beg_HS},stepType=accum,stepRange=0-6,startStep=0,endStep=6 ${file_grb2_tmp} ${file_grb2}" to reset the incorrect values.
Just in case someone runs into the same problem as I did. It could be a way to temporally resolve it.