.
authorA.M. Thurnherr <ant@ldeo.columbia.edu>
Mon, 15 Apr 2013 13:19:28 -0400
changeset 11 9c3b147b4372
parent 10 c835cd613f3e
child 12 0f89b1523648
.
RDI_Utils.pl
listEns
mkProfile
--- 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: Wed Mar 27 14:45:02 2013
+#                    dlm: Fri Apr 12 09:22:10 2013
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 43 51 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 44 68 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # miscellaneous RDI-specific utilities
@@ -41,6 +41,7 @@
 #	Sep 21, 2011: - added calculation of RMS heave acceleration
 #	Mar 27, 2013: - BUG: 3-beam solutions were not used in ref_lr_w
 #				  - disabled apparently unused code
+#	Apr 12, 2013: - added $min_pctg as optional parameter to mk_prof
 
 use strict;
 
@@ -217,9 +218,9 @@
 #	mk_prof($dta,$check,$filter,$lr_b0,$lr_b1,$min_corr,$max_e,$max_gap);
 #======================================================================
 
-sub ref_lr_w($$$$$$)								# calc ref-level vert vels
+sub ref_lr_w($$$$$$$)								# calc ref-level vert vels
 {
-	my($dta,$ens,$rl_b0,$rl_b1,$min_corr,$max_e) = @_;
+	my($dta,$ens,$rl_b0,$rl_b1,$min_corr,$max_e,$min_pctg) = @_;
 	my($i,@n,@bn,@v,@vel,@bv,@w);
 
 	for ($i=$rl_b0; $i<=$rl_b1; $i++) {
@@ -233,13 +234,13 @@
 			if ($dta->{ENSEMBLE}[$ens]->{CORRELATION}[$i][3] < $min_corr);
 		if ($dta->{BEAM_COORDINATES}) {
 			undef($dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i][0])
-				if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][0] < 100);
+				if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][0] < $min_pctg);
 			undef($dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i][1])
-				if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][1] < 100);
+				if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][1] < $min_pctg);
 			undef($dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i][2])
-				if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][2] < 100);
+				if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][2] < $min_pctg);
 			undef($dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i][3])
-	            if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][3] < 100);
+	            if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][3] < $min_pctg);
 			@v = velInstrumentToEarth($dta,$ens,
 					velBeamToInstrument($dta,
 						@{$dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i]}));
@@ -247,7 +248,7 @@
 			next if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][0] > 0 ||
 					 $dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][1] > 0 ||
 					 $dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][2] > 0 ||
-					 $dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][3] < 100);
+					 $dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][3] < $min_pctg);
 			@v = @{$dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i]};
 			# NB: no need to apply heading bias, as long as we only use w!
 		}
@@ -301,11 +302,13 @@
 }
 
 
