updated plots & seabed code; GoM data process correctly
authorA.M. Thurnherr <athurnherr@yahoo.com>
Thu, 16 Apr 2015 14:50:59 +0000
changeset 27 2053d8de8d6b
parent 26 b89d4b01fcc5
child 28 b07b23485336
updated plots & seabed code; GoM data process correctly
LADCP_w
LWplot_BR
LWplot_CAE
LWplot_Sv
LWplot_TL
LWplot_corr
LWplot_prof
LWplot_prof_2beam
LWplot_residuals
LWplot_spec
LWplot_w
acoustic_backscatter.pl
defaults.pl
edit_data.pl
time_lag.pl
--- a/LADCP_w	Thu Apr 16 10:31:09 2015 +0000
+++ b/LADCP_w	Thu Apr 16 14:50:59 2015 +0000
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L A D C P _ W 
 #                    doc: Fri Dec 17 18:11:13 2010
-#                    dlm: Thu Apr 16 10:24:42 2015
+#                    dlm: Thu Apr 16 14:27:45 2015
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 159 70 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 162 60 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # TODO:
@@ -146,7 +146,7 @@
 #				  - BUG: sVelProf[] was not allowed to have any gaps
 #	Jul  9, 2014: - BUG: Jul 6 bug fixes had been applied to older
 #				  		 version
-#				  - BUG: code meant to ensure gap-freee svel profiles did not work correctly
+#				  - BUG: code meant to ensure gap-free svel profiles did not work correctly
 #	Jul 12, 2014: - finally made output files executable
 #	Apr  5, 2015: - added check for required software
 #				  - BUG: removed dc/uc mean w fields from .prof again
@@ -157,6 +157,9 @@
 #					plotting sub-system)
 #				  - removed 30s sleep from PostProcess.sh call
 #				  - disabled active output when ANTS are not available
+#				  - removed /bin/ksh requirement
+#				  - BUG: error messages were not reported in the log file
+#				  - made seabed detection code more flexible
 
 # CTD REQUIREMENTS
 #	- elapsed		elapsed seconds; see note below
@@ -215,8 +218,6 @@
 $WCALC = '.' if ($WCALC eq '');
 $ANTS_TOOLS_AVAILABLE = (`which list` ne '');
 
-die("$0: Korn shell (/bin/ksh) required but not found\n")
-	unless (-x '/bin/ksh');
 die("$0: Generic Mapping Tools (GMT) required but not found (bad \$PATH?)\n")
 	unless (`which psxy` ne '');
 die("$0: ANTSlib required but not found (bad \$PATH?)\n")
@@ -300,8 +301,6 @@
 		unless numberp($length_of_timelag_windows[0]) && numberp($length_of_timelag_windows[1]);
 
 
-
-
 croak("$0: \$out_basename undefined\n")									# all plotting routines use this
 	unless defined($out_basename);
 &antsAddParams('out_basename',$out_basename);
@@ -348,6 +347,12 @@
 	print(STDERR "\n") if ($opt_v > 1);
 }
 
+sub error($)
+{
+	print(LOGF "ABORT: @_") if defined($out_log);
+	croak("ABORT: @_");
+}
+
 sub debugmsg(@)
 { printf(STDERR @_) if ($opt_v > 2); }
 
@@ -359,23 +364,23 @@
 readData($LADCP_file,\%LADCP);
 progress("\t%d ensembles\n",scalar(@{$LADCP{ENSEMBLE}}));
 
-croak("$LADCP_file: not enough LADCP bins ($LADCP{N_BINS}) for choice of -r\n")
+error("$LADCP_file: not enough LADCP bins ($LADCP{N_BINS}) for choice of -r\n")
 	unless ($LADCP{N_BINS} >= $refLr_lastBin);
 
-croak("$0: first reference-layer bin outside valid range\n")
+error("$0: first reference-layer bin outside valid range\n")
 	unless ($refLr_firstBin>=1 && $refLr_firstBin<=$LADCP{N_BINS});
-croak("$0: last reference-layer bin outside valid range\n")
+error("$0: last reference-layer bin outside valid range\n")
 	unless ($refLr_lastBin>=1 && $refLr_lastBin<=$LADCP{N_BINS});
-croak("$0: first reference-layer bin > last reference-layer bin\n")
+error("$0: first reference-layer bin > last reference-layer bin\n")
 	unless ($refLr_firstBin <= $refLr_lastBin);
 
 $LADCP_lastBin = $LADCP{N_BINS}-1
 	if ($LADCP_lastBin eq '*');
-croak("$0: first valid LADCP bin outside valid range\n")
+error("$0: first valid LADCP bin outside valid range\n")
 	unless ($LADCP_firstBin>=1 && $LADCP_firstBin<=$LADCP{N_BINS});
-croak("$0: last valid LADCP bin outside valid range\n")
+error("$0: last valid LADCP bin outside valid range\n")
 	unless ($LADCP_lastBin>=1 && $LADCP_lastBin<=$LADCP{N_BINS});
-croak("$0: first valid LADCP bin > last valid LADCP bin\n")
+error("$0: first valid LADCP bin > last valid LADCP bin\n")
 	unless ($LADCP_firstBin <= $LADCP_lastBin);
 
 warning(0,"first reference-layer bin < first valid LADCP bin\n")
@@ -432,12 +437,12 @@
 		$cte += editCorr($ens,$opt_c);
 #		$pte += editTilt($ens,$opt_t);
 	}
