before EGU 2013
authorA.M. Thurnherr <athurnherr@yahoo.com>
Sat, 06 Apr 2013 13:10:52 +0000
changeset 19 12aaf0962ee6
parent 18 ef28756fa320
child 20 7caeef8595b0
before EGU 2013
LADCPproc
LADCPproc.defaults
LADCPproc.loadCTD
README
libdiscard_dc_beam2.pl
libdiscard_uc_beam4.pl
--- a/LADCPproc
+++ b/LADCPproc
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L A D C P P R O C 
 #                    doc: Thu Sep 16 20:36:10 2010
-#                    dlm: Sun Oct 28 09:14:16 2012
+#                    dlm: Fri Mar 29 15:24:15 2013
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 77 28 NIL 0 0 72 10 2 4 NIL ofnI
+#                    uE-Info: 97 66 NIL 0 0 72 10 2 4 NIL ofnI
 #======================================================================
 
 # NOTES:
@@ -75,6 +75,7 @@
 #	May 18, 2012: - reduced "implausibly short cast" threshold to 5 min because of Dan's shallow casts
 #	Jun 13, 2012: - added CTD_depth to tds output
 #	Oct 28, 2012: - added -z
+#	Mar 16, 2013: - BUG: usage message had a -p)PI flag
 
 ($ANTS)    = (`which ANTSlib` =~ m{^(.*)/[^/]*$});
 ($PERL_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$});
@@ -93,6 +94,8 @@
 require "$PERL_TOOLS/RDI_Coords.pl";
 require "$PERL_TOOLS/RDI_Utils.pl";
 
+$ANTSLIBS = $LADCPPROC;							# for -L libraries
+
 $antsSummary = "$version -- process LADCP data to get shear, time series";
 
 $antsParseHeader = 0;
@@ -102,7 +105,6 @@
     '[use -r)DI bottom-track data]',
     '[-s)etup <file>] [-g)ps <lat,lon>]',
     '[-c)ompass-corr <offset,cos-fac,sin-fac>]',
-    '[enable -p)PI editing]',
     '[-o)utput grid <resolution[5m]>]',
     '[-i)nitial LADCP time lag <guestimate>]',
     '[-l)ag LADCP <by>] [auto-lag -w)indow <size[120s]>] [-n) <auto-lag windows[20]]',
@@ -265,9 +267,10 @@
 
 print(STDERR "\n\tLADCP...") if ($opt_d);
 
-#-------------------------------------------
+#-------------------------------------------------
 # transform to earth coordinates if required
-#-------------------------------------------
+#	- save beam_vels for later (e.g. wake) editing
+#-------------------------------------------------
 
 $U = 0;		# velocity indices
 $V = 1;
@@ -282,6 +285,7 @@
 	for (my($ens)=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
 		$LADCP{ENSEMBLE}[$ens]->{TILT} = &angle_from_vertical($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL});
 		for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
+			@{$LADCP{ENSEMBLE}[$ens]->{BEAM_VEL}[$bin]} =  @{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]};
 			@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} =
 				velInstrumentToEarth(\%LADCP,$ens,velBeamToInstrument(\%LADCP,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}));
 			@{$LADCP{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$bin]} =					# fake it to fool ref_lr_w
@@ -364,6 +368,16 @@
 	if (!$opt_z && abs($LADCP_prof_range-0.99*$CTD_prof_range) >
 						max(0.2*0.99*$CTD_prof_range,abs($LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH}),50));
 
+#----------------------------------------------------------------
+# call edit function
+#	- e.g. for wake editing
+#	- this is done here, because during step 5 the velocities are
+#	  sound-speed corrected, i.e. 
+#----------------------------------------------------------------
+
+&edit_LADCP_vels()
+	if (exists(&edit_LADCP_vels));
+
 #----------------------------------------------------------------------
 # Step 5: Add CTD to LADCP Data & correct velocities for sound speed
 #	- {DEPTH} field is overwritten!
@@ -484,9 +498,9 @@
 		if ($opt_d);
 }
 
-#----------------------------------------------------------------------
-# Step 8: Edit Data & also produce depth-time-series output vial callback
-#----------------------------------------------------------------------
+#-----------------------------------------------------------------------
+# Step 8: Edit Data & also produce depth-time-series output via callback
+#-----------------------------------------------------------------------
 
 print(STDERR "Calculating shear profiles & producing time-depth-series (.tds) output...");
 
--- a/LADCPproc.defaults
+++ b/LADCPproc.defaults
@@ -1,9 +1,9 @@
 #======================================================================
 #                    L A D C P P R O C . D E F A U L T S 
 #                    doc: Fri Sep 17 09:44:21 2010
-#                    dlm: Wed May 16 15:22:36 2012
+#                    dlm: Tue Jan  8 15:31:40 2013
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 28 25 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 51 63 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # default parameters for [LADCPproc]
@@ -26,6 +26,7 @@
 #	Jul 12, 2011: - added $PPI_editing_enabled
 #	Apr 11, 2012: - cosmetics
 #	May 16, 2012: - BUG: comment var name typo
+#	Jan  8, 2013: - added CTD_ASCII_header_lines
 
 #----------------------------------------------------------------------
 # ASCII CTD file support
@@ -45,8 +46,9 @@
 # $CTD_ASCII_lat_field 		= 4;
 # $CTD_ASCII_lon_field 		= 5;
 
-# The following variable is optional.
+# The following variables are optional:
 
+# $CTD_ASCII_header_lines	= 4;			# if this variable is defined, #-comments are disallowed
 # $CTD_ASCII_badval 		= 999;
 
 #----------------------------------------------------------------------