-sub mk_prof($$$$$$$$)										# make profile
+sub mk_prof(...)											# make profile
 {
-	my($dta,$check,$filter,$lr_b0,$lr_b1,$min_corr,$max_e,$max_gap) = @_;
+	my($dta,$check,$filter,$lr_b0,$lr_b1,$min_corr,$max_e,$max_gap,$min_pctg) = @_;
 	my($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz);
 	my($rms_heave_accel_ssq,$rms_heave_accel_nsamp);
+
+	$min_pctg = 100 unless defined($min_pctg);
 	
 	for (my($z)=0,my($e)=0; $e<=$#{$dta->{ENSEMBLE}}; $e++) {
 		checkEnsemble($dta,$e) if ($check);
@@ -317,7 +320,7 @@
 		filterEnsemble($dta,$e)
 			if (defined($filter) &&
 				$dta->{ENSEMBLE}[$e]->{PERCENT_GOOD}[0][0] > 0);
-		ref_lr_w($dta,$e,$lr_b0,$lr_b1,$min_corr,$max_e);	# ref. layer w
+		ref_lr_w($dta,$e,$lr_b0,$lr_b1,$min_corr,$max_e,$min_pctg);	# ref. layer w
 	
 		if (defined($firstgood)) {
 			$dta->{ENSEMBLE}[$e]->{ELAPSED_TIME} =			# time since start
--- a/listEns
+++ b/listEns
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L I S T E N S 
 #                    doc: Sat Jan 18 18:41:49 2003
-#                    dlm: Wed Mar 20 11:52:46 2013
+#                    dlm: Fri Apr 12 10:37:10 2013
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 38 45 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 39 49 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # Print useful info from the ensemble list or dump ensembles to
@@ -36,6 +36,7 @@
 #	Jan  5, 2011: - added -b
 #	May 12, 2011: - disabled error exit on built-in-test errors when ensembles are dumped to stdout
 #	Mar 20, 2013: - removed DATA_FORMAT stuff
+#	Apr 12, 2013: - added bin number to -E output
 
 # Notes:
 #	- -E outputs data in earth coordinates, unless -b is set also
@@ -167,7 +168,7 @@
 					"\n"
 			);
 			print(P "#ANTS#FIELDS# " .
-					"{dz} {u} {v} {w} {e} {cor1} {cor2} {cor3} {cor4} " .
+					"{bin} {dz} {u} {v} {w} {e} {cor1} {cor2} {cor3} {cor4} " .
 					"{amp1} {amp2} {amp3} {amp4} "
 			);
 			if ($beamCoords) {
@@ -203,7 +204,7 @@
 				$v[2] = nan unless defined($v[2]);
 				$v[3] = nan unless defined($v[3]);
 				my(@out) = (
-					$dz,$v[0],$v[1],$v[2],$v[3],
+					$b,$dz,$v[0],$v[1],$v[2],$v[3],
 					@{$dta{ENSEMBLE}[$e]->{CORRELATION}[$b]},
 					@{$dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b]},
 					@{$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b]}
--- 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 Sep 21 12:03:14 2011
+#                    dlm: Fri Apr 12 09:24:14 2013
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 747 30 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 269 72 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # Make an LADCP Profile by Integrating W (similar to Firing's scan*).
@@ -78,6 +78,7 @@
 #	Sep  9, 2011: - BUG: range calculation for Earth coordinate data included bins without
 #						 valid velocities
 #	Sep 21, 2010: - added %rms_heave_acceleration
+#	Apr 12, 2013: - added -p
 
 # NOTES:
 #	- the battery values are based on transmission voltages (different
@@ -105,13 +106,13 @@
 	"[-s)uppress checkensemble()] " .
 	"[require -4)-beam solutions] " .
 	"[-r)ef-layer <bin|1,bin|6>] [-n) vels <min|2>] " .
-	"[-e)rr-vel <max|0.1>] [-c)orrelation <min>] " .
+	"[-e)rr-vel <max[0.1]] [-c)orrelation <min>] [-p)ct-good <min[100]>] " .
 	"[-m)ax <gap>] " .
 	"[-d)rift <dx,dy>] [-g)ps <start lat,lon/end lat,lon>] " .
 	"[output -f)ields <field[,...]> " .
 	"[-M)agnetic <declination>] [profile -B)ottom <depth>] " .
 	"<RDI file>\n")
-		unless (&Getopts("4AB:F:M:Qd:r:n:e:c:g:f:m:s") && @ARGV == 1);
+		unless (&Getopts("4AB:F:M:Qd:r:n:e:c:g:f:m:sp:") && @ARGV == 1);
 
 $RDI_Coords::minValidVels = 4 if ($opt_4);			# no 3-beam solutions
 
@@ -122,6 +123,7 @@
 $opt_e = 0.1   	unless defined($opt_e);
 $opt_c = 70	   	unless defined($opt_c);
 $opt_m = 120	unless defined($opt_m);
+$opt_p = 100	unless defined($opt_p);
 
 ($minb,$maxb) = split(',',$opt_r);					# reference layer
 die("$0: can't decode -r $opt_r\n") unless defined($maxb);
@@ -264,7 +266,7 @@
 #======================================================================
 
 ($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz,$rms_heave_accel) =
-	mk_prof(\%dta,!$opt_s,$opt_F,$minb,$maxb,$opt_c,$opt_e,$opt_m);
+	mk_prof(\%dta,!$opt_s,$opt_F,$minb,$maxb,$opt_c,$opt_e,$opt_m,$opt_p);
 
 unless (($atbottom > $firstgood) && ($lastgood > $atbottom)) {
 	if ($opt_Q) {