pre IWISE
authorA.M. Thurnherr <athurnherr@yahoo.com>
Fri, 17 Jun 2011 13:32:05 -0400
changeset 6 603221e51c6f
parent 5 29faa9e6226c
child 7 e06925788055
pre IWISE
RDI_BB_Read.pl
RDI_Coords.pl
RDI_Utils.pl
listEns
test_velBeamToBeamPair
--- a/RDI_BB_Read.pl
+++ b/RDI_BB_Read.pl
@@ -1,9 +1,9 @@
 #======================================================================
 #                    R D I _ B B _ R E A D . P L 
 #                    doc: Sat Jan 18 14:54:43 2003
-#                    dlm: Sun Aug 15 16:35:54 2010
+#                    dlm: Thu May 12 10:50:34 2011
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 47 72 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 48 61 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # Read RDI BroadBand Binary Data Files (*.[0-9][0-9][0-9])
@@ -45,6 +45,7 @@
 #	Aug 15, 2010: - downgraded "unexpected number of data types" from error to warning
 #				  - BUG: WBRcfn had not been set correctly
 #				  - modified to allow processing files without time info
+#	May 12, 2011: - added code to report built-in-test errors
 
 # FIRMWARE VERSIONS:
 #	It appears that different firmware versions generate different file
@@ -279,6 +280,7 @@
 
 my($WBRcfn);							# current file name
 my(@WBRofs);							# data type offsets
+my($BIT_errors) = 0;					# built-in-test errors
 
 my($FmtErr) = "%s: illegal %s Id 0x%04x at ensemble %d";
 
@@ -565,6 +567,8 @@
 
 		${$E}[$ens]->{BUILT_IN_TEST_ERROR} = undef
 			unless (${$E}[$ens]->{BUILT_IN_TEST_ERROR});
+		$BIT_errors++ if (${$E}[$ens]->{BUILT_IN_TEST_ERROR});
+
 		${$E}[$ens]->{XDUCER_DEPTH} /= 10;
 		${$E}[$ens]->{HEADING} /= 100;
 		${$E}[$ens]->{PITCH} = unpack('s',pack('S',${$E}[$ens]->{PITCH})) / 100;
@@ -800,6 +804,8 @@
 	WBRens($dta->{N_BINS},$dta->{ENSEMBLE_BYTES},
 		   $dta->{BT_PRESENT},$dta->{DATA_FORMAT},
 		   \@{$dta->{ENSEMBLE}});
+	print(STDERR "$WBRcfn: $BIT_errors built-in-test errors\n")
+		if ($BIT_errors);
 }
 
 sub checkEnsemble($$)
--- a/RDI_Coords.pl
+++ b/RDI_Coords.pl
@@ -1,9 +1,9 @@
 #======================================================================
 #                    R D I _ C O O R D S . P L 
 #                    doc: Sun Jan 19 17:57:53 2003
-#                    dlm: Thu Dec 23 15:00:02 2010
+#                    dlm: Sat Jan 22 22:35:17 2011
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 30 48 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 262 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # RDI Workhorse Coordinate Transformations
@@ -27,7 +27,9 @@
 #	May 23, 2009: - debugged & renamed to &velBeamToBPEarth
 #	May 23, 2010: - changed prototypes of rad() & deg() to conform to ANTS
 #	Dec 20, 2010: - cosmetics
-#	Dec 23, 3020: - added &velBeamToBPInstrument
+#	Dec 23, 2010: - added &velBeamToBPInstrument
+#	Jan 22, 2011: - made velApplyHdgBias calculate sin/cos every time to allow
+#				    per-ensemble corrections
 
 use strict;
 use POSIX;
@@ -245,28 +247,19 @@
 # Bias correction for beam-coordinate data is done in velInstrumentToEarth()
 #======================================================================
 
-{ # STATIC SCOPE
-	my($sh,$ch);
+sub velApplyHdgBias(@)
+{
+	my($dta,$ens,$v1,$v2,$v3,$v4) = @_;
+	return undef unless (defined($v1) && defined($v2));
 
-	sub velApplyHdgBias(@)
-	{
-		my($dta,$ens,$v1,$v2,$v3,$v4) = @_;
-		return undef unless (defined($v1) && defined($v2));
-	
-		unless (defined($sh)) {
-			printf(STDERR "$0: warning HEADING_ALIGNMENT == %g ignored\n",
-						  $dta->{HEADING_ALIGNMENT})
-				if ($dta->{HEADING_ALIGNMENT});
-			$sh = sin(rad(-$dta->{HEADING_BIAS}));
-			$ch = cos(rad(-$dta->{HEADING_BIAS}));
-		}
+	my($sh) = sin(rad(-$dta->{HEADING_BIAS}));
+	my($ch) = cos(rad(-$dta->{HEADING_BIAS}));
 
-		return ( $v1*$ch + $v2*$sh,
-				-$v1*$sh + $v2*$ch,
-				 $v3              ,
-				 $v4              );
-	}
-} # STATIC SCOPE
+	return ( $v1*$ch + $v2*$sh,
+			-$v1*$sh + $v2*$ch,
+			 $v3			  ,
+			 $v4			  );
+}
 
 #----------------------------------------------------------------------
 # Pitch/Roll Functions
