V1.2 release candidate
authorA.M. Thurnherr <athurnherr@yahoo.com>
Thu, 07 May 2015 13:09:03 +0000
changeset 23 fb0c269b1eaa
parent 22 051b45f1c571
child 24 1a761865f839
V1.2 release candidate
HISTORY
RDI_Utils.pl
listBins
mkProfile
splitPD0
splitRDI
--- a/HISTORY
+++ b/HISTORY
@@ -1,9 +1,9 @@
 ======================================================================
                     H I S T O R Y 
                     doc: Tue May 15 18:04:39 2012
-                    dlm: Fri Jul 12 12:46:50 2013
+                    dlm: Thu May  7 13:08:32 2015
                     (c) 2012 A.M. Thurnherr
-                    uE-Info: 17 30 NIL 0 0 72 3 2 8 NIL ofnI
+                    uE-Info: 21 64 NIL 0 0 72 3 2 8 NIL ofnI
 ======================================================================
 
 May 15, 2012:
@@ -16,3 +16,7 @@
   - V1.1 [.hg/hgrc]
   - various minor improvements
 
+May  7, 2015:
+  - V1.2 [.hg/hgrc]
+  - version used for LADCPproc V1.3 (Explorer/Slocum processing)
+
--- a/RDI_Utils.pl
+++ b/RDI_Utils.pl
@@ -1,9 +1,9 @@
 #======================================================================
 #                    R D I _ U T I L S . P L 
 #                    doc: Wed Feb 12 10:21:32 2003
-#                    dlm: Thu May 29 09:23:46 2014
+#                    dlm: Sun Mar 22 10:19:08 2015
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 302 0 NIL 0 0 72 10 2 4 NIL ofnI
+#                    uE-Info: 494 98 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # miscellaneous RDI-specific utilities
@@ -50,6 +50,7 @@
 #	Feb 22, 2014: - changed gap heuristic
 #			      - Earth coord beam-pair warning removed
 #	May 29, 2014: - removed unused code (disabled warning) from ref_lr_w
+#	Mar 22, 2015: - BUG: mk_prof could bomb because of division-by-zero in return statement
 
 use strict;
 
@@ -489,7 +490,8 @@
 	
 	filterEnsembleStats() if defined($filter);
 
-	return ($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz,sqrt($rms_heave_accel_ssq/$rms_heave_accel_nsamp));
+	return ($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz,
+			($rms_heave_accel_nsamp>0) ? sqrt($rms_heave_accel_ssq/$rms_heave_accel_nsamp) : 'nan');
 }
 
 #----------------------------------------------------------------------
--- a/listBins
+++ b/listBins
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L I S T B I N S 
 #                    doc: Fri Aug 25 15:57:05 2006
-#                    dlm: Mon Nov 24 19:46:05 2014
+#                    dlm: Sun Mar 22 12:22:47 2015
 #                    (c) 2006 A.M. Thurnherr
-#                    uE-Info: 284 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 63 63 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # Split data file into per-bin time series.
@@ -49,11 +49,19 @@
 #   Mar  4, 2014: - added support for missing PITCH/ROLL/HEADING
 #	Apr 22, 2014: - BUG: extraneous semicolon
 #	Nov 24, 2014: - enabled -w always
+#	Mar 22, 2015: - replaced -f by -o (allowing for pipes)
 
 # General Notes:
 #	- everything (e.g. beams) is numbered from 1
 #	- no support for BT data
 
+# Post-Processing:
+#	- e.g. in a Makefile,
+#		BFILT = | list -Lconv ensemble elapsed dn12='str2dec_time(\$$date,\$$time,2012)' heading pitch roll temp u v w err_vel w12 w34 corr1 corr2 corr3 corr4 amp1 amp2 amp3 amp4 > `basename $@ .b1`.b%d
+#	- used as follows
+#		listBins -o "${BFILT}"
+#	- this writes only the interesting fields and calculates a 2012-referenced decimal day field
+
 # Soundspeed Correction:
 #	- applied as described in the RDI coord-trans manual
 #	- sound-speed variation over range is ignored (valid for small gradients)
