time_lag.pl
changeset 27 2053d8de8d6b
parent 26 b89d4b01fcc5
child 29 c1ff35103176
equal deleted inserted replaced
26:b89d4b01fcc5 27:2053d8de8d6b
     1 #======================================================================
     1 #======================================================================
     2 #                    T I M E _ L A G . P L 
     2 #                    T I M E _ L A G . P L 
     3 #                    doc: Fri Dec 17 21:59:07 2010
     3 #                    doc: Fri Dec 17 21:59:07 2010
     4 #                    dlm: Thu Apr 16 10:25:37 2015
     4 #                    dlm: Thu Apr 16 12:13:25 2015
     5 #                    (c) 2010 A.M. Thurnherr
     5 #                    (c) 2010 A.M. Thurnherr
     6 #                    uE-Info: 63 0 NIL 0 0 72 2 2 4 NIL ofnI
     6 #                    uE-Info: 276 41 NIL 0 0 72 2 2 4 NIL ofnI
     7 #======================================================================
     7 #======================================================================
     8 
     8 
     9 # HISTORY:
     9 # HISTORY:
    10 #	Dec 17, 2010: - created
    10 #	Dec 17, 2010: - created
    11 #	Dec 18, 2010: - adapted for multi-pass lagging
    11 #	Dec 18, 2010: - adapted for multi-pass lagging
    54 #	May 23, 2014: - BUG: $s range check required in mad_w()
    54 #	May 23, 2014: - BUG: $s range check required in mad_w()
    55 #   Apr 16, 2015: - turned output specifies into lists (re-design of
    55 #   Apr 16, 2015: - turned output specifies into lists (re-design of
    56 #                   plotting sub-system)
    56 #                   plotting sub-system)
    57 #				  - BUG: executable flag was not set on file output
    57 #				  - BUG: executable flag was not set on file output
    58 #				  - disabled active output when ANTS are not available
    58 #				  - disabled active output when ANTS are not available
       
    59 #				  - croak -> error
    59 
    60 
    60 # DIFFICULT STATIONS:
    61 # DIFFICULT STATIONS:
    61 #	NBP0901#131		this requires the search-radius doubling heuristic
    62 #	NBP0901#131		this requires the search-radius doubling heuristic
    62 
    63 
    63 # TODO:
    64 # TODO:
   103 
   104 
   104 
   105 
   105 sub bestLag($$$$)								# find best lag in window
   106 sub bestLag($$$$)								# find best lag in window
   106 {
   107 {
   107 	my($fe,$le,$ww,$soi) = @_;					# first/last LADCP ens, window width, scan-offset increment
   108 	my($fe,$le,$ww,$soi) = @_;					# first/last LADCP ens, window width, scan-offset increment
   108 #	$le = $lastGoodEns
       
   109 #		unless ($le <= $lastGoodEns);
       
   110 	die("assertion failed\n\tfe = $fe, le = $le, firstGoodEns = $firstGoodEns, lastGoodEns = $lastGoodEns")
   109 	die("assertion failed\n\tfe = $fe, le = $le, firstGoodEns = $firstGoodEns, lastGoodEns = $lastGoodEns")
   111 		unless ($fe>=$firstGoodEns && $le<=$lastGoodEns);
   110 		unless ($fe>=$firstGoodEns && $le<=$lastGoodEns);
   112 
   111 
   113 	my($bestso) = 0;							# error at first-guess offset
   112 	my($bestso) = 0;							# error at first-guess offset
   114 	my($bestmad) = mad_w($fe,$le,0);
   113 	my($bestmad) = mad_w($fe,$le,0);
   272 			&antsAddParams('elapsed.bot',$LADCP{ENSEMBLE}[$LADCP_atbottom]->{ELAPSED});
   271 			&antsAddParams('elapsed.bot',$LADCP{ENSEMBLE}[$LADCP_atbottom]->{ELAPSED});
   273 
   272 
   274 			foreach my $of (@out_TL) {
   273 			foreach my $of (@out_TL) {
   275 				progress("<$of> ");
   274 				progress("<$of> ");
   276 				$of = ">$of" unless ($of =~ /^$|^\s*\|/);
   275 				$of = ">$of" unless ($of =~ /^$|^\s*\|/);
   277 		        open(STDOUT,$of) || croak("$of: $!\n");
   276 		        open(STDOUT,$of) || error("$of: $!\n");
   278 				undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
   277 				undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
   279 
   278 
   280 				for (my($wi)=0; $wi<@elapsed_buf; $wi++) {
   279 				for (my($wi)=0; $wi<@elapsed_buf; $wi++) {
   281 					&antsOut($elapsed_buf[$wi],$so_buf[$wi],$mad_buf[$wi],
   280 					&antsOut($elapsed_buf[$wi],$so_buf[$wi],$mad_buf[$wi],
   282 								($elapsed_buf[$wi]<$LADCP{ENSEMBLE}[$LADCP_atbottom]->{ELAPSED}));
   281 								($elapsed_buf[$wi]<$LADCP{ENSEMBLE}[$LADCP_atbottom]->{ELAPSED}));