2022 A16N pre-cruise draft
authorA.M. Thurnherr <athurnherr@yahoo.com>
Fri, 18 Nov 2022 12:57:25 -0500
changeset 63 4832af086e8c
parent 62 9f3282aa7b9b
child 64 58ef697c01ae
2022 A16N pre-cruise
LADCP_w_CTD
LADCP_w_ocean
LADCP_w_postproc
defaults.pl
--- a/LADCP_w_CTD	Fri Sep 09 12:38:20 2022 -0400
+++ b/LADCP_w_CTD	Fri Nov 18 12:57:25 2022 -0500
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L A D C P _ W _ C T D 
 #                    doc: Mon Nov  3 17:34:19 2014
-#                    dlm: Fri Sep  9 12:38:13 2022
+#                    dlm: Fri Sep 16 14:39:17 2022
 #                    (c) 2014 A.M. Thurnherr
-#                    uE-Info: 25 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 108 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 $antsSummary = 'pre-process SBE 9plus CTD data for LADCP_w';
@@ -102,10 +102,9 @@
 #	May 10, 2022: - BUG: non-numeric ids no longer worked
 #				  - added -d to allow for station and cast numbering
 #	May 17, 2022: - made station cast numbering work based on input file name
-#	Aut 29, 2022: - BUG: -d should not depend on length of BASENAME
-# HISTORY END
 #	Jun 27, 2022: - BUG: fill_gaps code could not deal with format errors (nans)
 #				  - reversed semantics of -m because modulo error correction code has bugs
+#	Aug 29, 2022: - BUG: -d should not depend on length of BASENAME
 # HISTORY END
 
 # NOTES:
--- a/LADCP_w_ocean	Fri Sep 09 12:38:20 2022 -0400
+++ b/LADCP_w_ocean	Fri Nov 18 12:57:25 2022 -0500
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L A D C P _ W _ O C E A N 
 #                    doc: Fri Dec 17 18:11:13 2010
-#                    dlm: Mon Oct 18 21:27:57 2021
+#                    dlm: Fri Sep 16 14:11:02 2022
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 2040 92 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 331 56 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # TODO:
@@ -328,6 +328,7 @@
 #				  - added {dc,uc}_exposure_time to .wprof output
 #	Oct 18, 2021: - BUG: Sv profiles included bins without valid w
 #				  - moved Sv profile code after additional filters; 
+#	Sep 16, 2022: - added support for $SS_use_BT_allowed
 # HISTORY END
 
 # CTD REQUIREMENTS
@@ -1313,9 +1314,13 @@
 #		warning(0,sprintf("Large instrument vs. backscatter-derived water-depth difference (%.1fm)\n",$dd))
 #			if ($dd > 10);
 	}
