Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
bufr.pm:bufrresolve_source [2016-04-18 07:52:19] pals |
bufr.pm:bufrresolve_source [2022-05-31 09:29:31] external edit |
||
---|---|---|---|
Line 1: | Line 1: | ||
<code perl> | <code perl> | ||
- | # | + | # |
- | # (C) Copyright 2010-2016 MET Norway | + | # (C) Copyright 2010-2019 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); | ||
use Geo::BUFR; | use Geo::BUFR; | ||
+ | |||
+ | # This is actually default in BUFR.pm, but provided here to make it | ||
+ | # easier for users to change to ' | ||
+ | use constant DEFAULT_TABLE_FORMAT => ' | ||
# Will be used if neither --tablepath nor $ENV{BUFR_TABLES} is set | # Will be used if neither --tablepath nor $ENV{BUFR_TABLES} is set | ||
- | use constant | + | use constant |
+ | use constant DEFAULT_TABLE_PATH_ECCODES => '/ | ||
# Ought to be your most up-to-date B table | # Ought to be your most up-to-date B table | ||
- | use constant | + | use constant |
+ | use constant DEFAULT_TABLE_ECCODES => ' | ||
# Parse command line options | # Parse command line options | ||
Line 36: | Line 43: | ||
GetOptions( | GetOptions( | ||
| | ||
- | ' | + | ' |
' | ' | ||
' | ' | ||
Line 45: | Line 52: | ||
' | ' | ||
# descriptors on one line | # descriptors on one line | ||
- | ' | + | ' |
+ | ' | ||
' | ' | ||
) or pod2usage(-verbose => 0); | ) or pod2usage(-verbose => 0); | ||
Line 83: | Line 91: | ||
# bufrresolve.pl to complain in this case | # bufrresolve.pl to complain in this case | ||
Geo:: | Geo:: | ||
+ | |||
+ | # Set BUFR table format | ||
+ | my $tableformat = (defined $option{tableformat}) ? uc $option{tableformat} : DEFAULT_TABLE_FORMAT; | ||
+ | Geo:: | ||
# Set BUFR table path | # Set BUFR table path | ||
Line 92: | Line 104: | ||
Geo:: | Geo:: | ||
} else { | } else { | ||
- | # If all else fails, use the libbufr bufrtables | + | # If all else fails, use the default tablepath in BUFRDC/ |
- | Geo:: | + | |
+ | | ||
+ | } elsif ($tableformat eq ' | ||
+ | Geo:: | ||
+ | } | ||
} | } | ||
# BUFR table file to use | # BUFR table file to use | ||
- | my $table = $option{bufrtable} || DEFAULT_TABLE; | + | my $table = $option{bufrtable} || |
+ | ($tableformat eq ' | ||
my $bufr = Geo:: | my $bufr = Geo:: | ||
Line 137: | Line 154: | ||
| | ||
| | ||
- | | + | |
+ | | ||
| | ||
| | ||
Line 143: | Line 161: | ||
2) bufrresolve.pl --code <code or flag table> | 2) bufrresolve.pl --code <code or flag table> | ||
- | | + | |
+ | | ||
| | ||
| | ||
3) bufrresolve.pl --flag < | 3) bufrresolve.pl --flag < | ||
- | | + | |
+ | | ||
| | ||
| | ||
Line 160: | Line 180: | ||
examples of use. | examples of use. | ||
- | It is supposed that the code and flag tables are contained in a file | + | The tables used can be selected |
- | with same name as corresponding B table except for having prefix C | + | C< |
- | instead of B. The tables used can be chosen | + | tableformat |
- | C< | + | bufrresolve.pl will be overridden |
- | DEFAULT_TABLE | + | BUFR_TABLES is set. You should consider edit the source code of |
- | be overriden | + | bufrresolve.pl |
- | should consider edit the source code if you are not satisfied with the | + | tablepath and bufrtable (search for ' |
- | defaults chosen. | + | |
+ | For tableformat ECCODES, see | ||
+ | L< | ||
+ | for more info on how to set C< | ||
+ | |||
+ | For the table name in C< | ||
+ | table, e.g. B0000000000098013001.TXT. Replacing B with D or C, or | ||
+ | omitting this prefix altogether, or even omitting the trailing ' | ||
+ | (i.e. 0000000000098013001) will also work. | ||
+ | |||
+ | For the table name in C< | ||
+ | of table location, e.g. ' | ||
+ | ' | ||
+ | up local sequence descriptors, | ||
+ | and the local table to get the full expansion, e.g. | ||
+ | ' | ||
+ | |||
+ | See also L</" | ||
=head1 OPTIONS | =head1 OPTIONS | ||
Line 175: | Line 212: | ||
descriptors on one line | descriptors on one line | ||
| | ||
- | |||
| | ||
+ | | ||
| | ||
| | ||
- | |||
| | ||
the same as consulting perldoc bufrresolve.pl | the same as consulting perldoc bufrresolve.pl | ||
Line 195: | Line 231: | ||
Options may be abbreviated, | Options may be abbreviated, | ||
+ | |||
+ | =head1 CAVEAT | ||
+ | |||
+ | The C< | ||
+ | is no guarantee that the same BUFR descriptor resolves the same way | ||
+ | for different BUFR tables. However, as soon as a new BUFR descriptor | ||
+ | is introduced in a BUFR table, it is extremely rare that the | ||
+ | descriptor is redefined in later versions. So for convenience, | ||
+ | bufrresolve.pl uses a default table (adding option C< | ||
+ | tell you which table, unless you use C< | ||
+ | explicitely). If this is the wrong table for your purpose (most common | ||
+ | case will be if the descriptor was added in a higher version than that | ||
+ | of the default table), you definitely should use C< | ||
+ | the appropriate table. | ||
=head1 NOTE ON --VERBOSE | =head1 NOTE ON --VERBOSE | ||
Line 202: | Line 252: | ||
or later someone would type C< | or later someone would type C< | ||
by Perl would be interpreted as if the arguments were C<307080 000001 | by Perl would be interpreted as if the arguments were C<307080 000001 | ||
- | --verbose>, | + | --verbose>, |
=head1 AUTHOR | =head1 AUTHOR | ||
Line 210: | Line 260: | ||
=head1 COPYRIGHT | =head1 COPYRIGHT | ||
- | Copyright (C) 2010-2016 MET Norway | + | Copyright (C) 2010-2019 MET Norway |
=cut | =cut | ||
</ | </ |