--- a/RDI_Utils.pl
+++ b/RDI_Utils.pl
@@ -1,9 +1,9 @@
 #======================================================================
 #                    R D I _ U T I L S . P L 
 #                    doc: Wed Feb 12 10:21:32 2003
-#                    dlm: Thu Dec 16 05:36:27 2010
+#                    dlm: Thu May 12 11:02:26 2011
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 333 65 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 304 3 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # miscellaneous RDI-specific utilities
@@ -36,6 +36,8 @@
 #	Dec  8, 2010: - changed missing w warning to happen only if gap is longer than 15s
 #	Dec 10, 2010: - beautified gap warning
 #	Dec 16, 2010: - BUG: gaps at end caused mk_prof to throw away profile
+#	May 12, 2011: - added code to skip ensembles with built-in-test errors in mk_prof()
+#				  - immediately disabled this code becasue it does appear to make matters worse
 
 use strict;
 
@@ -296,6 +298,10 @@
 	
 	for (my($z)=0,my($e)=0; $e<=$#{$dta->{ENSEMBLE}}; $e++) {
 		checkEnsemble($dta,$e) if ($check);
+###		The following line of code, which can only have an effect if check is disabled,
+###		seems reasonable but has been found to make matters worse with one particular
+###		data file from a BB150. 
+###		next if ($dta->{ENSEMBLE}[$e]->{BUILT_IN_TEST_ERROR});
 	
 		filterEnsemble($dta,$e)
 			if (defined($filter) &&
--- a/listEns
+++ b/listEns
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L I S T E N S 
 #                    doc: Sat Jan 18 18:41:49 2003
-#                    dlm: Wed Jan  5 06:09:49 2011
+#                    dlm: Thu May 12 10:46:46 2011
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 191 73 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 37 99 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # Print useful info from the ensemble list or dump ensembles to
@@ -34,6 +34,7 @@
 #	Aug 15, 2010: - BUG: usage typo
 #	Dec 10, 2010: - changed ANTS output to time/date instead of UNIX time
 #	Jan  5, 2011: - added -b
+#	May 12, 2011: - disabled error exit on built-in-test errors when ensembles are dumped to stdout
 
 # Notes:
 #	- -E outputs data in earth coordinates, unless -b is set also
@@ -253,6 +254,8 @@
 				my($v) = eval("\$dta{ENSEMBLE}[$e]->{$fn}$fi");
 				print(defined($v) ? " $v" : " nan");
 			}
+			print(" BUILT-IN-TEST ERROR")
+				if defined($dta{ENSEMBLE}[$e]->{BUILT_IN_TEST_ERROR});
 			print("\n");
 		}
 		
@@ -273,7 +276,7 @@
 		die("3-beams used in ensemble #$dta{ENSEMBLE}[$e]->{NUMBER}\n")
 			if ($dta{ENSEMBLE}[$e]->{N_BEAMS_USED} < 4);
 		die("BIT error in ensemble $dta{ENSEMBLE}[$e]->{NUMBER}\n")
-			if defined($dta{ENSEMBLE}[$e]->{BUILT_IN_TEST_ERROR});
+			if ($opt_Q || $opt_A || $opt_E) && defined($dta{ENSEMBLE}[$e]->{BUILT_IN_TEST_ERROR});
 		die("Low gain in ensemble #$dta{ENSEMBLE}[$e]->{NUMBER}\n")
 			if ($dta{ENSEMBLE}[$e]->{LOW_GAIN});
 