-	croak("$LADCP_file: no valid data\n") unless ($nvv > 0);
+	error("$LADCP_file: no valid data\n") unless ($nvv > 0);
 	progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$opt_c,$cte,round(100*$cte/$nvv));
 #	progress("\tattitude threshold (-t %d deg): %d velocites removed (%d%% of total)\n",$opt_t,$pte,round(100*$pte/$nvv));
 } else {
 	progress("Editing velocity data...\n");
-	croak("$LADCP_file: cannot apply beamvel-mask $opt_m to earth-coordinate data\n")
+	error("$LADCP_file: cannot apply beamvel-mask $opt_m to earth-coordinate data\n")
 		if defined($opt_m);
 	$nvv = $cte = 0;
 	for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
@@ -445,7 +450,7 @@
 		$cte += editCorr_Earthcoords($ens,$opt_c);
 #		$pte += editTilt($ens,$opt_t);
 	}
-	croak("$LADCP_file: no valid data\n") unless ($nvv > 0);
+	error("$LADCP_file: no valid data\n") unless ($nvv > 0);
 	progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$opt_c,$cte,round(100*$cte/$nvv));
 #	progress("\tattitude threshold (-t %d deg): %d velocites removed (%d%% of total)\n",$opt_t,$pte,round(100*$pte/$nvv));
 }
@@ -523,7 +528,7 @@
 	progress("\t$nvw valid velocities in bins $LADCP_firstBin-$LADCP_lastBin\n");
 }
 
-croak("$LADCP_file: insufficient valid velocities\n") unless ($nvw > 1000);
+error("$LADCP_file: insufficient valid velocities\n") unless ($nvw > 1000);
 
 #----------------------------------------------
 # STEP: Edit earth-coordinate -velocity data
@@ -556,12 +561,12 @@
 
 ($firstGoodEns,$lastGoodEns,$LADCP_atbottom,$LADCP_w_gap_time) =
 	calcLADCPts(\%LADCP,$opt_s,$refLr_firstBin,$refLr_lastBin,$opt_g);
-croak("$LADCP_file: no good ensembles\n")
+error("$LADCP_file: no good ensembles\n")
 	unless defined($firstGoodEns) && ($lastGoodEns-$firstGoodEns > 0);
 
 my($cast_duration) = $LADCP{ENSEMBLE}[$lastGoodEns]->{ELAPSED} -
 				     $LADCP{ENSEMBLE}[$firstGoodEns]->{ELAPSED};
-croak("$0: implausibly short cast ($cast_duration seconds)\n")
+error("$0: implausibly short cast ($cast_duration seconds)\n")
 	unless ($cast_duration > 600);
 
 $LADCP{MEAN_DT} = $cast_duration / ($lastGoodEns-$firstGoodEns-1);
@@ -590,7 +595,7 @@
 	foreach my $of (@out_LADCP) {
 	    progress("<$of> ");
 	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);
-		open(STDOUT,$of) || croak("$of: $!\n");
+		open(STDOUT,$of) || error("$of: $!\n");
 		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
 		for (my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) {
 			&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER},
@@ -605,6 +610,9 @@
 	progress("\n");
 }
 
+error("deepest depth is at end of cast (no upcast data)\n")
+	if ($lastGoodEns-$LADCP_atbottom < 100);
+
 #----------------------------------------------------------------------
 # More editing
 #	- this requires ${first,last}GoodEns to be known
@@ -635,8 +643,8 @@
 #--------------
 
 progress("Reading CTD data from <$CTD_file>...\n");
-open(STDIN,$CTD_file) || croak("$CTD_file: $!\n");
-croak("$CTD_file: no data\n") unless (&antsIn());
+open(STDIN,$CTD_file) || error("$CTD_file: $!\n");
+error("$CTD_file: no data\n") unless (&antsIn());
 undef($antsOldHeaders);
 ($CTD_elapsed,$CTD_depth,$CTD_svel,$CTD_w) = &fnr('elapsed','depth','ss','w');
 $CTD_temp = &fnrNoErr('temp');
@@ -646,7 +654,7 @@
 $CTD_maxdepth = -1;
 
 do {																		# read data
-	croak("$0: cannot deal with non-numeric CTD elapsed time\n")
+	error("$0: cannot deal with non-numeric CTD elapsed time\n")
 		unless &antsNumbers($CTD_elapsed);
 	push(@{$CTD{ELAPSED}},$ants_[0][$CTD_elapsed]);
 	push(@{$CTD{DEPTH}},  $ants_[0][$CTD_depth]);
@@ -669,7 +677,7 @@
 	$CTD{W_tt}[$s] = ($CTD{W}[$s+1] + $CTD{W}[$s-1] - 2*$CTD{W}[$s]) / $CTD{DT}**2;
 }
 
-croak("$0: CTD start depth must be numeric\n")
+error("$0: CTD start depth must be numeric\n")
 	unless numberp($CTD{DEPTH}[0]);
 if (($CTD{DEPTH}[0] < -$opt_d) && !defined($opt_d)) {
 	$opt_d = -1 * round($CTD{DEPTH}[0]);
@@ -747,7 +755,7 @@
 	$CTD{TIME_LAG} =														
 		calc_lag($number_of_timelag_windows[0],$length_of_timelag_windows[0],
 				 int(1/$CTD{DT}+0.5),$firstGoodEns,$lastGoodEns);
-	croak("$0: Cannot proceed without valid lag!\n") unless defined($CTD{TIME_LAG});
+	error("$0: Cannot proceed without valid lag!\n") unless defined($CTD{TIME_LAG});
 	progress("\telapsed(CTD) ~ elapsed(LADCP) + %.2fs\n",$CTD{TIME_LAG});
 
 	#---------------------------------
@@ -789,7 +797,7 @@
 		shift(@splits);
 	}
 			
