bufr.pm:bufrdump.pl_source

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous 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:31:28]
pals
Line 39: Line 39:
            'csv',         # Use CSV format for printing            'csv',         # Use CSV format for printing
            'delimiter=s', # Choose the delimiter for the CSV format            'delimiter=s', # Choose the delimiter for the CSV format
-           'sort',        # Sort on stationid (wmonr/nationalnr/call_sign/buoy_id/aircraft)+           'sort',        # Sort on stationid (wmonr/nationalnr/call_sign/buoy_id/aircraft/wigosid)
            'sort_on=s',   # Sort on specified parameter            'sort_on=s',   # Sort on specified parameter
            'station=s',   # Filter on list of stations            'station=s',   # Filter on list of stations
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 before wigosid
                         if ($msg{wmonr}) {                         if ($msg{wmonr}) {
                             $stnid = '00_' . $msg{wmonr};                             $stnid = '00_' . $msg{wmonr};
Line 200: Line 200:
                         } elsif ($msg{aircraft}) {                         } elsif ($msg{aircraft}) {
                             $stnid = '40_' . $msg{aircraft};                             $stnid = '40_' . $msg{aircraft};
 +                        } elsif ($msg{wigosid}) {
 +                            $stnid = '50_' . $msg{wigosid};
                         } 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 '>=' +            || $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:
         }         }
  
-        if ($f_operator =~ /~/) + # Some parameters might need special massaging 
-            if (grep {$_ eq $f_param} @ascii_params) { +        if ($f_operator !~ /~/) {
-                # Single quoting is neccessary to make the later eval work +
-                $msg_value = "'" . $msg_value . "'"; +
-            } +
-        } else {+
             if ($f_param eq 'wmonr' || $f_param eq 'buoy_id') {             if ($f_param eq 'wmonr' || $f_param eq 'buoy_id') {
                 # Make non octal by removing leading 0                 # Make non octal by removing leading 0
Line 505: Line 503:
             }             }
         }         }
 +
 + my $condition = "$msg_value $op $f_value";
 + # Some values should be string values
 + if ($f_operator =~ /~/) {
 +     $condition = "q{$msg_value} $op $f_value";
 + } elsif (grep {$_ eq $f_param} @ascii_params) {
 +     $condition = "q{$msg_value} $op q{$f_value}";
 + }
  
         # Finally, do the criterium check         # Finally, do the criterium check
-        if (eval "$msg_value $op $f_value") { + if (eval $condition) { 
-            # No need to check the remaining alternative criteria +     # No need to check the remaining alternative criteria 
-            $i += $num_alt if $num_alt; +     $i += $num_alt if $num_alt; 
-            next; +     next; 
-        } else { + } else { 
-            next if $num_alt; +     next if $num_alt; 
-            return 1; +     return 1; 
-        }+ }
     }     }
  
Line 528: Line 534:
     return if !$req_stations;     return if !$req_stations;
     die "Station list must start with 'wmonr=', 'nationalnr=', "     die "Station list must start with 'wmonr=', 'nationalnr=', "
-        . "'call_sign=', 'buoy_id=' or aircraft='"+        . "'call_sign=', 'buoy_id=', 'aircraft=' or 'wigosid='"
         unless $req_stations         unless $req_stations
-        =~ /^(wmonr=|nationalnr=|call_sign=|buoy_id=|aircraft=)/;+        =~ /^(wmonr=|nationalnr=|call_sign=|buoy_id=|aircraft=|wigosid=)/;
  
     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 the decoded observations on station identification;   --sort          Sort the decoded observations on station identification;
                   first stations with wmonr, then stations with nationalnr,                   first stations with wmonr, then stations with nationalnr,
-                  call sign, buoy_id or aircraft (others left out)+                  call sign, buoy_idaircraft or wigosid (others left out)
   --sort_on <parameter>[-] Sort the decoded observations on increasing   --sort_on <parameter>[-] Sort the decoded observations on increasing
                   values of parameter, or decreasing values if a '-'                   values of parameter, or decreasing values if a '-'
Line 771: Line 777:
 criteria which should match <param> or !<param> or <param> <operator> criteria which should match <param> or !<param> or <param> <operator>
 <value> where operator is one of =, !=, =~, !~, <, <=, > and >=. What <value> where operator is one of =, !=, =~, !~, <, <=, > and >=. What
-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 '|' on criteria may be phrased as alternatives by separating them with '|' on
 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 >= '2012-02-10 06:00:00'   obstime >= '2012-02-10 06:00:00'
   HW | HWA | PW | PWA   HW | HWA | PW | PWA
Line 830: Line 836:
   --station buoyid=64607,64609   --station buoyid=64607,64609
   --station aircraft=EU3421,JHCWUURA   --station aircraft=EU3421,JHCWUURA
 +  --station wigosid=0-376-0-511,0-20000-0-01492
  
 You cannot mix different kinds of stations this way (before '=' you You cannot mix different kinds of stations this way (before '=' you
-must choose either wmonr, nationalnr, call_sign, buoy_id or +must choose either wmonr, nationalnr, call_sign, buoy_id, aircraft or 
-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, compared to using option --station. It is +considerably, compared to using option --station. It is possible to 
-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.
  • bufr.pm/bufrdump.pl_source.txt
  • Last modified: 2022-05-31 09:29:31
  • (external edit)