Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
bufr.pm:bufrresolve_source [2010-04-05 08:19:37] pals |
bufr.pm:bufrresolve_source [2025-11-05 09:24:36] (current) pals |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | < | + | < |
| - | # | + | # |
| - | # (C) Copyright 2010, met.no | + | # (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); | ||
| 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 |
| - | # Ought to be your most up-to-date B table | + | use constant |
| - | use constant | + | |
| # Parse command line options | # Parse command line options | ||
| Line 36: | Line 40: | ||
| GetOptions( | GetOptions( | ||
| | | ||
| - | ' | + | ' |
| - | ' | + | ' |
| ' | ' | ||
| ' | ' | ||
| Line 45: | Line 49: | ||
| ' | ' | ||
| # descriptors on one line | # descriptors on one line | ||
| - | ' | + | ' |
| - | ' | + | ' |
| + | ' | ||
| ) or pod2usage(-verbose => 0); | ) or pod2usage(-verbose => 0); | ||
| Line 66: | Line 71: | ||
| foreach (@ARGV) { | foreach (@ARGV) { | ||
| pod2usage(" | pod2usage(" | ||
| + | } | ||
| + | if (defined $option{code} && $option{code} !~ /^\d+$/) { | ||
| + | pod2usage(" | ||
| + | } | ||
| + | if (defined $option{flag} && $option{flag} !~ /^\d+$/) { | ||
| + | pod2usage(" | ||
| } | } | ||
| + | |||
| # Set verbosity level for the BUFR module | # Set verbosity level for the BUFR module | ||
| my $verbose = $option{verbose} ? 1 : 0; | my $verbose = $option{verbose} ? 1 : 0; | ||
| Geo:: | Geo:: | ||
| + | |||
| + | # From version 1.32 a descriptor sequence ending in e.g. 106000 031001 | ||
| + | # will be allowed unless strict checking is set, and we really want | ||
| + | # bufrresolve.pl to complain in this case | ||
| + | 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 80: | Line 101: | ||
| Geo:: | Geo:: | ||
| } else { | } else { | ||
| - | # If all else fails, use the libemos 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} || Geo:: |
| my $bufr = Geo:: | my $bufr = Geo:: | ||
| Line 93: | Line 118: | ||
| my $code_table = $option{code}; | my $code_table = $option{code}; | ||
| if (defined $option{flag}) { | if (defined $option{flag}) { | ||
| - | print $bufr-> | + | |
| + | print "No bits are set\n"; | ||
| + | } else { | ||
| + | | ||
| + | } | ||
| } else { | } else { | ||
| print $bufr-> | print $bufr-> | ||
| Line 112: | Line 141: | ||
| =pod | =pod | ||
| + | |||
| + | =encoding utf8 | ||
| =head1 SYNOPSIS | =head1 SYNOPSIS | ||
| Line 119: | Line 150: | ||
| | | ||
| | | ||
| - | | + | |
| + | | ||
| | | ||
| - | | + | |
| | | ||
| - | 2) bufrresolve.pl --code <code_table> | + | 2) bufrresolve.pl --code <code or flag table> |
| - | | + | |
| + | | ||
| | | ||
| - | | + | |
| - | 3) bufrresolve.pl --flag < | + | 3) bufrresolve.pl --flag < |
| - | | + | |
| + | | ||
| | | ||
| - | | + | |
| =head1 DESCRIPTION | =head1 DESCRIPTION | ||
| Line 139: | Line 173: | ||
| Execute without arguments for Usage, with option C< | Execute without arguments for Usage, with option C< | ||
| - | additional info. See also L</https:// | + | additional info. See also L< |
| 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 and D tables except for having | + | C< |
| - | prefix C instead of B or D. The tables used can be chosen | + | tableformat |
| - | with options C< | + | bufrresolve.pl |
| - | coded DEFAULT_TABLE | + | BUFR_TABLES is set. You should consider edit the source code of |
| - | will 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 157: | Line 208: | ||
| descriptors on one line | descriptors on one line | ||
| | | ||
| - | |||
| | | ||
| + | | ||
| | | ||
| - | | + | |
| | | ||
| the same as consulting perldoc bufrresolve.pl | the same as consulting perldoc bufrresolve.pl | ||
| Line 170: | Line 220: | ||
| and --noexpand are mutually exclusive (full expansion is default). | and --noexpand are mutually exclusive (full expansion is default). | ||
| - | Usage 2): Prints the content | + | Usage 2): Prints the contents |
| + | (named by the table B descriptor). | ||
| - | Usage 3): Displays the bits set for flag value <value> in flag table | + | Usage 3): Displays the bits set when the data value for the requested |
| - | < | + | flag table is < |
| 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< | ||
| + | show you the tables used). 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 should definitely use | ||
| + | C< | ||
| =head1 AUTHOR | =head1 AUTHOR | ||
| Line 183: | Line 247: | ||
| =head1 COPYRIGHT | =head1 COPYRIGHT | ||
| - | Copyright (C) 2010 met.no | + | Copyright (C) 2010-2025 MET Norway |
| =cut | =cut | ||
| </ | </ | ||