-	croak("$0: Cannot proceed without at least one lag!\n")					# fill failed lag with surrounding data
+	error("$0: Cannot proceed without at least one lag!\n")					# fill failed lag with surrounding data
 		unless defined($valid_lag);
 	while ($valid_lag < $#CTD_time_lag) {									# forward
 		$CTD_time_lag[$valid_lag+1] = $CTD_time_lag[$valid_lag];
@@ -851,7 +859,7 @@
 			&& numberp($CTD{DEPTH}[$scan])) {
 		$LADCP{ENSEMBLE}[$ens]->{REFLR_W_NOSSCORR} = $LADCP{ENSEMBLE}[$ens]->{REFLR_W};				
 	    $LADCP{ENSEMBLE}[$ens]->{REFLR_W} *= $CTD{SVEL}[$scan]/1500; 	# correct for sound-speed variations at source
-		croak(sprintf("\n$0: negative depth (%.1fm) in CTD file at elapsed(CTD) = %.1fs (use -d?)\n",
+		error(sprintf("\n$0: negative depth (%.1fm) in CTD file at elapsed(CTD) = %.1fs (use -d?)\n",
 			$CTD{DEPTH}[$scan],$CTD{ELAPSED}[$scan]))
 				unless ($CTD{DEPTH}[$scan] >= 0);
 		$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} = $CTD{DEPTH}[$scan];
@@ -880,13 +888,13 @@
 						100*sqrt($sumWsq/$nWsq),100*sqrt($sumWsqI/$nWsqI));
 	warning(0,"%.2f cm/s reference-layer w_ocean away from boundaries\n",100*sqrt($sumWsqI/$nWsqI))
 		if (sqrt($sumWsqI/$nWsqI) > 0.05);
-#	croak("$0: rms reference-layer w_ocean is too large\n")
+#	error("$0: rms reference-layer w_ocean is too large\n")
 #		unless (sqrt($sumWsqI/$nWsqI) < 0.07);
 } elsif ($nWsq > 0) {
 	&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',nan);
 	progress("\t%.2f cm/s rms reference-layer w_ocean\n",100*sqrt($sumWsq/$nWsq));
 } else {
-	croak("$0: no valid vertical velocities\n");
+	error("$0: no valid vertical velocities\n");
 }
 
 #----------------------------------------------------------------------
@@ -915,14 +923,23 @@
 			find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH});
 		($water_depth_BT,$sig_water_depth_BT) =
 			find_seabed(\%LADCP,$LADCP_atbottom,$LADCP{BEAM_COORDINATES});
-		if (defined($water_depth_BT)) {
+		if (defined($water_depth) && defined($water_depth_BT)) {
 			my($dd) = abs($water_depth_BT - $water_depth);
-			warning(2,sprintf("Large RDI vs. own water-depth difference (%.1fm)\n",$dd))
+			warning(2,sprintf("Large instrument vs. backscatter-derived water-depth difference (%.1fm)\n",$dd))
 				if ($dd > 5);
 		}
+		if (!$SS_use_BT && !defined($water_depth) && defined($water_depth_BT)) {
+			warning(1,"using water_depth from BT data\n");
+			$SS_use_BT = 1;
+		}
+		if ($SS_use_BT) {
+			$water_depth = $water_depth_BT;
+			$sig_water_depth = $sig_water_depth_BT;
+		}
 	}
 	
