This was a doubt I had some time ago: Is it possible to concatenate different-sized grib data files? I mean, do something like:

cat file1 file2 file... > very_big_file

so that I could use a single ctl to access all data? At the time, I had a set of "non-templatable" like this:

    1st binary file, 4 years of montly data
    2nd binary file, 6 years of montly data
  ...
(n-1)th binary file, 6 years of montly data
   n-th binary file, 2 years of montly data

Since I had different years in the same file, I couldn't use templates (see comment for newer versions of grads). So either I splited everything into yearly files, or I joined all of them into a single file.

To complicate even further, the grib files were from ECMWF, so there were some junk bytes at the end of each file.

After some testing, I found out how to do it. Here's the walktrou:

cat file1 file2 ... fileN > my_big_file
grib2ctl.pl -verf my_big_file > my_big_file.ctl
gribmap -E -i my_big_file.ctl

Step 1: cat all files together:

Step 2: Use grib2ctl.pl to generate the proper ctl.

Step 3: Use gribmap to generate the a new map for the new file.

The upper case option '-E' tells gribmap to ignore those junk bytes both at the end and in the middle of the grib file!! (that's the trick). Now it is possible to open the concatenated file.

What if my grib file don't have junk bytes?

You can do the same thing, just remove the '-E' option for gribmap.

Pages you should read:

Doing GRIB in GrADS
About grib2ctl
[|http://grads.iges.org/grads/gadoc/gradutilgribmap.htmlAbout gribmap]]
About templates

Page last modified on May 26, 2015, at 05:38 PM
Powered by PmWiki