--- a/.lsfit.poly
+++ b/.lsfit.poly
@@ -1,9 +1,9 @@
#======================================================================
# . L S F I T . P O L Y
# doc: Wed Feb 24 09:40:06 1999
-# dlm: Sun May 13 08:25:37 2018
+# dlm: Mon May 11 11:54:03 2020
# (c) 1999 A.M. Thurnherr
-# uE-Info: 114 36 NIL 0 0 72 2 2 4 NIL ofnI
+# uE-Info: 31 55 NIL 0 0 72 2 2 4 NIL ofnI
#======================================================================
# What you need to provide if you wanna fit a different
@@ -28,6 +28,7 @@
# Sep 19, 2011: - moved part of the usage code into init() to allow use in [pgram]
# Jan 10, 2013: - added extremum output when fitting parabola (-o 2)
# May 13, 2018: - BUG: replaced opt_o with modelNFit in &modelCleanup()
+# May 11, 2020: - increased extremum output precision
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
@@ -115,11 +116,11 @@
my($extX) = -$A[2] / (2 * $A[3]);
if ($A[3] > 0) {
- &antsInfo(".lsfit.poly: minimum at %.1f",$extX);
+ &antsInfo(".lsfit.poly: minimum at %g",$extX);
} elsif ($A[3] < 0) {
- &antsInfo(".lsfit.poly: maximum at %.1f",$extX);
+ &antsInfo(".lsfit.poly: maximum at %g",$extX);
} else {
- &antsInfo(".lsfit.poly: saddle point at %.1f",$extX);
+ &antsInfo(".lsfit.poly: saddle point at %g",$extX);
}
}
--- a/libDeines99.pl
+++ b/libDeines99.pl
@@ -1,11 +1,13 @@
#======================================================================
# L I B D E I N E S 9 9 . P L
# doc: Wed Apr 15 11:57:01 2020
-# dlm: Wed Apr 15 11:57:01 2020
+# dlm: Thu May 7 16:06:56 2020
# (c) 2020 A.M. Thurnherr
-# uE-Info: 14 2 NIL 0 0 70 0 2 4 NIL ofnI
+# uE-Info: 9 34 NIL 0 0 70 0 2 4 NIL ofnI
#======================================================================
+# Acoustic Backscatter Coefficient [db]
+
sub Sv($$$$$)
{
my($temp,$pulse_length,$noise_level,$range,$echo_amplitude) = @_;
--- a/libRDI_Coords.pl
+++ b/libRDI_Coords.pl
@@ -1,9 +1,9 @@
#======================================================================
# R D I _ C O O R D S . P L
# doc: Sun Jan 19 17:57:53 2003
-# dlm: Wed Mar 28 12:30:12 2018
+# dlm: Mon Jun 29 10:59:01 2020
# (c) 2003 A.M. Thurnherr
-# uE-Info: 109 22 NIL 0 0 72 10 2 4 NIL ofnI
+# uE-Info: 61 83 NIL 0 0 72 10 2 4 NIL ofnI
#======================================================================
# RDI Workhorse Coordinate Transformations
@@ -57,6 +57,8 @@
# Nov 26, 2017: - BUG: velBeamtoBPEarth() did not respect missing values
# Nov 27, 2017: - BUG: numbersp() from [antslib.pl] was used
# Mar 28, 2018: - added &loadInstrumentTransformation()
+# Jun 5, 2020: - added sscorr_w & sscorr_w_mooring
+# Jun 29, 2020: - added comments for sscorr_w, which conflicts with LADCP_w_ocean
use strict;
use POSIX;
@@ -673,5 +675,61 @@
}
#----------------------------------------------------------------------
+# Sound Speed Correction for Vertical Velocity
+# - Usage: sscorr_w(<observed w>,<beam_angle>,<ADCP sVel setup>,salin,temp,press,<vertical temp. gradient>
+#----------------------------------------------------------------------
+
+sub sscorr_w($$$$$$$$)
+{
+ my($w,$beamAngle,$ssADCP,$salin,$temp,$press,$dz,$dtdz) = @_;
+
+ return 'nan' unless numberp($w);
+ my($tanSqBeamAngle) = tan(rad($beamAngle))**2;
+
+ my($ssXD) = sVel($salin,$temp,$press);
+ my($ssBin) = sVel($salin,$temp+$dz*$dtdz,$press-$dz);
+ my($Kn) = sqrt(1 + (1 - $ssBin/$ssXD)**2 * $tanSqBeamAngle);
+ return $w * $ssBin/$ssADCP / $Kn;
+}
+
+#----------------------------------------------------------------------
+# Sound Speed Correction for Vertical Velocity
+# - Usage: sscorr_w_mooring(\$ADCP,<ens-idx>,<bin-idx>,<press>,<salin>,<vertical temp. gradient>)
+# - Notes:
+# - RDI Coord. Trans. manual sec. 4.1
+# - manual error: the ^2 applies to the []
+# - difference between pressure and depth over instrument range ignored
+# - Assumptions:
+# - libEOS83.pl loaded
+# - $ADCP{ENSEMBLE}[$ens-idx]->VELOCITY}[2] contains measured w
+# - sound speed variation dominated by temperature
+# - vertical temperature gradient is constant in time (violated
+# at least on superinertial time scales)
+#----------------------------------------------------------------------
+
+sub sscorr_w_mooring($$$$$)
+{
+ my($ADCP,$ei,$bi,$press,$salin,$dtdz) = @_;
+
+ my($w) = $ADCP->{ENSEMBLE}[$ei]->{VELOCITY}[2];
+ return 'nan' unless numberp($w);
+
+ my($tanSqBeamAngle) = tan(rad($ADCP->{BEAM_ANGLE}))**2;
+
+ $Global::P{ITS} = 90;
+ my($ssXD) = sVel($salin,$ADCP->{ENSEMBLE}[$ei]->{TEMPERATURE},$press);
+ my($ssADCP) = $ADCP->{ENSEMBLE}[$ei]->{SPEED_OF_SOUND};
+
+ my($dz) = $ADCP->{ENSEMBLE}[$ei]->{BLANKING_DISTANCE} + $bi * $ADCP->{ENSEMBLE}[$ei]->{BIN_LENGTH};
+ $dz *= -1 if ($ADCP->{ENSEMBLE}[$ei]->{XDUCER_FACING_DOWN}); # z increases upward
+
+ my($ssBin) = sVel($salin,
+ $ADCP->{ENSEMBLE}[$ei]->{TEMPERATURE} + $dz*$dtdz,
+ $press-$dz); # ignore press/depth difference across range
+
+ my($Kn) = sqrt(1 + (1 - $ssBin/$ssXD)**2 * $tanSqBeamAngle); # RDI manual
+ return $w * $ssBin/$ssADCP / $Kn;
+}
+
1;
--- a/libvec.pl
+++ b/libvec.pl
@@ -1,9 +1,9 @@
#======================================================================
# L I B V E C . P L
# doc: Sat Mar 20 12:50:32 1999
-# dlm: Thu May 24 21:51:20 2018
+# dlm: Mon Mar 1 08:46:35 2021
# (c) 1999 A.M. Thurnherr
-# uE-Info: 170 0 NIL 0 0 70 2 2 4 NIL ofnI
+# uE-Info: 45 70 NIL 0 0 70 2 2 4 NIL ofnI
#======================================================================
# HISTORY:
@@ -42,6 +42,7 @@
# system)
# Aug 7, 2016: - made vel_u and vel_v deal with nans
# Nov 15, 2017: - re-enabled usage-message (of sorts) for vel_u only
+# Mar 1, 2021: - adapted rotation_ts and angle_ts to deal with nans
require "$ANTS/libPOSIX.pl"; # acos()
@@ -210,7 +211,8 @@
sub rotation_ts(@)
{
- my($a) = &antsFunUsage(1,"f","<angle>",@_);
+ my($a) = &antsFunUsage(1,".","<angle>",@_);
+ return nan unless numberp($a);
my($rot) = defined($last_in) ? angle_diff($a,$last_in) : nan;
$last_in = $a;
@@ -222,7 +224,8 @@
sub angle_ts(@)
{
- my($a) = &antsFunUsage(1,"f","<angle>",@_);
+ my($a) = &antsFunUsage(1,".","<angle>",@_);
+ return nan unless numberp($a);
$last_out = $last_in = $a
unless (defined($last_in));