Re: Converting GRIB To NetCDF

NOTE: The decoders mailing list is no longer active. The list archives are made available for historical reasons.

On Fri, 3 Dec 2004, Matthew Hanna wrote:

Hi!  I am trying to convert some GRIB files to NetCDF so I can use the
data in my research project.
I found the gribtonc program and its friends and was able to compile
them and work with the example data.

hiya matthew,

i think the problem might be a old version of the decoders package, make
sure you have version decoders-3.0.6.tar.Z.

the files in question were downloaded/made cdls/converted to netcdf w/o
any problems. the platform was solaris 5.9 but that shouldn't matter.  the
cdl's for the u/v winds are attached to the msg. if you  want to have
both u/v winds in the same netcdf file, just include the v variable:

        float  v(record,level,lat,lon) ;
               v:long_name = "v-component of wind at isobaric levels" ;
               v:GRIB_parameter_number = 34 ;
               v:GRIB_level_flag = 100 ;
               v:units = "m/s" ;
               v:_FillValue = -9999.f ;
               v:navigation = "nav" ;

in the u_winds.cdl file, might want to rename file too.

a method for created a cdl w/ all the variables needed, concate the grib
files together before running gribtocdl routine.

robb...

ps daryl these are grib 1 files not grib 2 files. Dec 6 there will be a
decoders release w/ grib 2 decoders and utilities in java, so it will be
platform independant.




The data I am using for my research can be found at
ftp://usgodae1.usgodae.org/pub/outgoing/fnmoc/models/
in both the coamps and nogaps folders.  Occasionally I get lucky and I
am able to create a cdl file and a netcdf
file but for the most part I just get cdl files that don't work.

Example
---------------------------
I download these files:
ftp://usgodae1.usgodae.org/pub/outgoing/fnmoc/models/nogaps/2004/2004120100/US058GMET-GR1mdl.0058_0240_00000F0RL2004120100_0100_006000-000000wnd_ucmp
ftp://usgodae1.usgodae.org/pub/outgoing/fnmoc/models/nogaps/2004/2004120100/US058GMET-GR1mdl.0058_0240_00000F0RL2004120100_0100_006000-000000wnd_vcmp

I run gribtocdl to create the cdl files:
$ gribtocdl
US058GMET-GR1mdl.0058_0240_14400F0RL2004120100_0105_000100-000000wnd_ucmp
 > wnd_ucmp.cdl
$ gribtocdl
US058GMET-GR1mdl.0058_0240_14400F0RL2004120100_0105_000100-000000wnd_vcmp
 > wnd_vcmp.cdl

In this case wnd_ucmp.cdl doesn't look right.  It is missing the lat and
lon information and perhaps a few other details however
wnd_vcmp.cdl looks like it is correct.

I run gribtonc to create the new netcdf files:
US058GMET-GR1mdl.0058_0240_14400F0RL2004120100_0105_000100-000000wnd_ucmp
Dec 03 14:53:37 gribtonc[1884]: Starting Up
ncgen: wnd_ucmp.cdl line 6: dimension length must be positive
ncgen: wnd_ucmp.cdl line 7: dimension length must be positive
ncgen: wnd_ucmp.cdl line 9: dimension length must be positive
ncgen: wnd_ucmp.cdl line 10: dimension length must be positive
ncgen: wnd_ucmp.cdl line 11: dimension length must be positive
ncgen: wnd_ucmp.cdl line 130: too many values for this variable, 0 >= 0
Dec 03 14:53:37 gribtonc[1884]: can't run "ncgen -o wnd_ucmp.nc
wnd_ucmp.cdl"
Dec 03 14:53:37 gribtonc[1884]: can't create or size 0 output netCDF
file wnd_ucmp.nc, exiting
Dec 03 14:53:37 gribtonc[1884]: Exiting
Dec 03 14:53:37 gribtonc[1884]: 0 WMO msgs, 0 GRIBs decoded, 0 written

US058GMET-GR1mdl.0058_0240_14400F0RL2004120100_0105_000100-000000wnd_vcmp
Dec 03 14:54:47 gribtonc[2068]: Starting Up
Dec 03 14:54:47 gribtonc[2068]: 1: wrote v_fhg(0,0,*,*) to wnd_vcmp.nc
Dec 03 14:54:47 gribtonc[2068]: EOF on input
Dec 03 14:54:47 gribtonc[2068]: Exiting
Dec 03 14:54:47 gribtonc[2068]: 1 WMO msgs, 1 GRIBs decoded, 1 written

So wnd_ucmp.nc wasn't created but wnd_vcmp.nc was.  wnd_vcmp.nc is
exactly what I expected.  These two files are supposed to go together.
In fact, once I can get this working the two netcdf files will be merged
into one file and will possibly include additional data from the same
folder where these files were downloaded from.

If it helps I believe these GRIB files were created using GrADS.

Can someone please help me figure this out?

Thanks!
Matthew Hanna


==============================================================================
Robb Kambic                                Unidata Program Center
Software Engineer III                      Univ. Corp for Atmospheric Research
rkambic@xxxxxxxxxxxxxxxx                   WWW: http://www.unidata.ucar.edu/
==============================================================================
  • 2004 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the decoders archives: