Geo::BUFR

Geo::BUFR 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 Geo::BUFR as well as providing potential users of Geo::BUFR an easy start. The first 5 programs are included in the CPAN Geo::BUFR distribution.

You might want to change the value of the following constants in source code: DEFAULT_TABLE_PATH, DEFAULT_TABLE and DEFAULT_CTABLE.

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). If the BUFR message is contained in a WMO bulletin, will also print WMO ahl.

source code

Example: Executing bufrread.pl without arguments

Example: buffread.pl --help

Example: Processing a file containing several BUFR SYNOP bulletines, 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 message with option --codetables set (to resolve code and flag values)

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

Example: Processing a BUFR message 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 file containing BUFR BUOY bulletins with recoverable formatting errors in the BUFR messages, with option --strict_checking set

bufrresolve.pl

Displays information in BUFR tables.

source code

Example: Executing bufrresolve.pl without arguments

Example: bufrresolve.pl --help

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

bufralter.pl

bufralter.pl provides an even easier way to do some basic manipulation of BUFR messages than does bufr_reencode.pl (although much more restricted in what changes are possible). Besides, bufralter.pl has the nice feature of not touching the text between the BUFR messages. This might be handy if you for example have a file with WMO bulletines and want to do some changes in the BUFR messages without affecting or losing the WMO bulletin envelopes.

source code

Example: Executing bufralter.pl without arguments

Example: bufralter.pl --help

Example: Altering a single subset BUFR SYNOP message, by changing value of hour, minute and temperature in section 4, incrementing update sequence number and changing version number for master table and local table.

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 Geo::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.

So far only dumping of BUFR SYNOP and BUFR TEMP has been implemented. More observations types are likely to be included in the future.

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