-	if (!$SS_use_BT && !defined($water_depth) && defined($water_depth_BT)) {		# warn if use of BT was not
-		warning(1,"using water_depth from ADCP BT data\n");							# explicitly requested
-		$SS_use_BT = 1;
+	if (!$SS_use_BT && !defined($water_depth) && defined($water_depth_BT)) {		# ADCP BT data available but not requested
+		if ($SS_use_BT_allowed) {
+			warning(1,"using water_depth from ADCP BT data\n");						# 
+			$SS_use_BT = 1;
+        } else {
+			warning(1,"disregarding water_depth = %dm from ADCP BT data\n",$water_depth_BT);						# 
+        }
 	}
 	if ($SS_use_BT && numberp($water_depth_BT)) {									# water depth from BT data
 		&antsAddParams('water_depth_from','BT_data');
--- a/LADCP_w_postproc	Fri Sep 09 12:38:20 2022 -0400
+++ b/LADCP_w_postproc	Fri Nov 18 12:57:25 2022 -0500
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L A D C P _ W _ P O S T P R O C 
 #                    doc: Fri Apr 24 17:15:59 2015
-#                    dlm: Wed May 18 08:52:28 2022
+#                    dlm: Mon Sep 19 18:33:30 2022
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 193 67 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 92 33 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 $antsSummary = 'edit and re-grid LADCP vertical-velocity samples';
@@ -88,6 +88,8 @@
 #	May 10, 2022: - added -f
 #	May 17, 2022: - changed semantics to take output file name from input file names
 #	May 18, 2022: - BUG: new semantics did not work (oops)
+#	Sep 19, 2022: - BUG: plot did not work any more (unclear since when) for dual-head
+#						 profiles
 # HISTORY END
 
 
@@ -433,7 +435,6 @@
 
 $min_depth =  9e99;										# sentinels
 $max_depth = -9e99;
-
 $curF = $P{PATHNAME};															# current input file (sentinel)
 $filt = 0;
 for ($r=0; &antsIn(); $r++) {
@@ -610,25 +611,26 @@
 }
 
 #&antsInfo("WARNING: unknown water depth (no height-above-bottom)")
+
 #	unless numberp($P{water_depth});
 
 my(@dcwm,@ucwm,@dcns,@ucns,@dcwmad,@ucwmad);
 for (my($bi)=0; $bi<=max($#dcw,$#ucw); $bi++) {
 	$dcwm[$bi] = median(@{$dcw[$bi]}); 
 	$ucwm[$bi] = median(@{$ucw[$bi]});
-	$dcns[$bi] = @{$dcw[$bi]};
+	$dcns[$bi] = @{$dcw[$bi]}; 
 	$ucns[$bi] = @{$ucw[$bi]};
 	$dcwmad[$bi] = mad2($dcwm[$bi],@{$dcw[$bi]});
 	$ucwmad[$bi] = mad2($ucwm[$bi],@{$ucw[$bi]});
 	push(@{$out[$bi]},
-			 ($bi+0.5)*$opt_o,
-			 (numberp($P{water_depth}) ? $P{water_depth}-($bi+0.5)*$opt_o : nan),
-			 avg(@{$dce[$bi]}),
-			 (($dcns[$bi]>=$opt_k)?$dcwm[$bi]:nan),(($dcns[$bi]>=$opt_k)?$dcwmad[$bi]:nan),
-			 scalar(@{$dcw[$bi]}),
-			 avg(@{$uce[$bi]}),
-			 (($ucns[$bi]>=$opt_k)?$ucwm[$bi]:nan),(($ucns[$bi]>=$opt_k)?$ucwmad[$bi]:nan),
-			 scalar(@{$ucw[$bi]}));
+			 ($bi+0.5)*$opt_o,																# depth
+			 (numberp($P{water_depth}) ? $P{water_depth}-($bi+0.5)*$opt_o : nan),			# hab
+			 avg(@{$dce[$bi]}),																# dc_elapsed
+			 (($dcns[$bi]>=$opt_k)?$dcwm[$bi]:nan),(($dcns[$bi]>=$opt_k)?$dcwmad[$bi]:nan),	# dc_w, dc_w.mad
+			 scalar(@{$dcw[$bi]}),															# dc_w.nsamp
+			 avg(@{$uce[$bi]}),																# uc_elapsed
+			 (($ucns[$bi]>=$opt_k)?$ucwm[$bi]:nan),(($ucns[$bi]>=$opt_k)?$ucwmad[$bi]:nan),	# uc_w, uc_w.mad
+			 scalar(@{$ucw[$bi]}));															# uc_w.nsamp
 	if ($dual_head) {
 		push(@{$out[$bi]},$dc_diff[$bi],$uc_diff[$bi],
 						  $dc_R[$bi],$dc_var[$bi],$dc_rms_wdiff[$bi],
@@ -642,25 +644,34 @@
 if (defined($opt_p)) {																# complete summary plot
 	GMT_setR($R);
 
-	if ($P{water_depth} > 0) {															# SEABED
+	if ($P{water_depth} > 0) {														# SEABED
 		GMT_psxy('-G204/153/102');
 		print(GMT "$xmin $ymax\n0.07 $ymax\n0.07 $P{water_depth}\n $xmin $P{water_depth}\n");
 	}
 
 	GMT_psxy('-W1.5,coral');														# median profiles
 	for (my($bi)=0; $bi<=$#dcw; $bi++) {
-#		printf(GMT "%f %f\n",(($dcns[$bi]>=$opt_k)?$dcwm[$bi]:nan),($bi+0.5)*$opt_o);
-		printf(GMT "%f %f\n",(numberp($DL_dc_median[$bi]) &&
-							  numberp($UL_dc_median[$bi]) &&
-							  ($dcns[$bi]>=$opt_k)?$dcwm[$bi]:nan)
-							,($bi+0.5)*$opt_o);
+		if ($dual_head) {
+			printf(GMT "%f %f\n",(numberp($DL_dc_median[$bi]) &&
+								  numberp($UL_dc_median[$bi]) &&
+								  ($dcns[$bi]>=$opt_k)?$dcwm[$bi]:nan)
+								,($bi+0.5)*$opt_o);
+		} else {
+			printf(GMT "%f %f\n",(($dcns[$bi]>=$opt_k)?$dcwm[$bi]:nan)
+								,($bi+0.5)*$opt_o);
+		}
 	}
 	GMT_psxy('-W1.5,SeaGreen');
 	for (my($bi)=0; $bi<=$#ucw; $bi++) {
-		printf(GMT "%f %f\n",(numberp($DL_uc_median[$bi]) &&
-							  numberp($UL_uc_median[$bi]) &&
-							  ($ucns[$bi]>=$opt_k)?$ucwm[$bi]:nan)
-							,($bi+0.5)*$opt_o);
+		if ($dual_head) {
+			printf(GMT "%f %f\n",(numberp($DL_uc_median[$bi]) &&
+								  numberp($UL_uc_median[$bi]) &&
+								  ($ucns[$bi]>=$opt_k)?$ucwm[$bi]:nan)
+								,($bi+0.5)*$opt_o);
+		} else {
+			printf(GMT "%f %f\n",(($ucns[$bi]>=$opt_k)?$ucwm[$bi]:nan)
+								,($bi+0.5)*$opt_o);
+		}
 	}
 
 	GMT_psxy('-Sc0.1 -Gcoral');														# m.a.d. profiles
--- a/defaults.pl	Fri Sep 09 12:38:20 2022 -0400
+++ b/defaults.pl	Fri Nov 18 12:57:25 2022 -0500
@@ -1,9 +1,9 @@
 #======================================================================
 #                    D E F A U L T S . P L 
 #                    doc: Tue Oct 11 17:11:21 2011
-#                    dlm: Tue Oct 26 12:12:27 2021
+#                    dlm: Fri Sep 16 14:09:13 2022
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 183 72 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 95 81 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -91,6 +91,8 @@
 #	Jun 30, 2021: - ditto
 #	Jul  9, 2021: - added $layer_residuals_rms_max
 #	Sep  1, 2021: - added $seabed_contamination_Sv_grad_limit
+#	Sep 16, 2022: - added $SS_use_BT_allowed (default to 0) to allow
+#				    disabling use of ADCP BT data altogether (enabled by default)
 # HISTORY END
 
 #======================================================================
@@ -446,11 +448,20 @@
 $Sv_ref_bin = 1; 
 
 
-# Set to folloing variable to 1 to use ADCP BT data to detect seabed 
-# instead of default code based on Sv (echo amplitude). I do not know
-# which code is better.
+# By default, the ADCP BT data (from WM15 or BT pings) are ignored, i.e.
+# only  "post-processed" BT data (from regular "water-track" pings) are
+# used for the seabed detection. Set $SS_use_BT = 1 if you want to use
+# the water depth information from the ADCP BT data instead. This is
+# not recommended, because the WM15 BT data often returns values even
+# the seabed is out of range. If no seabed is detected in the
+# water-track data but the ADCP BT data has apparently valid water
+# depths and if $SS_use_BT_allowed is true, the software sets
+# $SS_use_BT = 1 for the profile and uses BT data. This, too, is 
+# not recommended because of erroneous bottom detection by the
+# ADCPs.
 
-$SS_use_BT = 0;
+$SS_use_BT 		   = 0;
+$SS_use_BT_allowed = 0;
 
 
 # The following variable defines the minimum Sv signal in a bin (max - min)
@@ -499,8 +510,6 @@
 
 #======================================================================
 # Bottom Tracking
-#	- at present, the ADCP BT data are ignored, i.e. "post-processed"
-#	  BT data are used.
 #======================================================================
 
 # Don't look for BT-referenced velocities if package is more than $BT_max_range