Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
bufr.pm:bufrdump.pl_source [2015-03-18 13:17:24] pals |
bufr.pm:bufrdump.pl_source [2018-04-25 08:41:39] pals |
||
---|---|---|---|
Line 2: | Line 2: | ||
# | # | ||
- | # (C) Copyright 2010, met.no | + | # (C) Copyright 2010-2018, met.no |
# | # | ||
# 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 39: | Line 39: | ||
' | ' | ||
' | ' | ||
- | ' | + | ' |
' | ' | ||
' | ' | ||
Line 189: | Line 189: | ||
if ($sort) { | if ($sort) { | ||
# Sort wmonr before nationalnr before call | # Sort wmonr before nationalnr before call | ||
- | # sign before buoy_id before aircraft | + | # sign before buoy_id before aircraft |
if ($msg{wmonr}) { | if ($msg{wmonr}) { | ||
$stnid = ' | $stnid = ' | ||
Line 200: | Line 200: | ||
} elsif ($msg{aircraft}) { | } elsif ($msg{aircraft}) { | ||
$stnid = ' | $stnid = ' | ||
+ | } elsif ($msg{wigosid}) { | ||
+ | $stnid = ' | ||
} else { | } else { | ||
# Skip observation if no station identification found | # Skip observation if no station identification found | ||
Line 406: | Line 408: | ||
return unless $criteria_ref; | return unless $criteria_ref; | ||
- | my @ascii_params = qw(aircraft call_sign icao_id name obstime type); | + | my @ascii_params = qw(aircraft call_sign icao_id name obstime type wigosid); |
# Note that the loop counter $i might be changed in the loop | # Note that the loop counter $i might be changed in the loop | ||
Line 451: | Line 453: | ||
my $op; | my $op; | ||
if ($f_operator eq '<' | if ($f_operator eq '<' | ||
- | | $f_operator eq '< | + | |
- | | $f_operator eq '>' | + | |
- | | $f_operator eq '> | + | |
- | | $f_operator eq ' | + | |
- | | $f_operator eq ' | + | |
$op = $f_operator; | $op = $f_operator; | ||
} elsif ($f_operator eq ' | } elsif ($f_operator eq ' | ||
- | | $f_operator eq ' | + | || $f_operator eq ' |
if (grep {$_ eq $f_param} @ascii_params) { | if (grep {$_ eq $f_param} @ascii_params) { | ||
$msg_value =~ s/\s*$//; | $msg_value =~ s/\s*$//; | ||
Line 469: | Line 471: | ||
} | } | ||
- | | + | # Some parameters might need special massaging |
- | if (grep {$_ eq $f_param} @ascii_params) { | + | |
- | # Single quoting is neccessary to make the later eval work | + | |
- | $msg_value = "'" | + | |
- | } | + | |
- | } else { | + | |
if ($f_param eq ' | if ($f_param eq ' | ||
# Make non octal by removing leading 0 | # Make non octal by removing leading 0 | ||
Line 505: | Line 503: | ||
} | } | ||
} | } | ||
+ | |||
+ | my $condition = " | ||
+ | # Some values should be string values | ||
+ | if ($f_operator =~ /~/) { | ||
+ | $condition = " | ||
+ | } elsif (grep {$_ eq $f_param} @ascii_params) { | ||
+ | $condition = " | ||
+ | } | ||
# Finally, do the criterium check | # Finally, do the criterium check | ||
- | | + | if (eval $condition) { |
- | # No need to check the remaining alternative criteria | + | |
- | $i += $num_alt if $num_alt; | + | |
- | next; | + | |
- | } else { | + | } else { |
- | next if $num_alt; | + | |
- | return 1; | + | |
- | } | + | } |
} | } | ||
Line 528: | Line 534: | ||
return if !$req_stations; | return if !$req_stations; | ||
die " | die " | ||
- | . "' | + | . "' |
unless $req_stations | unless $req_stations | ||
- | =~ / | + | =~ / |
my ($id, $rest) = split /=/, $req_stations; | my ($id, $rest) = split /=/, $req_stations; | ||
Line 591: | Line 597: | ||
} | } | ||
- | my @ascii_params = qw(aircraft call_sign icao_id obstime name type); | + | my @ascii_params = qw(aircraft call_sign icao_id obstime name type wigosid); |
my $lexical_sort = grep {$_ eq $sort_on} @ascii_params; | my $lexical_sort = grep {$_ eq $sort_on} @ascii_params; | ||
Line 690: | Line 696: | ||
--sort | --sort | ||
first stations with wmonr, then stations with nationalnr, | first stations with wmonr, then stations with nationalnr, | ||
- | call sign, buoy_id | + | call sign, buoy_id, aircraft |
--sort_on < | --sort_on < | ||
values of parameter, or decreasing values if a ' | values of parameter, or decreasing values if a ' | ||
Line 771: | Line 777: | ||
criteria which should match < | criteria which should match < | ||
< | < | ||
- | follows =~ and !~ should be a Perl regular expression. The parameter | + | follows =~ and !~ should be a Perl match regular expression. The parameter |
criteria may be phrased as alternatives by separating them with ' | criteria may be phrased as alternatives by separating them with ' | ||
a single line. An example filter file is | a single line. An example filter file is | ||
Line 799: | Line 805: | ||
- | call_sign =~ '^L[A-N]..$' | + | call_sign =~ /^L[A-N]..$/ |
obstime >= ' | obstime >= ' | ||
HW | HWA | PW | PWA | HW | HWA | PW | PWA | ||
Line 830: | Line 836: | ||
--station buoyid=64607, | --station buoyid=64607, | ||
--station aircraft=EU3421, | --station aircraft=EU3421, | ||
+ | --station wigosid=0-376-0-511, | ||
You cannot mix different kinds of stations this way (before ' | You cannot mix different kinds of stations this way (before ' | ||
- | must choose either wmonr, nationalnr, call_sign, buoy_id or | + | must choose either wmonr, nationalnr, call_sign, buoy_id, aircraft |
- | aircraft). Note also that providing the stations in the BUFR | + | wigosid). Note also that providing the stations in the BUFR descriptor |
- | descriptor part (first part) of the filter file will speed up | + | part (first part) of the filter file will speed up execution time |
- | execution time considerably, | + | considerably, |
- | possible to combine --filter with --station if done with some care, | + | combine --filter with --station if done with some care, |
e.g. specifying WMO block 01 and the required parameters in filter | e.g. specifying WMO block 01 and the required parameters in filter | ||
file, then the requested stations in station list. | file, then the requested stations in station list. |