V2.0
authorA.M. Thurnherr <athurnherr@yahoo.com>
Sat, 24 Jul 2021 10:35:41 -0400
changeset 56 8f120b9f795a
parent 55 2d8e1139acd5
child 57 69e39fcb7f41
V2.0 - lots of bug fixes - major new features: - dropped CTD scans handled correctly (no more apparent clock drifts) - support for data files collected with Nortek Signature instruments - much improved data editing - significant changes: - no minimum limit for eps_VKE - updated for GMT6 - much better data quality information in summary plots
HISTORY
LADCP_VKE
LADCP_w_CTD
LADCP_w_HowTo.pdf
LADCP_w_howto.pdf
LADCP_w_ocean
LADCP_w_postproc
acoustic_backscatter.pl
bottom_tracking.pl
default_output.pl
defaults.pl
edit_data.pl
find_seabed.pl
plot_backscatter.pl
plot_bin_residuals.pl
plot_correlation.pl
plot_mean_residuals.pl
plot_residual_profs.pl
plot_residuals.pl
plot_residuals12.pl
plot_residuals34.pl
plot_time_lags.pl
plot_wprof.pl
plot_wsamp.pl
time_lag.pl
time_series.pl
version.pl
--- a/HISTORY	Sat Apr 10 06:00:45 2021 -0400
+++ b/HISTORY	Sat Jul 24 10:35:41 2021 -0400
@@ -1,374 +1,456 @@
 ======================================================================
                     H I S T O R Y 
                     doc: Mon Oct 12 16:09:24 2015
-                    dlm: Tue Nov 27 17:00:26 2018
+                    dlm: Sat Jul 24 10:35:19 2021
                     (c) 2015 A.M. Thurnherr
-                    uE-Info: 373 28 NIL 0 0 72 3 2 4 NIL ofnI
+                    uE-Info: 327 25 NIL 0 0 72 3 2 4 NIL ofnI
 ======================================================================
 
 ----------------------------------------------------------------------
-First Released Version (howto does not cover VKE parameterization)
+V1.0:
+	- First Released Version (howto does not cover VKE parameterization)
 ----------------------------------------------------------------------
 
-V1.0:
-	Oct 12, 2015:
-		- finalized HowTo V1.0 (antsLibVer V6.2, ADCP_tools V1.3)
-		- uploaded to Mercurial server
+Oct 12, 2015: - finalized HowTo V1.0 (antsLibVer V6.2, ADCP_tools V1.3)
+			  - uploaded to Mercurial server
 
 ----------------------------------------------------------------------		
-First Version with Full HowTo (including VKE parameterization)
+V1.1:
+	- First Version with Full HowTo (including VKE parameterization)
 ----------------------------------------------------------------------
 
-V1.1:
-	Oct 12, 2015: V1.1beta1
-		- added [version.pl]
-		- adapted to version.pl: [LADCP_w_ocean] [LADCP_w_CTD]
-			[LADCP_VKE] [LADCP_w_postproc]
-		- modified [LADCP_w_CTD] to allow processing ASCII CNV files with
-		  wrong number of scans in header
-	Nov 25-27, 2015:
-		- minor mods to [LADCP_w_ocean] to try to get it to work on
-		  Windows (R. Robertson)
-	Dec 22, 2015:
-		- removed Plots/ Documentation/ Dec_17_2010/ Dec_24_2010/
-				  Dec_30_2010/ Oct_11_2011/ Jul_04_2011/ from repo
-		- moved PostProces.sh to Utilities/ and modified README
-	Jan  4, 2016:
-		- decreased default vertical resolution to 20m [defaults.pl] [LADCP_w_ocean]
-		- removed beta from version [version.pl] [.hg/hgrc]
+Oct 12, 2015: - V1.1beta1
+			  - added [version.pl]
+			  - adapted to version.pl: [LADCP_w_ocean] [LADCP_w_CTD]
+				  [LADCP_VKE] [LADCP_w_postproc]
+			  - modified [LADCP_w_CTD] to allow processing ASCII CNV files with
+                wrong number of scans in header
+
+Nov 25-27, 2015:
+			  - minor mods to [LADCP_w_ocean] to try to get it to work on
+                Windows (R. Robertson)
+
+Dec 22, 2015: - removed Plots/ Documentation/ Dec_17_2010/ Dec_24_2010/
+						Dec_30_2010/ Oct_11_2011/ Jul_04_2011/ from repo
+              - moved PostProces.sh to Utilities/ and modified README
+
+Jan  4, 2016: - decreased default vertical resolution to 20m [defaults.pl] [LADCP_w_ocean]
+			  - removed beta from version [version.pl] [.hg/hgrc]
 
 ----------------------------------------------------------------------
-First Widely Released Version (many significant improvements)
+V1.2:
+	- First Widely Released Version (many significant improvements)
 ----------------------------------------------------------------------
 
-V1.2:
-	Jan  5, 2016: V1.2beta
-		- updated [version.pl]
-		- added support for [ADCP_tools_lib.pl]: [version.pl] [LADCP_w_ocean]
-	Jan 24, 2016:
-		- added QC for mean residuals
-		- added QC for dual-head wprofs
-		- added automatic editing of bad time lagged data
-	Jan 25 -- Mar 8:
-		- many bug fixes and small improvements
-	Mar 8, 2016:
-		- added updated howto pdf
-		- updated [version.pl] with new ANTSlib prerequisite version
-		- published as V1.2beta
+Jan  5, 2016: - V1.2beta
+			  - updated [version.pl]
+              - added support for [ADCP_tools_lib.pl]: [version.pl] [LADCP_w_ocean]
+
+Jan 24, 2016: - added QC for mean residuals
+			  - added QC for dual-head wprofs
+              - added automatic editing of bad time lagged data
 
-	Mar 9, 2016: V1.2beta2
-		- added hab field to .wprof output [LADCP_w_ocean]
-	Mar 10, 2016:
-		- published
+Jan 25 -- Mar 8:
+			  - many bug fixes and small improvements
+
+Mar  8, 2016: - added updated howto pdf
+			  - updated [version.pl] with new ANTSlib prerequisite version
+              - published as V1.2beta
+
+Mar  9, 2016: - V1.2beta2
+		      - added hab field to .wprof output [LADCP_w_ocean]
+			 
+Mar 10, 2016: - published
 
-	Mar 13, 2016: V1.2beta3
-		- updated [version.pl] [.hg/hgrc]
-		- added simple ASCII CTD format [LADCP_w_CTD]
-		- added auto directory creation to [defaults.pl]
-		- updated howto
-		- published V1.2beta3
-		- updated [version.pl] [.hg/hgrc] to V1.2beta4
-		- added ADCP-file checks in [LADCP_w_ocean]
-		- updated howto
+Mar 13, 2016: - V1.2beta3
+			  - updated [version.pl] [.hg/hgrc]
+			  - added simple ASCII CTD format [LADCP_w_CTD]
+			  - added auto directory creation to [defaults.pl]
+			  - updated howto
+			  - published V1.2beta3
+			  - updated [version.pl] [.hg/hgrc] to V1.2beta4
+			  - added ADCP-file checks in [LADCP_w_ocean]
+              - updated howto
 
-	Mar 16, 2016: V1.2beta4
-		- published on server		
-		- updated [version.pl] to beta5 (gmt5)
-		- adapted to GMT5
+Mar 16, 2016: - V1.2beta4
+			  - published on server 	  
+			  - updated [version.pl] to beta5 (gmt5)
+              - adapted to GMT5
 
-	Mar 17, 2016: V1.2beta5
-		- updated [.hg/hgrc]
-		- various plot improvements
-		- updated howto
-		- published
-		- V1.2beta6 [version.pl] [.hg/hgrc]
-		- changed surface-wave stat in [LADCP_w_ocean]
+Mar 17, 2016: - V1.2beta5
+			  - updated [.hg/hgrc]
+			  - various plot improvements
+			  - updated howto
+			  - published
+			  - V1.2beta6 [version.pl] [.hg/hgrc]
+              - changed surface-wave stat in [LADCP_w_ocean]
 
-	Mar 18-29, 2016: V1.2beta6
-		- [LADCP_VKE]:
-			- added -k to supply external eps
-			- re-designed QC checks (slope estimates)
-			- several other minor improvements
-			- [LADCP_wspec]:
-				- added median # of samples to output
-		- [LADCP_w_CTD]:
-			- added support for $ENV{VERB}
-		- [LADCP_w_ocean]
-			- added -r)ms residual filter with 4cm/s default cutoff
-			- fixed a couple of minor bugs (Sv correction had been disabled)
-			- replaced CTD w with CTD acceleration in wprof plots
-	Mar 29, 2016: V1.2beta6
-		- update antsMinLib to 6.6, perl-tools to 1.5 [version.pl]
-		- updated howto
-		- exported [default_paths.pl] from [defaults.pl]
+Mar 18-29, 2016: V1.2beta6
+			  - [LADCP_VKE]:
+				  - added -k to supply external eps
+				  - re-designed QC checks (slope estimates)
+				  - several other minor improvements
+				  - [LADCP_wspec]:
+					  - added median # of samples to output
+			  - [LADCP_w_CTD]:
+				  - added support for $ENV{VERB}
+			  - [LADCP_w_ocean]
+				  - added -r)ms residual filter with 4cm/s default cutoff
+				  - fixed a couple of minor bugs (Sv correction had been disabled)
+                  - replaced CTD w with CTD acceleration in wprof plots
 
+Mar 29, 2016: - V1.2beta6
+			  - update antsMinLib to 6.6, perl-tools to 1.5 [version.pl]
+			  - updated howto
+              - exported [default_paths.pl] from [defaults.pl]
+
+Mar 30, 2016: - V1.2beta7
+			  - updated [version.pl] [.hg/hgrc]
+			  - [LADCP_w_CTD]: added station as optional 3rd header field in
+                               ASCII format
 
-	Mar 30, 2016: V1.2beta7
-		- updated [version.pl] [.hg/hgrc]
- 		- [LADCP_w_CTD]: added station as optional 3rd header field in
-		   				 ASCII format
-	Mar 31, 2016:
-		- improved version %PARAMs in all utilities
-		- [LADCP_VKE]
-			- added averaging of spectra (inc. setting PARAMs)
-			- improved %PARAMs (also in [LADCP_wspec])
-			- fixed slight bug in [LADCP_wspec]
-			- removed code to generate different output names on -d/-u
-			- added -q
+Mar 31, 2016: - improved version %PARAMs in all utilities
+			  - [LADCP_VKE]
+				  - added averaging of spectra (inc. setting PARAMs)
+				  - improved %PARAMs (also in [LADCP_wspec])
+				  - fixed slight bug in [LADCP_wspec]
+				  - removed code to generate different output names on -d/-u
+                  - added -q
 
-	Apr 3, 2016:
-		- reduced low-p0 cutoff from 1e-7 to 5e-8 in [LADCP_VKE]
-		- similarly reduced equatorial band from 5 to 3 degrees
+Apr  3, 2016: - reduced low-p0 cutoff from 1e-7 to 5e-8 in [LADCP_VKE]
+              - similarly reduced equatorial band from 5 to 3 degrees
 
-	Apr  6, 2016:
-		- fixed GMT-5 related bug in [LADCP_w_ocean]
-		- increased calibration constant by 20% in [LADCP_VKE]
-		- updated howto
-		- published V1.2beta7
-
-	Apr 14, 2016: V1.2beta8
-		- [LADCP_w_postproc] improved warning messages
+Apr  6, 2016: - fixed GMT-5 related bug in [LADCP_w_ocean]
+			  - increased calibration constant by 20% in [LADCP_VKE]
+			  - updated howto
+              - published V1.2beta7
 
-	Apr 16, 2016:
-		- [LADCP_VKE] allow for nans in LADCP_wspec output
-		- updated [version.pl]
+Apr 14, 2016: - V1.2beta8
+			  - [LADCP_w_postproc] improved warning messages
 
-	May 12, 2016:
-		- updated version to 1.2
-		- updated HowTo
-		- published
+Apr 16, 2016: - [LADCP_VKE] allow for nans in LADCP_wspec output
+              - updated [version.pl]
+
+May 12, 2016: - updated version to 1.2
+			  - updated HowTo
+              - published
 
 ----------------------------------------------------------------------		
-Adding Corrections For Beam-Pointing Errors
+V1.3:
+	- Adding Corrections For Beam-Pointing Errors
 ----------------------------------------------------------------------
 
-V1.3:
-	May 12, 2016:
-		- updated [version.pl]
-		- [LADCP_w_ocean] added fields to wsamp output
+May 12, 2016: - updated [version.pl]
+			  - [LADCP_w_ocean] added fields to wsamp output
+
+May 17, 2015:
+May 18, 2015: - [LADCP_w_ocean] added fields to wsamp output
+			  - modified _wprof fig (mean instead of rms tilts)
+			  - minor mods elsewhere (e.g. version info in all plots)
+			  - added new plots [defaults.pl] requiring mods to [LADCP_w_ocean]:
+				  - [plot_acceleration_residuals.pl]
+				  - [plot_attitude_biases_w.pl]
+				  - [plot_attitude_residuals.pl]
+				  - [plot_residual_profs.pl]
+			  - removed assumption of 1500m/s ADCP soundspeed setting (various files)
+              - added correct w12, w34 for earth velocity data
+
+May 19, 2016: - updated to ADCP_tools V1.6 (coord trans interface change)
 
-	May 17-18, 2015:
-		- [LADCP_w_ocean] added fields to wsamp output
-		- modified _wprof fig (mean instead of rms tilts)
-		- minor mods elsewhere (e.g. version info in all plots)
-		- added new plots [defaults.pl] requiring mods to [LADCP_w_ocean]:
-			- [plot_acceleration_residuals.pl]
-			- [plot_attitude_biases_w.pl]
-			- [plot_attitude_residuals.pl]
-			- [plot_residual_profs.pl]
-		- removed assumption of 1500m/s ADCP soundspeed setting (various files)
-		- added correct w12, w34 for earth velocity data
+May 24: 2016: - implemented bin-depth caching
+			  - improved LADCP_w_postproc plot
+              - improved various plots (esp. for partial-depth casts)
+
+May 25, 2016: - updated version to V1.3beta1 [version.pl] [.hg/hgrc]
+		  	  - published
 
-	May 19, 2016:
-		- updated to ADCP_tools V1.6 (coord trans interface change)
+May 26, 2016: - V1.3beta2
+			  - updated version to V1.3beta2 [version.pl] [.hg/hgrc]
+			  - udated ANTS_tools lib to V1.7 (beam interpolation)
+			  - adapted [LADCP_w_ocean] to beam interpolation
+			  - minor improvement to [LADCP_w_postproc]
+              - improved [plot_wprof.pl]
 
-	May 24: 2016:
-		- implemented bin-depth caching
-		- improved LADCP_w_postproc plot
-		- improved various plots (esp. for partial-depth casts)
+Jun  1, 2016: - improvements to [LADCP_w_ocean]
+			  - added [default_output.pl]
+              - added [plot_residuals12.pl] [plot_residuals34.pl]
+
+Jun  2, 2016: - minor improvement and bug fix in [LADCP_w_ocean]
 
-	May 25, 2016:
-		- updated version to V1.3beta1 [version.pl] [.hg/hgrc]
-		- published
+Jun  3, 2016: - minor bug fix in [LADCP_w_ocean]
+
+Jun  6, 2016: - minor improvement in [LADCP_w_ocean] [defaults.pl] [edit_data.pl]
+
+Jun  8, 2016: - removed plot_attitude_biases_w.pl
+              - slight improvement to [plot_attitude_residuals.pl]
+
+Jun 11, 2016: - began debugging w12 & w34 for Earth-coord data [LADCP_w_ocean]
 
-	May 26, 2016: V1.3beta2
-		- updated version to V1.3beta2 [version.pl] [.hg/hgrc]
-		- udated ANTS_tools lib to V1.7 (beam interpolation)
-		- adapted [LADCP_w_ocean] to beam interpolation
-		- minor improvement to [LADCP_w_postproc]
-		- improved [plot_wprof.pl]
+Jul  7, 2016: - major BUG in [LADCP_w_ocean] (beam-pair velocities for Earth
+				  coord data)
 
-	Jun  1, 2016
-		- improvements to [LADCP_w_ocean]
-		- added [default_output.pl]
-		- added [plot_residuals12.pl] [plot_residuals34.pl]
+Jul 12, 2016: - docu in [defaults.pl] 	  
+
+Jul 29, 2016: - minor plotting bug in [LADCP_w_CTD]
+
+Jul 31, 2016: - minor bug in [LADCP_w_ocean] [defaults.pl]		  
 
-	Jun  2, 2016:
-		- minor improvement and bug fix in [LADCP_w_ocean]
+Aug  5, 2016: - committed version found on whoosher after repair
+			  - manually uploaded from ECOGIG cruise laptop:
+				  - [LADCP_w_ocean]   changes since Jun 11, 2016
+				  - [defaults.pl]	  changes since Jun  2, 2016
+				  - [LADCP_w_CTD]	  changes since May 26, 2016
+			  - updated [version.pl] to require ANTSlib V6.7
+              - updated HISTORY
 
-	Jun  3, 2016:
-		- minor bug fix in [LADCP_w_ocean]
+Aug 16, 2016: - [LADCP_VKE] increased -l default 1.2e-7 based on UK2.5 SR1
+				  repeat section
 
-	Jun  6, 2016:
-		- minor improvement in [LADCP_w_ocean] [defaults.pl] [edit_data.pl]
+Dec 22, 2016: - [LADCP_w_ocean] moved $opt_p to [defaults.pl] 				  
+
+Dec 23, 2016: - [LADCP_w_ocean] minor bug
 
-	Jun  8, 2016:
-		- removed plot_attitude_biases_w.pl
-		- slight improvement to [plot_attitude_residuals.pl]
+Sep  1, 2016: - [LADCP_VKE] changed -l to mean epsilon, and increased value to 1e-10
 
-	Jun 11, 2016:
-		- began debugging w12 & w34 for Earth-coord data [LADCP_w_ocean]
+Mar  6, 2017: - [LADCP_w_ocean] minor bug
+              - [time_lag.pl] minor bug
+
+Mar  7, 2017: - added time lines to [plot_time_lags.pl]
 
-	Jul  7, 2016:
-		- major BUG in [LADCP_w_ocean] (beam-pair velocities for Earth
-		  coord data)
+Mar  9, 2017: - tightened timelag editing condition in [time_lag.pl]
+              - updated [HISTORY]
+
+Mar 12, 2017: - adapted to antslib V6.8 [version.pl]
+			  - adapted ADCP_tools to V1.9
+			  - increased -o default from 20 to 40m
+              - updated to V1.3
 
-	Jul 12, 2016:
-		- docu in [defaults.pl]		  
+Mar 15, 2017: - added [loadANTS.pl] for V1.3
+              - updated howto
+
+Mar 16, 2017: - published
 
-	Jul 29, 2016:
-		- minor plotting bug in [LADCP_w_CTD]
+----------------------------------------------------------------------
+V 1.4
+----------------------------------------------------------------------
 
-	Jul 31, 2016:
-		- minor bug in [LADCP_w_ocean] [defaults.pl]		  
+Oct  3, 2017: - added -q option to LADCP_w_CTD for reprocessing as 1Hz files
 
-	Aug  5, 2016:
-		- committed version found on whoosher after repair
-		- manually uploaded from ECOGIG cruise laptop:
-			- [LADCP_w_ocean] 	changes since Jun 11, 2016
-			- [defaults.pl]		changes since Jun  2, 2016
-			- [LADCP_w_CTD]		changes since May 26, 2016
-        - updated [version.pl] to require ANTSlib V6.7
-        - updated HISTORY
+Oct 12, 2017: - re-wrote code in [LADCP_w_ocean] to deal with earth coordinates
+		   	    (MAJOR BUG FIX)
+
+Oct 13, 2017: - bugfix in [edit_data.pl]
+
+Oct 17, 2017: - improvements and bugfix in [LADCP_VKE]
 
-	Aug 16, 2016:
-		- [LADCP_VKE] increased -l default 1.2e-7 based on UK2.5 SR1
-		  			  repeat section
+Nov 26, 2017: - significant bug fixes in [LADCP_w_ocean] related to
+				  - ping-coherent residual removal
+                  - bad beam
+
+Nov 27, 2017: - improved gap heuristics in [time_series.pl]
+              - added @valid_ensmeble_range [defaults.pl]
+
+Nov 28, 2017: - increased version to V1.4 [version.pl] [.hg/hgrc]
+			  - worked on updating howto
+			  - improvements to [LADCP_w_ocean]
+              - removed wcorr plot from [LADCP_w_postproc]
+
+Nov 29, 2017: - replaced opt_i by initial_time_lag in [defaults.pl]
 
-	Dec 22, 2016:
-		- [LADCP_w_ocean] moved $opt_p to [defaults.pl]		  			  
+Dec  9, 2017: - removed common options from [LADCP_w_ocean] [LADCP_w_postproc]
+                [LADCP_wspec] [LADCP_w_CTD] [LADCP_VKE]
 
-	Dec 23, 2016:
-		- [LADCP_w_ocean] minor bug
+Dec 14, 2017: - improvements to [LADCP_wspec]
+
+Dec 17, 2017: - added dependencies to [LADCP_w_ocean] [LADCP_w_CTD]
+
+Mar  8, 2018: - improvements to [LADCP_w_CTD]
 
-	Sep  1, 2016:
-		- [LADCP_VKE] changed -l to mean epsilon, and increased value to
-					  1e-10
+Mar  9, 2018: - improvements to [LADCP_w_CTD]
+
+Mar 20, 2018: - added blue background color for in-ice profiles in [plot_wprof.pl]
+              - fixed acceleration unit error in [plot_wprof.pl]
 
-	Mar  6, 2017:
-		- [LADCP_w_ocean] minor bug
-		- [time_lag.pl] minor bug
+Mar 22, 2018: - adapted howto
+			  - massively improved time-lagging heuristic [time_lag.pl]
+              - improved [plot_time_lags.pl]
+
+Mar 27, 2018: - bugfix to new time lagging heuristic in [time_lag.pl]
 
-	Mar  7, 2017:
-		- added time lines to [plot_time_lags.pl]
+Apr 24, 2018: - improvements to [LADCP_w_ocean] [LADCP_VKE] [defaults.pl]
 
-	Mar  9, 2017:
-		- tightened timelag editing condition in [time_lag.pl]
-		- updated [HISTORY]
+Apr 25, 2018: - improvement to [LADCP_VKE]
+
+May  1, 2018: - added reflr_u filter in [LADCP_w_ocean] [edit_data.pl] [time_series.pl]
+              - added ambiguity velocity check in [LADCP_w_ocean]
 
-	Mar 12, 2017:
-		- adapted to antslib V6.8 [version.pl]
-		- adapted ADCP_tools to V1.9
-		- increased -o default from 20 to 40m
-		- updated to V1.3
+May  2, 2018: - bug fixes in [LADCP_w_ocean], related to
+				  - reflr threshold
+				  - PPI
+              - adapted [defaults.pl] to reflr_u filter
 