--- a/LADCPproc.loadCTD
+++ b/LADCPproc.loadCTD
@@ -1,9 +1,9 @@
 #======================================================================
 #                    L A D C P P R O C . L O A D C T D 
 #                    doc: Thu Dec  9 18:39:01 2010
-#                    dlm: Fri Oct 19 11:27:44 2012
+#                    dlm: Tue Jan  8 15:33:54 2013
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 76 46 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 46 107 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -20,6 +20,7 @@
 #						 for binary files
 #				  - BUG: CTD_badval had not been considered when setting $CTD{first_elapsed}
 #				  - BUG: CNV format error was not detected correctly any more
+#   Jan  8, 2013: - added CTD_ASCII_header_lines
 
 sub readCTD_ASCII($$)
 {
@@ -38,9 +39,14 @@
 	open(F,$fn) || croak("$fn: $!\n");
 	my($sumLat,$sumLon); my($nPos) = 0;
 	my($ds);
+	my($skip) = $CTD_ASCII_header_lines;
 	while (chomp($ds = <F>)) {
-		next if ($ds =~ /^#/);
-		$ds =~ s/^\s+//;					# strip leading spaces
+		if (defined($CTD_ASCII_header_lines)) {							# fixed header
+			next if ($skip-- > 0);
+		} else {														# comments beginning with # allowed
+			next if ($ds =~ /^#/);
+		}
+		$ds =~ s/^\s+//;												# strip leading spaces
 		my(@rec) = split('\s+',$ds);
 		push(@{$dtaR->{press}},($rec[$CTD_ASCII_press_field-1] == $CTD_ASCII_badval) ? nan : $rec[$CTD_ASCII_press_field-1]);
 		push(@{$dtaR->{temp}}, ($rec[$CTD_ASCII_temp_field-1]  == $CTD_ASCII_badval) ? nan : $rec[$CTD_ASCII_temp_field-1]);
--- a/README
+++ b/README
@@ -1,9 +1,9 @@
 ======================================================================
                     R E A D M E 
                     doc: Tue May 15 18:10:40 2012
-                    dlm: Fri Oct 19 10:03:50 2012
+                    dlm: Sat Mar 16 13:27:24 2013
                     (c) 2012 A.M. Thurnherr
-                    uE-Info: 61 46 NIL 0 0 72 3 2 8 NIL ofnI
+                    uE-Info: 18 14 NIL 0 0 72 3 2 8 NIL ofnI
 ======================================================================
 
 This directory contains a re-implementation of the shear method for
@@ -14,12 +14,11 @@
 Essentially, the software is a re-implementation of the shear method
 for LADCP velocity processing. Data editing borrows heavily from Eric
 Firing's c/Matlab/perl code that was used extensively during the later
-stages of the WOCE. However, some of the algorithms were simplified
-considerably, in particular
+stages of the WOCE. However, some of the algorithms were simplified.
+In particular,
 
-1) a much simpler gridding algorithm is used
-2) no PPI editing is carried out
-3) there is no support for using GPS data for velocity referencing
+1) a much simpler gridding algorithm is used, and
+2) there is no support for using GPS data for velocity referencing.
 
 In regions of good scattering, the shear output from this software when
 applied to data collected with current RDI instruments can be expected
new file mode 100644
--- /dev/null
+++ b/libdiscard_dc_beam2.pl
@@ -0,0 +1,23 @@
+#======================================================================
+#                    L I B D I S C A R D _ D C _ B E A M 2 . P L 
+#                    doc: Thu Mar 28 21:57:14 2013
+#                    dlm: Fri Mar 29 15:29:21 2013
+#                    (c) 2013 A.M. Thurnherr
+#                    uE-Info: 13 30 NIL 0 0 72 2 2 4 NIL ofnI
+#======================================================================
+
+sub edit_LADCP_vels()
+{
+    print(STDERR "\t\tDISCARDING beam-2 velocities from downcast...\n");
+    
+    for (my($ens)=$LADCP_start; $ens<=$LADCP_bottom; $ens++) {
+        for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
+            undef($LADCP{ENSEMBLE}[$ens]->{BEAM_VEL}[$bin][1]);
+            @{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} =
+            	velInstrumentToEarth(\%LADCP,$ens,velBeamToInstrument(\%LADCP,@{$LADCP{ENSEMBLE}[$ens]->{BEAM_VEL}[$bin]}));
+        }
+    }
+}
+
+1;
+
new file mode 100644
--- /dev/null
+++ b/libdiscard_uc_beam4.pl
@@ -0,0 +1,23 @@
+#======================================================================
+#                    L I B D I S C A R D _ U C _ B E A M 4 . P L 
+#                    doc: Thu Mar 28 21:57:14 2013
+#                    dlm: Fri Mar 29 15:28:22 2013
+#                    (c) 2013 A.M. Thurnherr
+#                    uE-Info: 15 60 NIL 0 0 72 2 2 4 NIL ofnI
+#======================================================================
+
+sub edit_LADCP_vels()
+{
+    print(STDERR "\t\tDISCARDING beam-4 velocities from upcast...\n");
+    
+    for (my($ens)=$LADCP_bottom; $ens<=$LADCP_end; $ens++) {
+        for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
+            undef($LADCP{ENSEMBLE}[$ens]->{BEAM_VEL}[$bin][3]);
+            @{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} =
+            	velInstrumentToEarth(\%LADCP,$ens,velBeamToInstrument(\%LADCP,@{$LADCP{ENSEMBLE}[$ens]->{BEAM_VEL}[$bin]}));
+        }
+    }
+}
+
+1;
+