BUFR.pm

BUFR.pm is a CPAN module for BUFR decoding and encoding developed at the Norwegian Meteorological Institute (met.no).

Below you will find a toolkit of BUFR handling programs used actively at met.no, with examples of use and complete source code. Hopefully this will demonstrate the power of BUFR.pm as well as providing potential users of BUFR.pm an easy start. The first 4 programs are in fact included in the CPAN BUFR distribution.

A line consisting solely of three dots (...) in the examples of output from running the programs, marks that a (not so interesting) part of the output has been left out.

bufrread.pl

Decodes and prints section 0-4 in BUFR messages in input file(s).

source code

Example: Executing bufrread.pl without arguments

Example: buffread.pl --help

Example: Processing a multisubset multimessage BUFR SYNOP file with no options set

Example: Same as above, but with options --param and --data_only set

Example: Same as previous example, but with option --filter also set. Note that the program bufrdump.pl described below provides the same option but with more functionality.

Example: Processing a BUFR TEMP file with option --codetables set (to resolve code and flag values)

Example: Processing a file containing operators 222000 and 223000 with option --bitmap set (to display bitmapped entities on same line)

Example: Processing a file containing associated fields and change scale and data width operators

Example: Same as above, but with options --all_operators and --data_only set

Example: Processing a BUFR BUOY file with recoverable formatting errors with option --strict_checking set

bufrresolve.pl

Displays information in BUFR tables.

source code

Example: Executing bufrresolve.pl without arguments (or with --help, for this program this amounts to the same)

Example: Executing bufrresolve.pl on a table D descriptor (309052)

Example: Same as above, but with option --partial

Example: Same as above, but with option --simple

Example: Executing bufrresolve.pl on a sequence of descriptors with option --noexpand

Example: Showing content of code table (option --code)

Example: Resolving flag value (option --flag)

bufrencode.pl

Encode a BUFR message based on data and metadata text files.

source code

Example: Executing bufrencode.pl without arguments

Example: bufrencode.pl --help

Example: Encoding a 2 subset BUFR SYNOP message

bufr_reencode.pl

Encode BUFR message(s) based on a text file matching what you would get by running bufrread.pl on the resulting BUFR file. This might be a handy alternative to bufrencode.pl for encoding new BUFR messages: start with a similar BUFR message you know is correctly formatted, run bufrread.pl on this, edit the output as desired, and using this as input to bufr_reencode.pl.

source code

Example: Executing bufr_reencode.pl without arguments

Example: bufr_reencode.pl --help

Example: Encoding a single subset BUFR SYNOP message

bufrdump.pl

A BUFR toolkit wouldn't be complete unless you have a way to dump the contents of BUFR files in a way which requires no prior knowledge whatsoever of the BUFR format. Therefore, the program bufrdump.pl is included even though it actually does not employ BUFR.pm, but rather is a wrapper around a Fortran program (bufrdump) which uses the ECMWF libbufr library for the BUFR decoding. The reason for this choice was that for this particular program speed might be important (expecting users to dump huge BUFR files and grep'ing on the output), besides the fact that the main part of the program would be equally boring to code whether in Fortran or Perl.

The parameters are dumped in a name=value fashion according to what most users at met.no expects, e.g. TA=-9.3 for temperature at 2 m equal to -9.3 Celsius. If your users are accustomed to other symbols and/or units, this should be rather easy to modify in source code of bufrdump.F.

source code

Example: Executing bufrdump.pl without arguments

Example: bufrdump.pl --help

Example: Dumping a multisubset multimessage BUFR SYNOP file with no options set

Example: Same as above, but with option --param set

Example: Same as above, but also with option --filter set

Example: Dumping a BUFR TEMP message with no options set