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 [2022-05-31 09:29:31] external edit |
bufr.pm:bufrextract.pl_source [2023-02-05 09:07:45] (current) pals |
||
---|---|---|---|
Line 2: | Line 2: | ||
# | # | ||
- | # (C) Copyright 2010-2019 MET Norway | + | # (C) Copyright 2010-2023 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 32: | Line 32: | ||
| | ||
' | ' | ||
+ | ' | ||
' | ' | ||
' | ' | ||
' | ' | ||
- | ' | ||
' | ' | ||
' | ' | ||
Line 44: | 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 54: | 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 137: | 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 150: | Line 155: | ||
my $msg = $bufr-> | my $msg = $bufr-> | ||
- | print $OUT $msg; | + | print $OUT $msg, $gts_eom; |
} | } | ||
} | } | ||
Line 172: | 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 183: | 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 195: | 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 213: | 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 244: | 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 256: | Line 251: | ||
=head1 COPYRIGHT | =head1 COPYRIGHT | ||
- | Copyright (C) 2010-2019 MET Norway | + | Copyright (C) 2010-2023 MET Norway |
=cut | =cut | ||
- | |||
</ | </ |