-	Mar 15, 2017:
-		- added [loadANTS.pl] for V1.3
-		- updated howto
+May 13, 2018: - fixed bug in [LADCP_wspec]
+
+May 16, 2018: - improvement to [LADCP_wspec]
+
+May 22, 2018: - improvement to [LADCP_w_CTD]
+
+Jul 24, 2018: - improvement to [LADCP_w_CTD]
 
-	Mar 16, 2017:
-		- published
+Sep 13, 2018: - added '.' to library path in [version.pl]
+
+Oct  4, 2018: - improvements to [LADCP_w_CTD]
 
-----------------------------------------------------------------------		
+Oct  5, 2018: - improvements and bugfix in [LADCP_w_CTD]
+
+Oct 31, 2018: - improvements to [LADCP_w_postproc]
 
-	Oct 3, 2017:
-		- added -q option to LADCP_w_CTD for reprocessing as 1Hz files
+Nov  1, 2018: - improvements to [LADCP_w_postproc]
+
+Nov  2, 2018: - 2-beam residuals bug fix in [LADCP_w_ocean]
 
-	Oct 12, 2017:
-		- re-wrote code in [LADCP_w_ocean] to deal with earth coordinates
-		  (MAJOR BUG FIX)
+Nov 17, 2018: - updated [HISTORY]
+			  - updated prerequisites in [version.pl]
+			  - updated [LADCP_w_howto.pdf]
+			  - updated [.hg/hgrc]
+              - published V1.4
 
-	Oct 13, 2017:
-		- bugfix in [edit_data.pl]
-
-	Oct 17, 2017:
-		- improvements and bugfix in [LADCP_VKE]
+----------------------------------------------------------------------
+V2.0
+	- lots of bug fixes 
+	- major new features:
+		- dropped CTD scans handled correctly (no more apparent clock drifts)
+		- support for data files collected with Nortek Signature instruments
+		- much improved data editing 
+	- significant changes:
+		- no minimum limit for eps_VKE
+		- updated for GMT6
+		- much better data quality information in summary plots
+----------------------------------------------------------------------
 
-	Nov 26, 2017:
-		- significant bug fixes in [LADCP_w_ocean] related to
-			- ping-coherent residual removal
-			- bad beam
+Mar 25, 2019: - [LADCP_w_CTD] changed error message to allow creating 1Hz from 4Hz file (SBE19)
+              - [LADCP_w_CTD] BUG: ITS was not set. How is this possible?????
 
-	Nov 27, 2017:
-		- improved gap heuristics in [time_series.pl]
-		- added @valid_ensmeble_range [defaults.pl]
+Apr 12, 2019: - [LADCP_w_ocean] added logfile error message for non-existing file
+
+Apr 18, 2019: - [LADCP_w_ocean] added addtional RDI coordinate transformation %PARAMs
 
-	Nov 28, 2017:
-		- increased version to V1.4 [version.pl] [.hg/hgrc]
-		- worked on updating howto
-		- improvements to [LADCP_w_ocean]
-		- removed wcorr plot from [LADCP_w_postproc]
+Apr 21, 2019: - [LADCP_w_CTD] modified code to allow production of 24Hz files (previous code required
+							  min 2 samples per bin, allowing for max 12Hz sampling rate)
+              - [LADCP_w_ocean] BUG: removed duplicate warning about lacking water-depth info
+
+Aug 27, 2019: - [LADCP_w_CTD] began adding correction for dropped CTD scans
 
-	Nov 29, 2017:
-		- replaced opt_i by initial_time_lag in [defaults.pl]
+Aug 28, 2019: - [LADCP_w_CTD] made it work
+			  - [LADCP_w_CTD] added -g
 
-	Dec  9, 2017:		
-		- removed common options from [LADCP_w_ocean] [LADCP_w_postproc]
-		  [LADCP_wspec] [LADCP_w_CTD] [LADCP_VKE]
+Aug 30, 2019: - [LADCP_w_CTD] renamed -g to -m)odulo error correction (not)
+			  - [LADCP_w_CTD] added -f)ill missing data
+
+Sep 10, 2019: - [LADCP_w_ocean] BUG: -i was erroneously listed as the initial CTD time offset
 
-	Dec 14, 2017:		
-		- improvements to [LADCP_wspec]
-
-	Dec 17, 2017:
-		- added dependencies to [LADCP_w_ocean] [LADCP_w_CTD]
+Sep 12, 2019: - [LADCP_VKE] disabled default -l cut-off (used to be 5e-11 W/kg)
+			  - [LADCP_w_ocean] modified .prof output layout to be consistent with [LADCP_w_postproc]
+	
+Oct 29, 2019: - [plot_*.pl] updated psscale -B to gmt5 syntax
+	
+May 15, 2020: - [LADCP_w_ocean] BUG: re-binning on -r did not work for v12 and v34
+			  - [LADCP_w_ocean] BUG: before re-binning, upcast v12 and v34 were actuall from DC data
+			  - [LADCP_w_ocean] BUG: all beam-pair velocity stats were contaminated by missing values
+			  - [LADCP_w_ocean] made bin residuals per beam pair
+			  - [default_output.pl] removed a couple of time-depth plots from level 1
+			  - [default_output.pl] changed semmantics so that pushing to plot adds,
+									instead of overwwriting
+			  - [default_output.pl] BUG: one of the plots did not repect plotting level
+			  - [plot_mean_residuals.pl] adapted to bin-residuals separate per beam pair
+			  - [plot_mean_residuals.pl] added orange range
+              - [plot_mean_residuals.pl] slightly relaxed green range
 
-	Mar  8, 2018:
-		- improvements to [LADCP_w_CTD]
+May 16, 2020: - [LADCP_w_ocean] BUG: write_residual_profs() clobbered layout
+			  - [plot_wprof.pl] added residual profile data to background
 
-	Mar  9, 2018:
-		- improvements to [LADCP_w_CTD]
+May 23, 2020: - [plot_wprof.pl] BUG: windows without samples made program bomb
 
-	Mar 20, 2018:
-		- added blue background color for in-ice profiles in [plot_wprof.pl]
-		- fixed acceleration unit error in [plot_wprof.pl]
+May 25, 2020: - added [write_residual_profs.pl]
+
+Jun 22, 2020: - [LADCP_w_ocean] sscorr_w renamed to remove conflict with [RDI_Coords.pl]
 
-	Mar 22, 2018:
-		- adapted howto
-		- massively improved time-lagging heuristic [time_lag.pl]
-		- improved [plot_time_lags.pl]
+Jun 26, 2020: - [LADCP_w_CTD] added salinity -b)ias correction
+
+Jun 29, 2020: - [svel_corrections.pl] renamed sscorr_w to remove conflict with RDI_Coords.pl
+
+Mar 17, 2021: - [LADCP_w_ocean] turned multi-ping error into warning (for Nortek files)
 
-	Mar 27, 2018:
-		- bugfix to new time lagging heuristic in [time_lag.pl]
+Mar 23, 3021: - [LADCP_w_ocean] adapted to ADCP_tools V2.4 (Nortek PD0 files)
+			  - [plot_wprof.pl] BUG: instrument frequency was rounded to 100kHz
 
-	Apr 24, 2018:
-		- improvements to [LADCP_w_ocean] [LADCP_VKE] [defaults.pl]
-
-	Apr 25, 2018:
-		- improvement to [LADCP_VKE]
+Apr 29, 2021: - [LADCP_w_CTD] improved warning message
+	
+Jun 29, 2021: - [LADCP_w_CTD] improved plot labelling
 
-	May  1, 2018:
-		- added reflr_u filter in [LADCP_w_ocean] [edit_data.pl] [time_series.pl]
-		- added ambiguity velocity check in [LADCP_w_ocean]
+Jun 30, 2021: - [LADCP_w_CTD] improved plot labelling
+			  - [LADCP_w_ocean]
+					- BUG: rms instead of mean tilt was reported in fig
+			        - added pitch/roll/tilt to output profile
+			  - [default_output.pl] renamed plot_mean_residuals to plot_bin_residuals
+		  	  - [plot_bin_residuals.pl]  renamed from plot_mean_residuals.pl
+			  - [plot_wprof.pl] improved quality semaphore
 
-	May  2, 2018:
-	 	- bug fixes in [LADCP_w_ocean], related to
-	 		- reflr threshold
-	 		- PPI
-	 	- adapted [defaults.pl] to reflr_u filter
+Jul  1, 2021: - [LADCP_w_ocean] made %PARAMs more standard
+			  - [LADCP_w_ocean] added %dc_w.mu, %uc_w.mu
+			  - [plot_bin_residuals.pl] adapted to more standard %PARAMs
+			  - [plot_wprof.pl] replaced bin setup by <w> in legend
+			  - [LADCP_VKE] made %PARAMs more standard
+              - [LADCP_w_postproc] made %PARAMs more standard
+			  - [LADCP_w_postproc] added -z to remove biases
+			  - [LADCP_w_postproc] added %?c_w_diff.rms to output
+			  - [LADCP_w_postproc] BUG: dc_corr returned strange rms
+			  - [acoustic_backscatter.pl] [bottom_tracking.pl]
+			    [find_seabed.pl] [plot_backscatter.pl]
+				[plot_correlation.pl] [plot_residuals12.pl]
+				[plot_residuals34.pl] [plot_wsamp.pl] [time_lag.pl] made %PARAMs more standard
 
-	May 13, 2018:
-		- fixed bug in [LADCP_wspec]
-
-	May 16, 2018:
-		- improvement to [LADCP_wspec]
+Jul  6, 2021: - [LADCP_w_ocean] BUG: %uc_w.mu was off by factor 2
 
-	May 22, 2018:
-		- improvement to [LADCP_w_CTD]
-
-	Jul 24, 2018:
-		- improvement to [LADCP_w_CTD]
-
-	Sep 13, 2018:
-		- added '.' to library path in [version.pl]
-
-	Oct  4, 2018:
-		- improvements to [LADCP_w_CTD]
-
-	Oct  5, 2018:
-		- improvements and bugfix in [LADCP_w_CTD]
+Jul  7, 2021: - [plot_wprof.pl] added colored background to <w>
+              - [LADCP_w_postproc] reversed logic of -z (enables bias correction by default)
+			  - [LADCP_w_postproc] BUG: plot had label in wrong location for single-head profiles
 
-	Oct 31, 2018:
-		- improvements to [LADCP_w_postproc]
-
-	Nov  1, 2018:
-		- improvements to [LADCP_w_postproc]
+Jul  9, 2021: - [LADCP_w_ocean] added LR_RMS_BP_RESIDUAL, dc_lr_bp_res.rms, uc_lr_bp_res.rms
+			  - [LADCP_w_ocean] added residuals profile filter
+			  - [defaults.pl] - added $layer_residuals_rms_max
+			  - [plot_wprof.pl] adapted to new residual editing (calculation in LADCP_w_ocean)
+              - [LADCP_w_postproc] added window correlation stats
+			  - [LADCP_w_postproc] updated %PARAM names
+			  - [edit_data.pl] added editHighResidualLayers()
+			  
+Jul 11, 2021: - [LADCP_w_ocean] added %dc_w.var, %uc_w.var
+			  - [LADCP_w_ocean] reduced warning associated with residuals profile filter
+			  - [LADCP_w_ocean] disable time-lag filtering for transmission-error corrected CTD files
+			  
+Jul 13, 2021: - [LADCP_w_ocean] set dc_w.mu, dc_w.var to nan on insufficient data
+			  - [LADCP_w_ocean] BUG: residuals profile filter bombed when no data were removed
+			  - [LADCP_w_ocean] BUG: rms BT discrepancy was broken (residuals profile filter)
+			  - [LADCP_w_ocean] BUG: *_w.var did not respect -k
+			  - [LADCP_w_CTD] improved gaps PARAMs
+			  - [LADCP_w_CTD] added clock/transmission warnings
+              - [LADCP_w_postproc] BUG: dc_sig, dc_rms confusion
+			  
+Jul 23, 2021: - [LADCP_w_ocean] added %ADCP_type
+			  - [LADCP_VKE] returned to published empirical calibration constant (20% difference is not significant)
+			  - [LADCP_VKE] added calibration constant to output metadata
+			  - [LADCP_VKE] changed opt_a default from nan to 0 (ambient mixing)
+			  - [LADCP_VKE] BUG: -z default was only 1, which means that -k20 from LADCP_w_ocean applies; in
+					 practice I found with A20 that there are the effective value is >60; which means
+					 that this bug did not matter much in practice
+			  - [LADCP_VKE] changed calibration constant back, because it makes sense, and because it is now
+				recorded in the meta-data
+			  - [LADCP_w_postproc] added summary info to plot
+			  - [LADCP_w_postproc] added seabed to plot
+			  - [LADCP_w_postproc] added annotations to plot
 
-	Nov  2, 2018:
-		- 2-beam residuals bug fix in [LADCP_w_ocean]
+Jul 24, 2021: - [HISTORY] updated
+			  - V2.0 released			  
+				
 
-	Nov 17, 2018:
-		- updated [HISTORY]
-		- updated prerequisites in [version.pl]
-		- updated [LADCP_w_howto.pdf]
-		- updated [.hg/hgrc]
 
--- a/LADCP_VKE	Sat Apr 10 06:00:45 2021 -0400
+++ b/LADCP_VKE	Sat Jul 24 10:35:41 2021 -0400
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L A D C P _ V K E 
 #                    doc: Tue Oct 14 11:05:16 2014 
-#                    dlm: Thu Sep 12 13:49:04 2019
+#                    dlm: Sat Jul 24 09:44:26 2021
 #                    (c) 2012 A.M. Thurnherr
-#                    uE-Info: 111 71 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 120 45 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 $antsSummary = 'calculate VKE from LADCP-derived vertical-velocity profiles';
@@ -109,6 +109,16 @@
 #	Apr 24, 2018: - BUG: output was one field too wide (filled with nans) because antsBufNFields was not reset
 #	Apr 25, 2018: - added -y and removed spectral bins from default output
 #	Sep 12, 2019: - disabled default -l cut-off (used to be 5e-11 W/kg)
+#	Jul  1, 2021: - made %PARAMs more standard
+#	Jul 23, 2021: - returned to published empirical calibration constant (20% difference is not significant)
+#				  - added calibration constant to output metadata
+#				  - changed opt_a default from nan to 0 (ambient mixing)
+#				  - BUG: -z default was only 1, which means that -k20 from LADCP_w_ocean applies; in 
+#						 practice I found with A20 that there are the effective value is >60; which means
+#						 that this bug did not matter much in practice
+#				  - changed calibration constant back, because it makes sense, and because it is now
+#				    recorded in the meta-data
+# HISTORY END
 
 ($ANTSLIB) = (`which ANTSlib` =~ m{^(.*)/[^/]*$});
 ($WCALC)   = ($0              =~ m{^(.*)/[^/]*$});
@@ -129,11 +139,11 @@
 #----------------------------------------------------------------------
 
 #my($c) = 0.0215;						# Thurnherr et al. (GRL 2015)
-my($c) = 0.026;							# increased by 20% for V1.2beta7
+my($c) = 0.026;							# increased by 21% for V1.2beta7
 $opt_q = 3;								# Equatorial band: little more than a guess based on 2015 P16N
 $opt_l = 0;								# [W/kg]; cutoff disabled Sep 12, 2019
-$opt_a = nan;							# assume background dissipation for samples that pass the tests but have eps below -l
-$opt_z = 1;								# number of w_ocean samples to require
+$opt_a = 0;								# assume background dissipation for samples that pass the tests but have eps below -l
+$opt_z = 50;							# number of w_ocean samples to require (note that the .wprof inputs may have harsher limits)
 $opt_o = 0;								# remove mean before calculating spectra
 $opt_s = 150;							# surface layer to exclude from spectra
 $opt_g = 40;							# max gap to interpolate over
@@ -196,17 +206,17 @@
 		if ($bufi == 0) {															# do once for mulitple files
 			&antsAddParams('ADCP_bin_length','','ADCP_blanking_distance','',		# delete most %PARAMs, leaving
 						   'ADCP_frequency','','ADCP_orientation','',				# 	only potentially useful ones (from last file):
-						   'ADCP_pulse_length','','BT_max_bin_range_diff','',		#		%profile_id
-						   'BT_max_range','','BT_max_w_error','',					#		%water_depth
-						   'BT_rms_w_discrepancy','','CTD_time_lags','',			#		%lat
+						   'ADCP_pulse_length','','BT_bin_range_diff.max','',		#		%profile_id
+						   'BT_range.max','','BT_w_error.max','',					#		%water_depth
+						   'BT_w_discrepancy.rms','','CTD_time_lags','',			#		%lat
 						   'LADCP_firstBin','','LADCP_lastBin','',					#		%lon
-						   'LADCP_w_ocean::version','','SS_min_samp','',			#		%dnXX
-						   'SS_max_allowed_depth_range','','SS_min_signal','',
-						   'Sv_ref_bin','','TL_max_allowed_three_lag_spread','',
-						   'dc_rms_accel_pkg','','dc_rms_tilt','',
-						   'uc_rms_accel_pkg','','uc_rms_tilt','',
-						   'max_depth','','max_elapsed','','max_ens','',
-						   'min_depth','','min_elapsed','','min_ens','',
+						   'LADCP_w_ocean::version','','SS_samp.min','',			#		%dnXX
+						   'SS_allowed_depth_range.max','','SS_signal.min','',
+						   'Sv_ref_bin','','TL_allowed_three_lag_spread.max','',
+						   'dc_pkg_accel.rms','','dc_tilt.rms','',
+						   'uc_pkg_accel.rms','','uc_tilt.rms','',
+						   'depth.max','','elapsed.max','','ens.max','',
+						   'depth.min','','elapsed.min','','ens.min','',
 						   'out_basename','','outgrid_dz','','run_label','',
 						   'outgrid_firstbin','','outgrid_lastbin','',
 						   'outgrid_minsamp','','per_bin_valid_frac_lim','',
@@ -214,7 +224,7 @@
 						   'refLr_lastBin','','rms_w_reflr_err','',
 						   'rms_w_reflr_err_interior','',
 						   'sidelobe_editing','','surface_layer_depth','',
-						   'vessel_draft','','w_max_lim','',
+						   'vessel_draft','','w_lim.max','',
 						   'water_depth.sig','','water_depth_from','',
 			);
 		}
@@ -267,12 +277,13 @@
 
 $n_input_files = 1 + @specbuf;									# number of input files provided
 
+&antsFloatOpt(\$opt_e,$c);										# default parameterization
+&antsFloatOpt(\$opt_x,1);										# spectral fit stddev scale factor
+
 &antsAddParams('LADCP_VKE::input_files.n',$n_input_files,
 			   'LADCP_VKE::wsamp.min',$opt_z,
-			   'LADCP_VKE::eps.minlim',$opt_l);
-
-&antsFloatOpt(\$opt_e,$c);										# default parameterization
-&antsFloatOpt(\$opt_x,1);										# spectral fit stddev scale factor
+			   'LADCP_VKE::eps.minlim',$opt_l,
+			   'LADCP_VKE::calibration_constant',$opt_e);
 
 if (defined($opt_c)) {											# shortwave cutoff supplied
 	$lmin = ($opt_c < 1) ? 2*$PI/$opt_c : $opt_c;
@@ -363,15 +374,14 @@
 		for (my($bi)=0; $bi<@specbuf; $bi++) {									# loop over all buffered files
 			next unless @{$specbuf[$bi][$wi]};									# skip input files w/o valid spectra
 			if (abs($specbuf[$bi][$wi][$df] - $ants_[$r][$df]) > 0) {			# depth mismatch
-				die("assertion failed") unless ($wi == 0);						# only allowed in bottom window
+#				die("assertion failed ($specbuf[$bi][$wi][$df] - $ants_[$r][$df] @ wi=$wi)") unless ($wi == 0);						# only allowed in bottom window
 				if (abs($specbuf[$bi][$wi][$df] - $ants_[$r][$df]) >
 					abs($ants_[$r][$maxdf] - $ants_[$r][$mindf])) {
-						printf(STDERR "WARNING: ignoring bottom window from input file #%d because of depth mismatch\n",$bi+1)
+						printf(STDERR "WARNING: ignoring window #$wi from input file #%d because of depth mismatch\n",$bi+1)
 							if ($f == $fs_fmin);
 						next;
 				}
 			}
-#			print(STDERR "specbuf[$bi][$wi][$f] = $specbuf[$bi][$wi][$f]\n");
 			if (numberp($specbuf[$bi][$wi][$f])) {
 				$sum += $specbuf[$bi][$wi][$f]; $ns++;
             }
@@ -562,7 +572,7 @@
 	}
 
 	#-----------------------------------------------------------------------------------------------------
-	# QC Tests:
+	# eps.VKE QC Tests:
 	#	- the following limits were independently derived 
 	#		p0fit.rms <= 0.4			primary filter used in Thurnherr et al. (GRL 2015)
 	#		-3 <= p0fit.slope <= -1		based largely on 2016 I08S data with sufficient/insufficient range
--- a/LADCP_w_CTD	Sat Apr 10 06:00:45 2021 -0400
+++ b/LADCP_w_CTD	Sat Jul 24 10:35:41 2021 -0400
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L A D C P _ W _ C T D 
 #                    doc: Mon Nov  3 17:34:19 2014
-#                    dlm: Fri Jun 26 13:07:13 2020
+#                    dlm: Tue Jul 13 11:33:11 2021
 #                    (c) 2014 A.M. Thurnherr
-#                    uE-Info: 144 14 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 226 118 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 $antsSummary = 'pre-process SBE 9plus CTD data for LADCP_w';
@@ -93,11 +93,20 @@
 #	Aug 30, 2019: - renamed -g to -m)odulo error correction (not)
 #				  - added -f)ill missing data
 #	Jun 26, 2020: - added salinity -b)ias correction
+#	Apr 29, 2021: - improved warning message
+#	Jun 29, 2021: - improved plot labelling
+#	Jun 30, 2021: - ditto
+#	Jul 13, 2021: - improved gaps PARAMs
+#				  - added clock/transmission warnings
+# HISTORY END
 
 # NOTES:
 #	w_CTD is positive during the downcast to make the sign of the apparent
 #		  water velocity consistent with w_ocean
 
+# TODO:
+#	- add transmission warnings to figure?
+
 ($ANTS)  = (`which ANTSlib`   =~ m{^(.*)/[^/]*$});
 ($WCALC) = ($0                =~ m{^(.*)/[^/]*$});
 $WCALC   = '.' if ($WCALC eq '');
@@ -214,7 +223,7 @@
 			$fill_gaps = 1;
 		} else {
 			print(STDERR "\n\n") if ($opt_v > 1);
-			print(STDERR "WARNING: timeY and/or modError missing from $CNVfile -- cannot correct for CTD modulo errors\n");
+			print(STDERR "WARNING: timeY and/or modError missing from $CNVfile -- cannot correct for CTD transmission errors\n");
 	    }
 	}
 	
