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
Previous revision
bufr.pm:bufrdump.pl_source [2015-03-18 13:17:24]
pals
bufr.pm:bufrdump.pl_source [2022-05-31 09:29:31] (current)
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/icao_id/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 188: Line 188:
                 if ($txt) {                 if ($txt) {
                     if ($sort) {                     if ($sort) {
-                        # Sort wmonr before nationalnr before call +                        # Sort wmonr before nationalnr before call sign before 
-                        # sign before buoy_id before aircraft+                        # buoy_id before aircraft before icaoid 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{icao_id}) {
 +                            $stnid = '50_' . $msg{icao_id};
 +                        } elsif ($msg{wigosid}) {
 +                            $stnid = '60_' . $msg{wigosid};
                         } else {                         } else {
                             # Skip observation if no station identification found                             # Skip observation if no station identification found
Line 406: Line 410:
     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 455:
         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 473:
         }         }
  
-        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 505:
             }             }
         }         }
 +
 + 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 536:
     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=', 'icao_id' or 'wigosid='"
         unless $req_stations         unless $req_stations
-        =~ /^(wmonr=|nationalnr=|call_sign=|buoy_id=|aircraft=)/;+        =~ /^(wmonr=|nationalnr=|call_sign=|buoy_id=|aircraft=|icao_id=|wigosid=)/;
  
     my ($id, $rest) = split /=/, $req_stations;     my ($id, $rest) = split /=/, $req_stations;
Line 591: Line 599:
     }     }
  
-    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 698:
   --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, icao_id 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 780:
 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 808:
  
  
-  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 839:
   --station buoyid=64607,64609   --station buoyid=64607,64609
   --station aircraft=EU3421,JHCWUURA   --station aircraft=EU3421,JHCWUURA
 +  --station icao_id=ENGM,ENBO
 +  --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_idaircraft
-aircraft). Note also that providing the stations in the BUFR+icao_id or wigosid). Note also that providing the stations in the BUFR
 descriptor part (first part) of the filter file will speed up descriptor part (first part) of the filter file will speed up
 execution time considerably, compared to using option --station. It is execution time considerably, compared to using option --station. It is
  • bufr.pm/bufrdump.pl_source.1426684644.txt.gz
  • Last modified: 2022-05-31 09:23:11
  • (external edit)