adapted to Nortek
authorAndreas Thurnherr <ant@ldeo.columbia.edu>
Thu, 04 Mar 2021 08:38:53 -0500
changeset 55 540d6574caca
parent 54 21cf468fa8e0
child 56 82384f531dba
adapted to Nortek
RDI_PD0_IO.pl
listEns
--- a/RDI_PD0_IO.pl
+++ b/RDI_PD0_IO.pl
@@ -1,9 +1,9 @@
 #======================================================================
 #                    R D I _ P D 0 _ I O . P L 
 #                    doc: Sat Jan 18 14:54:43 2003
-#                    dlm: Tue Apr 14 21:43:23 2020
+#                    dlm: Wed Mar  3 15:02:04 2021
 #                    (c) 2003 A.M. Thurnherr
-#					 uE-Info: 126 73 NIL 0 0 72 0 2 4 NIL ofnI
+#					 uE-Info: 1047 82 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
     
 # Read RDI PD0 binary data files (*.[0-9][0-9][0-9])
@@ -123,7 +123,9 @@
 #					progreass; not sure whether this merge is successful
 #				  - disabled duplicate ens detection, which turns reading into
 #					O(N^2) process
-#	Apr 14, 2020: - BUG: WBPens did not work for ens# > 65535 (high byte)	
+#	Apr 14, 2020: - BUG: WBPens did not work for ens# > 65535 (high byte)
+#	Mar  3, 2021: - adapted to Nortek PD0 files
+# END OF HISTORY
     
 # FIRMWARE VERSIONS:
 #	It appears that different firmware versions generate different file
@@ -1030,21 +1032,26 @@
 		#--------------------
 
 		my($pctg_di) = WBRdtaIndex(0x0400);
-		die("no percent good data in ensemble #$ensNo\n")
-			unless defined($pctg_di);
-	    
-		sysseek(WBRF,$start_ens+$WBRofs[$pctg_di],0) || die("$WBRcfn: $!");
-		sysread(WBRF,$buf,2+$ndata) == 2+$ndata || die("$WBRcfn: $!");
-		($id,@dta) = unpack("vC$ndata",$buf);
-
-		$id == 0x0400 ||
-			die(sprintf($FmtErr,$WBRcfn,"Percent-Good Data",$id,$ensNo));
-
-		for ($i=0,$bin=0; $bin<$nbins; $bin++) {
-			for ($beam=0; $beam<4; $beam++,$i++) {
-				${$E}[$ens]->{PERCENT_GOOD}[$bin][$beam] = $dta[$i];
-			}
-		}
+		if (defined($pctg_di)) {
+			sysseek(WBRF,$start_ens+$WBRofs[$pctg_di],0) || die("$WBRcfn: $!");
+			sysread(WBRF,$buf,2+$ndata) == 2+$ndata || die("$WBRcfn: $!");
+			($id,@dta) = unpack("vC$ndata",$buf);
+			$id == 0x0400 ||
+	            die(sprintf($FmtErr,$WBRcfn,"Percent-Good Data",$id,$ensNo));
+			for ($i=0,$bin=0; $bin<$nbins; $bin++) {
+				for ($beam=0; $beam<4; $beam++,$i++) {
+					${$E}[$ens]->{PERCENT_GOOD}[$bin][$beam] = $dta[$i];
+				}
+	        }
+        } else {
+			printf(STDERR "\nWARNING (RDI_PD0_IO): Percent-Good data missing from PD0 file\n")
+				if ($ens == 0);
+			for ($i=0,$bin=0; $bin<$nbins; $bin++) {
+				for ($beam=0; $beam<4; $beam++,$i++) {
+					${$E}[$ens]->{PERCENT_GOOD}[$bin][$beam] = 100;				# fake it
+                }
+            }			
+        }	    
 
 		#-----------------------------------------
 		# Bottom-Track Data
--- a/listEns
+++ b/listEns
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L I S T E N S 
 #                    doc: Sat Jan 18 18:41:49 2003
-#                    dlm: Sun Feb 28 15:46:21 2021
+#                    dlm: Wed Mar  3 15:35:40 2021
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 351 1 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 239 14 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 $synopsis = 'list ensemble summaries (default), dump ensembles (-E), time-average ensembles (-T)';
@@ -62,6 +62,8 @@
 #	May 31, 2018: - BUG: -A was disabled by default
 #	Feb 13, 2020: - added support for $readDataProgress
 #	Feb 19, 2021: - BUG: -T did not handle new years correctly
+#	Mar  3, 2021: - BUG: debug statement left in place
+# END OF HISTORY
 
 # Notes:
 #	- -E/-B outputs data in earth coordinates, unless -b is set also
@@ -234,7 +236,7 @@
 
 		open(P,">$file") || die("$file: $!\n");
 		print(P "#!/usr/bin/perl -S list\n");
-		print(P "#ANTS#PARAMS# " .
+		printf(P "#ANTS#PARAMS# " .
 				"date{$dta{ENSEMBLE}[$e]->{DATE}} " .
 				"time{$dta{ENSEMBLE}[$e]->{TIME}} " .
 				"soundspeed_correction{%s} " .
@@ -531,8 +533,6 @@
 	}
 } # define output format
 
-die("$yearbase") unless ($yearbase > 1900);
-
 #----------------------------------------------------------------------
 # Loop Over Ensembles
 #----------------------------------------------------------------------