@@ -268,13 +277,14 @@
 	my($scans_filled) = 0;
 	my($scans_replaced) = 0;
 	my($scans_deleted) = 0;
+	my($tot_gaps) = 0;
 
 	for (my($scan)=30; $scan<@ants_; $scan++) {										# start a bit more than 1 second into the cast
 		next if ($ants_[$scan][$systimeF] == $ants_[$scan-1][$systimeF]);			# skip forward to next systime second
 
 		if ($ants_[$scan][$systimeF] > $ants_[$scan-1][$systimeF]+1) {				# gap spans at least one full second
 			print(STDERR "\n\n") if ($opt_v > 1);
-			printf(STDERR "WARNING: %d full seconds of data missing at elapsed %d s\n",
+			printf(STDERR "WARNING: $CNVfile: %d full seconds of data missing at elapsed %d s\n",
 				$ants_[$scan][$systimeF]-$ants_[$scan-1][$systimeF]-1,
 				$ants_[$scan-1][$systimeF]-$ants_[0][$systimeF]);
 			my(@splicescan);														# scan to splice in 
@@ -306,6 +316,7 @@
 		for (my($s)=$second_start; $s<=$scan; $s++) {
 			$ngaps++ if ($ants_[$s][$xmerrF] > $ants_[$s-1][$xmerrF]);
 		}
+		$tot_gaps += $ngaps;
 
 		my(@splicescan);															# scan to splice in 
 		$splicescan[$systimeF] = $ants_[$second_start][$systimeF];
@@ -364,17 +375,29 @@
 #		$sts = 1;
 #	}
 
-	&antsAddParams('gaps_scans_filled',$scans_filled,
-				   'scans_removed',$scans_deleted,
-				   'gap_scans_cleared',$scans_replaced);
+	&antsAddParams('CTD_transmission_errors',$tot_gaps,
+				   'CTD_scans_added',$scans_filled,
+				   'CTD_scans_deleted',$scans_deleted,
+				   'CTD_gap_scans_cleared',$scans_replaced);
 
 	if ($opt_v>1 && $scans_filled) {
-		printf(STDERR "\n\t%d scans removed (clock drift)",$scans_deleted);
-		printf(STDERR "\n\t%d scans added (gaps & clock drift)",$scans_filled);
+		printf(STDERR "\n\t%d scans removed (clock jitter/drift)",$scans_deleted);
+		printf(STDERR "\n\t%d scans added (gaps & clock jitter/drift)",$scans_filled);
 		printf(STDERR "\n\t%d scans cleared (gap clusters)",$scans_replaced);
 	}
 	printf(STDERR "\n") if ($opt_v);
-} # if ($fill_gaps
+
+	if ($tot_gaps) {
+		printf(STDERR "WARNING: $CNVfile: %d transmission errors\n",$tot_gaps);
+		printf(STDERR "WARNING: $CNVfile: CTD clock drift (%d scans removed)\n",$scans_deleted-$scans_filled)
+			if ($scans_deleted-$scans_filled > 2);
+	} else {
+		printf(STDERR "WARNING: $CNVfile: CTD clock drift (%d scans removed)\n",$scans_deleted-$scans_filled)
+			if ($scans_deleted-$scans_filled > 2);
+		printf(STDERR "WARNING: $CNVfile: CTD clock drift (%d scans added)\n",$scans_filled-$scans_deleted)
+			if ($scans_filled-$scans_deleted > 2);
+	}
+} # if ($fill_gaps)
 
 #----------------------------------------------------------------------
 # Redirect STDOUT to %.6Hz & create %_w_CTD.ps,%_sspd.ps if STDOUT is a tty
@@ -906,12 +929,13 @@
     }
 	GMT_psbasemap('-Bg60a30f5:"Elapsed Time [min]":/g1a1f0.1:"Downward Package Velocity [ms@+-1@+]":WeSn');
 	GMT_unitcoords();
-	GMT_pstext('-F+f14,Helvetica,coral+jBR'); 	 print(GMT "0.98 0.96 dc\n");
-	GMT_pstext('-F+f14,Helvetica,SeaGreen+jBR'); print(GMT "0.98 0.93 uc\n");
-	GMT_pstext('-F+f14,Helvetica,magenta+jBR');  print(GMT "0.98 0.89 winch\n");
+	GMT_pstext('-F+f14,Helvetica,coral+jBR -Gwhite'); 	 print(GMT "0.98 0.96 downcast\n");
+	GMT_pstext('-F+f14,Helvetica,SeaGreen+jBR -Gwhite'); print(GMT "0.98 0.92 upcast\n");
+	GMT_pstext('-F+f14,Helvetica,magenta+jBR -Gwhite');  print(GMT "0.98 0.88 winch\n");
 	GMT_pstext('-F+f14,Helvetica,blue+jTL -N');
 	if (defined($outfile)) { printf(GMT "0.01 1.06 $outfile\n",$id); }
 	else 				   { printf(GMT "0.01 1.06 %03d\n",$id); }
+	GMT_pstext('-F+f9,Helvetica,orange+jBL -N -Gwhite'); print(GMT "0.01 0.01 V$VERSION\n");
 	GMT_end();	                
 
 	my($xmin) = round($min_sspd-3,5);
@@ -928,11 +952,12 @@
 		GMT_psxy('-W1.5,SeaGreen') if ($r == $atBtm);
 	}
 	GMT_unitcoords();
-	GMT_pstext('-F+f14,Helvetica,coral+jTR'); 	 print(GMT "0.98 0.02 dc\n");
-	GMT_pstext('-F+f14,Helvetica,SeaGreen+jTR'); print(GMT "0.98 0.06 uc\n");
+	GMT_pstext('-F+f14,Helvetica,coral+jTR -Gwhite'); 	 print(GMT "0.98 0.02 downcast\n");
+	GMT_pstext('-F+f14,Helvetica,SeaGreen+jTR -Gwhite'); print(GMT "0.98 0.06 upcast\n");
 	GMT_pstext('-F+f14,Helvetica,blue+jTL -N');
 	if (defined($outfile)) { printf(GMT "0.01 -0.06 $outfile\n",$id); }
 	else 				   { printf(GMT "0.01 -0.06 %03d\n",$id); }
+	GMT_pstext('-F+f9,Helvetica,orange+jBL -N -Gwhite'); print(GMT "0.01 0.99 V$VERSION\n");
 	GMT_end();	                
 }
 
Binary file LADCP_w_HowTo.pdf has changed
Binary file LADCP_w_howto.pdf has changed
--- a/LADCP_w_ocean	Sat Apr 10 06:00:45 2021 -0400
+++ b/LADCP_w_ocean	Sat Jul 24 10:35:41 2021 -0400
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L A D C P _ W _ O C E A N 
 #                    doc: Fri Dec 17 18:11:13 2010
-#                    dlm: Tue Mar 23 09:16:10 2021
+#                    dlm: Fri Jul 23 08:50:23 2021
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 308 65 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 323 36 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # TODO:
@@ -306,6 +306,21 @@
 #	Jun 22, 2020: - sscorr_w renamed to remove conflict with [RDI_Coords.pl]
 #	Mar 17, 2021: - turned multi-ping error into warning (for Nortek files)
 #	Mar 23, 3021: - adapted to ADCP_tools V2.4 (Nortek PD0 files)
+#	Jun 30, 2021: - BUG: rms instead of mean tilt was reported in fig
+#				  - added pitch/roll/tilt to output profile
+#	Jul  1, 2021: - made %PARAMs more standard
+#				  - added %dc_w.mu, %uc_w.mu
+#	Jul  6, 2021: - BUG: %uc_w.mu was off by factor 2
+#	Jul  9, 2021: - added LR_RMS_BP_RESIDUAL, dc_lr_bp_res.rms, uc_lr_bp_res.rms
+#				  - added residuals profile filter
+#	Jul 11, 2021: - added %dc_w.var, %uc_w.var
+#				  - reduced warning associated with residuals profile filter
+#				  - disable time-lag filtering for transmission-error corrected CTD files
+#	Jul 13, 2021: - set dc_w.mu, dc_w.var to nan on insufficient data
+#				  - BUG: residuals profile filter bombed when no data were removed
+#				  - BUG: rms BT discrepancy was broken (residuals profile filter)
+#				  - BUG: *_w.var did not respect -k
+#	Jul 23, 2021: - added %ADCP_type
 # HISTORY END
 
 # CTD REQUIREMENTS
@@ -316,6 +331,14 @@
 #	- w_winch		OPTIONAL; winch-speed estimate
 #	- temp			OPTIONAL; used for backscatter calculation
 #	- %lat/%lon		OPTIONAL
+#	- %CTD_transmission_errors	OPTIONAL; if defined, -l is implicitly enabled
+
+# OUTPUT PITCH
+#	- gimbal pitch is used
+
+# OUTPUT EQUIVALENCES:
+#	1) list -Q %uc_w.var UL/042.wprof
+#	   list dc_w='$dc_w-%dc_w.mu' UL/042.wprof | avg -Qm dc_w
 
 # 2-BEAM SOLUTIONS
 #	- both for beam- and earth-coordinate data, two separate two-beam
@@ -422,7 +445,7 @@
 if ($opt_V) {
 	printf(STDERR "+------------------------------+\n");
 	printf(STDERR "| LADCP_w Software V%s        |\n",$VERSION);
-	printf(STDERR "| (c) 2015-2017 A.M. Thurnherr |\n");
+	printf(STDERR "| (c) 2015-2021 A.M. Thurnherr |\n");
 	printf(STDERR "+------------------------------+\n");
 	exit(0);
 }
@@ -649,6 +672,7 @@
 
 &antsAddParams('ADCP_bin_length',$LADCP{BIN_LENGTH},
 			   'ADCP_pulse_length',$LADCP{TRANSMITTED_PULSE_LENGTH},
+			   'ADCP_type',$LADCP{INSTRUMENT_TYPE},
 			   'ADCP_frequency',$LADCP{BEAM_FREQUENCY},
 			   'ADCP_blanking_distance',$LADCP{BLANKING_DISTANCE});
 
@@ -931,13 +955,13 @@
 my($dc_sumTilts,$dc_n,$uc_sumTilts,$uc_n) = (0,0,0,0);
 $fprm = $pte = 0;
 for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
-	my($ne) = editTilt($ens,$opt_t);
+	my($ne) = editTilt($ens,$opt_t);									# this sets the TILT field
 	if ($ne == 0) {
 		if ($ens <= $LADCP_atbottom) {
-			$dc_sumTilts += &SQR($LADCP{ENSEMBLE}[$ens]->{TILT});
+			$dc_sumTilts += $LADCP{ENSEMBLE}[$ens]->{TILT};
 			$dc_n++;
         } else {
-			$uc_sumTilts += &SQR($LADCP{ENSEMBLE}[$ens]->{TILT});
+			$uc_sumTilts += $LADCP{ENSEMBLE}[$ens]->{TILT};
 			$uc_n++;
         }
     } else {
@@ -945,9 +969,9 @@
     }
 	$fprm += editFarBins($ens,$first_bad_bin) if defined($first_bad_bin);
 }
-my($dc_mean_tilt) = ($dc_n > 0) ? sqrt($dc_sumTilts/$dc_n) : nan;
-my($uc_mean_tilt) = ($uc_n > 0) ? sqrt($uc_sumTilts/$uc_n) : nan;
-&antsAddParams('dc_mean_tilt',$dc_mean_tilt,'uc_mean_tilt',$uc_mean_tilt);
+my($dc_mean_tilt) = ($dc_n > 0) ? $dc_sumTilts/$dc_n : nan;
+my($uc_mean_tilt) = ($uc_n > 0) ? $uc_sumTilts/$uc_n : nan;
+&antsAddParams('dc_tilt.mu',$dc_mean_tilt,'uc_tilt.mu',$uc_mean_tilt);
 
 progress("\tattitude threshold (max_tilt = %d deg): %d velocites removed (%d%% of total)\n",
 	$opt_t,$pte,round(100*$pte/$nvv));
@@ -963,6 +987,9 @@
 error("$CTD_file: no data\n") unless (&antsIn());
 undef($antsOldHeaders);
 
+$opt_l = 1																	# disable time-lag filtering
+	if defined($P{CTD_transmission_errors});								# for transmission-corrected CTD files
+
 &antsAddDeps($CTD_file);
 &antsAddParams('lat',$P{lat}) if defined($P{lat});
 &antsAddParams('lon',$P{lon}) if defined($P{lon});
@@ -1138,7 +1165,7 @@
 
 progress("Merging CTD with LADCP data...\n");
 
-&antsAddParams('w_max_lim',$w_max_lim);
+&antsAddParams('w_lim.max',$w_max_lim);
 
 my($cli) = 0;																	# current-lag index
 my($lag) = $CTD_time_lag[$cli];													# current lag
@@ -1213,7 +1240,7 @@
 
 my($dc_rms_apkg) = ($dc_n > 0) ? sqrt($dc_sumsq / $dc_n) : nan;			# rms package acceleration
 my($uc_rms_apkg) = ($uc_n > 0) ? sqrt($uc_sumsq / $uc_n) : nan;
-&antsAddParams('dc_rms_accel_pkg',$dc_rms_apkg,'uc_rms_accel_pkg',$uc_rms_apkg);
+&antsAddParams('dc_accel_pkg.rms',$dc_rms_apkg,'uc_accel_pkg.rms',$uc_rms_apkg);
 	
 if ($nWsq > 0 && $nWsqI > 0) {
 	&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',sqrt($sumWsqI/$nWsqI));
@@ -1582,6 +1609,7 @@
 			if defined($LADCP{ENSEMBLE}[$ens]->{V34}[$bin]);
 		push(@{$DNCAST{PITCH}[$bi]},$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH});
 		push(@{$DNCAST{ROLL}[$bi]},$LADCP{ENSEMBLE}[$ens]->{ROLL});
+		push(@{$DNCAST{TILT}[$bi]},$LADCP{ENSEMBLE}[$ens]->{TILT});
 	}
 }
 
@@ -1595,6 +1623,7 @@
 	$DNCAST{MEDIAN_V34}[$bi]  	= median(@{$DNCAST{V34}[$bi]});
 	$DNCAST{MEAN_PITCH}[$bi]  	= avg(@{$DNCAST{PITCH}[$bi]});
 	$DNCAST{MEAN_ROLL}[$bi]  	= avg(@{$DNCAST{ROLL}[$bi]});
+	$DNCAST{MEAN_TILT}[$bi]  	= avg(@{$DNCAST{TILT}[$bi]});
 	$DNCAST{MAD_W}[$bi]		  	= mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]});
 	$DNCAST{N_SAMP}[$bi]		= @{$DNCAST{W}[$bi]};
 }
@@ -1651,6 +1680,7 @@
 			if defined($LADCP{ENSEMBLE}[$ens]->{V34}[$bin]);
 		push(@{$UPCAST{PITCH}[$bi]},$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH});
 		push(@{$UPCAST{ROLL}[$bi]},$LADCP{ENSEMBLE}[$ens]->{ROLL});
+		push(@{$UPCAST{TILT}[$bi]},$LADCP{ENSEMBLE}[$ens]->{TILT});
 	}
 }
 
@@ -1664,6 +1694,7 @@
 	$UPCAST{MEDIAN_V34}[$bi]  	= median(@{$UPCAST{V34}[$bi]});
 	$UPCAST{MEAN_PITCH}[$bi]  	= avg(@{$UPCAST{PITCH}[$bi]});
 	$UPCAST{MEAN_ROLL}[$bi]  	= avg(@{$UPCAST{ROLL}[$bi]});
+	$UPCAST{MEAN_TILT}[$bi]  	= avg(@{$UPCAST{TILT}[$bi]});
 	$UPCAST{MAD_W}[$bi]		  	= mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]});
 	$UPCAST{N_SAMP}[$bi]		= @{$UPCAST{W}[$bi]};
 }
@@ -1802,6 +1833,7 @@
 				if defined($LADCP{ENSEMBLE}[$ens]->{V34}[$bin]);
 			push(@{$DNCAST{PITCH}[$bi]},$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH});
 			push(@{$DNCAST{ROLL}[$bi]},$LADCP{ENSEMBLE}[$ens]->{ROLL});
+			push(@{$DNCAST{TILT}[$bi]},$LADCP{ENSEMBLE}[$ens]->{TILT});
 		}
 	}
 	for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) {							# bin data into profile
@@ -1814,6 +1846,7 @@
 		$DNCAST{MEDIAN_V34}[$bi]  	= median(@{$DNCAST{V34}[$bi]});
 		$DNCAST{MEAN_PITCH}[$bi]  	= avg(@{$DNCAST{PITCH}[$bi]});
 		$DNCAST{MEAN_ROLL}[$bi]  	= avg(@{$DNCAST{ROLL}[$bi]});
+		$DNCAST{MEAN_TILT}[$bi]  	= avg(@{$DNCAST{TILT}[$bi]});
 		$DNCAST{MAD_W}[$bi] 		= mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]});
 		$DNCAST{N_SAMP}[$bi]		= @{$DNCAST{W}[$bi]};
 	}
@@ -1840,7 +1873,8 @@
 			push(@{$UPCAST{V34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{V34}[$bin])
 				if defined($LADCP{ENSEMBLE}[$ens]->{V34}[$bin]);
 			push(@{$UPCAST{PITCH}[$bi]},$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH});
-			push(@{$UPCAST{ROLL}[$bi]},$LADCP{ENSEMBLE}[$ens]->{ROLL});
+			push(@{$UPCAST{ROLL}<[$bi]},$LADCP{ENSEMBLE}[$ens]->{ROLL});
+			push(@{$UPCAST{TILT}[$bi]},$LADCP{ENSEMBLE}[$ens]->{TILT});
 		}
 	}
 	for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) {
@@ -1853,6 +1887,7 @@
 		$UPCAST{MEDIAN_V34}[$bi]  	= median(@{$UPCAST{V34}[$bi]});
 		$UPCAST{MEAN_PITCH}[$bi]  	= avg(@{$UPCAST{PITCH}[$bi]});
 		$UPCAST{MEAN_ROLL}[$bi]  	= avg(@{$UPCAST{ROLL}[$bi]});
+		$UPCAST{MEAN_TILT}[$bi]  	= avg(@{$UPCAST{TILT}[$bi]});
 		$UPCAST{MAD_W}[$bi] 		= mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]});
 		$UPCAST{N_SAMP}[$bi]		= @{$UPCAST{W}[$bi]};
 	}
@@ -1860,11 +1895,11 @@
 
 $lastGoodEns = $realLastGoodEns;													# now the ensemble range is final
 
-&antsAddParams('min_depth',$min_depth,'max_depth',$max_depth,						# define plot range limits
-			   'min_ens',$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER},
-			   'max_ens',$LADCP{ENSEMBLE}[$lastGoodEns]->{NUMBER},
-			   'min_elapsed',$LADCP{ENSEMBLE}[$firstGoodEns]->{CTD_ELAPSED},
-			   'max_elapsed',$LADCP{ENSEMBLE}[$lastGoodEns]->{CTD_ELAPSED});
+&antsAddParams('depth.min',$min_depth,'depth.max',$max_depth,						# plot range limits
+			   'ens.min',$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER},
+			   'ens.max',$LADCP{ENSEMBLE}[$lastGoodEns]->{NUMBER},
+			   'elapsed.min',$LADCP{ENSEMBLE}[$firstGoodEns]->{CTD_ELAPSED},
+			   'elapsed.max',$LADCP{ENSEMBLE}[$lastGoodEns]->{CTD_ELAPSED});
 
 #-----------------------------------------------
 # Add residuals to depth-binned profiles (wprof)
@@ -1891,6 +1926,12 @@
 	$DNCAST{MEAN_RESIDUAL34}[$bi] = avg(@{$DNCAST{RESIDUAL34}[$bi]});
 }
 
+for (my($bi)=0; $bi<$#{$DNCAST{ENSEMBLE}}; $bi++) {							# rms beampair residual in 5-bin-thick layers
+	$DNCAST{LR_RMS_BP_RESIDUAL}[$bi] = 
+		rms(@{$DNCAST{MEAN_RESIDUAL12}}[max(0,$bi-2)..min($#{$DNCAST{ENSEMBLE}},$bi+2)],
+		    @{$DNCAST{MEAN_RESIDUAL34}}[max(0,$bi-2)..min($#{$DNCAST{ENSEMBLE}},$bi+2)]);
+}
+
 for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) {
 	next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
 	my(@bindepth) = binDepths($ens);
@@ -1910,159 +1951,217 @@
 	$UPCAST{MEAN_RESIDUAL34}[$bi] = avg(@{$UPCAST{RESIDUAL34}[$bi]});
 }
 
+for (my($bi)=0; $bi<$#{$UPCAST{ENSEMBLE}}; $bi++) {							# rms beampair residual in 5-bin-thick layers
+	$UPCAST{LR_RMS_BP_RESIDUAL}[$bi] = 
+		rms(@{$UPCAST{MEAN_RESIDUAL12}}[max(0,$bi-2)..min($#{$UPCAST{ENSEMBLE}},$bi+2)],
+		    @{$UPCAST{MEAN_RESIDUAL34}}[max(0,$bi-2)..min($#{$UPCAST{ENSEMBLE}},$bi+2)]);
+}
+
 progress("\n");
 
+#-----------------------------------------------
+# Apply high-layer-residuals filter
+#-----------------------------------------------
+
+progress("Applying residuals profile filter...\n");   
+&antsAddParams('layer_residuals_rms.max',$layer_residuals_rms_max);
+progress("\t5-bin rms residuals > $layer_residuals_rms_max: ");
+my($nbrm) = editHighResidualLayers($layer_residuals_rms_max);
+my($nbrmf) = 0;
+$nbrmf = $nbrm / (@{$DNCAST{LR_RMS_BP_RESIDUAL}}+@{$UPCAST{LR_RMS_BP_RESIDUAL}})
+	if ($nbrm > 0);
+progress("$nbrm bins removed  (%d%% of profile)\n",round(100*$nbrmf));
+warning(2,"large fraction (%d%%) of profile exceeds residuals-profile threshold\n",round(100*$nbrmf))
+	if ($nbrmf >= 0.1);		
+
+#------------------------
+# Profile is now final
+#	=> calc <w>, w.var
+#------------------------
+
+my($dcw,$ucw,$nw) = (0,0);															# <w> (vertically averaged)
+for (my($bi)=0; $bi<@{$DNCAST{ENSEMBLE}}; $bi++) {
+	next unless ($DNCAST{N_SAMP}[$bi]>=$opt_k) && numberp($DNCAST{MEDIAN_W}[$bi]);
+	$dcw += $DNCAST{MEDIAN_W}[$bi];
+	$nw++;
+}
+$dcw = $nw ? ($dcw/$nw) : nan;
+$nw = 0;
+for (my($bi)=0; $bi<@{$UPCAST{ENSEMBLE}}; $bi++) {
+	next unless ($UPCAST{N_SAMP}[$bi]>=$opt_k) && numberp($UPCAST{MEDIAN_W}[$bi]);
+	$ucw += $UPCAST{MEDIAN_W}[$bi];
+	$nw++;
+}
+$ucw = $nw ? ($ucw/$nw) : nan;
+
+my($dcss,$ucss,$nw) = (0,0);														# variance(w)
+for (my($bi)=0; $bi<@{$DNCAST{ENSEMBLE}}; $bi++) {
+	next unless ($DNCAST{N_SAMP}[$bi]>=$opt_k) && numberp($DNCAST{MEDIAN_W}[$bi]);
+	$dcss += ($DNCAST{MEDIAN_W}[$bi] - $dcw)**2;
+	$nw++;
+}
+$dcss = ($nw > 1) ? ($dcss/$nw) : nan;
+$nw = 0;
+for (my($bi)=0; $bi<@{$UPCAST{ENSEMBLE}}; $bi++) {
+	next unless ($UPCAST{N_SAMP}[$bi]>=$opt_k) && numberp($UPCAST{MEDIAN_W}[$bi]);
+	$ucss += ($UPCAST{MEDIAN_W}[$bi] - $ucw)**2;
+	$nw++;
+}
+$ucss = ($nw > 1) ? ($ucss/$nw) : nan;
+
+&antsAddParams('dc_w.mu',$dcw,'dc_w.var',$dcss,'uc_w.mu',$ucw,'uc_w.var',$ucss);
+
 #-------------------------------------------------
 # Calculate and Output ADCP-Bin-Averaged Residuals
 #-------------------------------------------------
 
-#if (@out_BR) {
-	progress("Binning vertical-velocity residuals wrt. ADCP bin number...");
+progress("Binning vertical-velocity residuals wrt. ADCP bin number...");
 
-	local(@dc_bres12,@uc_bres12,@dc_bres34,@uc_bres34);
-	for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) {						# DOWNCAST
-		next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
-		my(@bindepth) = binDepths($ens);
-		for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
-			next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
-			push(@{$dc_bres12[$bin]},
-					$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]
-					- $DNCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o])
-						if numberp($DNCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o]);
-			push(@{$dc_bres34[$bin]},
-					$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]
-					- $DNCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o])
-						if numberp($DNCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o]);
-		}
+local(@dc_bres12,@uc_bres12,@dc_bres34,@uc_bres34);
+for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) {						# DOWNCAST
+	next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
+	my(@bindepth) = binDepths($ens);
+	for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
+		next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
+		next unless numberp($DNCAST{MEDIAN_W}[$bindepth[$bin]/$opt_o]);
+		push(@{$dc_bres12[$bin]},
+				$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]
+				- $DNCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o])
+					if numberp($DNCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o]);
+		push(@{$dc_bres34[$bin]},
+				$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]
+				- $DNCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o])
+					if numberp($DNCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o]);
 	}
