Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
bufr.pm:bufralter.pl_source [2010-04-06 08:14:30] pals |
bufr.pm:bufralter.pl_source [2023-02-05 10:21:16] (current) pals |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | + | < |
- | # | + | # |
- | # (C) Copyright 2010, met.no | + | # (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 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 => '/ | ||
# Parse command line options | # Parse command line options | ||
Line 55: | Line 61: | ||
' | ' | ||
' | ' | ||
+ | ' | ||
' | ' | ||
' | ' | ||
Line 79: | Line 86: | ||
Geo:: | Geo:: | ||
- | # Set verbosity level for the BUFR module. Must be set also for each | + | # Set verbosity level |
- | # BUFR object generated | + | Geo::BUFR-> |
- | my $verbose | + | |
- | Geo:: | + | # Set BUFR table format |
+ | my $tableformat | ||
+ | Geo:: | ||
# Set BUFR table path | # Set BUFR table path | ||
Line 92: | 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:: | ||
+ | } | ||
} | } | ||
Line 104: | Line 117: | ||
$OUT = *STDOUT; | $OUT = *STDOUT; | ||
} | } | ||
+ | binmode($OUT); | ||
# Change input separator to ' | # Change input separator to ' | ||
Line 138: | Line 152: | ||
$/ = $oldeol; | $/ = $oldeol; | ||
my $bufr = Geo:: | my $bufr = Geo:: | ||
- | $bufr-> | ||
$out .= alter($bufr); | $out .= alter($bufr); | ||
Line 147: | Line 160: | ||
} | } | ||
- | print $OUT $out; | + | print $OUT $out if $out; |
Line 159: | Line 172: | ||
} | } | ||
- | my $new_bufr; | + | my $new_bufr |
my @subset_data; | my @subset_data; | ||
my @subset_desc; | my @subset_desc; | ||
Line 172: | Line 185: | ||
if ($isub == 1) { | if ($isub == 1) { | ||
- | $new_bufr | + | $new_bufr-> |
@subset_data = (); | @subset_data = (); | ||
@subset_desc = (); | @subset_desc = (); | ||
Line 329: | Line 342: | ||
=pod | =pod | ||
+ | |||
+ | =encoding utf8 | ||
=head1 SYNOPSIS | =head1 SYNOPSIS | ||
Line 357: | Line 372: | ||
[--outfile < | [--outfile < | ||
[--strict_checking n] | [--strict_checking n] | ||
+ | [--tableformat < | ||
[--tablepath <path to BUFR tables>] | [--tablepath <path to BUFR tables>] | ||
[--verbose n] | [--verbose n] | ||
Line 372: | Line 388: | ||
=head1 OPTIONS | =head1 OPTIONS | ||
- | |||
| | ||
Line 379: | Line 394: | ||
to set a missing value. Repeat the option if more | to set a missing value. Repeat the option if more | ||
sequence descriptors are to be set. Example: | sequence descriptors are to be set. Example: | ||
- | --data 004004=-1+ --data | + | --data 004004=-1+ --data |
012101=missing This will set the data value for | 012101=missing This will set the data value for | ||
first (and only first!) occurrence of these 3 | first (and only first!) occurrence of these 3 | ||
Line 410: | Line 425: | ||
| | ||
| | ||
- | | + | |
i.e. remove all descriptors from 222000 on | i.e. remove all descriptors from 222000 on | ||
| | ||
Line 420: | Line 435: | ||
| | ||
| | ||
+ | | ||
| | ||
Set path to BUFR tables (overrides $ENV{BUFR_TABLES}) | Set path to BUFR tables (overrides $ENV{BUFR_TABLES}) | ||
- | | + | |
output is sent to STDOUT, so ought to be combined with | output is sent to STDOUT, so ought to be combined with | ||
option --outfile | option --outfile | ||
Line 433: | Line 449: | ||
set the environment variable BUFR_TABLES to the directory where your | set the environment variable BUFR_TABLES to the directory where your | ||
BUFR tables are located (unless the default path provided by | BUFR tables are located (unless the default path provided by | ||
- | bufralter.pl works for you). | + | bufralter.pl works for you). For tableformat ECCODES, se |
+ | L< | ||
+ | for more info on how to set C< | ||
=head1 AUTHOR | =head1 AUTHOR | ||
Line 441: | Line 459: | ||
=head1 COPYRIGHT | =head1 COPYRIGHT | ||
- | Copyright (C) 2010 met.no | + | Copyright (C) 2010-2023 MET Norway |
=cut | =cut | ||
- | |||
</ | </ |