end of EN620
authorAndreas Thurnherr <ant@ldeo.columbia.edu>
Sun, 21 Oct 2018 19:53:09 -0400
changeset 44 b7654ea68af6
parent 42 80d039881d2c
child 45 5767cbe470a0
end of EN620
RDI_PD0_IO.pl
listBins
meanProf
--- a/RDI_PD0_IO.pl
+++ b/RDI_PD0_IO.pl
@@ -1,9 +1,9 @@
 #======================================================================
 #                    R D I _ P D 0 _ I O . P L 
 #                    doc: Sat Jan 18 14:54:43 2003
-#                    dlm: Sat Dec 23 16:03:46 2017
+#                    dlm: Fri Feb  2 12:49:54 2018
 #                    (c) 2003 A.M. Thurnherr
-#					 uE-Info: 1184 24 NIL 0 0 72 2 2 4 NIL ofnI
+#					 uE-Info: 772 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 	
 # Read RDI PD0 binary data files (*.[0-9][0-9][0-9])
--- 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: Sat Dec 23 16:10:11 2017
+#                    dlm: Wed Aug 29 07:23:21 2018
 #                    (c) 2006 A.M. Thurnherr
-#                    uE-Info: 104 28 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 136 20 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # Split data file into per-bin time series.
@@ -66,6 +66,7 @@
 #				  - BUG: 3-beam %ages were incorrect: 1) they were based on goodvels instead of the
 #						 entire ensemble range; 2) pings-per-ensemble were not considered
 #				  - BUG: output layout was all messed up for non-valid velocities
+#	Aug 29, 2018: - added error message on -r decoding failures
 
 # General Notes:
 #	- everything (e.g. beams) is numbered from 1
@@ -132,8 +133,11 @@
 $opt_o = '>bin%d.raw' unless defined($opt_o);
 $ifn = $ARGV[0];
 
-($first_ens,$last_ens) = split(',',$opt_r)
-	if defined($opt_r);
+if (defined($opt_r)) {
+	($first_ens,$last_ens) = split(',',$opt_r);
+	die("Cannot decode -r $opt_r\n")
+		unless ($first_ens>0 && $last_ens>$first_ens);
+}
 
 if (defined($opt_S)) {
 	($SS_salin,$SS_temp,$SS_depth) = split(',',$opt_S);
--- a/meanProf
+++ b/meanProf
@@ -2,9 +2,9 @@
 #======================================================================
 #                    M E A N P R O F 
 #                    doc: Fri Feb 22 08:40:18 2008
-#                    dlm: Wed Mar 16 07:02:38 2016
+#                    dlm: Fri Aug 24 13:45:21 2018
 #                    (c) 2008 A.M. Thurnherr
-#                    uE-Info: 14 49 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 15 71 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # extract time-averaged mean profile from ADCP data
@@ -12,6 +12,7 @@
 # HISTORY:
 #	Feb 22, 2008: - created from [listBins]
 #	Mar 16, 2016: - adapted to new Getopt library
+#	Aug 24, 2018: - BUG: code bombed when there are no 4-beam solutions
 
 # Soundspeed Correction:
 #	- applied as described in the RDI coord-trans manual
@@ -194,7 +195,8 @@
 	$mean_pcg3[$b] = $sum_pcg3[$b] / $n_pcg3[$b]; $mean_pcg4[$b] = $sum_pcg4[$b] / $n_pcg4[$b];
 	$mean_u[$b] = $sum_u[$b] / $good_vels[$b]; $mean_v[$b] = $sum_v[$b] / $good_vels[$b];
 	$mean_w[$b] = $sum_w[$b] / $good_vels[$b];
-	$mean_e[$b] = $sum_e[$b] / ($good_vels[$b] - $three_beam[$b]);
+	$mean_e[$b] = $sum_e[$b] / ($good_vels[$b] - $three_beam[$b])
+		if ($good_vels[$b] - $three_beam[$b] > 0);
 }
 
 for ($e=$fe; $e<=$le; $e++) {