-	for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) {						# UPCAST 
-		next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
-		my(@bindepth) = binDepths($ens);
-		for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
-			next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
-			push(@{$uc_bres12[$bin]},
-					$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]
-					- $UPCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o])
-						if numberp($UPCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o]);
-			push(@{$uc_bres34[$bin]},
-					$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]
-					- $UPCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o])
-						if numberp($UPCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o]);
-		}
+}
+for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) {						# UPCAST 
+	next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
+	my(@bindepth) = binDepths($ens);
+	for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
+		next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
+		next unless numberp($UPCAST{MEDIAN_W}[$bindepth[$bin]/$opt_o]);
+		push(@{$uc_bres12[$bin]},
+				$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]
+				- $UPCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o])
+					if numberp($UPCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o]);
+		push(@{$uc_bres34[$bin]},
+				$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]
+				- $UPCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o])
+					if numberp($UPCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o]);
 	}
-	local(@dc_avg_bres12,@uc_avg_bres12,@dc_avg_bres12_nsamp,@uc_avg_bres12_nsamp);	# means/stddevs
-	local(@dc_avg_bres34,@uc_avg_bres34,@dc_avg_bres34_nsamp,@uc_avg_bres34_nsamp);	
-	for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {		
-		$dc_bres12_nsamp[$bin] = @{$dc_bres12[$bin]};
-		if ($dc_bres12_nsamp[$bin] > 0) {
-			$dc_avg_bres12[$bin] = avg(@{$dc_bres12[$bin]}); 
-			$dc_sig_bres12[$bin] = stddev2($dc_avg_bres12[$bin],@{$dc_bres12[$bin]});
-		} else {
-			$dc_avg_bres12[$bin] = nan;
-			$dc_sig_bres12[$bin] = nan;
-		}
-		$uc_bres12_nsamp[$bin] = @{$uc_bres12[$bin]};
-		if ($uc_bres12_nsamp[$bin] > 0) {
-			$uc_avg_bres12[$bin] = avg(@{$uc_bres12[$bin]}); 
-			$uc_sig_bres12[$bin] = stddev2($uc_avg_bres12[$bin],@{$uc_bres12[$bin]});
-		} else {
-			$uc_avg_bres12[$bin] = nan;
-			$uc_sig_bres12[$bin] = nan;
-		}
-		$dc_bres34_nsamp[$bin] = @{$dc_bres34[$bin]};
-		if ($dc_bres34_nsamp[$bin] > 0) {
-			$dc_avg_bres34[$bin] = avg(@{$dc_bres34[$bin]}); 
-			$dc_sig_bres34[$bin] = stddev2($dc_avg_bres34[$bin],@{$dc_bres34[$bin]});
-		} else {
-			$dc_avg_bres34[$bin] = nan;
-			$dc_sig_bres34[$bin] = nan;
-		}
-		$uc_bres34_nsamp[$bin] = @{$uc_bres34[$bin]};
-		if ($uc_bres34_nsamp[$bin] > 0) {
-			$uc_avg_bres34[$bin] = avg(@{$uc_bres34[$bin]}); 
-			$uc_sig_bres34[$bin] = stddev2($uc_avg_bres34[$bin],@{$uc_bres34[$bin]});
-		} else {
-			$uc_avg_bres34[$bin] = nan;
-			$uc_sig_bres34[$bin] = nan;
-		}
+}
+local(@dc_avg_bres12,@uc_avg_bres12,@dc_avg_bres12_nsamp,@uc_avg_bres12_nsamp); # means/stddevs
+local(@dc_avg_bres34,@uc_avg_bres34,@dc_avg_bres34_nsamp,@uc_avg_bres34_nsamp); 
+for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {	    
+	$dc_bres12_nsamp[$bin] = @{$dc_bres12[$bin]};
+	if ($dc_bres12_nsamp[$bin] > 0) {
+		$dc_avg_bres12[$bin] = avg(@{$dc_bres12[$bin]}); 
+		$dc_sig_bres12[$bin] = stddev2($dc_avg_bres12[$bin],@{$dc_bres12[$bin]});
+	} else {
+		$dc_avg_bres12[$bin] = nan;
+		$dc_sig_bres12[$bin] = nan;
 	}
+	$uc_bres12_nsamp[$bin] = @{$uc_bres12[$bin]};
+	if ($uc_bres12_nsamp[$bin] > 0) {
+		$uc_avg_bres12[$bin] = avg(@{$uc_bres12[$bin]}); 
+		$uc_sig_bres12[$bin] = stddev2($uc_avg_bres12[$bin],@{$uc_bres12[$bin]});
+	} else {
+		$uc_avg_bres12[$bin] = nan;
+		$uc_sig_bres12[$bin] = nan;
+	}
+	$dc_bres34_nsamp[$bin] = @{$dc_bres34[$bin]};
+	if ($dc_bres34_nsamp[$bin] > 0) {
+		$dc_avg_bres34[$bin] = avg(@{$dc_bres34[$bin]}); 
+		$dc_sig_bres34[$bin] = stddev2($dc_avg_bres34[$bin],@{$dc_bres34[$bin]});
+	} else {
+		$dc_avg_bres34[$bin] = nan;
+		$dc_sig_bres34[$bin] = nan;
+	}
+	$uc_bres34_nsamp[$bin] = @{$uc_bres34[$bin]};
+	if ($uc_bres34_nsamp[$bin] > 0) {
+		$uc_avg_bres34[$bin] = avg(@{$uc_bres34[$bin]}); 
+		$uc_sig_bres34[$bin] = stddev2($uc_avg_bres34[$bin],@{$uc_bres34[$bin]});
+	} else {
+		$uc_avg_bres34[$bin] = nan;
+		$uc_sig_bres34[$bin] = nan;
+	}
+}
 
-	local($uc_bres12_max_nsamp,$dc_bres12_max_nsamp) = (0,0);							# calc rms in block of well sampled bins
-	local($uc_bres34_max_nsamp,$dc_bres34_max_nsamp) = (0,0);
-	for (my($bin)=$LADCP_firstBin; $bin<=$LADCP_lastBin-1; $bin++) {				# SKIP 1ST BIN!!!
-		next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);				# skip bins not included in gridded output
-		$dc_bres12_max_nsamp = $dc_bres12_nsamp[$bin]									# nsamp in best sampled bin
-			if ($dc_bres12_nsamp[$bin] > $dc_bres12_max_nsamp);
-		$uc_bres12_max_nsamp = $uc_bres12_nsamp[$bin]
-			if ($uc_bres12_nsamp[$bin] > $uc_bres12_max_nsamp);
-		$dc_bres34_max_nsamp = $dc_bres34_nsamp[$bin]									# nsamp in best sampled bin
-			if ($dc_bres34_nsamp[$bin] > $dc_bres34_max_nsamp);
-		$uc_bres34_max_nsamp = $uc_bres34_nsamp[$bin]
-			if ($uc_bres34_nsamp[$bin] > $uc_bres34_max_nsamp);
+local($uc_bres12_max_nsamp,$dc_bres12_max_nsamp) = (0,0);							# calc rms in block of well sampled bins
+local($uc_bres34_max_nsamp,$dc_bres34_max_nsamp) = (0,0);
+for (my($bin)=$LADCP_firstBin; $bin<=$LADCP_lastBin-1; $bin++) {				# SKIP 1ST BIN!!!
+	next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);				# skip bins not included in gridded output
+	$dc_bres12_max_nsamp = $dc_bres12_nsamp[$bin]									# nsamp in best sampled bin
+		if ($dc_bres12_nsamp[$bin] > $dc_bres12_max_nsamp);
+	$uc_bres12_max_nsamp = $uc_bres12_nsamp[$bin]
+		if ($uc_bres12_nsamp[$bin] > $uc_bres12_max_nsamp);
+	$dc_bres34_max_nsamp = $dc_bres34_nsamp[$bin]									# nsamp in best sampled bin
+		if ($dc_bres34_nsamp[$bin] > $dc_bres34_max_nsamp);
+	$uc_bres34_max_nsamp = $uc_bres34_nsamp[$bin]
+		if ($uc_bres34_nsamp[$bin] > $uc_bres34_max_nsamp);
+}
+my($dc_sumsq12,$uc_sumsq12,$dc_n12,$uc_n12) = (0,0,0,0);						# calc rms residuals
+my($dc_sumsq34,$uc_sumsq34,$dc_n34,$uc_n34) = (0,0,0,0);
+for (my($bin)=$LADCP_firstBin; $bin<=$LADCP_lastBin-1; $bin++) {				# SKIP 1ST BIN
+	next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);				# skip bins not included in gridded output
+	if ($dc_bres12_nsamp[$bin] >= $dc_bres12_max_nsamp/3) { 					# skip bins with < 1/3 max(nsamp)
+		$dc_sumsq12 += $dc_avg_bres12[$bin]**2;
+		$dc_n12++;
 	}
-	my($dc_sumsq12,$uc_sumsq12,$dc_n12,$uc_n12) = (0,0,0,0);						# calc rms residuals
-	my($dc_sumsq34,$uc_sumsq34,$dc_n34,$uc_n34) = (0,0,0,0);
-	for (my($bin)=$LADCP_firstBin; $bin<=$LADCP_lastBin-1; $bin++) {				# SKIP 1ST BIN
-		next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);				# skip bins not included in gridded output
-		if ($dc_bres12_nsamp[$bin] >= $dc_bres12_max_nsamp/3) {						# skip bins with < 1/3 max(nsamp)
-			$dc_sumsq12 += $dc_avg_bres12[$bin]**2;
-			$dc_n12++;
-		}
-		if ($uc_bres12_nsamp[$bin] >= $uc_bres12_max_nsamp/3) {
-			$uc_sumsq12 += $uc_avg_bres12[$bin]**2;
-			$uc_n12++;
-		}
-		if ($dc_bres34_nsamp[$bin] >= $dc_bres34_max_nsamp/3) {						# skip bins with < 1/3 max(nsamp)
-			$dc_sumsq34 += $dc_avg_bres34[$bin]**2;
-			$dc_n34++;
-		}
-		if ($uc_bres34_nsamp[$bin] >= $uc_bres34_max_nsamp/3) {
-			$uc_sumsq34 += $uc_avg_bres34[$bin]**2;
-			$uc_n34++;
-		}
+	if ($uc_bres12_nsamp[$bin] >= $uc_bres12_max_nsamp/3) {
+		$uc_sumsq12 += $uc_avg_bres12[$bin]**2;
+		$uc_n12++;
+	}
+	if ($dc_bres34_nsamp[$bin] >= $dc_bres34_max_nsamp/3) { 					# skip bins with < 1/3 max(nsamp)
+		$dc_sumsq34 += $dc_avg_bres34[$bin]**2;
+		$dc_n34++;
+	}
+	if ($uc_bres34_nsamp[$bin] >= $uc_bres34_max_nsamp/3) {
+		$uc_sumsq34 += $uc_avg_bres34[$bin]**2;
+		$uc_n34++;
 	}
-	$dc_bres12_rms = ($dc_n12 > 0) ? sqrt($dc_sumsq12/$dc_n12) : nan;
-	$uc_bres12_rms = ($uc_n12 > 0) ? sqrt($uc_sumsq12/$uc_n12) : nan;
-	$dc_bres34_rms = ($dc_n34 > 0) ? sqrt($dc_sumsq34/$dc_n34) : nan;
-	$uc_bres34_rms = ($uc_n34 > 0) ? sqrt($uc_sumsq34/$uc_n34) : nan;
+}
+$dc_bres12_rms = ($dc_n12 > 0) ? sqrt($dc_sumsq12/$dc_n12) : nan;
+$uc_bres12_rms = ($uc_n12 > 0) ? sqrt($uc_sumsq12/$uc_n12) : nan;
+$dc_bres34_rms = ($dc_n34 > 0) ? sqrt($dc_sumsq34/$dc_n34) : nan;
+$uc_bres34_rms = ($uc_n34 > 0) ? sqrt($uc_sumsq34/$uc_n34) : nan;
 
-	&antsAddParams('dc_bin_residuals12.rms',$dc_bres12_rms,
-				   'dc_bin_residuals34.rms',$dc_bres34_rms,
-				   'uc_bin_residuals12.rms',$uc_bres12_rms,
-				   'uc_bin_residuals34.rms',$uc_bres34_rms);
-	
-	progress("\n\twriting binned residuals to ");
+&antsAddParams('dc_bin_residuals12.rms',$dc_bres12_rms,
+			   'dc_bin_residuals34.rms',$dc_bres34_rms,
+			   'uc_bin_residuals12.rms',$uc_bres12_rms,
+			   'uc_bin_residuals34.rms',$uc_bres34_rms);
+
+progress("\n\twriting binned residuals to ");
 
-	my($saveParams) = $antsCurParams;
-	@antsNewLayout = ('bin','dc_residual12','dc_residual12.sig','dc_residual12.nsamp',
-						    'uc_residual12','uc_residual12.sig','uc_residual12.nsamp',
-						    'dc_residual34','dc_residual34.sig','dc_residual34.nsamp',
-						    'uc_residual34','uc_residual34.sig','uc_residual34.nsamp');
-	&antsAddParams('BR_max_bin',max(scalar(@dc_bres12),scalar(@uc_bres12),
-									scalar(@dc_bres34),scalar(@uc_bres34)));
+my($saveParams) = $antsCurParams;
+@antsNewLayout = ('bin','dc_residual12','dc_residual12.sig','dc_residual12.nsamp',
+						'uc_residual12','uc_residual12.sig','uc_residual12.nsamp',
+						'dc_residual34','dc_residual34.sig','dc_residual34.nsamp',
+						'uc_residual34','uc_residual34.sig','uc_residual34.nsamp');
+&antsAddParams('BR_bin.max',max(scalar(@dc_bres12),scalar(@uc_bres12),
+								scalar(@dc_bres34),scalar(@uc_bres34)));
 
-	foreach my $of (@out_BR) {
-	    progress("<$of> ");
-		my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/);						# plot_sub(out_file)
-		if (defined($arg)) {
-			require "$WCALC/${sub}.pl";
-			&{$sub}($arg);
-			next;
-		}
-	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);
-		open(STDOUT,$of) || error("$of: $!\n");
-		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
-		for (my($bin)=0; $bin<max(scalar(@dc_bres12),scalar(@uc_bres12)); $bin++) {
-			&antsOut($bin+1,$dc_avg_bres12[$bin],$dc_sig_bres12[$bin],$dc_bres12_nsamp[$bin],
-							$uc_avg_bres12[$bin],$uc_sig_bres12[$bin],$uc_bres12_nsamp[$bin],
-							$dc_avg_bres34[$bin],$dc_sig_bres34[$bin],$dc_bres34_nsamp[$bin],
-							$uc_avg_bres34[$bin],$uc_sig_bres34[$bin],$uc_bres34_nsamp[$bin]);
-		}
-	    &antsOut('EOF'); open(STDOUT,">&2");
+foreach my $of (@out_BR) {
+	progress("<$of> ");
+	my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/);						# plot_sub(out_file)
+	if (defined($arg)) {
+		require "$WCALC/${sub}.pl";
+		&{$sub}($arg);
+		next;
 	}
-	$antsCurParams = $saveParams;
-	progress("\n");
-#}
+	$of = ">$of" unless ($of =~ /^$|^\s*\|/);
+	open(STDOUT,$of) || error("$of: $!\n");
+	undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
+	for (my($bin)=0; $bin<max(scalar(@dc_bres12),scalar(@uc_bres12)); $bin++) {
+		&antsOut($bin+1,$dc_avg_bres12[$bin],$dc_sig_bres12[$bin],$dc_bres12_nsamp[$bin],
+						$uc_avg_bres12[$bin],$uc_sig_bres12[$bin],$uc_bres12_nsamp[$bin],
+						$dc_avg_bres34[$bin],$dc_sig_bres34[$bin],$dc_bres34_nsamp[$bin],
+						$uc_avg_bres34[$bin],$uc_sig_bres34[$bin],$uc_bres34_nsamp[$bin]);
+	}
+	&antsOut('EOF'); open(STDOUT,">&2");
+}
+$antsCurParams = $saveParams;
+progress("\n");
 
 #--------------------------------------------------
 # Calculate BT-referenced vertical-velocity profile
@@ -2075,14 +2174,14 @@
 
 	my($sumSq) = my($n) = 0;
 	for (my($bi)=0; $bi<=$#{$BT{MEDIAN_W}}; $bi++) {
-		next unless defined($BT{MEDIAN_W}[$bi]);
+		next unless numbersp($BT{MEDIAN_W}[$bi],$DNCAST{MEDIAN_W}[$bi],$UPCAST{MEDIAN_W}[$bi]);
 		next unless ($BT{N_SAMP}[$bi]>=$opt_k && $DNCAST{N_SAMP}[$bi]>=$opt_k && $UPCAST{N_SAMP}[$bi]>=$opt_k);
 		$sumSq += ($BT{MEDIAN_W}[$bi] - $DNCAST{MEDIAN_W}[$bi]/2 - $UPCAST{MEDIAN_W}[$bi]/2)**2;
 		$n++;
 	}
 	if ($n > 0) {
 		my($rms) = round(sqrt($sumSq/$n),0.001);
-		&antsAddParams('BT_rms_w_discrepancy',$rms);
+		&antsAddParams('BT_w_discrepancy.rms',$rms);
 		progress("\t$rms m/s rms vertical-velocity discrepancy\n");
 	}
 }
@@ -2128,6 +2227,7 @@
 		  for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
 			  next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
 			  my($bi) = $bindepth[$bin]/$opt_o;
