How do I get the BUFR decoding/encoding utilities to work?

Created by Yves Pelletier
Keywords:
utilities encoding decoding
Last updated by:
Yves Pelletier

libECBUFR includes two utilities: bufr_encoder and bufr_decoder.

Make sure to set the environment variable BUFR_TABLES to the directory containing tables B and D. If you installed libECBUFR using the downloadable debian package, the proper command under the most commonly used Unix shells would be:

export BUFR_TABLES=/usr/share/libecbufr

Assuming you have a BUFR file named data.bufr, the basic decoding command is:

bufr_decoder -inbufr data.bufr

By default, the data dump includes the units and definition of the descriptors, to increase human readability.

Now to produce an ascii dump and template suitable for re-encoding back to BUFR:

bufr_decoder -inbufr data.bufr -output data.txt -dump -otemplate template.txt

The -dump switch tells the decoder to omit descriptor name and unit. The -otemplate switch tells the decoder to produce an ASCII dump of the descriptor sequence in section 3. The command will produce two files: data.txt and template.txt. These files may be edited, values altered, etc. This can be useful, for instance, when prototyping a new template or a new BUFR product.

Then, to re-encode, use the following command:

bufr_encoder -datafile data.txt -outbufr newdata.bufr -template template.txt -compress

The switch -compress may be omitted. In that case the BUFR data will be uncompressed.

To view all the available switches, just enter "bufr_decoder" or "bufr_encoder".