post IWISE_2011
authorA.M. Thurnherr <ant@ldeo.columbia.edu>
Sat, 09 Jul 2011 15:08:37 -0400
changeset 7 e06925788055
parent 6 603221e51c6f
child 8 7ad053ea1742
post IWISE_2011
mkProfile
splitRDI
--- 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 Jan  5 01:05:50 2011
+#                    dlm: Wed Jun 22 05:39:48 2011
 #                    (c) 2003 A.M. Thurnherr
-#                    uE-Info: 233 47 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 245 0 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # Make an LADCP Profile by Integrating W (similar to Firing's scan*).
@@ -72,6 +72,9 @@
 #	Dec 10, 2010: - made mkProfile exit with status 0 if no good ens found but -Q is set
 #	Dec 19, 2010: - finally made -A default and activated output file
 #	Jan  5, 2011: - made no-good-ensembles found test much more robust
+#	Jun 22, 2011: - added bandwith/power warnings
+#				  - added ping-interval calculation
+#				  - BUG: post-recovery rotations were always zero
 
 # NOTES:
 #	- the battery values are based on transmission voltages (different
@@ -144,6 +147,7 @@
 } elsif (!$dta{EARTH_COORDINATES}) {
 	die("$ARGV[0]: only beam and earth coordinates implemented so far\n");
 }
+
 if (defined($opt_M)) {								# magnetic declination
 	$dta{HEADING_BIAS} = -1*$opt_M;
 } else {
@@ -219,6 +223,36 @@
 }
 
 #======================================================================
+# Step 0: Check data & Calculate Ping Rates
+#======================================================================
+
+unless ($dta{NARROW_BANDWIDTH}) {
+	print(STDERR "WARNING: $0 WIDE BANDWIDTH!\n");
+}
+
+unless ($dta{TRANSMIT_POWER_HIGH}) {
+	print(STDERR "WARNING: $0 LOW TRANSMIT POWER!\n");
+}
+
+printf(STDERR "# of ensembles       : %d\n",scalar(@{$dta{ENSEMBLE}}));
+
+my($sdt1,$sdt2,$ndt);
+my($mindt1) = my($mindt2) = 9e99;
+my($maxdt1) = my($maxdt2) = 0;
+for (my($e)=2; $e<=$#{$dta{ENSEMBLE}}; $e+=2,$ndt++) {
+	my($dt1) = $dta{ENSEMBLE}[$e-1]->{UNIX_TIME} - $dta{ENSEMBLE}[$e-2]->{UNIX_TIME};
+	my($dt2) = $dta{ENSEMBLE}[$e-0]->{UNIX_TIME} - $dta{ENSEMBLE}[$e-1]->{UNIX_TIME};
+	$mindt1 = $dt1 if ($dt1 < $mindt1);
+	$mindt2 = $dt2 if ($dt2 < $mindt2);
+	$maxdt1 = $dt1 if ($dt1 > $maxdt1);
+	$maxdt2 = $dt2 if ($dt2 > $maxdt2);
+	$sdt1 += $dt1; $sdt2 += $dt2;
+}
+
+printf(STDERR "Ping intervals       : %.1fs/%.1fs (%.1fs-%.1fs/%.1fs-%.1fs)\n",
+			$sdt1/$ndt,$sdt2/$ndt,$mindt1,$maxdt1,$mindt2,$maxdt2);
+
+#======================================================================
 # Step 1: Integrate w & determine water depth 
 #======================================================================
 
@@ -623,7 +657,7 @@
 }
 $upprrms = $prrms - $dnprrms;
 
-for (; $e<=$#{$dta->{ENSEMBLE}}; $e++) {		# post-recovery
+for (; $e<=$#{$dta{ENSEMBLE}}; $e++) {			# post-recovery
 	$postrot += rot($e);
 }
 
@@ -642,7 +676,6 @@
 # PRODUCE OUTPUT
 #======================================================================
 
-printf(STDERR "# of ensembles       : %d\n",scalar(@{$dta{ENSEMBLE}}));
 printf(STDERR "Start of cast        : %s (#%5d) at %6.1fm\n",
 					$dta{ENSEMBLE}[$firstgood]->{TIME},
 					$dta{ENSEMBLE}[$firstgood]->{NUMBER},
--- a/splitRDI
+++ b/splitRDI
@@ -2,15 +2,16 @@
 #======================================================================
 #                    S P L I T R D I 
 #                    doc: Sat Aug 21 22:20:27 2010
-#                    dlm: Sat Aug 21 23:18:41 2010
+#                    dlm: Fri Jun 24 11:30:06 2011
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 51 44 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 27 68 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # split RDI files based on list of ensemble numbers (e.g. from yoyo -t)
 
 # HISTORY:
 #	Aug 21, 2010: - created
+#	Jun 24, 2011: - replaced -b, -n by -o
 
 # NOTES:
 #	- it is assumed that the input file begins with ensemble #1
@@ -18,21 +19,27 @@
 #	- turning-point ensembles are written to preceding profile,
 #	  for compatibility with [yoyo]
 
+# FILE NAME CONVENTION:
+#	- in order to assign individual yoyo casts numerical station numbers,
+#	  by default, the yoyo cast number is inserted after the station number
+
+# EXAMPLE:
+#	splitRDI 017DL000.000 `mkProfile 017DL000.000 | yoyo -QFens -ut`
+
 $0 =~ m{(.*/)[^/]+};
 require "$1RDI_BB_Read.pl";
 use Getopt::Std;
 
 die("Usage: $0 " .
-	"[out-file -b)asename <bn>] " .
-	"[out-file -n) <digits>] " .
+	"[-o)ut-file <fmt[e.g. 017%02dDL000.000]>] " .
 	"<RDI file> <ens> <ens[...]>\n")
-		unless (&getopts('b:n:') && @ARGV>=3);
+		unless (&getopts('o:') && @ARGV>=3);
 
-chomp($opt_b = `basename $ARGV[0] .000`)		# basename
-	unless defined($opt_b);
-$opt_n = 2										# number of digits in profile #
-	unless defined($opt_n);
-		
+$opt_o = substr($ARGV[0],0,3)					# default output filename format
+		 . '%02d'
+		 . substr($ARGV[0],-9)
+			unless defined($opt_o);
+	
 readHeader($ARGV[0],\%hdr); shift;				# get length of ensembles
 $ens_len = $hdr{ENSEMBLE_BYTES} + 2;
 
@@ -48,7 +55,7 @@
 	sysread(WBRF,$buf,$nBytes) == $nBytes ||
 		die("$WBRcfn: file truncated");
 
-	$fn = $opt_b . sprintf("_%0${opt_n}d.000",$cnr++);
+	$fn = sprintf($opt_o,$cnr++);
 	open(F,">$fn") || die("$fn: $!\n");
 	syswrite(F,$buf,$nBytes) == $nBytes ||
 		die("$fn: $!\n");