@@ -76,8 +84,8 @@
 require "$1RDI_Utils.pl";
 
 die("Usage: $0 [-r)ange <first_ens,last_ens>] [-R)enumber ensembles] " .
-			  "[output -f)ile <pat[bin%d.raw]>] " .
-			  "[-a)ll ens (not just those with good vels)] " .
+			  "[-o)utput <redirection[>bin%d.raw]>] " .
+			  "[output -a)ll ens (not just those with good vels)] " .
 			  "[-M)agnetic <declination>] " .
 			  "[-S)oundspeed correction <salin|*,temp|*,depth|*> " .
 			  "[-P)itch/Roll <bias/bias>] [-B)eamvel <bias/bias/bias/bias>] " .
@@ -85,7 +93,7 @@
 		 	  "[-p)ct-good <min>] " .
 		 	  "[output -b)eam coordinates] " .
 			  "<RDI file>\n")
-	unless (&Getopts("4abB:d:f:M:p:r:P:RS:") && @ARGV == 1);
+	unless (&Getopts("4abB:d:M:o:p:r:P:RS:") && @ARGV == 1);
 
 ($P{pitch_bias},$P{roll_bias}) = split('[,/]',$opt_P);
 ($P{velbias_b1},$P{velbias_b2},$P{velbias_b3},$P{velbias_b4}) = split('[,/]',$opt_B);
@@ -103,7 +111,7 @@
 print(STDERR "WARNING: magnetic declination not set!\n")
 	unless defined($opt_M) || defined($opt_b);
 
-$opt_f = 'bin%d.raw' unless defined($opt_f);
+$opt_o = '>bin%d.raw' unless defined($opt_o);
 $ifn = $ARGV[0];
 
 ($first_ens,$last_ens) = split(',',$opt_r)
@@ -130,9 +138,9 @@
 sub dumpBin($$$)						# write time series of single bin
 {
 	my($b,$fe,$le) = @_;
-	my($file) = sprintf($opt_f,$b+1);
+	my($out) = sprintf($opt_o,$b+1);
 
-	open(P,">$file") || die("$file: $!\n");
+	open(P,"$out") || die("$out: $!\n");
 	print(P "#ANTS#PARAMS# ");
 	foreach my $k (keys(%P)) {
 		print(P "$k\{$P{$k}\} ");
@@ -176,7 +184,7 @@
 		print(P "$dta{ENSEMBLE}[$e]->{NUMBER} ");
 		print(P "$dta{ENSEMBLE}[$e]->{DATE} ");
 		print(P "$dta{ENSEMBLE}[$e]->{TIME} ");
-		printf(P "%d ",$dta{ENSEMBLE}[$e]->{UNIX_TIME}-$t0);
+		printf(P "%d ",$dta{ENSEMBLE}[$e]->{UNIX_TIME}-$t0);		# elapsed time
 		print(P defined($dta{ENSEMBLE}[$e]->{HEADING}) ? "$dta{ENSEMBLE}[$e]->{HEADING} " : 'nan ');
 		print(P defined($dta{ENSEMBLE}[$e]->{PITCH}) ? "$dta{ENSEMBLE}[$e]->{PITCH} " : 'nan ');
 		print(P defined($dta{ENSEMBLE}[$e]->{ROLL}) ? "$dta{ENSEMBLE}[$e]->{ROLL} " : 'nan ');
--- a/mkProfile
+++ b/mkProfile
@@ -2,9 +2,9 @@
 #======================================================================
 #                    M K P R O F I L E 
 #                    doc: Sun Jan 19 18:55:26 2003
-#                    dlm: Wed Nov  5 13:02:59 2014
+#                    dlm: Sun Mar 22 10:22:46 2015
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 255 17 NIL 0 0 72 10 2 4 NIL ofnI
+#                    uE-Info: 91 63 NIL 0 0 72 10 2 4 NIL ofnI
 #======================================================================
 
 # Make an LADCP Profile by Integrating W (similar to Firing's scan*).
@@ -88,6 +88,7 @@
 #	Mar  4, 2014: - added support to allow missing PITCH/ROLL/HEADING values
 #	May 24, 2014: - finally added (gimbal-)pitch & roll to default output
 #				  - renamed heading to hdg and pitchroll to tilt
+#	Mar 22, 2015: - made it work for moored time series as well
 
 # NOTES:
 #	- the battery values are based on transmission voltages (different
@@ -255,6 +256,9 @@
 	print(STDERR "$ARGV[0]: truncated file (ends at max depth)\n")
 } elsif (($atbottom > $firstgood) && ($lastgood > $atbottom)) {
 	# all good
+} elsif ($lastgood > $firstgood) {
+	print(STDERR "$ARGV[0]: no bottom depth found\n")
+		unless ($atbottom > 0);
 } else {
 	if ($opt_Q) {
 		print(STDERR "$ARGV[0]: no valid cast data found\n");
rename from splitRDI
rename to splitPD0