Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
bufr.pm:bufrread.pl [2022-05-31 09:29:31] external edit |
bufr.pm:bufrread.pl [2023-02-05 10:14:41] (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 35: | Line 35: | ||
use constant DEFAULT_TABLE_PATH_ECCODES => '/ | use constant DEFAULT_TABLE_PATH_ECCODES => '/ | ||
# Ought to be your most up-to-date code table(s) | # Ought to be your most up-to-date code table(s) | ||
- | use constant DEFAULT_CTABLE_BUFRDC => 'C0000000000000029000'; | + | use constant DEFAULT_CTABLE_BUFRDC => 'C0000000000000037000'; |
- | use constant DEFAULT_CTABLE_ECCODES => ' | + | use constant DEFAULT_CTABLE_ECCODES => ' |
# Parse command line options | # Parse command line options | ||
Line 43: | Line 43: | ||
| | ||
' | ' | ||
- | ' | + | ' |
+ | # | ||
' | ' | ||
' | ' | ||
Line 105: | Line 106: | ||
eval { $ahl_regexp = qr/ | eval { $ahl_regexp = qr/ | ||
die " | die " | ||
- | # When filtering on ahl we assume file is composed of GTS bulletins only | ||
- | Geo:: | ||
} | } | ||
Line 124: | Line 123: | ||
# Arrays over filter criteria, used if option --filter is set | # Arrays over filter criteria, used if option --filter is set | ||
- | my @fid; # Filter descriptors, | + | my @fid; # Filter descriptors, |
my @fiv; # Filter values, e.g. $fiv[1] = [ [ 3, 895 ], [ 6 252 ] ] | my @fiv; # Filter values, e.g. $fiv[1] = [ [ 3, 895 ], [ 6 252 ] ] | ||
my @num_desc; # Number of filter descriptors for each criterion, e.g. $num_desc[1] = 2 | my @num_desc; # Number of filter descriptors for each criterion, e.g. $num_desc[1] = 2 | ||
Line 332: | Line 331: | ||
# Read in contents of $filter_file into variables @fid, @fiv, | # Read in contents of $filter_file into variables @fid, @fiv, | ||
# @num_desc, @num_val and $num_criteria, | # @num_desc, @num_val and $num_criteria, | ||
+ | # Note that index 0 of the arrays is not used. | ||
sub read_filter_file { | sub read_filter_file { | ||
my $filter_file = shift; | my $filter_file = shift; | ||
Line 357: | Line 357: | ||
} else { | } else { | ||
my @values = split; | my @values = split; | ||
+ | # Check that value line contains correct number of values | ||
+ | die " | ||
+ | . " for line $. in filter file ' | ||
+ | if scalar @values != scalar @{$fid[$num_criteria]}; | ||
# Remove leading 0's in numerical values (to prepare for string comparison) | # Remove leading 0's in numerical values (to prepare for string comparison) | ||
for $_ (@values) { s/ | for $_ (@values) { s/ | ||
Line 375: | Line 379: | ||
my ($data, $descriptors) = @_; | my ($data, $descriptors) = @_; | ||
- | my $num_ordinary_criteria = @fid - $num_required_criteria; | + | my $num_ordinary_criteria = $#fid - $num_required_criteria; |
my $num_success_req_criteria = 0; # Number of required criteria successfully fulfilled | my $num_success_req_criteria = 0; # Number of required criteria successfully fulfilled | ||
my $num_success_ord_criteria = 0; # Number of ordinary criteria successfully fulfilled | my $num_success_ord_criteria = 0; # Number of ordinary criteria successfully fulfilled | ||
Line 433: | Line 437: | ||
or $num_success_ord_criteria > 0)) { | or $num_success_ord_criteria > 0)) { | ||
return 0; # Don't filter this observation | return 0; # Don't filter this observation | ||
+ | } else { | ||
+ | next DESC; | ||
} | } | ||
} else { | } else { | ||
Line 500: | Line 506: | ||
--ahl < | --ahl < | ||
| | ||
- | | + | |
+ | when printing section 4 | ||
| | ||
| | ||
Line 552: | Line 559: | ||
Using C< | Using C< | ||
- | the criteria in <filter file> | + | the criteria in <filter file> |
- | D!). Comments (starting with #) are ignored. An example of a filter | + | marked |
- | file is | + | filter |
D: 001001 | D: 001001 | ||
Line 598: | Line 605: | ||
=head1 COPYRIGHT | =head1 COPYRIGHT | ||
- | Copyright (C) 2010-2019 MET Norway | + | Copyright (C) 2010-2023 MET Norway |
=cut | =cut | ||
</ | </ |