# HG changeset patch # User A.M. Thurnherr # Date 1337194580 0 # Node ID 65582c1723552f3a705559dc3bceda87bf6fa560 # Parent d0af7f7aa23bb79f10772a966c1d50382205f363 V1.0beta3 diff --git a/HISTORY b/HISTORY --- a/HISTORY +++ b/HISTORY @@ -1,9 +1,9 @@ ====================================================================== H I S T O R Y doc: Tue May 15 18:04:39 2012 - dlm: Wed May 16 06:57:27 2012 + dlm: Wed May 16 18:52:31 2012 (c) 2012 A.M. Thurnherr - uE-Info: 17 24 NIL 0 0 72 3 2 8 NIL ofnI + uE-Info: 22 35 NIL 0 0 72 3 2 8 NIL ofnI ====================================================================== May 15, 2012: @@ -15,3 +15,8 @@ May 16, 2012: - V1.0beta2 [.hg/hgrc] - added ANTSlib to doc + +May 16, 2012: + - V1.0beta3 [.hg/hgrc] + - bug fixes for shallow casts [LADCPproc.backscatter] + - added support for -r)DI BT data diff --git a/LADCPproc b/LADCPproc --- 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: Wed May 16 06:54:18 2012 +# dlm: Wed May 16 18:44:45 2012 # (c) 2010 A.M. Thurnherr -# uE-Info: 79 14 NIL 0 0 72 10 2 4 NIL ofnI +# uE-Info: 73 0 NIL 0 0 72 10 2 4 NIL ofnI #====================================================================== $antsSummary = 'process LADCP data to get shear, time series'; @@ -69,6 +69,7 @@ # Apr 17, 2012: - BAD BUG: magdec code call was bad and did not return correct value. ever. # Apr 18, 2012: - replaced Sv.n by Sv.nsamp # May 16, 2012: - adapted to ANTSlib V5.0 +# - added support for -r)DI BT data ($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$}); ($PERL_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$}); @@ -87,9 +88,10 @@ require "$PERL_TOOLS/RDI_Utils.pl"; $antsParseHeader = 0; -&antsUsage('24a:b:c:df:g:i:kl:n:o:p:s:t:u:w:',2, +&antsUsage('24a:b:c:df:g:i:kl:n:o:p:rs:t:u:w:',2, '[use -2)dary CTD sensor pair]', '[require -4)-beam LADCP solutions]', + '[use -r)DI bottom-track data]', '[-s)etup ] [-g)ps ]', '[-c)ompass-corr ]', '[enable -p)PI editing]', @@ -277,7 +279,10 @@ @{$LADCP{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$bin]} = # fake it to fool ref_lr_w (0,0,0,defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]) ? 100 : 0); } + @{$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}} = + velInstrumentToEarth(\%LADCP,$ens,velBeamToInstrument(\%LADCP,@{$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}})); } + $LADCP{BEAM_COORDINATES} = 0; $LADCP{EARTH_COORDINATES} = 1; unless ($opt_4) { @@ -424,24 +429,29 @@ print(STDERR "\n\tin acoustic backscatter profiles...") if ($opt_d); ($water_depth,$sig_water_depth) = find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}); - - $min_hab = $water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; - printf(STDERR "\n\twater depth = %d(+-%.1f)m",$water_depth,$sig_water_depth); - printf(STDERR "\n\tclosest approach = %dmab",$min_hab); + printf(STDERR "\n\t\twater depth = %d(+-%.1f)m",$water_depth,$sig_water_depth) + if ($opt_d); print(STDERR "\n\tin RDI BT data...") if ($opt_d); ($BT_water_depth,$sig_BT_water_depth) = find_seabed(\%LADCP,$LADCP_bottom,$LADCP{BEAM_COORDINATES}); - if (defined($BT_water_depth)) { - $min_hab = $BT_water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; - printf(STDERR "\n\twater depth = %d(+-%.1f)m",$BT_water_depth,$sig_BT_water_depth); - printf(STDERR "\n\tclosest approach = %dmab",$min_hab); -# $water_depth = $BT_water_depth; # assume BT data are better -# $sig_water_depth = $sig_BT_water_depth; # (at least they are higher vertical resolution) + printf(STDERR "\n\t\twater depth = %d(+-%.1f)m",$BT_water_depth,$sig_BT_water_depth) + if ($opt_d); + } else { + printf(STDERR "\n\t\tno seabed found") if ($opt_d); } - unless (defined($water_depth)) { + if ($opt_r) { # use RDI BT data + $water_depth = $BT_water_depth; + $sig_water_depth = $sig_BT_water_depth; + } + $min_hab = $water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; + + if (defined($water_depth)) { + printf(STDERR "\n\twater depth = %d(+-%.1f)m",$water_depth,$sig_water_depth); + printf(STDERR "\n\tclosest approach = %dmab",$min_hab); + } else { print(STDERR "\n\tno seabed found\n"); print(STDERR "\n\tunknown water depth => PPI editing disabled\n") if ($opt_d); diff --git a/LADCPproc.BT b/LADCPproc.BT --- a/LADCPproc.BT +++ b/LADCPproc.BT @@ -1,9 +1,9 @@ #====================================================================== # L A D C P P R O C . B T # doc: Wed Oct 20 21:05:37 2010 -# dlm: Fri Jul 8 03:24:56 2011 +# dlm: Wed May 16 18:45:15 2012 # (c) 2010 A.M. Thurnherr -# uE-Info: 148 69 NIL 0 0 72 10 2 4 NIL ofnI +# uE-Info: 16 51 NIL 0 0 72 10 2 4 NIL ofnI #====================================================================== # HISTORY: @@ -13,6 +13,7 @@ # - added BTrangeFlag # - added $BT processing parameters # - changed from echo amplitude to Sv +# May 16, 2012: - added support for -r)DI BT data my($BEAM1) = 0; my($BEAM2) = 1; @@ -23,7 +24,7 @@ my($DEBUG) = 0; -sub binBTprof($) +sub CTDvelFromSv($) { my($ens) = @_; @@ -92,6 +93,49 @@ $CTD_w = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$W]; } + return ($CTD_u,$CTD_v,$CTD_w); +} + +sub depthAtRange($$) +{ + my($ens,$range) = @_; + return $LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP} ? + $LADCP{ENSEMBLE}[$ens]->{DEPTH} - $range : + $LADCP{ENSEMBLE}[$ens]->{DEPTH} + $range; +} + +sub CTDvelFromBT($) +{ + my($ens) = @_; + + return (undef,undef,undef) + unless defined($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$W]); + $nBTfound++; + + $nBTrangeFlag++,return # inconsistent range (&, impliclity, large tilt) + unless (max(@{$LADCP{ENSEMBLE}[$ens]->{BT_RANGE}})-min(@{$LADCP{ENSEMBLE}[$ens]->{BT_RANGE}}) + <= $BT_max_bin_spread*$LADCP{BIN_LENGTH}); + + my($range) = round(avg(@{$LADCP{ENSEMBLE}[$ens]->{BT_RANGE}})); + + $nBTdepthFlag++,return # BT range inconsistent with water depth + unless defined($BT_min_depth) || + (abs($water_depth-depthAtRange($ens,$range)) < $sig_water_depth + $BT_max_depth_error); + + return ($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$U], + $LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$V], + $LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$W]); +} + + +sub binBTprof($) +{ + my($ens) = @_; + my($CTD_u,$CTD_v,$CTD_w); + + ($CTD_u,$CTD_v,$CTD_w) = $opt_r ? CTDvelFromBT($ens) : CTDvelFromSv($ens); + return unless defined($CTD_w); + $nBTwFlag++,return if (abs($CTD_w-$LADCP{ENSEMBLE}[$ens]->{W}) > $BT_max_w_difference); printf(STDERR "good BT [%5.2f %5.2f %5.2f] found at ens $ens\n",$CTD_u,$CTD_v,$CTD_w) diff --git a/LADCPproc.backscatter b/LADCPproc.backscatter --- a/LADCPproc.backscatter +++ b/LADCPproc.backscatter @@ -1,9 +1,9 @@ #====================================================================== # L A D C P P R O C . B A C K S C A T T E R # doc: Wed Oct 20 13:02:27 2010 -# dlm: Tue Apr 10 13:46:28 2012 +# dlm: Wed May 16 17:55:14 2012 # (c) 2010 A.M. Thurnherr -# uE-Info: 52 59 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 279 33 NIL 0 0 72 2 2 4 NIL ofnI #====================================================================== # HISTORY: @@ -17,6 +17,10 @@ # Jul 14, 2011: - implemented Sv_V04 # Jul 15, 2011: - modified Sv_V04 to take noise levels into account (Sv_T11) # Apr 10, 2012: - BUG: ensonified volume in Sv_T11 was wrong +# May 16, 2012: - BUG: find_backscatter_seabed() used wrong start depth for +# search +# - BUG: same used bins entirely below seabed (only possible +# for shallow casts) my($BEAM1) = 0; my($BEAM2) = 1; @@ -252,21 +256,30 @@ sub find_backscatter_seabed($) { - my($search_below) = @_; - my($mdgi) = int($search_below/$GRID_DZ); # grid index to begin search + my($water_depth) = @_; my(@wdepth_gi); # water_depth indices - print(STDERR "\n\tseabed-max grid indices:") if ($opt_d); + my($search_below) = max(0,$water_depth-$BT_begin_search_above); + my($mdgi) = int($search_below/$GRID_DZ); # grid index to begin search + print(STDERR "\n\t\tlooking for seabed below $search_below m (gi >= $mdgi)") if ($opt_d); + + print(STDERR "\n\t\tseabed-max grid indices:") if ($opt_d); for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { # find backscatter min/max below $search_below in each bin - my($min,$max,$gimax,$lastvalid) = (1e99,-1e99,-1,-1); + my($min,$max,$gimax,$firstvalid,$lastvalid) = (1e99,-1e99,-1,-1,-1); for (my($gi)=$mdgi; $gi<@nSv; $gi++) { next unless ($nSv[$gi][$bin] > 0); + $firstvalid = $gi if ($firstvalid < 0); my($avg) = $sSv[$gi][$bin] / $nSv[$gi][$bin]; $lastvalid = $gi; $min = $avg if ($avg < $min); $max = $avg, $gimax = $gi if ($avg > $max); } + if ($gimax == $firstvalid) { # should be robust except maybe for huge bins + printf(STDERR "\n\t\tdata from below-seabed bins (%d-%d) discarded", + $bin+1,$LADCP{N_BINS}) if ($opt_d); + last; + } if ($max-$min>10 && $gimax!=$lastvalid) { # ignore boundary maxima & scatter printf(STDERR " %d",$gimax-$mdgi) if ($opt_d); push(@wdepth_gi,$gimax); diff --git a/LADCPproc.defaults b/LADCPproc.defaults --- 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 Apr 11 19:46:12 2012 +# dlm: Wed May 16 15:22:36 2012 # (c) 2010 A.M. Thurnherr -# uE-Info: 27 29 NIL 0 0 72 0 2 4 NIL ofnI +# uE-Info: 28 25 NIL 0 0 72 0 2 4 NIL ofnI #====================================================================== # default parameters for [LADCPproc] @@ -25,6 +25,7 @@ # Jul 7, 2011: - added BT processing parameters # Jul 12, 2011: - added $PPI_editing_enabled # Apr 11, 2012: - cosmetics +# May 16, 2012: - BUG: comment var name typo #---------------------------------------------------------------------- # ASCII CTD file support @@ -93,7 +94,7 @@ # does not work. #$BT_min_depth = xxx; -#$BT_max_depht = xxx; +#$BT_max_depth = xxx; # Maximum difference between water depth and average distance of echo max., # if $BT_min_depth and $BT_max_depth are not set. The stddev of the detected diff --git a/README.Run b/README.Run --- a/README.Run +++ b/README.Run @@ -1,9 +1,9 @@ ====================================================================== R E A D M E . R U N doc: Tue May 15 18:49:00 2012 - dlm: Tue May 15 19:16:34 2012 + dlm: Wed May 16 18:55:51 2012 (c) 2012 A.M. Thurnherr - uE-Info: 52 0 NIL 0 0 72 3 2 8 NIL ofnI + uE-Info: 44 0 NIL 0 0 72 3 2 8 NIL ofnI ====================================================================== NB: DO NOT RUN FROM CURRENT DIRECTORY. (Actually, you can but will have @@ -34,6 +34,13 @@ LADCPproc -p 001UL.sh 001UL000.000 001.cnv > /dev/null creates one file, 001UL.sh (shear profiles) +common LADCPproc OPTIONS: + -d generate diagnostic output + -r use RDI BT data instead of echo amplitudes to find + seabed and determine CTD velocity + -o output grid resolution (defaults to 5m) + -p generate shear profile output + -b generate BT output =CALCULATE LADCP VELOCITY PROFILE=