SYNOPSIS

bufrextract.pl <bufr file(s)>
    [--ahl <ahl_regexp>]
    [--only_ahl] | [--without_ahl]
    [--reuse_ahl n]
    [--help]
    [--outfile <filename>]
    [--verbose n]

DESCRIPTION

Extract all BUFR messages and/or corresponding AHLs from BUFR file(s), possibly filtering on AHL.

The AHL (Abbreviated Header Line) is recognized as the TTAAii CCCC DTG [BBB] immediately preceding the BUFR message.

Execute without arguments for Usage, with option --help for some additional info. See also https://wiki.met.no/bufr.pm/start for examples of use.

OPTIONS

--ahl <ahl_regexp> Extract BUFR messages and/or AHLs with AHL
                   matching <ahl_regexp> only
--only_ahl         Extract AHLs only
--without_ahl      Extract BUFR messages only
--reuse_ahl n  n=0 (default) AHL is considered belonging to a BUFR message
                   only if immediately preceding
               n=1 When filtering using --ahl: Reuse last AHL found if current
                   BUFR message has no immediately preceding AHL
--help             Display Usage and explain the options used. For even
                   more info you might prefer to consult perldoc bufrextract.pl
--outfile <filename>
                   Will print to <filename> instead of STDOUT
--verbose n        Set verbose level to n, 0<=n<=6 (default 0)

Options may be abbreviated, e.g. --h or -h for --help.

For option --ahl the <ahl_regexp> should be a Perl regular expression. E.g. --ahl 'ISS... ENMI' will decode only BUFR SHIP (ISS) from CCCC=ENMI.

If the bufr file(s) are known to consist solely of GTS bulletins, you probably should use --reuse 1 when applying --ahl, in order to extract all (and not only the first) BUFR messages in multi message bulletins (such bulletins are very rare, though). Note that the corresponding AHL is still printed only once.

No bufrtables are needed for running bufrextract.pl, since section 4 in BUFR message will not be decoded (which also speeds up execution quite a bit).

HINTS

With a little knowledge of Perl you could easily extend bufrextract.pl to extract BUFR messages based on whatever information is available in section 0-3, by making your own copy of bufrextract.pl and then employing one of the many get_ subroutines in BUFR.pm. For example, to extract only BUFR messages with data category 1, add the following line just before calling is_filtered() in code:

next if $bufr->get_data_category() != 1;

CAVEAT

bufrextract.pl expects the character sequence CRCRLF (\r\r\n in perl) between the AHL and the start of the BUFR message. If the file of BUFR messages has been prepared from a collection of GTS bulletins where this control character sequence has been removed, you should replace every 'BUFR' in file with '\r\r\nBUFR' before applying bufrextract.pl in order to get the AHLs or filter on AHL.

AUTHOR

Pål Sannes <pal.sannes@met.no>

COPYRIGHT

Copyright (C) 2010-2016 MET Norway