bufr.pm:mergebufrtemp.pl

Differences

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

Link to this comparison view

Next revision
Previous revision
bufr.pm:mergebufrtemp.pl [2015-02-04 15:58:56]
pals created
bufr.pm:mergebufrtemp.pl [2022-05-31 09:29:31] (current)
Line 123: Line 123:
 my $eddrf = 0; # extended delayed descriptor replication factor my $eddrf = 0; # extended delayed descriptor replication factor
 my ($ii,$i1,$i2) = (29,29,29); my ($ii,$i1,$i2) = (29,29,29);
-while (1) { +while ($desc1->[$i1] ne '031001' || $desc2->[$i2] ne '031001'{ 
-    last if ($desc1->[$i1] eq '031001' && $desc2->[$i2] eq '031001'); +    push(@$desc, @pressure_level_desc);
-    splice(@$desc, $ii, 10, @pressure_level_desc);+
     if ($desc1->[$i1] eq '031001') {     if ($desc1->[$i1] eq '031001') {
- # No more pressure levels in message 1, so fetch from message 2 +        # No more pressure levels in message 1, so fetch from message 2 
-        splice(@$data, $ii, 10, @$data2[$i2 .. $i2+9]);+        push(@$data, @$data2[$i2 .. $i2+9]);
         $i2 += 10;         $i2 += 10;
     } elsif ($desc2->[$i2] eq '031001') {     } elsif ($desc2->[$i2] eq '031001') {
- # No more pressure levels in message 2, so fetch from message 1 +        # No more pressure levels in message 2, so fetch from message 1 
-        splice(@$data, $ii, 10, @$data1[$i1 .. $i1+9]);+        push (@$data, @$data1[$i1 .. $i1+9]);
         $i1 += 10;         $i1 += 10;
     } elsif ($data1->[$i1+2] eq $data2->[$i2+2]) {     } elsif ($data1->[$i1+2] eq $data2->[$i2+2]) {
Line 149: Line 148:
         $i2 += 10;         $i2 += 10;
     } elsif ($data1->[$i1+2] > $data2->[$i2+2]) {     } elsif ($data1->[$i1+2] > $data2->[$i2+2]) {
- # pick the highest pressure, i.e. data1 +        # pick the highest pressure, i.e. data1 
-        splice(@$data, $ii, 10, @$data1[$i1 .. $i1+9]);+        push(@$data, @$data1[$i1 .. $i1+9]);
         $i1 += 10;         $i1 += 10;
     } else {     } else {
- # pick the highest pressure, i.e. data2 +        # pick the highest pressure, i.e. data2 
-        splice(@$data, $ii, 10, @$data2[$i2 .. $i2+9]);+        push(@$data, @$data2[$i2 .. $i2+9]);
         $i2 += 10;         $i2 += 10;
     }     }
Line 174: Line 173:
     $data->[$ii++] = 0;     $data->[$ii++] = 0;
     while ($nws1 > 0 || $nws2 > 0) {     while ($nws1 > 0 || $nws2 > 0) {
- splice(@$desc, $ii, 7, @windshear_level_desc);+        push(@$desc, @windshear_level_desc);
         if ($nws1 == 0) {         if ($nws1 == 0) {
-     # Fetch from message 2 +            # Fetch from message 2 
-            splice(@$data, $ii, 7, @$data2[$i2 .. $i2+6]);+            push(@$data, @$data2[$i2 .. $i2+6]);
             $i2 += 7;             $i2 += 7;
             $nws2--;             $nws2--;
         } elsif ($nws2 == 0) {         } elsif ($nws2 == 0) {
-     # Fetch from message 1 +            # Fetch from message 1 
-            splice(@$data, $ii, 7, @$data1[$i1 .. $i1+6]);+            push(@$data, @$data1[$i1 .. $i1+6]);
             $i1 += 7;             $i1 += 7;
             $nws1--;             $nws1--;
Line 188: Line 187:
             # see no reason why data1 should differ from data2 here,             # see no reason why data1 should differ from data2 here,
             # so we use data1             # so we use data1
-            splice(@$data, $ii, 7, @$data1[$i1 .. $i1+6]);+            push(@$data, @$data1[$i1 .. $i1+6]);
             $i1 += 7;             $i1 += 7;
             $i2 += 7;             $i2 += 7;
             $nws2--;             $nws2--;
         } elsif ($data1->[$i1+2] > $data2->[$i2+2]) {         } elsif ($data1->[$i1+2] > $data2->[$i2+2]) {
-     # pick the highest pressure, i.e. data1 +            # pick the highest pressure, i.e. data1 
-            splice(@$data, $ii, 7, @$data1[$i1 .. $i1+6]);+            push(@$data, @$data1[$i1 .. $i1+6]);
             $i1 += 7;             $i1 += 7;
             $nws1--;             $nws1--;
         } else {         } else {
-     # pick the highest pressure, i.e. data2 +            # pick the highest pressure, i.e. data2 
-            splice(@$data, $ii, 7, @$data2[$i2 .. $i2+6]);+            push(@$data, @$data2[$i2 .. $i2+6]);
             $i2 += 7;             $i2 += 7;
             $nws2--;             $nws2--;
Line 226: Line 225:
 sub combine_evss { sub combine_evss {
     my ($evss1,$evss2) = @_;     my ($evss1,$evss2) = @_;
-    my $binary1 = pack "N", $evss1; # Packed as 32 bits in big-endian order +    if (defined($evss1) && defined($evss2)) { 
-    my $binary2 = pack "N", $evss2; + my $binary1 = pack "N", $evss1; # Packed as 32 bits in big-endian order 
-    my $binary = $binary1 | $binary2; # bitwise or + my $binary2 = pack "N", $evss2; 
-    return unpack "N", $binary;+ my $binary = $binary1 | $binary2; # bitwise or 
 + return unpack "N", $binary; 
 +    } elsif (defined($evss1)) { 
 + return $evss1; 
 +    } else { 
 + return $evss2; 
 +    }
 } }
  
Line 245: Line 250:
 Will merge (the first) BUFR message in <bufr file 1> with (the first) Will merge (the first) BUFR message in <bufr file 1> with (the first)
 BUFR message in <bufr file 2> into one single BUFR message, printing BUFR message in <bufr file 2> into one single BUFR message, printing
-to STDOUT (unless C<--outfile> is set). The 2 input BUFR messages are+to STDOUT unless C<--outfile> is set. The 2 input BUFR messages are
 assumed to be single subset BUFR TEMPs utilizing TM305092 (this is assumed to be single subset BUFR TEMPs utilizing TM305092 (this is
 checked) containing data for the same station and termin (this is not checked) containing data for the same station and termin (this is not
Line 265: Line 270:
                     the same as consulting perldoc mergebufrtemp.pl                     the same as consulting perldoc mergebufrtemp.pl
  
-Options may be abbreviated, e.g. C<--he> or C<-he> for C<--help>.+Options may be abbreviated, e.g. C<--h> or C<-h> for C<--help>.
  
 To avoid having to use the C<--tablepath> option, you are adviced to To avoid having to use the C<--tablepath> option, you are adviced to
  • bufr.pm/mergebufrtemp.pl.1423065536.txt.gz
  • Last modified: 2022-05-31 09:23:11
  • (external edit)