-	&antsAddParams('water_depth',$water_depth,'water_depth.sig',$sig_water_depth);
+	&antsAddParams('water_depth',$water_depth,'water_depth.sig',$sig_water_depth)
+		if defined($water_depth);
 
 	if (numberp($water_depth)) {
 		if (numberp($water_depth_BT)) {
@@ -1266,7 +1283,7 @@
 	foreach my $of (@out_BR) {
 	    progress("<$of> ");
 	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);
-		open(STDOUT,$of) || croak("$of: $!\n");
+		open(STDOUT,$of) || error("$of: $!\n");
 		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
 		for (my($bin)=0; $bin<max(scalar(@dc_bres),scalar(@uc_bres)); $bin++) {
 			my($dc_avg) = avg(@{$dc_bres[$bin]});
@@ -1318,7 +1335,7 @@
 	foreach my $of (@out_w) {
 	    progress("<$of> ");
 	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);
-		open(STDOUT,$of) || croak("$of: $!\n");
+		open(STDOUT,$of) || error("$of: $!\n");
 		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
 	    
 		for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) {						# downcast
@@ -1407,7 +1424,7 @@
 	foreach my $of (@out_profile) {
 	    progress("<$of> ");
 	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);
-		open(STDOUT,$of) || croak("$of: $!\n");
+		open(STDOUT,$of) || error("$of: $!\n");
 		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
 	    
 		for (my($bi)=0; $bi<=max($#{$DNCAST{ENSEMBLE}},$#{$UPCAST{ENSEMBLE}},$#{$BT{NSAMP}}); $bi++) {
@@ -1443,7 +1460,7 @@
 	foreach my $of (@out_timeseries) {
 	    progress("<$of> ");
 	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);
-		open(STDOUT,$of) || croak("$of: $!\n");
+		open(STDOUT,$of) || error("$of: $!\n");
 		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
 		 
 		for ($ens=$firstGoodEns; $ens<=$realLastGoodEns; $ens++) {
--- a/LWplot_BR	Thu Apr 16 10:31:09 2015 +0000
+++ b/LWplot_BR	Thu Apr 16 14:50:59 2015 +0000
@@ -1,10 +1,10 @@
-#!/bin/ksh
+#!/bin/sh
 #======================================================================
 #					 L W P L O T _ B R 
 #                    doc: Mon Oct 17 10:57:12 2011
-#                    dlm: Thu Apr 16 08:08:23 2015
+#                    dlm: Thu Apr 16 10:40:35 2015
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 17 51 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 19 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -15,6 +15,7 @@
 #   Oct 30, 2103: - got rid of non-portable echo -e
 #	Apr  5, 2015: - made fixbb optional
 #	Apr 16, 2015: - removed copy of input on stdout
+#				  - changed shell from /bin/ksh to /bin/sh
 
 #--------------------------------------------------
 # Usage
--- a/LWplot_CAE	Thu Apr 16 10:31:09 2015 +0000
+++ b/LWplot_CAE	Thu Apr 16 14:50:59 2015 +0000
@@ -1,10 +1,10 @@
-#!/bin/ksh
+#!/bin/sh
 #======================================================================
 #                    L W P L O T _ C A E 
 #                    doc: Wed May 15 19:35:58 2013
-#                    dlm: Thu Apr 16 08:08:52 2015
+#                    dlm: Thu Apr 16 10:40:42 2015
 #                    (c) 2013 A.M. Thurnherr
-#                    uE-Info: 55 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 18 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -14,6 +14,7 @@
 #   Oct 30, 2013: - got rid of non-portable echo -e
 #	Apr  5, 2015: - made fixbb optional
 #   Apr 16, 2015: - removed copy of input on stdout
+#				  - changed shell from /bin/ksh to /bin/sh
 
 #--------------------------------------------------
 # Usage
--- a/LWplot_Sv	Thu Apr 16 10:31:09 2015 +0000
+++ b/LWplot_Sv	Thu Apr 16 14:50:59 2015 +0000
@@ -1,10 +1,10 @@
-#!/bin/ksh
+#!/bin/sh
 #======================================================================
 #					 L W P L O T _ S V 
 #                    doc: Sat Oct 15 13:42:50 2011
-#                    dlm: Thu Apr 16 08:09:17 2015
+#                    dlm: Thu Apr 16 11:18:10 2015
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 64 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 93 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -17,6 +17,8 @@
 #	May 20, 2013: - renamed volume_scattering_coeff to Sv
 #	Apr  5, 2015: - made fixbb optional
 #   Apr 16, 2015: - removed copy of input on stdout
+#				  - changed shell from /bin/ksh to /bin/sh
+#				  - added seabed if available
 
 #--------------------------------------------------
 # Usage
@@ -39,6 +41,7 @@
 	[ -z "$run_label" ] && run_label=`expr -- "$line" : '#ANTS#PARAMS#.*run_label{\([^}]*\)}`
 	[ -z "$min_depth" ] && min_depth=`expr -- "$line" : '#ANTS#PARAMS#.*min_depth{\([^}]*\)}`
 	[ -z "$max_depth" ] && max_depth=`expr -- "$line" : '#ANTS#PARAMS#.*max_depth{\([^}]*\)}`
+	[ -z "$water_depth" ] && water_depth=`expr -- "$line" : '#ANTS#PARAMS#.*water_depth{\([^}]*\)}`
 	[ -z "$min_ens" ] && min_ens=`expr -- "$line" : '#ANTS#PARAMS#.*min_ens{\([^}]*\)}`
 	[ -z "$max_ens" ] && max_ens=`expr -- "$line" : '#ANTS#PARAMS#.*max_ens{\([^}]*\)}`
 	[ -z "$ADCP_bin_length" ] && ADCP_bin_length=`expr -- "$line" : '#ANTS#PARAMS#.*ADCP_bin_length{\([^}]*\)}`
@@ -68,8 +71,10 @@
 			WANT_EURO_FONT true \
 	        PLOT_DEGREE_FORMAT ddd:mm:ssF
 
-R=-R`echo "scale=1;$min_ens-0.5"|bc`/`echo "scale=1;$max_ens+0.5"|bc`/`\
-	 echo "scale=1;$min_depth-$ADCP_bin_length/2"|bc`/`echo "scale=1;$max_depth+$ADCP_bin_length/2"|bc`
+[ -n "$water_depth" ] && blim=`echo "scale=1;$water_depth+25"|bc` \
+				      || blim=`echo "scale=1;$max_depth+$ADCP_bin_length"|bc`
+R=-R`echo "scale=1;$min_ens-0.5"|bc`/`echo "scale=1;$max_ens+0.5"|bc`/0/$blim
+
 U=-R0/1/0/1
 X=-JX10/-10
 C=-C`which LWplot_Sv | sed 's@LWplot_Sv$@Sv.cpt@'`
@@ -79,6 +84,12 @@
 
 awk "{print \$1, \$4, \$17, $ens_width, $bin_length}" $TMPFILE \
 	| psxy -P -K $R $X $C -Sr > "$eps_file"
+[ -n "$water_depth" ] && {
+	echo $min_ens $blim;
+	echo $max_ens $blim;
+	echo $max_ens $water_depth;
+	echo $min_ens $water_depth;
+} | psxy -O -K $R $X -G204/153/102 >> "$eps_file"
 	
 echo 0.02 0.02 12 0 0 TL $out_basename $run_label | pstext -O -K $U $X >> "$eps_file"
 
--- a/LWplot_TL	Thu Apr 16 10:31:09 2015 +0000
+++ b/LWplot_TL	Thu Apr 16 14:50:59 2015 +0000
@@ -1,10 +1,10 @@
-#!/bin/ksh
+#!/bin/sh
 #======================================================================
 #                    L W P L O T _ T L 
 #                    doc: Thu Oct 13 10:51:49 2011
-#                    dlm: Thu Apr 16 08:09:32 2015
+#                    dlm: Thu Apr 16 10:40:56 2015
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 57 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 27 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -23,6 +23,7 @@
 #	Apr  5, 2015: - made fixbb optional
 #				  - BUG: ps file had not been closed properly (fixbb took care of that)
 #   Apr 16, 2015: - removed copy of input on stdout
+#				  - changed shell from /bin/ksh to /bin/sh
 
 USAGE="Usage: $0 <eps-file> [in-file]"
 	[ $# -eq 2 ] && exec <"$2" "$0" "$1"
--- a/LWplot_corr	Thu Apr 16 10:31:09 2015 +0000
+++ b/LWplot_corr	Thu Apr 16 14:50:59 2015 +0000
@@ -1,10 +1,10 @@
-#!/bin/ksh
+#!/bin/sh
 #======================================================================
 #					 L W P L O T _ C O R R 
 #                    doc: Sat Oct 15 13:42:50 2011
-#                    dlm: Thu Apr 16 08:09:52 2015
+#                    dlm: Thu Apr 16 10:41:02 2015
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 62 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 20 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -16,6 +16,7 @@
 #	May 16, 2013: - adapted to file layout change
 #	Apr  5, 2015: - made fixbb optional
 #   Apr 16, 2015: - removed copy of input on stdout
+#				  - changed shell from /bin/ksh to /bin/sh
 
 #--------------------------------------------------
 # Usage
--- a/LWplot_prof	Thu Apr 16 10:31:09 2015 +0000
+++ b/LWplot_prof	Thu Apr 16 14:50:59 2015 +0000
@@ -1,10 +1,10 @@
-#!/bin/ksh
+#!/bin/sh
 #======================================================================
 #					 L W P L O T _ P R O F 
 #                    doc: Fri Oct 14 09:42:36 2011
-#                    dlm: Thu Apr 16 08:10:11 2015
+#                    dlm: Thu Apr 16 10:41:09 2015
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 65 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 24 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -20,6 +20,7 @@
 #   Oct 30, 2103: - got rid of non-portable echo -e
 #	Apr  5, 2015: - made fixbb optional
 #   Apr 16, 2015: - removed copy of input on stdout
+#				  - changed shell from /bin/ksh to /bin/sh
 
 #--------------------------------------------------
 # Usage
--- a/LWplot_prof_2beam	Thu Apr 16 10:31:09 2015 +0000
+++ b/LWplot_prof_2beam	Thu Apr 16 14:50:59 2015 +0000
@@ -1,10 +1,10 @@
-#!/bin/ksh
+#!/bin/sh
 #======================================================================
 #					 L W P L O T _ P R O F _ 2 B E A M 
 #                    doc: Fri Oct 14 09:42:36 2011
-#                    dlm: Thu Apr 16 08:10:32 2015
+#                    dlm: Thu Apr 16 13:59:55 2015
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 61 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 1 9 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -13,9 +13,9 @@
 #	Nov  3, 2014: - adapted to updated layout of .prof file
 #	Apr  5, 2015: - made fixbb optional
 #   Apr 16, 2015: - removed copy of input on stdout
-
-# NOTES:
-#	- this version plots 2-beam solutions instead of final w
+#				  - changed shell from /bin/ksh to /bin/sh
+#				  - slightly increased w range
+#				  - added seabed if available
 
 #--------------------------------------------------
 # Usage
@@ -37,6 +37,7 @@
 	[ -z "$run_label" ] && run_label=`expr -- "$line" : '#ANTS#PARAMS#.*run_label{\([^}]*\)}`
 	[ -z "$min_depth" ] && min_depth=`expr -- "$line" : '#ANTS#PARAMS#.*min_depth{\([^}]*\)}`
 	[ -z "$max_depth" ] && max_depth=`expr -- "$line" : '#ANTS#PARAMS#.*max_depth{\([^}]*\)}`
+	[ -z "$water_depth" ] && water_depth=`expr -- "$line" : '#ANTS#PARAMS#.*water_depth{\([^}]*\)}`
 	[ -z "$fields" ] && fields=`expr -- "$line" : '#ANTS#FIELDS# \(.*\)' | sed -e s/{//g -e s/}//g`
 done
 
@@ -65,17 +66,19 @@
 			WANT_EURO_FONT true \
 	        PLOT_DEGREE_FORMAT ddd:mm:ssF
 
-R=-R-0.07/0.35/$min_depth/$max_depth
-R2=-R-200/200/$min_depth/$max_depth
+[ -n "$water_depth" ] && blim=`echo "scale=0;$water_depth/1+25"|bc` \
+				      || blim=`echo "scale=0;$max_depth/1+25"|bc`
+R=-R-0.1/0.35/0/$blim
+R2=-R-200/200/0/$blim
 U=-R0/1/0/1
 X=-JX10/-10
 
 # FRAME
-{ echo 0 $min_depth; echo 0 $max_depth; } | psxy -P -K $R $X > "$eps_file"
-{ echo 0.07 $min_depth; echo 0.07 $max_depth; echo 0.18 $max_depth; echo 0.18 $min_depth; } | psxy -O -K $R $X -L -G200 >> "$eps_file"
-{ echo 50 $min_depth; echo 50 $max_depth; } | psxy -O -K $R2 $X >> "$eps_file"
-{ echo 100 $min_depth; echo 100 $max_depth; } | psxy -O -K $R2 $X >> "$eps_file"
-{ echo 150 $min_depth; echo 150 $max_depth; } | psxy -O -K $R2 $X >> "$eps_file"
+{ echo 0 0; echo 0 $blim; } | psxy -P -K $R $X > "$eps_file"
+{ echo 0.07 0; echo 0.07 $blim; echo 0.18 $blim; echo 0.18 0; } | psxy -O -K $R $X -L -G200 >> "$eps_file"
+{ echo 50 0; echo 50 $blim; } | psxy -O -K $R2 $X >> "$eps_file"
+{ echo 100 0; echo 100 $blim; } | psxy -O -K $R2 $X >> "$eps_file"
+{ echo 150 0; echo 150 $blim; } | psxy -O -K $R2 $X >> "$eps_file"
 
 # VERTICAL VELOCITIES (2-BEAM SOLUTIONS)
 awk '{print $7, $1}' $TMPFILE | psxy -O -K -N -Mn $R $X -W4,coral,6_2:0 >> "$eps_file"
@@ -94,17 +97,21 @@
 awk '{print $13,$1,$11}' $TMPFILE | sed '/nan/s/.*/nan/' | psxy -O -K -N -Mn $R2 $X -W1/SeaGreen >> "$eps_file"
 awk '{print $18,$1,$20}' $TMPFILE | sed '/nan/s/.*/nan/' | psxy -O -K -N -Mn $R2 $X -W1/black >> "$eps_file"
 
+# SEABED
+[ -n "$water_depth" ] && {
+	echo -0.1 $blim;
+	echo 0.35 $blim;
+	echo 0.35 $water_depth;
+	echo -0.1 $water_depth;
+} | psxy -O -K $R $X -G204/153/102 >> "$eps_file"
+
 # LABELS
 echo 0.02 0.02 12 0 0 TL $out_basename $run_label | pstext -O -K $U $X >> "$eps_file"
 echo 0.6 0.98 12 0 0 BR m.a.d. | pstext -O -K $U $X >> "$eps_file"
 
 # AXES
-if [ 0 -eq `echo "($max_depth-$min_depth)>1000"|bc` ]
-then
-	depth_tics=f10a100
-else
-	depth_tics=f100a500
-fi
+[ $blim -lt 1000 ] && depth_tics=f10a100\
+				   || depth_tics=f100a500
 
 psbasemap -O -K $R $X -Bf0.01a10-10.05:"Vertical Velocity [m/s]                               ":/$depth_tics:"Depth [m]":WeS >> "$eps_file"
 psbasemap -O -K $R $X -Ba10-9.95S >> "$eps_file"
--- a/LWplot_residuals	Thu Apr 16 10:31:09 2015 +0000
+++ b/LWplot_residuals	Thu Apr 16 14:50:59 2015 +0000
@@ -1,10 +1,10 @@
-#!/bin/ksh
+#!/bin/sh
 #======================================================================
 #					 L W P L O T _ R E S I D U A L S 
 #                    doc: Sat Oct 15 13:42:50 2011
-#                    dlm: Thu Apr 16 08:10:54 2015
+#                    dlm: Thu Apr 16 11:20:19 2015
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 63 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 91 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -17,6 +17,8 @@
 #   Apr 12, 2012: - made re-entrant
 #	Apr  5, 2015: - made fixbb optional
 #   Apr 16, 2015: - removed copy of input on stdout
+#				  - changed shell from /bin/ksh to /bin/sh
+#				  - added seabed if available
 
 #--------------------------------------------------
 # Usage
@@ -38,6 +40,7 @@
 	[ -z "$run_label" ] && run_label=`expr -- "$line" : '#ANTS#PARAMS#.*run_label{\([^}]*\)}`
 	[ -z "$min_depth" ] && min_depth=`expr -- "$line" : '#ANTS#PARAMS#.*min_depth{\([^}]*\)}`
 	[ -z "$max_depth" ] && max_depth=`expr -- "$line" : '#ANTS#PARAMS#.*max_depth{\([^}]*\)}`
+	[ -z "$water_depth" ] && water_depth=`expr -- "$line" : '#ANTS#PARAMS#.*water_depth{\([^}]*\)}`
 	[ -z "$min_ens" ] && min_ens=`expr -- "$line" : '#ANTS#PARAMS#.*min_ens{\([^}]*\)}`
 	[ -z "$max_ens" ] && max_ens=`expr -- "$line" : '#ANTS#PARAMS#.*max_ens{\([^}]*\)}`
 	[ -z "$ADCP_bin_length" ] && ADCP_bin_length=`expr -- "$line" : '#ANTS#PARAMS#.*ADCP_bin_length{\([^}]*\)}`
@@ -67,8 +70,9 @@
 			WANT_EURO_FONT true \
 	        PLOT_DEGREE_FORMAT ddd:mm:ssF
 
-R=-R`echo "scale=1;$min_ens-0.5"|bc`/`echo "scale=1;$max_ens+0.5"|bc`/`\
-	 echo "scale=1;$min_depth-$ADCP_bin_length/2"|bc`/`echo "scale=1;$max_depth+$ADCP_bin_length/2"|bc`
+[ -n "$water_depth" ] && blim=`echo "scale=1;$water_depth+25"|bc` \
+				      || blim=`echo "scale=1;$max_depth+$ADCP_bin_length"|bc`
+R=-R`echo "scale=1;$min_ens-0.5"|bc`/`echo "scale=1;$max_ens+0.5"|bc`/0/$blim
 U=-R0/1/0/1
 X=-JX10/-10
 C=-C`which LWplot_residuals | sed 's@LWplot_residuals$@residuals.cpt@'`
@@ -78,6 +82,12 @@
 
 awk "{print \$1, \$4, \$10, $ens_width, $bin_length}" $TMPFILE \
 	| psxy -P -K $R $X $C -Sr > "$eps_file"
+[ -n "$water_depth" ] && {
+	echo $min_ens $blim;
+	echo $max_ens $blim;
+	echo $max_ens $water_depth;
+	echo $min_ens $water_depth;
+} | psxy -O -K $R $X -G204/153/102 >> "$eps_file"
 	
 echo 0.02 0.02 12 0 0 TL $out_basename $run_label | pstext -O -K $U $X >> "$eps_file"
 
--- a/LWplot_spec	Thu Apr 16 10:31:09 2015 +0000
+++ b/LWplot_spec	Thu Apr 16 14:50:59 2015 +0000
@@ -1,10 +1,10 @@
-#!/bin/ksh
+#!/bin/sh
 #======================================================================
 #					 L W P L O T _ S P E C 
 #                    doc: Thu Sep  5 18:23:41 2013
-#                    dlm: Thu Apr 16 08:12:02 2015
+#                    dlm: Thu Apr 16 10:41:27 2015
 #                    (c) 2013 A.M. Thurnherr
-#                    uE-Info: 10 58 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 20 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # NB: THIS PLOTTING ROUTINE REQUIRES NON-PUBLIC ANTS TOOLS
@@ -16,6 +16,7 @@
 #	Jul 12, 2013: - added a -N to pgram to make it work with partial-depth casts
 #	Apr  5, 2015: - made fixbb optional
 #   Apr 16, 2015: - removed copy of input on stdout
+#				  - changed shell from /bin/ksh to /bin/sh
 
 #--------------------------------------------------
 # Usage
--- a/LWplot_w	Thu Apr 16 10:31:09 2015 +0000
+++ b/LWplot_w	Thu Apr 16 14:50:59 2015 +0000
@@ -1,10 +1,10 @@
-#!/bin/ksh
+#!/bin/sh
 #======================================================================
 #					 L W P L O T _ W 
 #                    doc: Sat Oct 15 13:42:50 2011
-#                    dlm: Thu Apr 16 08:12:31 2015
+#                    dlm: Thu Apr 16 11:17:23 2015
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 64 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 76 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -18,6 +18,8 @@
 #   Apr 12, 2012: - made re-entrant
 #	Apr  5, 2015: - made fixbb optional
 #   Apr 16, 2015: - removed copy of input on stdout
+#				  - changed shell from /bin/ksh to /bin/sh
+#				  - added seabed if available
 
 #--------------------------------------------------
 # Usage
@@ -39,6 +41,7 @@
 	[ -z "$run_label" ] && run_label=`expr -- "$line" : '#ANTS#PARAMS#.*run_label{\([^}]*\)}`
 	[ -z "$min_depth" ] && min_depth=`expr -- "$line" : '#ANTS#PARAMS#.*min_depth{\([^}]*\)}`
 	[ -z "$max_depth" ] && max_depth=`expr -- "$line" : '#ANTS#PARAMS#.*max_depth{\([^}]*\)}`
+	[ -z "$water_depth" ] && water_depth=`expr -- "$line" : '#ANTS#PARAMS#.*water_depth{\([^}]*\)}`
 	[ -z "$min_ens" ] && min_ens=`expr -- "$line" : '#ANTS#PARAMS#.*min_ens{\([^}]*\)}`
 	[ -z "$max_ens" ] && max_ens=`expr -- "$line" : '#ANTS#PARAMS#.*max_ens{\([^}]*\)}`
 	[ -z "$ADCP_bin_length" ] && ADCP_bin_length=`expr -- "$line" : '#ANTS#PARAMS#.*ADCP_bin_length{\([^}]*\)}`
@@ -68,8 +71,10 @@
 			WANT_EURO_FONT true \
 	        PLOT_DEGREE_FORMAT ddd:mm:ssF
 
-R=-R`echo "scale=1;$min_ens-0.5"|bc`/`echo "scale=1;$max_ens+0.5"|bc`/`\
-	 echo "scale=1;$min_depth-$ADCP_bin_length/2"|bc`/`echo "scale=1;$max_depth+$ADCP_bin_length/2"|bc`
+[ -n "$water_depth" ] && blim=`echo "scale=1;$water_depth+25"|bc` \
+				      || blim=`echo "scale=1;$max_depth+$ADCP_bin_length"|bc`
+R=-R`echo "scale=1;$min_ens-0.5"|bc`/`echo "scale=1;$max_ens+0.5"|bc`/0/$blim
+	 
 U=-R0/1/0/1
 X=-JX10/-10
 
@@ -78,6 +83,12 @@
 
 awk "{print \$1, \$4, \$7, $ens_width, $bin_length}" $TMPFILE \
 	| psxy -P -K $R $X -C`which LWplot_w | sed 's@LWplot_w$@w.cpt@'` -Sr > "$eps_file"
+[ -n "$water_depth" ] && {
+	echo $min_ens $blim;
+	echo $max_ens $blim;
+	echo $max_ens $water_depth;
+	echo $min_ens $water_depth;
+} | psxy -O -K $R $X -G204/153/102 >> "$eps_file"
 	
 echo 0.02 0.02 12 0 0 TL $out_basename $run_label | pstext -O -K $U $X >> "$eps_file"
 
--- a/acoustic_backscatter.pl	Thu Apr 16 10:31:09 2015 +0000
+++ b/acoustic_backscatter.pl	Thu Apr 16 14:50:59 2015 +0000
@@ -1,9 +1,9 @@
 #======================================================================
 #                    A C O U S T I C _ B A C K S C A T T E R . P L 
 #                    doc: Wed Oct 20 13:02:27 2010
-#                    dlm: Fri Nov  7 14:45:44 2014
+#                    dlm: Thu Apr 16 14:40:22 2015
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 80 0 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 141 0 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -18,6 +18,7 @@
 #	Mar  4, 2014: - added support for missing PITCH/ROLL (TILT)
 #	Apr 17, 2014: - BUG: missing ;
 #	Nov  7, 2014: - BUG: calc_binDepths() was called without valid CTD depth
+#	Apr 16, 2015: - added min samp criterion for seabed search
 
 #----------------------------------------------------------------------
 # Volume Scattering Coefficient, following Deines (IEEE 1999)
@@ -113,7 +114,7 @@
 
 #----------------------------------------------------------------------
 # determine location of seabed from backscatter profiles
-#	input:	depth below seabed can possibly be (e.g. max CTD depth)
+#	input:	depth below which seabed can possibly be (e.g. max CTD depth)
 #	output:	median/mad of estimated water depth
 #----------------------------------------------------------------------
 
@@ -135,6 +136,9 @@
 			push(@wdepth,$depthmaxSv);
 		}
 	}
+
+	info("%d seabed samples found\n",scalar(@wdepth));
+	return (undef,undef) if (scalar(@wdepth) < $SS_min_samp);	# require min number of samples
 	
 	my($wd) = median(@wdepth);
 	return ($wd,mad2($wd,@wdepth));
--- a/defaults.pl	Thu Apr 16 10:31:09 2015 +0000
+++ b/defaults.pl	Thu Apr 16 14:50:59 2015 +0000
@@ -1,9 +1,9 @@
 #======================================================================
 #                    D E F A U L T S . P L 
 #                    doc: Tue Oct 11 17:11:21 2011
-#                    dlm: Thu Apr 16 08:32:02 2015
+#                    dlm: Thu Apr 16 14:40:08 2015
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 374 61 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 256 2 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -44,7 +44,8 @@
 #	Nov  4, 2014: - BUG: PPI_editing did not work as advertised
 #   Apr 16, 2015: - turned output specifies into lists (re-design of
 #                   plotting sub-system)
-
+#				  - croak -> error
+#				  - added $SS_use_BT
 
 #======================================================================
 # Data Input 
@@ -106,7 +107,7 @@
 
 # output subdirectories
 
-croak("$RUN: no such directory\n") unless (-d $RUN);
+error("$RUN: no such directory\n") unless (-d $RUN);
 $data_subdir = $plot_subdir = $log_subdir = $RUN;
 
 
@@ -207,7 +208,7 @@
 # Time Lagging
 #======================================================================
 
-# externally supplied lag
+# externally supplied lag initial guess
 
 # $opt_i = 567;
 
@@ -244,19 +245,34 @@
 # Seabed Search
 #======================================================================
 
-# # of ensembles around bottom to search
+# 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.
+
+$SS_use_BT = 0;
+
+
+# Require at least 5 valid samples for seabed detection. Only for
+# $SS_use_BT == 0.
+
+$SS_min_samp = 5;
+
+
+# Number of ensembles around bottom to search. Only for $SS_use_BT == 1.
 
 $SS_search_window_halfwidth = 200;	 
 
 
-# max allowed distance of seabed from mode of distribution
+# Maximum allowed distance of seabed from mode of distribution. 
+# Only for $SS_use_BT == 1.
 
 $SS_max_allowed_depth_range = 10;
 
 
 # The following numbers define the valid range of height-above bottom
-# for seabed detection. If the the mean BT_RANGE of a given ens
-# falls outside this range, the ensemble is ignored during seabed detection.
+# for seabed detection when $SS_use_BT == 1. If the the mean BT_RANGE of 
+# a given ens falls outside this range, the ensemble is ignored during 
+# seabed detection.
 # Also, bins falling outside this range are not considered during 
 # construction of accoustic backscatter profiles.
 
@@ -266,6 +282,8 @@
 
 #======================================================================
 # 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
@@ -303,7 +321,7 @@
 } elsif (-r "ProcessingParams") {
 	$processing_param_file = "ProcessingParams";
 } else {
-	croak("$0: cannot find either <ProcessingParams.$RUN> or <ProcessingParams[.default]>\n");
+	error("$0: cannot find either <ProcessingParams.$RUN> or <ProcessingParams[.default]>\n");
 }
 
 #----------------------------------------------------------------------
--- a/edit_data.pl	Thu Apr 16 10:31:09 2015 +0000
+++ b/edit_data.pl	Thu Apr 16 14:50:59 2015 +0000
@@ -1,9 +1,9 @@
 #======================================================================
 #                    E D I T _ D A T A . P L 
 #                    doc: Sat May 22 21:35:55 2010
-#                    dlm: Wed May 21 13:00:35 2014
+#                    dlm: Thu Apr 16 12:13:15 2015
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 339 74 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 357 20 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -30,6 +30,7 @@
 #	Mar  4, 2013: - added support for missing PITCH/ROLL (TILT) & HEADING
 #	May 20, 2014: - added editPPI()
 #	May 21, 2014: - got it to work correctly
+#				  - croak -> error
 
 # NOTES:
 #	- editCorr_Earthcoords() is overly conservative and removed most
@@ -353,7 +354,7 @@
 		elsif ($LADCP{BEAM_FREQUENCY} ==  300) { $bha = 3.7; }
 		elsif ($LADCP{BEAM_FREQUENCY} ==  150) { $bha = 6.7; }
 		elsif ($LADCP{BEAM_FREQUENCY} ==   75) { $bha = 8.4; }
-		else { croak("$0: unexpected transducer frequency $LADCP{BEAM_FREQUENCY}\n"); }
+		else { error("$0: unexpected transducer frequency $LADCP{BEAM_FREQUENCY}\n"); }
 	}
 	
 	for (my($e)=$fe; $e<=$te; $e++) {
--- a/time_lag.pl	Thu Apr 16 10:31:09 2015 +0000
+++ b/time_lag.pl	Thu Apr 16 14:50:59 2015 +0000
@@ -1,9 +1,9 @@
 #======================================================================
 #                    T I M E _ L A G . P L 
 #                    doc: Fri Dec 17 21:59:07 2010
-#                    dlm: Thu Apr 16 10:25:37 2015
+#                    dlm: Thu Apr 16 12:13:25 2015
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 63 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 276 41 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -56,6 +56,7 @@
 #                   plotting sub-system)
 #				  - BUG: executable flag was not set on file output
 #				  - disabled active output when ANTS are not available
+#				  - croak -> error
 
 # DIFFICULT STATIONS:
 #	NBP0901#131		this requires the search-radius doubling heuristic
@@ -105,8 +106,6 @@
 sub bestLag($$$$)								# find best lag in window
 {
 	my($fe,$le,$ww,$soi) = @_;					# first/last LADCP ens, window width, scan-offset increment
-#	$le = $lastGoodEns
-#		unless ($le <= $lastGoodEns);
 	die("assertion failed\n\tfe = $fe, le = $le, firstGoodEns = $firstGoodEns, lastGoodEns = $lastGoodEns")
 		unless ($fe>=$firstGoodEns && $le<=$lastGoodEns);
 
@@ -274,7 +273,7 @@
 			foreach my $of (@out_TL) {
 				progress("<$of> ");
 				$of = ">$of" unless ($of =~ /^$|^\s*\|/);
-		        open(STDOUT,$of) || croak("$of: $!\n");
+		        open(STDOUT,$of) || error("$of: $!\n");
 				undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
 
 				for (my($wi)=0; $wi<@elapsed_buf; $wi++) {