bufr.pm:sortbufrtemp.pl

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:sortbufrtemp.pl [2015-02-25 11:56:50]
pals
bufr.pm:sortbufrtemp.pl [2022-05-31 09:29:31] (current)
Line 126: Line 126:
     }     }
  
-    if ($bufr->get_descriptors_unexpanded() !~ /^309052/) {+    my $descriptors_unexpanded = $bufr->get_descriptors_unexpanded()
 +    if ($descriptors_unexpanded !~ /^30905(2|3)/) {
  if ($verbose > 0 && $isub == 1) {  if ($verbose > 0 && $isub == 1) {
      print "Removing message $imsg";      print "Removing message $imsg";
      print " contained in bulletin with ahl $ahl" if $ahl;      print " contained in bulletin with ahl $ahl" if $ahl;
-     print " since unexpanded descriptors did not start with 309052\n";+     print " since unexpanded descriptors did not start with 309052 or 309053\n";
  }  }
  next;  next;
Line 141: Line 142:
         my @plevels; # array of references to the 10 data values of         my @plevels; # array of references to the 10 data values of
                      # one pressure level                      # one pressure level
-        my $i1 = 29;+        my $i_eddrf ($descriptors_unexpanded =~ /^309052/) ? 29 : 19; 
 + my $i1 = $i_eddrf;
         while ($desc->[$i1] ne '031001') {         while ($desc->[$i1] ne '031001') {
             my @record = @$data[$i1 .. $i1+9];             my @record = @$data[$i1 .. $i1+9];
Line 147: Line 149:
                 push @plevels, \@record;                 push @plevels, \@record;
             } elsif ($verbose > 2) {             } elsif ($verbose > 2) {
-                print "Missing pressure in level ", ($i1 - 29)/10 + 1+                print "Missing pressure in level ", ($i1 - $i_eddrf)/10 + 1
                     . " in subset $isub in Message number $imsg";                     . " in subset $isub in Message number $imsg";
                 print " in $ahl" if $ahl;                 print " in $ahl" if $ahl;
Line 166: Line 168:
             }             }
             my ($new_data, $new_desc)             my ($new_data, $new_desc)
-                = get_sorted_data($data,$desc,\@plevels,$i1);+                = get_sorted_data($data,$desc,\@plevels,$i1,$i_eddrf);
             $subset_data[$isub] = $new_data;             $subset_data[$isub] = $new_data;
             $subset_desc[$isub] = $new_desc;             $subset_desc[$isub] = $new_desc;
Line 184: Line 186:
 ## missing) ## missing)
 sub get_sorted_data { sub get_sorted_data {
-    my ($data,$desc,$plevels,$i1) = @_;+    my ($data,$desc,$plevels,$i1,$i_eddrf) = @_;
     my ($new_data,$new_desc);     my ($new_data,$new_desc);
  
     # Section 4 up to where pressure level data starts is unaltered     # Section 4 up to where pressure level data starts is unaltered
-    for my $ii (0 .. 27) {+    for my $ii (0 .. $i_eddrf-2) {
         $new_desc->[$ii] = $desc->[$ii];         $new_desc->[$ii] = $desc->[$ii];
         $new_data->[$ii] = $data->[$ii];         $new_data->[$ii] = $data->[$ii];
Line 194: Line 196:
  
     # Then handle pressure levels (and eddrf)     # Then handle pressure levels (and eddrf)
-    $new_desc->[28] = '031002'; +    $new_desc->[$i_eddrf-1] = '031002'; 
-    $new_data->[28] = undef; # Will be filled with $eddrf later+    $new_data->[$i_eddrf-1] = undef; # Will be filled with $eddrf later
     my $eddrf = 0; # extended delayed descriptor replication factor     my $eddrf = 0; # extended delayed descriptor replication factor
  
Line 240: Line 242:
     $eddrf++;     $eddrf++;
  
-    $new_data->[28] = $eddrf;+    $new_data->[$i_eddrf-1] = $eddrf;
  
     # Section 4 after pressure level data is unaltered     # Section 4 after pressure level data is unaltered
Line 325: Line 327:
  
 Will extract from <bufr file> all BUFR TEMPs (recognized by unexpanded Will extract from <bufr file> all BUFR TEMPs (recognized by unexpanded
-descriptors in section 3 starting with 309052), sorting the pressure +descriptors in section 3 starting with 309052 or 309053), sorting the 
-levels and merging duplicate pressure levels (having same pressure, +pressure levels and merging duplicate pressure levels (having same 
-time and location coordinates) into one single level, printing to +pressure, time and location coordinates) into one single level, 
-STDOUT unless C<--outfile> is set. Pressure levels with missing +printing to STDOUT unless C<--outfile> is set. Pressure levels with 
-pressure will be removed.+missing pressure will be removed.
  
 Execute without arguments for Usage, with option C<--help> for some Execute without arguments for Usage, with option C<--help> for some
Line 344: Line 346:
                     n>=1: prints which BUFR messages were actually altered,                     n>=1: prints which BUFR messages were actually altered,
                           and which messages were removed because unexpanded                           and which messages were removed because unexpanded
-                          descriptors did not start with 309052+                          descriptors did not start with 309052 or 309053
                     n>=2: prints at which pressure level sorting                     n>=2: prints at which pressure level sorting
                           breaks, or first duplicate level encountered                           breaks, or first duplicate level encountered
Line 357: Line 359:
                     combined with option --outfile                     combined with option --outfile
    --help           Display Usage and explain the options used. Almost    --help           Display Usage and explain the options used. Almost
-                    the same as consulting perldoc mergebufrtemp.pl+                    the same as consulting perldoc sortbufrtemp.pl
  
 Options may be abbreviated, e.g. C<--h> or C<-h> for C<--help>. Options may be abbreviated, e.g. C<--h> or C<-h> for C<--help>.
  • bufr.pm/sortbufrtemp.pl.1424865410.txt.gz
  • Last modified: 2022-05-31 09:23:11
  • (external edit)