deleted file mode 100755
--- a/test_velBeamToBeamPair
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/usr/bin/perl
-#======================================================================
-#                    T E S T _ V E L B E A M T O B E A M P A I R 
-#                    doc: Thu May 21 13:40:27 2009
-#                    dlm: Thu May 21 15:03:47 2009
-#                    (c) 2009 A.M. Thurnherr
-#                    uE-Info: 89 24 NIL 0 0 72 0 2 4 NIL ofnI
-#======================================================================
-
-require	"RDI_Coords.pl";
-
-$dta{CONVEX_BEAM_PATTERN} = 1;
-$dta{BEAM_ANGLE} = 20;
-
-#---------------------------------------
-# Case 1: uplooker, bin 3 pointing south
-#---------------------------------------
-
-$dta{ENSEMBLE}[0]->{XDUCER_FACING_UP} = 1;
-$dta{ENSEMBLE}[0]->{HEADING} = 180;
-
-$dta{ENSEMBLE}[0]->{PITCH} = 0;
-$dta{ENSEMBLE}[0]->{ROLL} = 0;
-
-@RDI = velInstrumentToEarth(\%dta,0,velBeamToInstrument(\%dta,2,1,0,0));
-@ant = velBeamToBeamPair(\%dta,0,2,1,0,0);
-die("1: $RDI[0] $ant[0]\n")
-	unless (abs($RDI[0]-$ant[0]) < 1e-6);
-
-@RDI = velInstrumentToEarth(\%dta,0,velBeamToInstrument(\%dta,0,0,1,3));
-@ant = velBeamToBeamPair(\%dta,0,0,0,1,3);
-die("2: $RDI[1] $ant[2]\n")
-	unless (abs($RDI[1]-$ant[2]) < 1e-6);
-
-$dta{ENSEMBLE}[0]->{PITCH} = 20;
-$dta{ENSEMBLE}[0]->{ROLL} = 0;
-
-@RDI = velInstrumentToEarth(\%dta,0,velBeamToInstrument(\%dta,2,1,2,1));
-@ant = velBeamToBeamPair(\%dta,0,2,1,2,1);
-die("3: $RDI[0] $ant[0]\n")
-	unless (abs($RDI[0]-$ant[0]) < 1e-6);
-die("4: $RDI[1] $ant[2]\n")
-	unless (abs($RDI[1]-$ant[2]) < 1e-6);
-
-$dta{ENSEMBLE}[0]->{PITCH} = 0;
-$dta{ENSEMBLE}[0]->{ROLL} = 15;
-
-@RDI = velInstrumentToEarth(\%dta,0,velBeamToInstrument(\%dta,-2,-0.5,-2,-0.5));
-@ant = velBeamToBeamPair(\%dta,0,-2,-0.5,-2,-0.5);
-die("5: $RDI[0] $ant[0]\n")
-	unless (abs($RDI[0]-$ant[0]) < 1e-6);
-die("6: $RDI[1] $ant[2]\n")
-	unless (abs($RDI[1]-$ant[2]) < 1e-6);
-
-#-----------------------------------------
-# Case 1: downlooker, bin 3 pointing south
-#-----------------------------------------
-
-$dta{ENSEMBLE}[0]->{XDUCER_FACING_UP} = 0;
-$dta{ENSEMBLE}[0]->{HEADING} = 180;
-
-$dta{ENSEMBLE}[0]->{PITCH} = 0;
-$dta{ENSEMBLE}[0]->{ROLL} = 0;
-
-@RDI = velInstrumentToEarth(\%dta,0,velBeamToInstrument(\%dta,2,1,0,0));
-@ant = velBeamToBeamPair(\%dta,0,2,1,0,0);
-die("7: $RDI[0] $ant[0]\n")
-	unless (abs($RDI[0]+$ant[0]) < 1e-6);
-
-@RDI = velInstrumentToEarth(\%dta,0,velBeamToInstrument(\%dta,0,0,1,3));
-@ant = velBeamToBeamPair(\%dta,0,0,0,1,3);
-die("8: $RDI[1] $ant[2]\n")
-	unless (abs($RDI[1]-$ant[2]) < 1e-6);
-
-$dta{ENSEMBLE}[0]->{PITCH} = 20;
-$dta{ENSEMBLE}[0]->{ROLL} = 0;
-
-@RDI = velInstrumentToEarth(\%dta,0,velBeamToInstrument(\%dta,2,1,2,1));
-@ant = velBeamToBeamPair(\%dta,0,2,1,2,1);
-die("9: $RDI[0] $ant[0]\n")
-	unless (abs($RDI[0]+$ant[0]) < 1e-6);
-die("10: $RDI[1] $ant[2]\n")
-	unless (abs($RDI[1]-$ant[2]) < 1e-6);
-
-$dta{ENSEMBLE}[0]->{PITCH} = 0;
-$dta{ENSEMBLE}[0]->{ROLL} = 15;
-
-@RDI = velInstrumentToEarth(\%dta,0,velBeamToInstrument(\%dta,-2,-0.5,-2,-0.5));
-@ant = velBeamToBeamPair(\%dta,0,-2,-0.5,-2,-0.5);
-die("11: $RDI[0] $ant[0]\n")
-	unless (abs($RDI[0]+$ant[0]) < 1e-6);
-die("12: $RDI[1] $ant[2]\n")
-	unless (abs($RDI[1]-$ant[2]) < 1e-6);
-
-#----------------------------------------------------------------------
-
-print(STDERR "ok\n");