Project

General

Profile

converting netcdf to grib2 - some kind of grid error

Added by George Loriot over 8 years ago

I'm new to cdo, and am trying to convert netcdf output from our ARW WRF runs to grib2. After installing cdo (outlined below) I invoke
cdo -f grb2 copy wrfout.nc wrfout.grb2 (wrfout.nc is the existing netcdf output file, wrfout.grb2 is the desired copy of it in grib2 format)
and the result is
Warning (cdfSetVar) : Inconsistent variable definition for XLAT!
Warning (cdfSetVar) : Inconsistent variable definition for XLONG!
Warning (cdfSetVar) : Inconsistent variable definition for XLAT_U!
Warning (cdfSetVar) : Inconsistent variable definition for XLONG_U!
Warning (cdfSetVar) : Inconsistent variable definition for XLAT_V!
Warning (cdfSetVar) : Inconsistent variable definition for XLONG_V!
Warning (define_all_grids) : Time varying grids unsupported, using grid at time step 1!
GRIB_API ERROR : concept: no match for shortName=LU_INDEX
Warning (gribapiDefParam) : grib_api: No match for shortName=LU_INDEX
Warning (gribapiDefGrid) : Curvilinear grids are unsupported in GRIB format! Created wrong GDS!
GRIB_API ERROR : concept: no match for shortName=ZNU
Warning (gribapiDefParam) : grib_api: No match for shortName=ZNU

Error (gribapiDefGrid) : Unsupported grid type: generic

The grb2 file is created but only contains one variable instead of the full set of variables in the WRF output netcdf file.

Build:
centos 6.7, gcc, gfortran netcdf-3.6.3 (gcc build) grib_api 1.12.3, proj4.9.2
This built with no errors, and it runs with no runtime failure, except it doesn't recognize the grid in the netcdf file, which is Lambert conformal.

Is there something I'm missing here, such as a table to convert the grid? I could run wrf to output grid2 I think, but for vaious ananlyis we'd like to have both netcdf and grib2 output files.

Any help at will be much appreciated. Thnaks in advance.

George Loriot
Dept of Atmospheric Sciences
Lyndon State College
Lyndonville, VT


Replies (7)

RE: converting netcdf to grib2 - some kind of grid error - Added by George Loriot over 8 years ago

I should have mentioned that this is cdo-1.6.9

George Loriot
Lyndon State College

RE: converting netcdf to grib2 - some kind of grid error - Added by Ralf Mueller over 8 years ago

There is a fundamental difference between netcdf and grib2

  • netcdf is a self-descibing file format
    • shortnames have to be uniq
    • your are free to define global of variable attributes
    • your are free to create any kind of dimensions
  • grib1 and grib2 are standards from the WMO
    • main purpose is having a global standard to be able to chare data worldwide - that's why
    • data parameters (names,units,..) are moreless FIXED:
      information about these things is stored in text-tables coming with the reference implementation grib_api. You are free to add things in so called local tables for you own need, but you will not be able to chare these data sets with other grib2 users, because you table are let's-say private

HENCE: There is no general way to convert arbitrary netcdf files into grib2 format.

The CDO-Warning is about exactly this problem: the netcdf shortname is not part of the grib2 standard, so things cannot be converted out-of-the-box.

RE: converting netcdf to grib2 - some kind of grid error - Added by George Loriot over 8 years ago

Thank you for the speedy reply. I would still like to attempt to do this, at least for our ARW WRF netcdf output files. I think it means that I must update 'local definitions' somewhere; since we only want to use these grib2 files locally, we should be able to share the local text tables (definitions?)
Is there a pointer to the nomenclature for this and some documentation on how to do this? Is this a sensible thing to do? Is there a tool that shows what variables need definition or text-table?
Is there any other tool that would accomplish this goal, if cdo is not a good candidate?
Any help would be appreciated

Thanks in advance.

George Loriot

RE: converting netcdf to grib2 - some kind of grid error - Added by Ralf Mueller over 8 years ago

My recommendation is rather changing WRF output to something that can be converted to standard grib2, i.e. switch to shortname/standard_name/units that are already part of the official grib2 tables.

IMO, the combination of nc4 field compression and using float instead of double for output is similarly space-efficient like grib2. If its sensible, it depends on the number of changes: changing names is one thing, but changing units can be tedious, if your model should do this directly. If postprocessing is ok, you could use the setpartab operator.

good luck!

RE: converting netcdf to grib2 - some kind of grid error - Added by Mariana Scott almost 8 years ago

I have a quick follow up about this.

In attempting to convert WRF-ARW netCDF to GRIB, I ended up choosing a single variable that I am interested in with -selname,REFL_10CM.
Interestingly, I ended up getting the variable "NLWRS=Net long wave (surface) [W/m^2]" in my grib file.

When I look this variable up on the GRIB table, I see that it is assigned to number 112 (http://www.nco.ncep.noaa.gov/pmb/docs/on388/table2.html) which happens to be the same number that was assigned to my variable, REFL_10CM, in my netCDF file (cdo vardes wrfout_d03_....nc > varname). Therefore, I thought about just doing a "cdo -f grb copy -selcode" for the GRIB code I wanted in hopes that it would find the variable in the file. I think the variable REFL_10CM is equivalent to "Derived radar reflectivity backscatter from parameterized convection" REFZC nmber 167 in Parameter Table Version 129 (PDS Octet 4 = 129).

...and that's where I'm stuck. So, in short, would giving cdo a selcode for my variable do the trick?

RE: converting netcdf to grib2 - some kind of grid error - Added by Mariana Scott almost 8 years ago

So, I am able to change the variable name with:
cdo setparam,167.129 wrfout_d03_refl.grb wrfout_d03_refl_new.grb

However, instead of using variable number 167 from table 129 (REFZC) it is using variable number 167 from table 2 (VDDSF).
It seems like I'm getting close to a solution.

RE: converting netcdf to grib2 - some kind of grid error - Added by Ralf Mueller almost 8 years ago

That's why I avoid grb2 whenever I can - its not self-declarative.

scnr
ralf

    (1-7/7)