Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
bufr.pm:bufrextract.pl_source [2016-12-02 08:50:19] pals |
bufr.pm:bufrextract.pl_source [2025-11-05 09:28:24] (current) pals |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| <code perl> | <code perl> | ||
| - | # | + | # |
| - | # (C) Copyright 2010-2016 MET Norway | + | # (C) Copyright 2010-2025 MET Norway |
| # | # | ||
| # This program is free software; you can redistribute it and/or modify | # This program is free software; you can redistribute it and/or modify | ||
| Line 22: | Line 22: | ||
| use strict; | use strict; | ||
| + | use warnings; | ||
| use Getopt:: | use Getopt:: | ||
| use Pod::Usage qw(pod2usage); | use Pod::Usage qw(pod2usage); | ||
| Line 31: | Line 32: | ||
| | | ||
| ' | ' | ||
| + | ' | ||
| ' | ' | ||
| ' | ' | ||
| ' | ' | ||
| - | ' | ||
| ' | ' | ||
| ' | ' | ||
| Line 43: | Line 44: | ||
| # only_ahl and without_ahl are mutually exclusive | # only_ahl and without_ahl are mutually exclusive | ||
| - | pod2usage( -message => " | + | pod2usage( -message => " |
| | | ||
| | | ||
| - | if $option{only_ahl} && $option{without_ahl}; | + | if ( ($option{only_ahl} && |
| + | || ($option{without_ahl} && ($option{only_ahl} || $option{gts})) | ||
| + | || ($option{gts} && ($option{only_ahl} || $option{without_ahl})) ); | ||
| # Make sure there is at least one input file | # Make sure there is at least one input file | ||
| Line 53: | Line 56: | ||
| # Set verbosity level | # Set verbosity level | ||
| Geo:: | Geo:: | ||
| - | |||
| - | # Set whether last ahl should be reused if current BUFR message has no AHL | ||
| - | Geo:: | ||
| my $ahl_regexp; | my $ahl_regexp; | ||
| Line 136: | Line 136: | ||
| $current_message_number = $bufr-> | $current_message_number = $bufr-> | ||
| $current_ahl = $bufr-> | $current_ahl = $bufr-> | ||
| + | my $gts_eom = ''; | ||
| - | if ($current_ahl | + | if ($current_ahl) { |
| if ($option{only_ahl}) { | if ($option{only_ahl}) { | ||
| print $OUT $current_ahl, | print $OUT $current_ahl, | ||
| } elsif (!$option{without_ahl}) { | } elsif (!$option{without_ahl}) { | ||
| + | if ($option{gts}) { | ||
| + | my $current_gts_starting_line = $bufr-> | ||
| + | print $OUT $current_gts_starting_line; | ||
| + | $gts_eom = $bufr-> | ||
| + | } | ||
| # Use \r\r\n after AHL, since this is the standard | # Use \r\r\n after AHL, since this is the standard | ||
| # sequence used in GTS bulletins | # sequence used in GTS bulletins | ||
| Line 149: | Line 155: | ||
| my $msg = $bufr-> | my $msg = $bufr-> | ||
| - | print $OUT $msg; | + | print $OUT $msg, $gts_eom; |
| } | } | ||
| } | } | ||
| Line 171: | Line 177: | ||
| bufrextract.pl <bufr file(s)> | bufrextract.pl <bufr file(s)> | ||
| [--ahl < | [--ahl < | ||
| - | [--only_ahl] | [--without_ahl] | + | [--only_ahl] | [--without_ahl] | [--gts] |
| [--outfile < | [--outfile < | ||
| - | [--reuse_ahl n] | ||
| [--help] | [--help] | ||
| [--verbose n] | [--verbose n] | ||
| Line 182: | Line 187: | ||
| possibly filtering on AHL. | possibly filtering on AHL. | ||
| - | The AHL (Abbreviated Header Line) is recognized as the TTAAii CCCC DTG | + | The AHL (Abbreviated Header Line) is recognized as the TTAAii CCCC |
| - | [BBB] immediately preceding the BUFR message. | + | YYGGgg |
| Execute without arguments for Usage, with option C< | Execute without arguments for Usage, with option C< | ||
| Line 194: | Line 199: | ||
| --ahl < | --ahl < | ||
| matching < | matching < | ||
| + | | ||
| | | ||
| | | ||
| | | ||
| Will print to < | Will print to < | ||
| - | | ||
| - | only if immediately preceding | ||
| - | n=1 When filtering using --ahl: Reuse last AHL found if current | ||
| - | BUFR message has no immediately preceding AHL | ||
| | | ||
| more info you might prefer to consult perldoc bufrextract.pl | more info you might prefer to consult perldoc bufrextract.pl | ||
| Line 212: | Line 214: | ||
| (ISS) from CCCC=ENMI. | (ISS) from CCCC=ENMI. | ||
| - | If the BUFR file(s) are known to consist solely of GTS bulletins, you | + | Use option |
| - | might consider setting | + | present) |
| - | to extract all (and not only the first) BUFR messages | + | envelope |
| - | bulletins. Such bulletins | + | the GTS: Attachment II-4. Format of Meteorological Messages. |
| - | also the L</" | + | |
| - | corresponding AHL is still extracted | + | |
| No bufrtables are needed for running bufrextract.pl, | No bufrtables are needed for running bufrextract.pl, | ||
| Line 243: | Line 243: | ||
| between the GTS AHL and the start of BUFR message (besides the | between the GTS AHL and the start of BUFR message (besides the | ||
| standard character sequence CRCRLF), likely leading bufrextract.pl to | standard character sequence CRCRLF), likely leading bufrextract.pl to | ||
| - | miss the AHL. Also, if applying C< | + | miss the AHL. |
| - | a GTS bulletin will then be wrongly associated with the AHL of the | + | |
| - | previous GTS bulletin when filtering on AHL. If bulletins with this | + | |
| - | kind of error is more of a concern than multi message bulletins, you | + | |
| - | should probably refrain from making use of the C< | + | |
| =head1 AUTHOR | =head1 AUTHOR | ||
| Line 255: | Line 251: | ||
| =head1 COPYRIGHT | =head1 COPYRIGHT | ||
| - | Copyright (C) 2010-2016 MET Norway | + | Copyright (C) 2010-2025 MET Norway |
| =cut | =cut | ||
| </ | </ | ||