+			  next unless numberp($DNCAST{MEDIAN_W}[$bi]);
 			  &antsOut(
 				  $LADCP{ENSEMBLE}[$ens]->{NUMBER},$bin+1,
 				  $CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
@@ -2168,6 +2268,7 @@
 		  for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
 			  next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
 			  my($bi) = $bindepth[$bin]/$opt_o;
+			  next unless numberp($UPCAST{MEDIAN_W}[$bi]);
 			  &antsOut(
 				  $LADCP{ENSEMBLE}[$ens]->{NUMBER},$bin+1,
 				  $CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
@@ -2217,8 +2318,12 @@
 	push(@antsNewLayout,'depth','hab',											# consistent with [LADCP_w_postproc]
 						'dc_elapsed','dc_w','dc_w.mad','dc_w.nsamp',
 						'uc_elapsed','uc_w','uc_w.mad','uc_w.nsamp'); 
-	push(@antsNewLayout,'dc_depth','dc_w12','dc_w34','dc_v12','dc_v34',			# additional fields (inconsistent w postproc)
+	push(@antsNewLayout,'dc_lr_bp_res.rms',										# additional fields (inconsistent w postproc)
+						'dc_depth','dc_w12','dc_w34','dc_v12','dc_v34',	
+						'uc_lr_bp_res.rms',
 						'uc_depth','uc_w12','uc_w34','uc_v12','uc_v34',
+						'dc_pitch.mu','dc_roll.mu','dc_tilt.mu',
+						'uc_pitch.mu','uc_roll.mu','uc_tilt.mu',
 	                    'BT_w','BT_w.mad','BT_w.nsamp');
 
 	foreach my $of (@out_profile) {
@@ -2244,12 +2349,16 @@
 					 $UPCAST{MEAN_ELAPSED}[$bi],									# uc data consistent w postproc
 					 $UPCAST{N_SAMP}[$bi]>=$opt_k?$UPCAST{MEDIAN_W}[$bi]:nan,
 					 $UPCAST{MAD_W}[$bi],$UPCAST{N_SAMP}[$bi],
-					 $DNCAST{MEAN_DEPTH}[$bi],										# remaining dc data
+					 $DNCAST{LR_RMS_BP_RESIDUAL}[$bi],								# remaining dc data
+					 $DNCAST{MEAN_DEPTH}[$bi],
 					 $DNCAST{MEDIAN_W12}[$bi],$DNCAST{MEDIAN_W34}[$bi],
 					 $DNCAST{MEDIAN_V12}[$bi],$DNCAST{MEDIAN_V34}[$bi],
-					 $UPCAST{MEAN_DEPTH}[$bi],										# remaining uc data
+					 $UPCAST{LR_RMS_BP_RESIDUAL}[$bi],								# remaining uc data
+					 $UPCAST{MEAN_DEPTH}[$bi],
 					 $UPCAST{MEDIAN_W12}[$bi],$UPCAST{MEDIAN_W34}[$bi],
 					 $UPCAST{MEDIAN_V12}[$bi],$UPCAST{MEDIAN_V34}[$bi],
+					 $DNCAST{MEAN_PITCH}[$bi],$DNCAST{MEAN_ROLL}[$bi],$DNCAST{MEAN_TILT}[$bi],	# instrument tilt
+					 $UPCAST{MEAN_PITCH}[$bi],$UPCAST{MEAN_ROLL}[$bi],$UPCAST{MEAN_TILT}[$bi],	
 					 $BT{N_SAMP}[$bi]>=$opt_k?$BT{MEDIAN_W}[$bi]:nan,				# BT data
 					 $BT{MAD_W}[$bi],$BT{N_SAMP}[$bi]
 			);
--- a/LADCP_w_postproc	Sat Apr 10 06:00:45 2021 -0400
+++ b/LADCP_w_postproc	Sat Jul 24 10:35:41 2021 -0400
@@ -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: Thu Nov  1 10:55:34 2018
+#                    dlm: Fri Jul 23 14:03:05 2021
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 71 77 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 740 38 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 $antsSummary = 'edit and re-grid LADCP vertical-velocity samples';
@@ -69,6 +69,19 @@
 #	Dec  9, 2017: - added $antsSuppressCommonOptions = 1;
 #	Oct 31, 2018: - improved label (no longer explained/residual stddev)
 #	Nov  1, 2018: - made layout consistent for dual- and single-head profiles
+#	Jul  1, 2021: - made %PARAMs more standard
+#				  - added -z to remove biases
+#				  - added %?c_w_diff.rms to output
+#				  - BUG: dc_corr returned strange rms
+#	Jul  7, 2021: - reversed logic of -z (enables bias correction by default)
+#				  - BUG: plot had label in wrong location for single-head profiles
+#	Jul  9, 2021: - added window correlation stats
+#				  - updated %PARAM names
+#	Jul 13, 2021: - BUG: dc_sig, dc_rms confusion
+#	Jul 23, 2021: - added summary info to plot
+#				  - added seabed to plot
+#				  - added annotations to plot
+# HISTORY END
 
 
 ($ANTS)  = (`which ANTSlib` =~ m{^(.*)/[^/]*$});
@@ -85,8 +98,9 @@
 &antsAddParams('LADCP_w_postproc::version',$VERSION);
 
 $antsSuppressCommonOptions = 1;
-&antsUsage('b:d:i:k:l:o:p:v:w:',1,
+&antsUsage('b:d:i:k:l:o:p:v:w:z',1,
 	'[profile -i)d <id>]',
+	'[disable -z)eroing of <w> (disable bias correction)]',
 	'[-o)utput bin <resolution>] [-k) require <min> samples]',
 	'[-v)alid bins <DL first>,<DL last>[,<UL first>,<UL_last>]',
 	'[-w) <DL_dc_field>,<DL_uc_field>[,<UL_dc_field>,<UL_uc_field>]',
@@ -156,9 +170,6 @@
 #----------------------------------------------------------------------
 
 if (-t STDOUT) {
-#	$opt_p = defined($opt_d) ? "$opt_d/%03d_wprof.ps,$opt_d/%03d_wcorr.ps"
-#							 : '%03d_wprof.ps,%03d_wcorr.ps'
-#		unless defined($opt_p);
 	$opt_p = defined($opt_d) ? "$opt_d/%03d_wprof.ps" : '%03d_wprof.ps'
 		unless defined($opt_p);
 	$outfile = defined($opt_d) ? sprintf('%s/%03d.wprof',$opt_d,$id)
@@ -235,26 +246,36 @@
 }
 
 #----------------------------------------------------------------------
-# Main Program
+# Correlation Statistics
+#
+#	return values:
+#		   R	correlation coefficient w_DL,w_UL
+#	     var	variance of avg(w_DL,w_UL)
+#	  DL_var	variance of w_DL
+#	  UL_var	variance of w_DL
+#	rms_diff	rms of w_DL-w_UL
 #----------------------------------------------------------------------
 
-sub dc_corr()
+sub dc_corr($$)
 {
+	my($fi,$li) = @_;
 	my($n) = 0;
 	my($ax,$ay) = (0,0);
+	my($ssq_diff) = 0;
 
-	for (my($bi)=int($opt_s/$opt_o); $bi<@DL_dc_median; $bi++) {
+	for (my($bi)=$fi; $bi<=$li; $bi++) {
 		next unless numberp($DL_dc_median[$bi]) && numberp($UL_dc_median[$bi]);
 		$n++;
 		$ax += $DL_dc_median[$bi];
 		$ay += $UL_dc_median[$bi];
+		$ssq_diff += ($DL_dc_median[$bi] - $UL_dc_median[$bi])**2;
 	}
-	return (nan,nan,nan) unless ($n > 2);
+	return (nan,nan,nan,nan,nan) unless ($n > 2);
 	$ax /= $n;
 	$ay /= $n;
 
 	my($syy,$sxy,$sxx) = (0,0,0);
-	for (my($bi)=int($opt_s/$opt_o); $bi<@DL_dc_median; $bi++) {
+	for (my($bi)=$fi; $bi<=$li; $bi++) {
 		next unless numberp($DL_dc_median[$bi]) && numberp($UL_dc_median[$bi]);
 		my($xt) = $DL_dc_median[$bi] - $ax;
 		my($yt) = $UL_dc_median[$bi] - $ay;
@@ -263,27 +284,33 @@
 		$sxy += $xt * $yt;
 	}
 	my($R) = $sxy/(sqrt($sxx * $syy) + 1e-16);
-	my($rms) = sqrt($sxx/$n);
-	return ($R,$rms);
+	my($var) = ($sxx + $syy) / (2*$n);			# variance of avg(w_DL,w_UL)
+	my($var_DL) = $sxx/$n;
+	my($var_UL) = $syy/$n;
+	my($rms_diff) = sqrt($ssq_diff/$n);
+	return ($R,$var,$var_DL,$var_UL,$rms_diff);
 }
 
-sub uc_corr(@)
+sub uc_corr($$)
 {
+	my($fi,$li) = @_;
 	my($n) = 0;
 	my($ax,$ay) = (0,0);
+	my($ssq_diff) = 0;
 
-	for (my($bi)=int($opt_s/$opt_o); $bi<@DL_dc_median; $bi++) {
+	for (my($bi)=$fi; $bi<=$li; $bi++) {
 		next unless numberp($DL_uc_median[$bi]) && numberp($UL_uc_median[$bi]);
 		$n++;
 		$ax += $DL_uc_median[$bi];
 		$ay += $UL_uc_median[$bi];
+		$ssq_diff += ($DL_uc_median[$bi] - $UL_uc_median[$bi])**2;
 	}
-	return (nan,nan,nan) unless ($n > 2);
+	return (nan,nan,nan,nan,nan) unless ($n > 2);
 	$ax /= $n;
 	$ay /= $n;
 
 	my($syy,$sxy,$sxx) = (0,0,0);
-	for (my($bi)=int($opt_s/$opt_o); $bi<@DL_dc_median; $bi++) {
+	for (my($bi)=$fi; $bi<=$li; $bi++) {
 		next unless numberp($DL_uc_median[$bi]) && numberp($UL_uc_median[$bi]);
 		my($xt) = $DL_uc_median[$bi] - $ax;
 		my($yt) = $UL_uc_median[$bi] - $ay;
@@ -292,11 +319,16 @@
 		$sxy += $xt * $yt;
 	}
 	my($R) = $sxy/(sqrt($sxx * $syy) + 1e-16);
-	my($sig) = sqrt(($sxx+$syy)/(2*$n));			# stddev of average w signal from DL & UL
-	return ($R,$sig);
+	my($var) = ($sxx + $syy) / (2*$n);			# variance of avg(w_DL,w_UL)
+	my($var_DL) = $sxx/$n;
+	my($var_UL) = $syy/$n;
+	my($rms_diff) = sqrt($ssq_diff/$n);
+	return ($R,$var,$var_DL,$var_UL,$rms_diff);
 }
 
 #----------------------------------------------------------------------
+# Main Program
+#----------------------------------------------------------------------
 
 $dcwF = &fnr($Ddwf); $ucwF = &fnr($Duwf);
 $eF = &fnr('elapsed');
@@ -304,10 +336,18 @@
 $bF = &fnr('bin');
 $dcF = &fnr('downcast');
 
-$first_label 	= &antsRequireParam('run_label');
-$bin_length 	= &antsRequireParam('ADCP_bin_length');
-$pulse_length   = &antsRequireParam('ADCP_pulse_length');
-$blanking_dist  = &antsRequireParam('ADCP_blanking_distance');
+$first_label 	 	= &antsRequireParam('run_label');
+
+$bin_length 	 	= &antsRequireParam('ADCP_bin_length');
+$pulse_length    	= &antsRequireParam('ADCP_pulse_length');
+$blanking_dist   	= &antsRequireParam('ADCP_blanking_distance');
+$instrument_type 	= &antsRequireParam('ADCP_type');
+$xducer_frequency	= &antsRequireParam('ADCP_frequency');
+$orientation		= &antsRequireParam('ADCP_orientation');
+
+$dc_var				= &antsRequireParam('dc_w.var');				# for dual-head LADCPs, variables will be 
+$uc_var				= &antsRequireParam('uc_w.var');				# overwritten by [du]c_corr()
+
 ($dayNoP,$dn) = &antsFindParam('dn\d\d');
 croak("$0: cannot determine day number\n")
 	unless defined($dayNoP);
@@ -404,21 +444,21 @@
 		#	blanking distance:	use smaller value, which is conservative e.g. for filters for ringing
 		#
 		my($warned);
-		unless (round($bin_length) == round($P{ADCP_bin_length})) {
+		unless (round($bin_length) == round(&antsRequireParam('ADCP_bin_length'))) {
 			unless ($warned) {
 				&antsInfo("WARNING: inconsistent ADCP sampling parameters in profile #$id --- using conservative values");
 				$warned = 1;
 			}
 			$bin_length = min($bin_length,$P{ADCP_bin_length});
 		}
-		unless (round($pulse_length) == round($P{ADCP_pulse_length})) {
+		unless (round($pulse_length) == round(&antsRequireParam('ADCP_pulse_length'))) {
 			unless ($warned) {
 				&antsInfo("WARNING: inconsistent ADCP sampling parameters in profile #$id --- using conservative values");
 				$warned = 1;
 			}
 			$pulse_length = min($pulse_length,$P{ADCP_pulse_length});
 		}
-		unless (round($blanking_dist) == round($P{ADCP_blanking_distance})) {
+		unless (round($blanking_dist) == round(&antsRequireParam('ADCP_blanking_distance'))) {
 			unless ($warned) {
 				&antsInfo("WARNING: inconsistent ADCP sampling parameters in profile #$id --- using conservative values");
 				$warned = 1;
@@ -426,6 +466,10 @@
 			$blanking_dist = min($blanking_dist,$P{ADCP_blanking_distance});
 		}
 
+		$instrument_type2 	= &antsRequireParam('ADCP_type');					# for summary info
+		$xducer_frequency2	= &antsRequireParam('ADCP_frequency');
+		$orientation2		= &antsRequireParam('ADCP_orientation');
+
 		$PROF = $STN = $ID = $id; $RUN = antsRequireParam('run_label');			# set variables for editing
 		undef(@rngMin); undef(@rngMax); undef(@bins);
 		unless ($return = do "./EditParams") {									# man perlfunc
@@ -460,13 +504,15 @@
 	
 	my($bi) = $ants_[0][$dF]/$opt_o;
 	if ($ants_[0][$dcF]) {														# downcast
-		push(@{$dcw[$bi]},$ants_[0][$dcwF]);									# 	vertical velocity
-		push(@{$dcw1[$bi]},$ants_[0][$dcwF]) if ($dual_head);					# 	single-instrument w
-		push(@{$dce[$bi]},$ants_[0][$eF]);	 									# 	elapsed time
+		push(@{$dcw[$bi]}, $ants_[0][$dcwF] - (!$opt_z ? $P{'dc_w.mu'} : 0));	# 	vertical velocity
+		push(@{$dcw1[$bi]},$ants_[0][$dcwF] - (!$opt_z ? $P{'dc_w.mu'} : 0))	# 	single-instrument w
+			if ($dual_head);					
+		push(@{$dce[$bi]}, $ants_[0][$eF]);	 									# 	elapsed time
 	} else {								 									# upcast
-		push(@{$ucw[$bi]},$ants_[0][$ucwF]);
-		push(@{$ucw1[$bi]},$ants_[0][$ucwF]) if ($dual_head);
-		push(@{$uce[$bi]},$ants_[0][$eF]);
+		push(@{$ucw[$bi]}, $ants_[0][$ucwF] - (!$opt_z ? $P{'uc_w.mu'} : 0));
+		push(@{$ucw1[$bi]},$ants_[0][$ucwF] - (!$opt_z ? $P{'uc_w.mu'} : 0))
+			if ($dual_head);
+		push(@{$uce[$bi]}, $ants_[0][$eF]);
 	}
 } # file-read loop
 
@@ -480,9 +526,35 @@
 					  ? $DL_uc_median[$bi] - $UL_uc_median[$bi] : nan;
 	}
 
-	($dc_R,$dc_sig) = &dc_corr();												# correlation statistics
-	($uc_R,$uc_sig) = &uc_corr();
-	&antsAddParams('dc_R',$dc_R,'uc_R',$uc_R,'dc_w.sig',$dc_sig,'uc_w.sig',$uc_sig);
+	($dc_R,$dc_var,$dc_var_DL,$dc_var_UL,$dc_rms_wdiff) = &dc_corr(int($opt_s/$opt_o),$#dcw1);		# correlation statistics
+	($uc_R,$uc_var,$uc_var_DL,$uc_var_UL,$uc_rms_wdiff) = &uc_corr(int($opt_s/$opt_o),$#ucw1);
+	&antsAddParams('dc_w.R',$dc_R,'uc_w.R',$uc_R,
+				   'DL_dc_w.var',$dc_var_DL,'UL_dc_w.var',$dc_var_UL,
+				   'DL_uc_w.var',$uc_var_DL,'UL_uc_w.var',$uc_var_UL,
+				   'dc_w.var',$dc_var,'uc_w.var',$uc_var,
+				   'dc_wdiff.rms',$dc_rms_wdiff,'uc_wdiff.rms',$uc_rms_wdiff);
+
+	my($last_depth,$last_bi,$dc_sumsq_res,$dc_n,$uc_sumsq_res,$uc_n);			# window correlation
+	for (my($bi)=0; $bi<=$#dcw1; $bi++) {
+		($dc_R[$bi],$dc_var[$bi],$dummy,$dummy,$dc_rms_wdiff[$bi]) =
+			&dc_corr(max(0,$bi-int(250/$opt_o)),min($#dcw1,$bi+int(250/$opt_o)));
+		($uc_R[$bi],$uc_var[$bi],$dummy,$dummy,$uc_rms_wdiff[$bi]) =
+			&uc_corr(max(0,$bi-int(250/$opt_o)),min($#dcw1,$bi+int(250/$opt_o)));
+	}
+		
+#		my($depth) = ($bi+0.5) * $opt_o;
+#		unless (defined($last_bi)) {
+#			$last_bi = $bi;
+#			$last_depth = $depth;
+#			next;
+#		}
+#		if ($depth >= $last_depth+500 || $bi == $#dcw1) {
+#			($dc_R[$bi],$dc_rms[$bi],$dc_rms_wdiff[$bi]) = &dc_corr($last_bi,$bi);
+#			($uc_R[$bi],$uc_rms[$bi],$uc_rms_wdiff[$bi]) = &uc_corr($last_bi,$bi);
+#			undef($last_bi);
+#			next;
+#		}
+#	}
 
 	if (defined($opt_p)) {														# plot 2nd-instrument profiles
 		GMT_psxy('-W1,coral,.');
@@ -501,18 +573,21 @@
 
 #----------------------------------------------------------------------
 # Average and Output Profiles, Add to Summary Plot
+#	- same output file layout for single- and dual-head systems
 #----------------------------------------------------------------------
 
 @antsNewLayout = ('depth','hab',
 				  'dc_elapsed','dc_w','dc_w.mad','dc_w.nsamp',
                   'uc_elapsed','uc_w','uc_w.mad','uc_w.nsamp',
-				  'dc_w.diff','uc_w.diff');										# DL-UL differences
+				  'dc_w.diff','uc_w.diff',										# DL-UL differences
+				  'dc_w.R','dc_w.var','dc_wdiff.rms',
+				  'uc_w.R','uc_w.var','uc_wdiff.rms');
 
 if ($dual_head) {																# dual-head output
 	&antsAddParams('profile_id',$id,'lat',$P{lat},'lon',$P{lon});				# selected %PARAMs
 	&antsAddParams($dayNoP,$dn,'run_label',"$first_label & $P{run_label}");
 	&antsAddParams('outgrid_dz',$opt_o,'outgrid_minsamp',$opt_k);
-	&antsAddParams('min_depth',round($min_depth),'max_depth',round($max_depth));
+	&antsAddParams('depth.min',round($min_depth),'depth.max',round($max_depth));
 	&antsAddParams('water_depth',$P{water_depth},'water_depth.sig',$P{water_depth.sig});
 	&antsAddParams('ADCP_bin_length',$bin_length,'ADCP_pulse_length',$pulse_length);
 	&antsAddParams('ADCP_blanking_distance',$blanking_dist);
@@ -540,9 +615,11 @@
 			 (($ucns[$bi]>=$opt_k)?$ucwm[$bi]:nan),(($ucns[$bi]>=$opt_k)?$ucwmad[$bi]:nan),
 			 scalar(@{$ucw[$bi]}));
 	if ($dual_head) {
-		push(@{$out[$bi]},$dc_diff[$bi],$uc_diff[$bi]);
+		push(@{$out[$bi]},$dc_diff[$bi],$uc_diff[$bi],
+						  $dc_R[$bi],$dc_var[$bi],$dc_rms_wdiff[$bi],
+						  $uc_R[$bi],$uc_var[$bi],$uc_rms_wdiff[$bi]);
 	} else {
-		push(@{$out[$bi]},nan,nan);
+		push(@{$out[$bi]},nan,nan,nan,nan,nan,nan);
 	}
 	&antsOut(@{$out[$bi]});				 
 }
@@ -550,6 +627,11 @@
 if (defined($opt_p)) {																# complete summary plot
 	GMT_setR($R);
 
+	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);
@@ -592,32 +674,78 @@
 	if ($dual_head) {
 		GMT_psxy('-W1,100/100/255');												# surface layer limit
 			print(GMT "-0.1 $opt_s\n0.07 $opt_s\n");
-		GMT_unitcoords();
-		if ($dc_R < 0.3 || !numberp($dc_R)) {										# correlation statistics
-			&antsInfo("WARNING: low dc correlation (r = %.1f) between UL and DL data in profile #$id",$dc_R);
-									GMT_pstext('-F+f12,Helvetica,coral+jTL -Gred');
-		} elsif ($dc_R < 0.5) { 	GMT_pstext('-F+f12,Helvetica,coral+jTL -Gyellow'); }
-		else {						GMT_pstext('-F+f12,Helvetica,coral+jTL -Gwhite'); }
-	        printf(GMT "%f %f r = %.1f\n",0.62,0.01,$dc_R);
-		GMT_pstext('-F+f12,Helvetica,coral+jTR -Gwhite');
-			printf(GMT "%f %f [%.1f cm/s stddev]\n",0.99,0.01,100*$dc_sig);
-		if ($uc_R < 0.3 || !numberp($uc_R)) {
-			&antsInfo("WARNING: low uc correlation (r = %.1f) between UL and DL data in profile #$id",$uc_R);
-									GMT_pstext('-F+f12,Helvetica,SeaGreen+jTL -Gred');
-		} elsif ($uc_R < 0.5) { 	GMT_pstext('-F+f12,Helvetica,SeaGreen+jTL -Gyellow'); }
-		else {						GMT_pstext('-F+f12,Helvetica,SeaGreen+jTL -Gwhite'); }
-	        printf(GMT "%f %f r = %.1f\n",0.62,0.05,$uc_R);
-		GMT_pstext('-F+f12,Helvetica,SeaGreen+jTR -Gwhite');
-			printf(GMT "%f %f [%.1f cm/s stddev]\n",0.99,0.05,100*$uc_sig);
+	}
+	
+	GMT_unitcoords();
+	my(@y) = (1.018,1.052,1.076,1.109);
+	
+	GMT_pstext('-F+f9,Helvetica,CornFlowerBlue+jTL -N');							# summary information
+	if ($dual_head) {
+		printf(GMT "0.64 $y[0] Dual-Head (%d / %d kHz)\n",
+					round($xducer_frequency,50),round($xducer_frequency2,50));
+	} else {
+		printf(GMT "0.64 $y[0] %d kHz $instrument_type $orientation\n",
+					round($xducer_frequency,50));
+	}
+	print( GMT "0.64 $y[1] rms <w>\n		0.77 $y[1] :\n");
+	if ($dual_head) {
+		printf(GMT "0.64 $y[2] rms @~D@~w\n		0.77 %f :\n",$y[2]+0.007);
+		printf(GMT "0.64 %f correl. (r)\n		0.77 $y[3] :\n",$y[3]-0.005);
 	}
 
-	GMT_pstext('-F+f14,Helvetica,blue+jTL -N');
+	if ($dual_head) {
+		if ($dc_rms_wdiff > sqrt($dc_var)) {
+			GMT_pstext('-F+f9,Helvetica,coral+jTR -N -Gyellow');
+		} else {
+			GMT_pstext('-F+f9,Helvetica,coral+jTR -N');
+		}
+		if (numberp($dc_R)) {
+			&antsInfo("WARNING: low dc correlation (r = %.1f) between UL and DL data in profile #$id",$dc_R)
+				if ($dc_R < 0.3);
+			printf(GMT "0.88 %f %.1fmm/s\n",$y[1]-0.005,round(sqrt($dc_var)*1000,.1));
+			printf(GMT "0.88 %f %.1fmm/s\n",$y[2]+0.001,round($dc_rms_wdiff*1000,.1));
+            printf(GMT "0.88 %f %.1f",$y[3]-0.005,$dc_R);
+        } else {
+			&antsInfo("WARNING: no overlap between UL and DL dc data below the surface layer in profile #$id");
+        }
+	} else {
+		GMT_pstext('-F+f9,Helvetica,coral+jTR -N');
+		printf(GMT "0.88 %f %.1fmm/s\n",$y[1]-0.005,round(sqrt($dc_var)*1000,.1));
+	}
+
+	if ($dual_head) {
+		if ($uc_rms_wdiff > sqrt($uc_var)) {
+			GMT_pstext('-F+f9,Helvetica,SeaGreen+jTR -N -Gyellow');
+		} else {
+			GMT_pstext('-F+f9,Helvetica,SeaGreen+jTR -N');
+		}
+		if (numberp($uc_R)) {
+			&antsInfo("WARNING: low uc correlation (r = %.1f) between UL and DL data in profile #$id",$uc_R)
+				if ($uc_R < 0.3);
+			printf(GMT "0.99 %f %.1fmm/s\n",$y[1]-0.005,round(sqrt($uc_var)*1000,.1));
+			printf(GMT "0.99 %f %.1fmm/s\n",$y[2]+0.001,round($uc_rms_wdiff*1000,.1));
+            printf(GMT "0.99 %f %.1f",$y[3]-0.005,$uc_R);
+        } else {
+			&antsInfo("WARNING: no overlap between UL and DL uc data below the surface layer in profile #$id");
+        }
+	} else {
+		GMT_pstext('-F+f9,Helvetica,SeaGreen+jTR -N');
+		printf(GMT "0.99 %f %.1fmm/s\n",$y[1]-0.005,round(sqrt($uc_var)*1000,.1));
+	}
+
+	GMT_pstext('-F+f14,Helvetica,blue+jTL -N');											# annotations
 	if (defined($outfile)) { print(GMT "0.01 -0.06 $outfile [$P{run_label}]\n"); }
 	else { 					printf(GMT "0.01 -0.06 %03d\n [$P{run_label}]",$id); }
 	GMT_pstext('-F+f12,Helvetica+jMR');
-		print(GMT '0.62 0.98 m.a.d.');
+		print(GMT '0.62 0.98 m.abs.dev.');
 	GMT_pstext('-F+f9,Helvetica,orange+jBR -N -Gwhite');
 		print(GMT "0.99 0.99 V$VERSION\n");
+	GMT_pstext('-F+f12,Helvetica,coral+jTL -Gwhite');
+		print(GMT "0.02 0.02 downcast\n");
+	GMT_pstext('-F+f12,Helvetica,SeaGreen+jTL -Gwhite');
+		print(GMT "0.24 0.02 upcast\n");
+	GMT_pstext('-F+f12,Helvetica+jBL -Gwhite');
+		print(GMT "0.02 0.98 b.track\n");
         
 	GMT_end();
 
--- a/acoustic_backscatter.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/acoustic_backscatter.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -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: Tue May 24 16:34:24 2016
+#                    dlm: Thu Jul  1 09:37:40 2021
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 212 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 32 46 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -29,6 +29,9 @@
 #	Mar 26, 2016: - BUG: nSv was declared local to this scope even though it is used outside
 #	May 18, 2016: - improved logging
 #   May 24, 2016: - calc_binDepths() -> binDepths()
+#	Jul  1, 2021: - made %PARAMs more standard
+# HISTORY END
+
 
 #----------------------------------------------------------------------
 # Volume Scattering Coefficient, following Deines (IEEE 1999)
@@ -227,8 +230,8 @@
 	my($search_below) = int($_[0]);										# grid index to begin search
 	my(@wdepth,@Sv_rng);												# list of water_depth indices
 
-	&antsAddParams('SS_min_signal',$SS_min_signal,'SS_min_samp',$SS_min_samp,
-				   'SS_max_allowed_depth_range',$SS_max_allowed_depth_range);
+	&antsAddParams('SS_signal.min',$SS_min_signal,'SS_samp.min',$SS_min_samp,
+				   'SS_allowed_depth_range.max',$SS_max_allowed_depth_range);
 				   
 	for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { 	# find backscatter min/max below $search_below in each bin
 		my($minSv,$maxSv,$depthmaxSv,$lastvalid) = (1e99,-1e99,-1,-1);
--- a/bottom_tracking.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/bottom_tracking.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    B O T T O M _ T R A C K I N G . P L 
 #                    doc: Wed Oct 20 21:05:37 2010
-#                    dlm: Tue May  1 21:48:54 2018
+#                    dlm: Thu Jul  1 09:38:25 2021
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 21 14 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 20 13 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -16,6 +16,8 @@
 #	Jan 26, 2016: - added %PARAMs
 #   May 24, 2016: - calc_binDepths() -> binDepths()
 #	May  1, 2018: - log-file cosmetics
+#	Jul  1, 2021: - made %PARAMs more standard
+# HISTORY END
 
 # This code is derived from the one used in LADCPproc, with the following
 # differences:
@@ -119,9 +121,9 @@
 {
 	my($LADCP_start,$LADCP_end,$wd,$sig_wd) = @_;
 
-	&antsAddParams('BT_max_range',$BT_max_range,
-				   'BT_max_bin_range_diff',$BT_max_bin_range_diff,
-				   'BT_max_w_error',$BT_max_w_error);
+	&antsAddParams('BT_range.max',$BT_max_range,
+				   'BT_bin_range_diff.max',$BT_max_bin_range_diff,
+				   'BT_w_error.max',$BT_max_w_error);
 
 	for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) {
 		next unless ($wd-$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} < $BT_max_range);
--- a/default_output.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/default_output.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    D E F A U L T _ O U T P U T . P L 
 #                    doc: Wed Jun  1 19:21:19 2016
-#                    dlm: Sat May 16 12:19:26 2020
+#                    dlm: Wed Jun 30 09:01:13 2021
 #                    (c) 2016 A.M. Thurnherr
-#                    uE-Info: 71 0 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 19 69 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # NOTES:
@@ -16,6 +16,7 @@
 #				  - changed semmantics so that pushing to plot adds,
 #				    instead of overwwriting
 #				  - BUG: one of the plots did not repect plotting level
+#	Jun 30, 2021: - renamed plot_mean_residuals to plot_bin_residuals
 
 #----------------------------------------------------------------------
 # Processing log (diagnostic messages) output
@@ -96,7 +97,7 @@
 # Per-bin vertical-velocity residuals (plot only)
 #----------------------------------------------------------------------
 
-push(@out_BR,"plot_mean_residuals($plot_dir/${out_basename}_bin_residuals.ps)")
+push(@out_BR,"plot_bin_residuals($plot_dir/${out_basename}_bin_residuals.ps)")
 	if ($plotting_level > 0);
 
 #----------------------------------------------------------------------
--- a/defaults.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/defaults.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    D E F A U L T S . P L 
 #                    doc: Tue Oct 11 17:11:21 2011
-#                    dlm: Sat May 16 10:53:34 2020
+#                    dlm: Fri Jul  9 13:30:48 2021
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 90 31 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 360 33 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -88,6 +88,9 @@
 #	May  2, 2018: - added max_hspeed
 #				  - replaced $PPI_seabed_editing_required by &PPI_seabed_editing_required
 #	May 16, 2020: - updated doc
+#	Jun 30, 2021: - ditto
+#	Jul  9, 2021: - added $layer_residuals_rms_max
+# HISTORY END
 
 #======================================================================
 # Output Log Files
@@ -348,6 +351,14 @@
 	}
 }
 
+
+# After the beam-pair residuals have been binned into profiles, rms
+# values in 5-output-bin-thick layers (200m by default) are calculated.
+# Vertical velocities from bins with values greater than the following 
+# limit are set to nan in the the output. 
+
+$layer_residuals_rms_max = 0.003;
+
 #======================================================================
 # Time Lagging
 #======================================================================
@@ -529,7 +540,7 @@
 #	- in contrast to -b, the other bins are still used e.g. for BT 
 #	- values recorded in %outgrid_firstbin, %outgrid_lastbin
 #	- values beyond range are:
-#		- greyed out in *_mean_residuals.ps
+#		- greyed out in *_bin_residuals.ps
 #		- not used in *_w.ps, *_residuals.ps
 
 $outGrid_firstBin = '*';			# use $LADCP_firstBin (-b)
--- a/edit_data.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/edit_data.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    E D I T _ D A T A . P L 
 #                    doc: Sat May 22 21:35:55 2010
-#                    dlm: Tue Mar 23 05:29:53 2021
+#                    dlm: Fri Jul  9 13:41:36 2021
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 409 100 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 597 63 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -45,6 +45,7 @@
 #	May  1, 2018: - added editLargeHSpeeds()
 #	Nov 17, 2018: - BUG: spurious letter "z" had crept in at some stage
 #	Mar 23, 2021: - updated PPI doc
+#	Jul  9, 2021: - added editHighResidualLayers()
 # END OF HISTORY
 
 # NOTES:
@@ -571,5 +572,34 @@
 }
 
 #======================================================================
+# $nbrm = editHighResidualLayers($max_lr_res)
+#	- filter applied after gridding
+#	- filter based on observation that profiles of beam-pair residuals
+#	  are good indicators of bad data, but very noisy
+#	- current version uses estimates in 5-bin-thick layers (200m by
+#	  default) 
+#	- filter cutoff based on 2021 A20 cruise which crossed region with
+#	  very weak backscatter
+#======================================================================
+
+sub editHighResidualLayers($)
+{
+	my($limit) = @_;
+
+	my($nbrm) = 0;
+	for (my($bi)=0; $bi<=$#{$DNCAST{LR_RMS_BP_RESIDUAL}}; $bi++) {
+		next unless ($DNCAST{LR_RMS_BP_RESIDUAL}[$bi] > $limit);
+		$DNCAST{MEDIAN_W}[$bi] = $DNCAST{MEDIAN_W12}[$bi] = $DNCAST{MEDIAN_W34}[$bi] = nan;
+		$nbrm++;
+	}
+	for (my($bi)=0; $bi<=$#{$UPCAST{LR_RMS_BP_RESIDUAL}}; $bi++) {
+		next unless ($UPCAST{LR_RMS_BP_RESIDUAL}[$bi] > $limit);
+		$UPCAST{MEDIAN_W}[$bi] = $UPCAST{MEDIAN_W12}[$bi] = $UPCAST{MEDIAN_W34}[$bi] = nan;
+		$nbrm++;
+	}
+    return $nbrm;
+}
+
+#======================================================================
 
 1;
--- a/find_seabed.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/find_seabed.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    F I N D _ S E A B E D . P L 
 #                    doc: Sun May 23 20:26:11 2010
-#                    dlm: Thu May 19 10:40:55 2016
+#                    dlm: Thu Jul  1 09:39:12 2021
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 18 46 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 19 46 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -16,6 +16,7 @@
 #	Jan 26, 2016: - added %PARAMs
 #	May 18, 2016: - removed assumption of 1500m/s soundspeed setting
 #	May 19, 2016: - updated to ADCP_tools V1.6
+#	Jul  1, 2021: - made %PARAMs more standard
 
 # NOTES:
 #	1) BT range is corrected for sound speed at the transducer. This is not
@@ -38,10 +39,10 @@
 	my($i,$dd,$sd,$nd);
 	my(@guesses);
 
-	&antsAddParams('SS_min_allowed_range',$SS_min_allowed_range,
-				   'SS_max_allowed_range',$SS_max_allowed_range,
+	&antsAddParams('SS_allowed_range.min',$SS_min_allowed_range,
+				   'SS_allowed_range.max',$SS_max_allowed_range,
 				   'SS_search_window_halfwidth',$SS_search_window_halfwidth,
-				   'SS_max_allowed_depth_range',$SS_max_allowed_depth_range);
+				   'SS_allowed_depth_range.max',$SS_max_allowed_depth_range);
 
 	return undef unless ($be-$SS_search_window_halfwidth >= 0 &&
 						 $be+$SS_search_window_halfwidth <= $#{$d->{ENSEMBLE}});
--- a/plot_backscatter.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/plot_backscatter.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    P L O T _ B A C K S C A T T E R . P L 
 #                    doc: Tue Jul 28 13:21:09 2015
-#                    dlm: Tue Oct 29 13:13:02 2019
+#                    dlm: Thu Jul  1 13:32:33 2021
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 73 54 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 30 42 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -15,6 +15,7 @@
 #   May 24, 2016: - calc_binDepths() -> binDepths()
 #				  - fixed for partial-depth casts
 #	Oct 29, 2019: - updated psscale -B to gmt5 syntax
+#	Jul  1, 2021: - adapted to more standard %PARAMs
 
 require "$ANTS/libGMT.pl";
 
@@ -22,18 +23,18 @@
 {
 	my($pfn) = @_;
 
-	return unless ($P{max_depth});
+	return unless ($P{'depth.max'});
 
-	my($xmin) = $P{min_ens}-0.5;
-	my($xmax) = $P{max_ens}+0.5;
-	my($ymin) = round(antsParam('min_depth')-25,50);
+	my($xmin) = $P{'ens.min'}-0.5;
+	my($xmax) = $P{'ens.max'}+0.5;
+	my($ymin) = round(antsParam('depth.min')-25,50);
 	my($ymax) = ($P{water_depth} > 0) ?
 				round($P{water_depth}+25,50) :
-				round($P{max_depth}+$P{ADCP_bin_length}+25,50);
+				round($P{'depth.max'}+$P{ADCP_bin_length}+25,50);
 
-	my($ens_width) = 10 / ($P{max_ens} - $P{min_ens} + 1);
+	my($ens_width) = 10 / ($P{'ens.max'} - $P{'ens.min'} + 1);
 	my($bin_length) = 10 * $P{ADCP_bin_length} / 
-						($P{max_depth}-$P{min_depth}+$P{ADCP_bin_length});
+						($P{'depth.max'}-$P{'depth.min'}+$P{ADCP_bin_length});
 
 	my($R) = "-R$xmin/$xmax/$ymin/$ymax";
 	GMT_begin($pfn,'-JX10/-10',$R,'-P');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plot_bin_residuals.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -0,0 +1,159 @@
+#======================================================================
+#                    P L O T _ B I N _ R E S I D U A L S . P L 
+#                    doc: Tue Jul 28 13:21:09 2015
+#                    dlm: Thu Jul  1 13:23:10 2021
+#                    (c) 2015 A.M. Thurnherr
+#                    uE-Info: 23 52 NIL 0 0 72 2 2 4 NIL ofnI
+#======================================================================
+
+# HISTORY:
+#	Jul 28, 2015: - created from [LWplot_BR]
+#	Jul 29, 2015: - finished
+#	Jul 30, 2015: - added bin_tics
+#				  - added outGrid_* support
+#	Jan 22, 2015: - many changes
+#				  - added quality assessment label
+#	Jan 25, 2016: - added return on no data
+#	Mar 16, 2016: - adapted to gmt5
+#   May 18, 2016: - added version
+#	May 15, 2020: - adapted to bin-residuals separate per beam pair
+#				  - added orange range
+#				  - slightly relaxed green range
+#	Jun 30, 2021: - renamed from plot_mean_residuals.pl
+#	Jul  1, 2021: - adapted to more standard %PARAMs
+
+require "$ANTS/libGMT.pl";
+
+sub plot_bin_residuals($)
+{
+	my($pfn) = @_;
+
+	return unless ($P{'BR_bin.max'});
+
+	my($xmin) = -0.05;
+	my($xmax) =  0.05;
+	my($ymin) =  0.5;
+	my($ymax) = $P{'BR_bin.max'} + 0.5;
+
+	my($R) = "-R$xmin/$xmax/$ymin/$ymax";
+	GMT_begin($pfn,'-JX10/-10',$R,'-P');
+
+	if ($outGrid_firstBin>$LADCP_firstBin || $outGrid_lastBin<$LADCP_lastBin) {		# mark used bins
+		GMT_psxy('-G200 -L');
+		printf(GMT ">\n%f %f\n%f %f\n%f %f\n%f %f\n",
+			$xmin,$LADCP_firstBin-0.5,
+			$xmax,$LADCP_firstBin-0.5,
+			$xmax,$outGrid_firstBin-0.5,
+			$xmin,$outGrid_firstBin-0.5)
+				if ($outGrid_firstBin>$LADCP_firstBin);
+		printf(GMT ">\n%f %f\n%f %f\n%f %f\n%f %f\n",
+			$xmin,$LADCP_lastBin+0.5,
+			$xmax,$LADCP_lastBin+0.5,
+			$xmax,$outGrid_lastBin+0.5,
+			$xmin,$outGrid_lastBin+0.5)
+				if ($outGrid_lastBin<$LADCP_lastBin);
+	}
+
+	GMT_psxy('-W1');																# plot zero line
+	printf(GMT "0 $ymin\n0 $ymax\n");
+
+	GMT_psxy('-W2,coral,8_2:0');
+		for (my($bin)=$LADCP_firstBin; $bin<@dc_bres12; $bin++) {			
+			next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);
+			next unless ($dc_bres12_nsamp[$bin] >= $dc_bres12_max_nsamp/3);
+			printf(GMT "%f %d\n",$dc_avg_bres12[$bin],$bin+1);
+        }
+	GMT_psxy('-W2,coral,1_1:0');
+		for (my($bin)=$LADCP_firstBin; $bin<@dc_bres34; $bin++) {			
+			next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);
+			next unless ($dc_bres34_nsamp[$bin] >= $dc_bres34_max_nsamp/3);
+			printf(GMT "%f %d\n",$dc_avg_bres34[$bin],$bin+1);
+        }
+	GMT_psxy('-Ex0.2/2,coral');
+		for (my($bin)=$LADCP_firstBin-1; $bin<@dc_bres12; $bin++) {
+			printf(GMT "%f %d %f\n",
+							$dc_avg_bres12[$bin],
+							$bin+1,
+							($dc_bres12_nsamp[$bin] > 1) ?
+								$dc_sig_bres12[$bin]/sqrt($dc_bres12_nsamp[$bin]-1) : 0);
+		}
+		for (my($bin)=$LADCP_firstBin-1; $bin<@dc_bres34; $bin++) {
+			printf(GMT "%f %d %f\n",
+							$dc_avg_bres34[$bin],
+							$bin+1,
+							($dc_bres34_nsamp[$bin] > 1) ?
+								$dc_sig_bres34[$bin]/sqrt($dc_bres34_nsamp[$bin]-1) : 0);
+        }
+	GMT_psxy('-W2,SeaGreen,8_2:0');
+		for (my($bin)=$LADCP_firstBin; $bin<@uc_bres12; $bin++) {			
+			next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);
+			next unless ($uc_bres12_nsamp[$bin] >= $uc_bres12_max_nsamp/3);
+			printf(GMT "%f %d\n",$uc_avg_bres12[$bin],$bin+1);
+        }
+	GMT_psxy('-W2,SeaGreen,1_1:0');
+		for (my($bin)=$LADCP_firstBin; $bin<@uc_bres34; $bin++) {			
+			next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);
+			next unless ($uc_bres34_nsamp[$bin] >= $uc_bres34_max_nsamp/3);
+			printf(GMT "%f %d\n",$uc_avg_bres34[$bin],$bin+1);
+        }
+	GMT_psxy('-Ex0.2/2,SeaGreen');
+		for (my($bin)=$LADCP_firstBin-1; $bin<@uc_bres12; $bin++) {
+			printf(GMT "%f %d %f\n",
+							$uc_avg_bres12[$bin],
+							$bin+1,
+							($uc_bres12_nsamp[$bin] > 1) ?
+								$uc_sig_bres12[$bin]/sqrt($uc_bres12_nsamp[$bin]-1) : 0);
+		}
+		for (my($bin)=$LADCP_firstBin-1; $bin<@uc_bres34; $bin++) {
+			printf(GMT "%f %d %f\n",
+							$uc_avg_bres34[$bin],
+							$bin+1,
+							($uc_bres34_nsamp[$bin] > 1) ?
+								$uc_sig_bres34[$bin]/sqrt($uc_bres34_nsamp[$bin]-1) : 0);
+        }
+
+	GMT_unitcoords();																	# LABELS
+	GMT_pstext('-F+f9,Helvetica,orange+jTR -N -Gwhite');
+        print(GMT "0.99 0.01 V$VERSION\n");
+        
+	GMT_pstext('-F+f14,Helvetica,blue+jBL -N');											# profile id
+		print(GMT "0.0 -0.03 $P{out_basename} $P{run_label}\n");
+
+	GMT_pstext('-F+f12,Helvetica-Bold,black+jBL -Gwhite'); 								# rms residuals
+		print(GMT "0.1 0.88 beams <1,2>\n");
+	GMT_pstext('-F+f12,Helvetica-Bold,black+jBL -Gwhite');
+		print(GMT "0.7 0.88 beams <3,4>\n");
+
+	GMT_pstext('-F+f12,Helvetica,coral+jBL');											# rms residuals
+		print(GMT "0.01 0.93 dc\n");
+	if ($dc_bres12_rms >= 0.005) { 		GMT_pstext('-F+f12,Helvetica,white+jBL -Gred'); }
+	elsif ($dc_bres12_rms >= 0.003) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gorange'); }
+	elsif ($dc_bres12_rms >= 0.0015) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gyellow'); }
+	else {								GMT_pstext('-F+f12,Helvetica,black+jBL -Ggreen'); }
+		printf(GMT "0.10 0.93 %.1f mm/s rms\n",1000*$dc_bres12_rms);
+
+	if ($dc_bres34_rms >= 0.005) { 		GMT_pstext('-F+f12,Helvetica,white+jBL -Gred'); }
+	elsif ($dc_bres34_rms >= 0.003) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gorange'); }
+	elsif ($dc_bres34_rms >= 0.0015) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gyellow'); }
+	else {								GMT_pstext('-F+f12,Helvetica,black+jBL -Ggreen'); }
+		printf(GMT "0.70 0.93 %.1f mm/s rms\n",1000*$dc_bres34_rms);
+
+	GMT_pstext('-F+f12,Helvetica,SeaGreen+jBL');
+		print(GMT "0.01 0.98 uc\n");
+	if ($uc_bres12_rms >= 0.005) { 		GMT_pstext('-F+f12,Helvetica,white+jBL -Gred'); }
+	elsif ($uc_bres12_rms >= 0.003) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gorange'); }
+	elsif ($uc_bres12_rms >= 0.0015) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gyellow'); }
+	else {								GMT_pstext('-F+f12,Helvetica,black+jBL -Ggreen'); }
+		printf(GMT "0.10 0.98 %.1f mm/s rms\n",1000*$uc_bres12_rms);
+	if ($uc_bres34_rms >= 0.005) { 		GMT_pstext('-F+f12,Helvetica,white+jBL -Gred'); }
+	elsif ($uc_bres34_rms >= 0.003) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gorange'); }
+	elsif ($uc_bres34_rms >= 0.0015) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gyellow'); }
+	else {								GMT_pstext('-F+f12,Helvetica,black+jBL -Ggreen'); }
+		printf(GMT "0.70 0.98 %.1f mm/s rms\n",1000*$uc_bres34_rms);
+
+	my($bin_tics) = ($ymax <= 20) ? 'f1a1' : 'f1a2';
+	GMT_setR($R);																		# FINISH PLOT
+	GMT_end("-Bf0.005a0.02:'Residual Vertical Velocity [m/s]':/$bin_tics:'Bin [#]':WeSn");
+}
+
+1; # return true on require
--- a/plot_correlation.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/plot_correlation.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    P L O T _ C O R R E L A T I O N . P L 
 #                    doc: Tue Jul 28 13:21:09 2015
-#                    dlm: Tue Oct 29 13:13:52 2019
+#                    dlm: Thu Jul  1 13:24:42 2021
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 17 53 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 18 47 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -15,6 +15,7 @@
 #   May 24, 2016: - calc_binDepths() -> binDepths()
 #				  - fixed for partial-depth casts
 #   Oct 29, 2019: - updated psscale -B to gmt5 syntax
+#	Jul  1, 2021: - adapted to more std %PARAMs
 
 require "$ANTS/libGMT.pl";
 
@@ -22,18 +23,18 @@
 {
 	my($pfn) = @_;
 
-	return unless ($P{max_depth});
+	return unless ($P{'depth.max'});
 
-	my($xmin) = $P{min_ens}-0.5;
-	my($xmax) = $P{max_ens}+0.5;
-	my($ymin) = round(antsParam('min_depth')-25,50);
+	my($xmin) = $P{'ens.min'}-0.5;
+	my($xmax) = $P{'ens.max'}+0.5;
+	my($ymin) = round(antsParam('depth.min')-25,50);
 	my($ymax) = ($P{water_depth} > 0) ?
 				round($P{water_depth}+25,50) :
-				round($P{max_depth}+$P{ADCP_bin_length}+25,50);
+				round($P{'depth.max'}+$P{ADCP_bin_length}+25,50);
 
-	my($ens_width) = 10 / ($P{max_ens} - $P{min_ens} + 1);
+	my($ens_width) = 10 / ($P{'ens.max'} - $P{'ens.min'} + 1);
 	my($bin_length) = 10 * $P{ADCP_bin_length} / 
-						($P{max_depth}-$P{min_depth}+$P{ADCP_bin_length});
+						($P{'depth.max'}-$P{'depth.min'}+$P{ADCP_bin_length});
 
 	my($R) = "-R$xmin/$xmax/$ymin/$ymax";
 	GMT_begin($pfn,'-JX10/-10',$R,'-P');
--- a/plot_mean_residuals.pl	Sat Apr 10 06:00:45 2021 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-#======================================================================
-#                    P L O T _ M E A N _ R E S I D U A L S . P L 
-#                    doc: Tue Jul 28 13:21:09 2015
-#                    dlm: Fri May 15 19:06:51 2020
-#                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 122 47 NIL 0 0 72 2 2 4 NIL ofnI
-#======================================================================
-
-# HISTORY:
-#	Jul 28, 2015: - created from [LWplot_BR]
-#	Jul 29, 2015: - finished
-#	Jul 30, 2015: - added bin_tics
-#				  - added outGrid_* support
-#	Jan 22, 2015: - many changes
-#				  - added quality assessment label
-#	Jan 25, 2016: - added return on no data
-#	Mar 16, 2016: - adapted to gmt5
-#   May 18, 2016: - added version
-#	May 15, 2020: - adapted to bin-residuals separate per beam pair
-#				  - added orange range
-#				  - slightly relaxed green range
-
-require "$ANTS/libGMT.pl";
-
-sub plot_mean_residuals($)
-{
-	my($pfn) = @_;
-
-	return unless ($P{BR_max_bin});
-
-	my($xmin) = -0.05;
-	my($xmax) =  0.05;
-	my($ymin) =  0.5;
-	my($ymax) = $P{BR_max_bin} + 0.5;
-
-	my($R) = "-R$xmin/$xmax/$ymin/$ymax";
-	GMT_begin($pfn,'-JX10/-10',$R,'-P');
-
-	if ($outGrid_firstBin>$LADCP_firstBin || $outGrid_lastBin<$LADCP_lastBin) {		# mark used bins
-		GMT_psxy('-G200 -L');
-		printf(GMT ">\n%f %f\n%f %f\n%f %f\n%f %f\n",
-			$xmin,$LADCP_firstBin-0.5,
-			$xmax,$LADCP_firstBin-0.5,
-			$xmax,$outGrid_firstBin-0.5,
-			$xmin,$outGrid_firstBin-0.5)
-				if ($outGrid_firstBin>$LADCP_firstBin);
-		printf(GMT ">\n%f %f\n%f %f\n%f %f\n%f %f\n",
-			$xmin,$LADCP_lastBin+0.5,
-			$xmax,$LADCP_lastBin+0.5,
-			$xmax,$outGrid_lastBin+0.5,
-			$xmin,$outGrid_lastBin+0.5)
-				if ($outGrid_lastBin<$LADCP_lastBin);
-	}
-
-	GMT_psxy('-W1');																# plot zero line
-	printf(GMT "0 $ymin\n0 $ymax\n");
-
-	GMT_psxy('-W2,coral,8_2:0');
-		for (my($bin)=$LADCP_firstBin; $bin<@dc_bres12; $bin++) {			
-			next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);
-			next unless ($dc_bres12_nsamp[$bin] >= $dc_bres12_max_nsamp/3);
-			printf(GMT "%f %d\n",$dc_avg_bres12[$bin],$bin+1);
-        }
-	GMT_psxy('-W2,coral,1_1:0');
-		for (my($bin)=$LADCP_firstBin; $bin<@dc_bres34; $bin++) {			
-			next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);
-			next unless ($dc_bres34_nsamp[$bin] >= $dc_bres34_max_nsamp/3);
-			printf(GMT "%f %d\n",$dc_avg_bres34[$bin],$bin+1);
-        }
-	GMT_psxy('-Ex0.2/2,coral');
-		for (my($bin)=$LADCP_firstBin-1; $bin<@dc_bres12; $bin++) {
-			printf(GMT "%f %d %f\n",
-							$dc_avg_bres12[$bin],
-							$bin+1,
-							($dc_bres12_nsamp[$bin] > 1) ?
-								$dc_sig_bres12[$bin]/sqrt($dc_bres12_nsamp[$bin]-1) : 0);
-		}
-		for (my($bin)=$LADCP_firstBin-1; $bin<@dc_bres34; $bin++) {
-			printf(GMT "%f %d %f\n",
-							$dc_avg_bres34[$bin],
-							$bin+1,
-							($dc_bres34_nsamp[$bin] > 1) ?
-								$dc_sig_bres34[$bin]/sqrt($dc_bres34_nsamp[$bin]-1) : 0);
-        }
-	GMT_psxy('-W2,SeaGreen,8_2:0');
-		for (my($bin)=$LADCP_firstBin; $bin<@uc_bres12; $bin++) {			
-			next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);
-			next unless ($uc_bres12_nsamp[$bin] >= $uc_bres12_max_nsamp/3);
-			printf(GMT "%f %d\n",$uc_avg_bres12[$bin],$bin+1);
-        }
-	GMT_psxy('-W2,SeaGreen,1_1:0');
-		for (my($bin)=$LADCP_firstBin; $bin<@uc_bres34; $bin++) {			
-			next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);
-			next unless ($uc_bres34_nsamp[$bin] >= $uc_bres34_max_nsamp/3);
-			printf(GMT "%f %d\n",$uc_avg_bres34[$bin],$bin+1);
-        }
-	GMT_psxy('-Ex0.2/2,SeaGreen');
-		for (my($bin)=$LADCP_firstBin-1; $bin<@uc_bres12; $bin++) {
-			printf(GMT "%f %d %f\n",
-							$uc_avg_bres12[$bin],
-							$bin+1,
-							($uc_bres12_nsamp[$bin] > 1) ?
-								$uc_sig_bres12[$bin]/sqrt($uc_bres12_nsamp[$bin]-1) : 0);
-		}
-		for (my($bin)=$LADCP_firstBin-1; $bin<@uc_bres34; $bin++) {
-			printf(GMT "%f %d %f\n",
-							$uc_avg_bres34[$bin],
-							$bin+1,
-							($uc_bres34_nsamp[$bin] > 1) ?
-								$uc_sig_bres34[$bin]/sqrt($uc_bres34_nsamp[$bin]-1) : 0);
-        }
-
-	GMT_unitcoords();																	# LABELS
-	GMT_pstext('-F+f9,Helvetica,orange+jTR -N -Gwhite');
-        print(GMT "0.99 0.01 V$VERSION\n");
-        
-	GMT_pstext('-F+f14,Helvetica,blue+jBL -N');											# profile id
-		print(GMT "0.0 -0.03 $P{out_basename} $P{run_label}\n");
-
-	GMT_pstext('-F+f12,Helvetica-Bold,black+jBL -Gwhite'); 							# rms residuals
-		print(GMT "0.1 0.88 beams <1,2>\n");
-	GMT_pstext('-F+f12,Helvetica-Bold,black+jBL -Gwhite');
-		print(GMT "0.7 0.88 beams <3,4>\n");
-
-	GMT_pstext('-F+f12,Helvetica,coral+jBL');											# rms residuals
-		print(GMT "0.01 0.93 dc\n");
-	if ($dc_bres12_rms >= 0.005) { 		GMT_pstext('-F+f12,Helvetica,white+jBL -Gred'); }
-	elsif ($dc_bres12_rms >= 0.003) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gorange'); }
-	elsif ($dc_bres12_rms >= 0.0015) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gyellow'); }
-	else {								GMT_pstext('-F+f12,Helvetica,black+jBL -Ggreen'); }
-		printf(GMT "0.10 0.93 %.1f mm/s rms\n",1000*$dc_bres12_rms);
-
-	if ($dc_bres34_rms >= 0.005) { 		GMT_pstext('-F+f12,Helvetica,white+jBL -Gred'); }
-	elsif ($dc_bres34_rms >= 0.003) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gorange'); }
-	elsif ($dc_bres34_rms >= 0.0015) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gyellow'); }
-	else {								GMT_pstext('-F+f12,Helvetica,black+jBL -Ggreen'); }
-		printf(GMT "0.70 0.93 %.1f mm/s rms\n",1000*$dc_bres34_rms);
-
-	GMT_pstext('-F+f12,Helvetica,SeaGreen+jBL');
-		print(GMT "0.01 0.98 uc\n");
-	if ($uc_bres12_rms >= 0.005) { 		GMT_pstext('-F+f12,Helvetica,white+jBL -Gred'); }
-	elsif ($uc_bres12_rms >= 0.003) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gorange'); }
-	elsif ($uc_bres12_rms >= 0.0015) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gyellow'); }
-	else {								GMT_pstext('-F+f12,Helvetica,black+jBL -Ggreen'); }
-		printf(GMT "0.10 0.98 %.1f mm/s rms\n",1000*$uc_bres12_rms);
-	if ($uc_bres34_rms >= 0.005) { 		GMT_pstext('-F+f12,Helvetica,white+jBL -Gred'); }
-	elsif ($uc_bres34_rms >= 0.003) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gorange'); }
-	elsif ($uc_bres34_rms >= 0.0015) { 	GMT_pstext('-F+f12,Helvetica,black+jBL -Gyellow'); }
-	else {								GMT_pstext('-F+f12,Helvetica,black+jBL -Ggreen'); }
-		printf(GMT "0.70 0.98 %.1f mm/s rms\n",1000*$uc_bres34_rms);
-
-	my($bin_tics) = ($ymax <= 20) ? 'f1a1' : 'f1a2';
-	GMT_setR($R);																		# FINISH PLOT
-	GMT_end("-Bf0.005a0.02:'Residual Vertical Velocity [m/s]':/$bin_tics:'Bin [#]':WeSn");
-}
-
-1; # return true on require
--- a/plot_residual_profs.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/plot_residual_profs.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    P L O T _ R E S I D U A L _ P R O F S . P L 
 #                    doc: Wed May 18 18:43:33 2016
-#                    dlm: Tue May 24 22:02:28 2016
+#                    dlm: Thu Jul  1 13:25:20 2021
 #                    (c) 2016 A.M. Thurnherr
-#                    uE-Info: 77 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 54 42 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -51,10 +51,10 @@
 
 	my($xmin) = -0.05;
 	my($xmax) =  0.05;
-	my($ymin) = round(antsParam('min_depth')-25,50);
+	my($ymin) = round(antsParam('depth.min')-25,50);
 	my($ymax) = ($P{water_depth} > 0) ?
 				round($P{water_depth}+25,50) :
-				round($P{max_depth}+$P{ADCP_bin_length}+25,50);
+				round($P{'depth.max'}+$P{ADCP_bin_length}+25,50);
 	                                              
 	my($R) = "-R$xmin/$xmax/$ymin/$ymax";
 	my($depth_tics) = ($ymax < 1000 ) ? 'f10a100g100' : 'f100a500g500';
@@ -75,17 +75,23 @@
 		print(GMT "0.0 -0.03 $P{out_basename} $P{run_label}\n");
 
 	GMT_pstext('-F+f12,Helvetica-Bold,black+jBL -Gwhite'); 							# rms residuals
-		print(GMT "0.01 0.89 beams <1,2>\n");
+		print(GMT "0.1 0.89 beams <1,2>\n");
+	GMT_pstext('-F+f12,Helvetica-Bold,black+jBR -Gwhite');
+		print(GMT "0.99 0.89 beams <3,4>\n");
+	GMT_pstext('-F+f12,Helvetica,coral+jBL -Gwhite');								# rms residuals
+		print(GMT "0.01 0.93 dc\n");
+	GMT_pstext('-F+f12,Helvetica,SeaGreen+jBL -Gwhite');
+		print(GMT "0.01 0.98 uc\n");
+
 	if ($r12DC >= $red_light) { 		GMT_pstext('-F+f12,Helvetica-Bold,coral+jBL -Gred'); }	
 	elsif ($r12DC >= $yellow_light) { 	GMT_pstext('-F+f12,Helvetica-Bold,coral+jBL -Gyellow'); }
 	else {								GMT_pstext('-F+f12,Helvetica-Bold,coral+jBL -Gwhite'); }
-		printf(GMT "0.01 0.935 %.1f mm/s rms\n",1000*$r12DC);
+		printf(GMT "0.1 0.935 %.1f mm/s rms\n",1000*$r12DC);
 	if ($r12UC >= $red_light) { 		GMT_pstext('-F+f12,Helvetica-Bold,SeaGreen+jBL -Gred'); }
 	elsif ($r12UC >= $yellow_light) { 	GMT_pstext('-F+f12,Helvetica-Bold,SeaGreen+jBL -Gyellow'); }
 	else {								GMT_pstext('-F+f12,Helvetica-Bold,SeaGreen+jBL -Gwhite'); }
-		printf(GMT "0.01 0.98 %.1f mm/s rms\n",1000*$r12UC);
-	GMT_pstext('-F+f12,Helvetica-Bold,black+jBR -Gwhite');
-		print(GMT "0.99 0.89 beams <3,4>\n");
+		printf(GMT "0.1 0.98 %.1f mm/s rms\n",1000*$r12UC);
+
 	if ($r34DC >= $red_light) { 		GMT_pstext('-F+f12,Helvetica-Bold,coral+jBR -Gred'); }
 	elsif ($r34DC >= $yellow_light) { 	GMT_pstext('-F+f12,Helvetica-Bold,coral+jBR -Gyellow'); }
 	else {								GMT_pstext('-F+f12,Helvetica-Bold,coral+jBR -Gwhite'); }
--- a/plot_residuals.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/plot_residuals.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    P L O T _ R E S I D U A L S . P L 
 #                    doc: Tue Jul 28 13:21:09 2015
-#                    dlm: Tue Oct 29 13:14:19 2019
+#                    dlm: Thu Jul  1 13:26:39 2021
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 20 0 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 81 0 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -24,18 +24,18 @@
 {
 	my($pfn) = @_;
 
-	return unless ($P{max_depth});
+	return unless ($P{'depth.max'});
 
-	my($xmin) = $P{min_ens}-0.5;
-	my($xmax) = $P{max_ens}+0.5;
-	my($ymin) = round(antsParam('min_depth')-25,50);
+	my($xmin) = $P{'ens.min'}-0.5;
+	my($xmax) = $P{'ens.max'}+0.5;
+	my($ymin) = round(antsParam('depth.min')-25,50);
 	my($ymax) = ($P{water_depth} > 0) ?
 				round($P{water_depth}+25,50) :
-				round($P{max_depth}+$P{ADCP_bin_length}+25,50);
+				round($P{'depth.max'}+$P{ADCP_bin_length}+25,50);
 
-	my($ens_width) = 10 / ($P{max_ens} - $P{min_ens} + 1);
+	my($ens_width) = 10 / ($P{'ens.max'} - $P{'ens.min'} + 1);
 	my($bin_length) = 10 * $P{ADCP_bin_length} / 
-						($P{max_depth}-$P{min_depth}+$P{ADCP_bin_length});
+						($P{'depth.max'}-$P{'depth.min'}+$P{ADCP_bin_length});
 
 	my($R) = "-R$xmin/$xmax/$ymin/$ymax";
 	GMT_begin($pfn,'-JX10/-10',$R,'-P');
--- a/plot_residuals12.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/plot_residuals12.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,14 +1,15 @@
 #======================================================================
 #                    P L O T _ R E S I D U A L S 1 2 . P L 
 #                    doc: Wed Jun  1 19:05:22 2016
-#                    dlm: Tue Oct 29 13:14:53 2019
+#                    dlm: Thu Jul  1 13:28:07 2021
 #                    (c) 2016 A.M. Thurnherr
-#                    uE-Info: 84 46 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 12 47 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
 #	Jun  1, 2016: - created from [plot_residuals.pl]
 #   Oct 29, 2019: - updated psscale -B to gmt5 syntax
+#	Jul  1, 2021: - adapted to more std %PARAMs
 
 require "$ANTS/libGMT.pl";
 
@@ -16,18 +17,18 @@
 {
 	my($pfn) = @_;
 
-	return unless ($P{max_depth});
+	return unless ($P{'depth.max'});
 
-	my($xmin) = $P{min_ens}-0.5;
-	my($xmax) = $P{max_ens}+0.5;
-	my($ymin) = round(antsParam('min_depth')-25,50);
+	my($xmin) = $P{'ens.min'}-0.5;
+	my($xmax) = $P{'ens.max'}+0.5;
+	my($ymin) = round(antsParam('depth.min')-25,50);
 	my($ymax) = ($P{water_depth} > 0) ?
 				round($P{water_depth}+25,50) :
-				round($P{max_depth}+$P{ADCP_bin_length}+25,50);
+				round($P{'depth.max'}+$P{ADCP_bin_length}+25,50);
 
-	my($ens_width) = 10 / ($P{max_ens} - $P{min_ens} + 1);
+	my($ens_width) = 10 / ($P{'ens.max'} - $P{'ens.min'} + 1);
 	my($bin_length) = 10 * $P{ADCP_bin_length} / 
-						($P{max_depth}-$P{min_depth}+$P{ADCP_bin_length});
+						($P{'depth.max'}-$P{'depth.min'}+$P{ADCP_bin_length});
 
 	my($R) = "-R$xmin/$xmax/$ymin/$ymax";
 	GMT_begin($pfn,'-JX10/-10',$R,'-P');
--- a/plot_residuals34.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/plot_residuals34.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,14 +1,15 @@
 #======================================================================
 #                    P L O T _ R E S I D U A L S 3 4 . P L 
 #                    doc: Wed Jun  1 19:05:22 2016
-#                    dlm: Tue Oct 29 13:15:21 2019
+#                    dlm: Thu Jul  1 13:29:22 2021
 #                    (c) 2016 A.M. Thurnherr
-#                    uE-Info: 84 68 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 12 47 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
 #	Jun  1, 2016: - created from [plot_residuals.pl]
 #   Oct 29, 2019: - updated psscale -B to gmt5 syntax
+#	Jul  1, 2021: - adapted to more std %PARAMs
 
 require "$ANTS/libGMT.pl";
 
@@ -16,18 +17,18 @@
 {
 	my($pfn) = @_;
 
-	return unless ($P{max_depth});
+	return unless ($P{'depth.max'});
 
-	my($xmin) = $P{min_ens}-0.5;
-	my($xmax) = $P{max_ens}+0.5;
-	my($ymin) = round(antsParam('min_depth')-25,50);
+	my($xmin) = $P{'ens.min'}-0.5;
+	my($xmax) = $P{'ens.max'}+0.5;
+	my($ymin) = round(antsParam('depth.min')-25,50);
 	my($ymax) = ($P{water_depth} > 0) ?
 				round($P{water_depth}+25,50) :
-				round($P{max_depth}+$P{ADCP_bin_length}+25,50);
+				round($P{'depth.max'}+$P{ADCP_bin_length}+25,50);
 
-	my($ens_width) = 10 / ($P{max_ens} - $P{min_ens} + 1);
+	my($ens_width) = 10 / ($P{'ens.max'} - $P{'ens.min'} + 1);
 	my($bin_length) = 10 * $P{ADCP_bin_length} / 
-						($P{max_depth}-$P{min_depth}+$P{ADCP_bin_length});
+						($P{'depth.max'}-$P{'depth.min'}+$P{ADCP_bin_length});
 
 	my($R) = "-R$xmin/$xmax/$ymin/$ymax";
 	GMT_begin($pfn,'-JX10/-10',$R,'-P');
--- a/plot_time_lags.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/plot_time_lags.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    P L O T _ T I M E _ L A G S . P L 
 #                    doc: Tue Jul 28 13:21:09 2015
-#                    dlm: Thu Mar 22 10:56:17 2018
+#                    dlm: Wed Jun 30 09:51:13 2021
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 40 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 64 77 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -61,6 +61,9 @@
         print(GMT "0.99 0.99 V$VERSION\n");
 	GMT_pstext('-F+f14,Helvetica,blue+jTL -N');
 		print(GMT "0.01 1.06 $P{out_basename} $P{run_label}\n");
+    GMT_pstext('-F+f14,Helvetica,coral+jBR -Gwhite');    print(GMT "0.98 0.07 downcast\n");
+    GMT_pstext('-F+f14,Helvetica,SeaGreen+jBR -Gwhite'); print(GMT "0.98 0.02 upcast\n");
+        
 
 	GMT_setR($R);
 	my($elapsed_tics) = ($xmax-$xmin < 45) ? 'f1a5' : 'f1a30';
--- a/plot_wprof.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/plot_wprof.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    P L O T _ W P R O F . P L 
 #                    doc: Sun Jul 26 11:08:50 2015
-#                    dlm: Tue Mar 23 08:28:12 2021
+#                    dlm: Tue Jul 13 12:51:25 2021
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 25 39 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 126 0 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -23,6 +23,11 @@
 #	May 16, 2020: - added residual profile data to background
 #	May 23, 2020: - BUG: windows without samples made program bomb
 #	Mar 23, 2021: - BUG: instrument frequency was rounded to 100kHz
+#	Jun 30, 2021: - improved quality semaphore
+#	Jul  1, 2021: - replaced bin setup by <w> in legend
+#	Jul  7, 2021: - added colored background to <w>
+#	Jul  9, 2021: - adapted to new residual editing (calculation in LADCP_w_ocean)
+# HISTORY END
 
 # Tweakables:
 #
@@ -73,7 +78,7 @@
     }
 }
 
-sub plotRes()
+sub plotRes_V1()
 {
 	my($last_depth,$dc_sumsq_res,$dc_n,$uc_sumsq_res,$uc_n);
 	for (my($bi)=0; $bi<=$#{$DNCAST{MEDIAN_W}}; $bi++) {
@@ -115,17 +120,37 @@
 	}
 }
 
+sub plotRes()
+{
+	for (my($bi)=0; $bi<=$#{$DNCAST{MEDIAN_W}}; $bi++) {
+		if ($DNCAST{LR_RMS_BP_RESIDUAL}[$bi] > 0.002) {
+			my($sat) = round(100*max(0.01-max($DNCAST{LR_RMS_BP_RESIDUAL}[$bi]-0.002,0),0) * 255);
+			GMT_psxy("-Gp300/12:F255/$sat/${sat}B-");
+			printf(GMT "%g %g\n%g %g\n%g %g\n%g %g\n",
+							-0.1,$bi*$opt_o,0,$bi*$opt_o,
+							0,($bi+1)*$opt_o,-0.1,($bi+1)*$opt_o);
+		}
+		if ($UPCAST{LR_RMS_BP_RESIDUAL}[$bi] > 0.002) {
+			my($sat) = round(100*max(0.01-max($UPCAST{LR_RMS_BP_RESIDUAL}[$bi]-0.002,0),0) * 255);
+			GMT_psxy("-Gp300/9:F255/$sat/${sat}B-");
+			printf(GMT "%g %g\n%g %g\n%g %g\n%g %g\n",
+							0,$bi*$opt_o,0.07,$bi*$opt_o,
+							0.07,($bi+1)*$opt_o,0,($bi+1)*$opt_o);
+		}
+	}
+}
+
 sub plot_wprof($)
 {
 	my($pfn) = @_;
 
 	$plot_wprof_xmin = -0.1
 		unless defined($plot_wprof_xmin);		
-	$plot_wprof_ymin = round(antsParam('min_depth')-25,50)
+	$plot_wprof_ymin = round(antsParam('depth.min')-25,50)
 		unless defined($plot_wprof_ymin);		
 	$plot_wprof_ymax = ($P{water_depth} > 0) ?
 					   round($P{water_depth}+25,50) :
-					   round($P{max_depth}+25,50)
+					   round($P{'depth.max'}+25,50)
 		unless defined($plot_wprof_ymax);					  	
 	$plot_wprof_xtics = "-0.05 0.05 0.15"
 		unless defined($plot_wprof_xtics);
@@ -169,48 +194,30 @@
 	GMT_unitcoords();																	# QUALITY SEMAPHORE
 	GMT_psxy('-Ggray90');
 	print(GMT "0.895 0.895\n0.985 0.895\n0.985 0.985\n0.895 0.985\n");
-	if ($dc_bres12_rms >= 0.005) { 		GMT_psxy('-Gred -N'); }
-	elsif ($dc_bres12_rms >= 0.003) { 	GMT_psxy('-Gorange -N'); }
-	elsif ($dc_bres12_rms >= 0.0015) { 	GMT_psxy('-Gyellow -N'); }
-	else {								GMT_psxy('-Ggreen -N'); }
-		print(GMT "0.90 0.90\n0.935 0.90\n0.935 0.935\n");							
-	if ($dc_bres34_rms >= 0.005) { 		GMT_psxy('-Gred -N'); }
-	elsif ($dc_bres34_rms >= 0.003) { 	GMT_psxy('-Gorange -N'); }
-	elsif ($dc_bres34_rms >= 0.0015) { 	GMT_psxy('-Gyellow -N'); }
-	else {								GMT_psxy('-Ggreen -N'); }
-		print(GMT "0.945 0.90\n0.98 0.90\n0.945 0.935\n");							
-	if ($uc_bres12_rms >= 0.005) { 		GMT_psxy('-Gred -N'); }
-	elsif ($uc_bres12_rms >= 0.003) { 	GMT_psxy('-Gorange -N'); }
-	elsif ($uc_bres12_rms >= 0.0015) { 	GMT_psxy('-Gyellow -N'); }
-	else {								GMT_psxy('-Ggreen -N'); }
-		print(GMT "0.90 0.98\n0.935 0.98\n0.935 0.945\n");							
-	if ($uc_bres34_rms >= 0.005) { 		GMT_psxy('-Gred -N'); }
-	elsif ($uc_bres34_rms >= 0.003) { 	GMT_psxy('-Gorange -N'); }
-	elsif ($uc_bres34_rms >= 0.0015) { 	GMT_psxy('-Gyellow -N'); }
-	else {								GMT_psxy('-Ggreen -N'); }
-		print(GMT "0.945 0.98\n0.98 0.98\n0.945 0.945\n");							
-if (0) {
-	if ($dc_bres12_rms >= 0.005) { 		GMT_psxy('-Gred -N -Sc0.3'); }
-	elsif ($dc_bres12_rms >= 0.003) { 	GMT_psxy('-Gorange -N -Sc0.3'); }
-	elsif ($dc_bres12_rms >= 0.0015) { 	GMT_psxy('-Gyellow -N -Sc0.3'); }
-	else {								GMT_psxy('-Ggreen -N -Sc0.3'); }
-		print(GMT "0.92 0.96\n");							
-	if ($dc_bres34_rms >= 0.005) { 		GMT_psxy('-Gred -N -Sc0.3'); }
-	elsif ($dc_bres34_rms >= 0.003) { 	GMT_psxy('-Gorange -N -Sc0.3'); }
-	elsif ($dc_bres34_rms >= 0.0015) { 	GMT_psxy('-Gyellow -N -Sc0.3'); }
-	else {								GMT_psxy('-Ggreen -N -Sc0.3'); }
-		print(GMT "0.96 0.96\n");							
-	if ($uc_bres12_rms >= 0.005) { 		GMT_psxy('-Gred -N -Sc0.3'); }
-	elsif ($uc_bres12_rms >= 0.003) { 	GMT_psxy('-Gorange -N -Sc0.3'); }
-	elsif ($uc_bres12_rms >= 0.0015) { 	GMT_psxy('-Gyellow -N -Sc0.3'); }
-	else {								GMT_psxy('-Ggreen -N -Sc0.3'); }
-		print(GMT "0.92 0.92\n");							
-	if ($uc_bres34_rms >= 0.005) { 		GMT_psxy('-Gred -N -Sc0.3'); }
-	elsif ($uc_bres34_rms >= 0.003) { 	GMT_psxy('-Gorange -N -Sc0.3'); }
-	elsif ($uc_bres34_rms >= 0.0015) { 	GMT_psxy('-Gyellow -N -Sc0.3'); }
-	else {								GMT_psxy('-Ggreen -N -Sc0.3'); }
-		print(GMT "0.96 0.92\n");
-} 		
+	if ($dc_bres12_rms >= 0.005) { 		GMT_psxy('-W1,coral,8_2:0 -Gred -N'); }
+	elsif ($dc_bres12_rms >= 0.003) { 	GMT_psxy('-W1,coral,8_2:0 -Gorange -N'); }
+	elsif ($dc_bres12_rms >= 0.0015) { 	GMT_psxy('-W1,coral,8_2:0 -Gyellow -N'); }
+	else {								GMT_psxy('-W1,coral,8_2:0 -Ggreen -N'); }
+#		print(GMT "0.90 0.90\n0.935 0.90\n0.935 0.935\n");							
+		print(GMT "0.90 0.90\n0.935 0.90\n0.935 0.935\n0.90 0.935\n");							
+	if ($dc_bres34_rms >= 0.005) { 		GMT_psxy('-W1,coral,1_1:0 -Gred -N'); }
+	elsif ($dc_bres34_rms >= 0.003) { 	GMT_psxy('-W1,coral,1_1:0 -Gorange -N'); }
+	elsif ($dc_bres34_rms >= 0.0015) { 	GMT_psxy('-W1,coral,1_1:0 -Gyellow -N'); }
+	else {								GMT_psxy('-W1,coral,1_1:0 -Ggreen -N'); }
+#		print(GMT "0.945 0.90\n0.98 0.90\n0.945 0.935\n");							
+		print(GMT "0.945 0.90\n0.98 0.90\n0.98  0.935\n0.945 0.935\n");							
+	if ($uc_bres12_rms >= 0.005) { 		GMT_psxy('-W1,SeaGreen,8_2:0 -Gred -N'); }
+	elsif ($uc_bres12_rms >= 0.003) { 	GMT_psxy('-W1,SeaGreen,8_2:0 -Gorange -N'); }
+	elsif ($uc_bres12_rms >= 0.0015) { 	GMT_psxy('-W1,SeaGreen,8_2:0 -Gyellow -N'); }
+	else {								GMT_psxy('-W1,SeaGreen,8_2:0 -Ggreen -N'); }
+#		print(GMT "0.90 0.98\n0.935 0.98\n0.935 0.945\n");							
+		print(GMT "0.90 0.98\n0.935 0.98\n0.935 0.945\n0.90 0.945\n");							
+	if ($uc_bres34_rms >= 0.005) { 		GMT_psxy('-W1,SeaGreen,1_1:0 -Gred -N'); }
+	elsif ($uc_bres34_rms >= 0.003) { 	GMT_psxy('-W1,SeaGreen,1_1:0 -Gorange -N'); }
+	elsif ($uc_bres34_rms >= 0.0015) { 	GMT_psxy('-W1,SeaGreen,1_1:0 -Gyellow -N'); }
+	else {								GMT_psxy('-W1,SeaGreen,1_1:0 -Ggreen -N'); }
+#		print(GMT "0.945 0.98\n0.98 0.98\n0.945 0.945\n");							
+		print(GMT "0.945 0.98\n0.98 0.98\n0.98 0.945\n0.945 0.945\n");							
 	
 	GMT_pstext('-F+f14,Helvetica,blue+jTL -N');											# LABELS
 		print(GMT "0.01 -0.06 $P{out_basename} [$P{run_label}]\n");
@@ -230,49 +237,79 @@
 			print(GMT "0.02 0.98 b.track\n");
 	}
 
+# The following values were established manually in July 2021 with
+# a GMT version that does not seem to respect y, maybe because of
+# super-/subscripts.
+#	my(@y) = (1.020,1.056,1.090,1.135);	# 0.036, 0.034, 0.035
+#	my(@y) = (1.020,1.056,1.088,1.131);
+	my(@y) = (1.020,1.060,1.088,1.127);
+
 	GMT_pstext('-F+f9,Helvetica,CornFlowerBlue+jTL -N');
-		printf(GMT "0.64 1.020 %d kHz $LADCP{INSTRUMENT_TYPE} $P{ADCP_orientation}\n",
-				round($LADCP{BEAM_FREQUENCY},50));
-		printf(GMT "0.64 1.055 %s [%.1fm/%1.fm/%1.fm]\n",
-			$LADCP{BEAM_COORDINATES} ? 'beam vels' : 'Earth vels',
-			$LADCP{BLANKING_DISTANCE},$LADCP{TRANSMITTED_PULSE_LENGTH},$LADCP{BIN_LENGTH});
-		print(GMT "0.64 1.090 mean tilt\n 		0.77 1.096 :\n");
-		print(GMT "0.64 1.130 rms a\@-pkg\@-\n	0.77 1.1315 :\n");
+		printf(GMT "0.64 $y[0] %d kHz $LADCP{INSTRUMENT_TYPE} $P{ADCP_orientation}\n",
+					round($LADCP{BEAM_FREQUENCY},50));
+
+#		printf(GMT "0.64 1.055 %s [%.1fm/%1.fm/%1.fm]\n",
+#			$LADCP{BEAM_COORDINATES} ? 'beam vels' : 'Earth vels',
+#			$LADCP{BLANKING_DISTANCE},$LADCP{TRANSMITTED_PULSE_LENGTH},$LADCP{BIN_LENGTH});
+
+		print( GMT "0.64 $y[1] mean w\n			0.77 $y[1] :\n");
+		printf(GMT "0.64 $y[2] mean tilt\n 		0.77 %f :\n",$y[2]+0.007);
+		print( GMT "0.64 $y[3] rms a\@-pkg\@-\n	0.77 $y[3] :\n");
 
-	if ($P{dc_mean_tilt} < 4) {
+	if (abs($P{'dc_w.mu'} - $P{'uc_w.mu'}) < 0.005) {
 		GMT_pstext('-F+f9,Helvetica,coral+jTL -N');
-	} elsif ($P{dc_mean_tilt} < 8) {
+	} elsif (abs($P{'dc_w.mu'} - $P{'uc_w.mu'}) < 0.01) {
+		GMT_pstext('-F+f9,Helvetica,coral+jTL -Gyellow -N');
+    } else {
+		GMT_pstext('-F+f9,Helvetica,coral+jTL -Gred -N');
+    }
+	printf(GMT "0.78 %f %dmm/s\n",$y[1]-0.006,round($P{'dc_w.mu'}*1000));
+
+	if (abs($P{'dc_w.mu'} - $P{'uc_w.mu'}) < 0.005) {
+		GMT_pstext('-F+f9,Helvetica,SeaGreen+jTL -N');
+	} elsif (abs($P{'dc_w.mu'} - $P{'uc_w.mu'}) < 0.01) {
+		GMT_pstext('-F+f9,Helvetica,SeaGreen+jTL -Gyellow -N');
+    } else {
+		GMT_pstext('-F+f9,Helvetica,SeaGreen+jTL -Gred -N');
+    }
+	printf(GMT "0.89 %f %dmm/s\n",$y[1]-0.006,round($P{'uc_w.mu'}*1000));
+
+
+	if ($P{'dc_tilt.mu'} < 4) {
+		GMT_pstext('-F+f9,Helvetica,coral+jTL -N');
+	} elsif ($P{'dc_tilt.mu'} < 8) {
 		GMT_pstext('-F+f9,Helvetica,coral+jTL -Gyellow -N');
 	} else {
 		GMT_pstext('-F+f9,Helvetica,coral+jTL -Gred -N');
 	}
-			printf(GMT "0.808 1.090 %.1f\\260\n",$P{dc_mean_tilt});
-	if ($P{uc_mean_tilt} < 4) {
+	printf(GMT "0.808 $y[2] %.1f\\260\n",$P{'dc_tilt.mu'});
+
+	if ($P{'uc_tilt.mu'} < 4) {
 		GMT_pstext('-F+f9,Helvetica,SeaGreen+jTL -N');
-	} elsif ($P{uc_mean_tilt} < 8) {
+	} elsif ($P{'uc_tilt.mu'} < 8) {
 		GMT_pstext('-F+f9,Helvetica,SeaGreen+jTL -Gyellow -N');
 	} else {
 		GMT_pstext('-F+f9,Helvetica,SeaGreen+jTL -Gred -N');
 	}
-			printf(GMT "0.91 1.090 %.1f\\260\n",$P{uc_mean_tilt});
+	printf(GMT "0.91 $y[2] %.1f\\260\n",$P{'uc_tilt.mu'});
 
-	if ($P{dc_rms_accel_pkg} < 0.1) {
+	if ($P{'dc_accel_pkg.rms'} < 0.1) {
 		GMT_pstext('-F+f9,Helvetica,coral+jTL -Gblue -N');
-	} elsif ($P{dc_rms_accel_pkg} < 0.7) {
+	} elsif ($P{'dc_accel_pkg.rms'} < 0.7) {
 		GMT_pstext('-F+f9,Helvetica,coral+jTL -N');
 	} else {
 		GMT_pstext('-F+f9,Helvetica,coral+jTL -Gyellow -N');
 	}
-		printf(GMT "0.78 1.125 %.1fm/s\@+2\@+\n",$P{dc_rms_accel_pkg});
+	printf(GMT "0.78 %f %.1fm/s\@+2\@+\n",$y[3]-0.01,$P{'dc_accel_pkg.rms'});
 		
-	if ($P{uc_rms_accel_pkg} < 0.1) {
+	if ($P{'uc_accel_pkg.rms'} < 0.1) {
 		GMT_pstext('-F+f9,Helvetica,SeaGreen+jTL -Gblue -N');
-	} elsif ($P{uc_rms_accel_pkg} < 0.7) {
+	} elsif ($P{'uc_accel_pkg.rms'} < 0.7) {
 		GMT_pstext('-F+f9,Helvetica,SeaGreen+jTL -N');
 	} else {
 		GMT_pstext('-F+f9,Helvetica,SeaGreen+jTL -Gyellow -N');
 	}
-		printf(GMT "0.89 1.125 %.1fm/s\@+2\@+\n",$P{uc_rms_accel_pkg});
+	printf(GMT "0.89 %f %.1fm/s\@+2\@+\n",$y[3]-0.01,$P{'uc_accel_pkg.rms'});
 		
 	my($depth_tics) = ($plot_wprof_ymax-$plot_prof_ymin < 1000 ) ? 'f10a100' : 'f100a500';				# AXES
 	setR1();
--- a/plot_wsamp.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/plot_wsamp.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    P L O T _ W S A M P . P L 
 #                    doc: Tue Jul 28 13:21:09 2015
-#                    dlm: Tue Oct 29 13:15:41 2019
+#                    dlm: Thu Jul  1 13:31:53 2021
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 17 0 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 21 47 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -18,6 +18,7 @@
 #   May 24, 2016: - calc_binDepths() -> binDepths()
 #				  - fixed for partial-depth profiles
 #	Oct 29, 2019: - updated psscale -B to gmt5 syntax
+#	Jul  1, 2021: - adapted to more std %PARAMs
 
 require "$ANTS/libGMT.pl";
 
@@ -25,19 +26,19 @@
 {
 	my($pfn) = @_;
 
-	return unless ($P{max_depth});
+	return unless ($P{'depth.max'});
 
-	my($xmin) = $P{min_ens}-0.5;
-	my($xmax) = $P{max_ens}+0.5;
-	my($ymin) = round(antsParam('min_depth')-25,50);
+	my($xmin) = $P{'ens.min'}-0.5;
+	my($xmax) = $P{'ens.max'}+0.5;
+	my($ymin) = round(antsParam('depth.min')-25,50);
 	my($ymax) = ($P{water_depth} > 0) ?
 				round($P{water_depth}+25,50) :
-				round($P{max_depth}+$P{ADCP_bin_length}+25,50);
+				round($P{'depth.max'}+$P{ADCP_bin_length}+25,50);
 
 
-	my($ens_width) = 10 / ($P{max_ens} - $P{min_ens} + 1);
+	my($ens_width) = 10 / ($P{'ens.max'} - $P{'ens.min'} + 1);
 	my($bin_length) = 10 * $P{ADCP_bin_length} / 
-						($P{max_depth}-$P{min_depth}+$P{ADCP_bin_length});
+						($P{'depth.max'}-$P{'depth.min'}+$P{ADCP_bin_length});
 
 	my($R) = "-R$xmin/$xmax/$ymin/$ymax";
 	GMT_begin($pfn,'-JX10/-10',$R,'-P');
--- a/time_lag.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/time_lag.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    T I M E _ L A G . P L 
 #                    doc: Fri Dec 17 21:59:07 2010
-#                    dlm: Tue Oct 16 16:26:06 2018
+#                    dlm: Thu Jul  1 09:39:53 2021
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 80 38 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 81 46 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -78,6 +78,7 @@
 #						 Solution: remove very unpopular lags first
 #	Oct  4, 2018: - added timelagging debug code
 #	Oct 16, 2018: - removed debug code
+#	Jul  1, 2021: - made %PARAMs more standard
 
 # DIFFICULT STATIONS:
 #	NBP0901#131		this requires the search-radius doubling heuristic
@@ -159,7 +160,7 @@
 	my($n_windows,$w_size,$scan_increment,$first_ens,$last_ens) = @_;
 	my($search_radius) = $scan_increment==1 ? 3 : $w_size;
 
-	&antsAddParams('TL_max_allowed_three_lag_spread',$TL_max_allowed_three_lag_spread);
+	&antsAddParams('TL_allowed_three_lag_spread.max',$TL_max_allowed_three_lag_spread);
 
 	my($ctmsg);
 	if ($first_ens==$firstGoodEns && $last_ens==$lastGoodEns) 	{ $ctmsg = "full-cast"; }
--- a/time_series.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/time_series.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    T I M E _ S E R I E S . P L 
 #                    doc: Sun May 23 16:40:53 2010
-#                    dlm: Sun Apr 21 14:13:05 2019
+#                    dlm: Sat Apr 24 11:19:07 2021
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 25 56 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 26 27 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -23,6 +23,7 @@
 #	May  1, 2018: - added reflr u and v calculations
 #				  - BUG: reflr u and v calcs did not work
 #	Apr 21, 2019: - improved surface gap warning message
+#	Apr 24, 2021: - output cosmetics
 
 # NOTES:
 #	- resulting DEPTH field based on integrated w without any sound speed correction
@@ -110,7 +111,7 @@
             		 ($depth == $max_depth)) {										# biased in-air data
             		 	my($md) = defined($max_depth) ? sprintf('%d',$max_depth) : 'undefined';
 						warning(1,"long surface gap (%ds) --- restarting at ens#$dta->{ENSEMBLE}[$e]->{NUMBER} " .
-								  "[depth = %d m; max_depth = $md]\n",$dt,$depth);
+								  "[depth = %d m; max_depth = $md m]\n",$dt,$depth);
 						$firstgood = $lastgood = $e;
 						undef($atbottom); undef($max_depth);
 						$depth = 0;
--- a/version.pl	Sat Apr 10 06:00:45 2021 -0400
+++ b/version.pl	Sat Jul 24 10:35:41 2021 -0400
@@ -1,9 +1,9 @@
 #======================================================================
 #                    V E R S I O N . P L 
 #                    doc: Tue Oct 13 10:40:57 2015
-#                    dlm: Tue Mar 23 09:15:39 2021
+#                    dlm: Sat Jul 24 09:55:02 2021
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 29 46 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 32 68 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -27,6 +27,9 @@
 #			      - updated ADCP tools to V2.2
 #	Sep 12, 2019: - updated to V1.5 because of CTD gap correction
 #	Mar 23, 2021: - updated ADCP_tools to V2.4
+#	Jun 29, 2021: - updated ANTSlib to V7.2
+#	Jul  1, 2021: - updated ANTSlib to V7.3
+#	Jul 24, 2021: - updated to V2.0 (major improvements) for release
 
 #$VERSION = '1.1';				# Jan  4, 2016
 #$VERSION = '1.2';				# May 12, 2016
@@ -34,7 +37,7 @@
 #$VERSION = '1.4';				# Nov 28, 2017
 $VERSION = '1.5';				# Sep 12, 2018
 
-$antsMinLibVersion 		= 7.1;
+$antsMinLibVersion 		= 7.3;
 $ADCP_tools_minVersion 	= 2.4;
 
 use lib '.';