author | A.M. Thurnherr <athurnherr@yahoo.com> |
Fri, 06 Mar 2015 15:54:23 -0500 | |
changeset 33 | dd5b67a41791 |
parent 31 | af03ca38fc2a |
parent 29 | f72cd642972c |
permissions | -rw-r--r-- |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
1 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
2 |
# L A D C P P R O C . B A C K S C A T T E R |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
3 |
# doc: Wed Oct 20 13:02:27 2010 |
33
dd5b67a41791
merged Explorer with DoMORE-1 changes
A.M. Thurnherr <athurnherr@yahoo.com>
diff
changeset
|
4 |
# dlm: Fri Mar 6 15:52:50 2015 |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
5 |
# (c) 2010 A.M. Thurnherr |
33
dd5b67a41791
merged Explorer with DoMORE-1 changes
A.M. Thurnherr <athurnherr@yahoo.com>
diff
changeset
|
6 |
# uE-Info: 32 0 NIL 0 0 72 2 2 4 NIL ofnI |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
7 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
8 |
|
1 | 9 |
# HISTORY: |
10 |
# Oct 20, 2010: - created |
|
11 |
# Dec 10, 2010: - BUG: backscatter above sea surface made code bomb |
|
12 |
# when run with uplooker data |
|
2 | 13 |
# Jun 15, 2011: - added calculation of backscatter profiles from |
14 |
# subset of bins |
|
3 | 15 |
# Jul 7, 2011: - use $BEAM? vars to clarify code |
16 |
# - save SV values to use in BT code |
|
6 | 17 |
# Jul 14, 2011: - implemented Sv_V04 |
8 | 18 |
# Jul 15, 2011: - modified Sv_V04 to take noise levels into account (Sv_T11) |
19 |
# Apr 10, 2012: - BUG: ensonified volume in Sv_T11 was wrong |
|
12 | 20 |
# May 16, 2012: - BUG: find_backscatter_seabed() used wrong start depth for |
21 |
# search |
|
22 |
# - BUG: same used bins entirely below seabed (only possible |
|
23 |
# for shallow casts) |
|
28
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
24 |
# Mar 21, 2014: - adapted to new [LADCPproc.utils] |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
25 |
# Mar 27, 2014: - adapted to depthOfBinAlongBeam() |
29 | 26 |
# May 25, 2014: - made search_below integer |
31 | 27 |
# Jul 27, 2014: - moved depthOfGI() to [LADCPproc.utils] |
28 |
# Aug 5, 2014: - BUG: find_backscatter_seabed() discarded everything if |
|
29 |
# LADCP bin 1 had the backscatter max at the edge of |
|
30 |
# the search domain, which could easily happen when |
|
31 |
# the bottom stop was a long way from the seabed |
|
3 | 32 |
|
33 |
my($BEAM1) = 0; |
|
34 |
my($BEAM2) = 1; |
|
35 |
my($BEAM3) = 2; |
|
36 |
my($BEAM4) = 3; |
|
1 | 37 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
38 |
#---------------------------------------------------------------------- |
8 | 39 |
# Volume Scattering Coefficient |
40 |
# |
|
41 |
# 1) There are currently 4 different methods for correcting echo |
|
42 |
# amplitudes as a function of range. The method to calculate Sv |
|
43 |
# of Deines (1999) is the only published one, although Visbeck's |
|
44 |
# correction was presumably used by Visbeck and Thurnherr (2009). |
|
45 |
# The third method (Thurnherr 2011) improves on Visbeck's code. |
|
46 |
# The fourth method consists in no correction. |
|
47 |
# 2) The following observations stand out when plotting echo amplitudes |
|
48 |
# against bin number in clear water (e.g. below 1400m in first |
|
49 |
# downcast of IWISE yoyo cast 160; [Documentation/Sv_comparison.eps]): |
|
50 |
# - the corrections works approximately for the valid bins |
|
51 |
# (2-13 in case of IWISE) but it amounts to a slight |
|
52 |
# overcorrection, i.e. the resulting corrected backscatter |
|
53 |
# profiles increase with increasing distance from the |
|
54 |
# transducer |
|
55 |
# - in terms of remaining vertical structure, the different |
|
56 |
# methods are nearly identical |
|
57 |
# - however, Visbeck (2004) shows fairly large instrument |
|
58 |
# dependent biases because (instrument-specific) noise |
|
59 |
# is not considered |
|
60 |
# - the vertical structure can be improved by decreasing the |
|
61 |
# attenuation parameter to something like 0.05; I have |
|
62 |
# verified this for the Deines and Thurnherr expressions |
|
63 |
# with a single IWISE station; however, there remain |
|
64 |
# small (but noticeable) instrument-specific biases |
|
65 |
# 3) Therefore, the default code is Deines (1999); if this is |
|
66 |
# not good enough, it is probably possible to derive an |
|
67 |
# empirical correction from in-situ data. |
|
68 |
#---------------------------------------------------------------------- |
|
69 |
||
70 |
#---------------------------------------------------------------------- |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
71 |
# Volume Scattering Coefficient, following Deines (IEEE 1999) |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
72 |
# NOTES: |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
73 |
# - instrument specific! (300kHz Workhorse) |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
74 |
# - no sound-speed correction applied |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
75 |
# - R in bin center, instead of last quarter |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
76 |
# - transmit power assumes 33V batteries |
8 | 77 |
# Results: |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
78 |
# - correction seems to work for a subset of bins (~bins 3-9 for |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
79 |
# 2010 P403 station 46) |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
80 |
# - this may imply that noise level depends on bin |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
81 |
# - far bins are important for seabed detection, i.e. cannot simply |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
82 |
# be discarded at this stage |
8 | 83 |
#---------------------------------------------------------------------- |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
84 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
85 |
sub log10 { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
86 |
my $n = shift; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
87 |
return log($n)/log(10); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
88 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
89 |
|
6 | 90 |
sub Sv_D99($$$$$) |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
91 |
{ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
92 |
my($temp,$PL,$Er,$R,$EA) = @_; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
93 |
my($C) = -143; # RDI Workhorse monitor |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
94 |
my($Ldbm) = 10 * log10($PL); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
95 |
my($PdbW) = 14.0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
96 |
my($alpha) = 0.069; |
8 | 97 |
# my($alpha) = 0.048; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
98 |
my($Kc) = 0.45; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
99 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
100 |
return $C + 10*log10(($temp+273)*$R**2) - $Ldbm - $PdbW |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
101 |
+ 2*$alpha*$R + $Kc*($EA-$Er); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
102 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
103 |
|
6 | 104 |
#---------------------------------------------------------------------- |
105 |
# Volume Scattering Coefficient, following Visbeck (code 2004) |
|
106 |
# |
|
107 |
## function [ts,bcs]=targ($EA,$R,$alpha,$PL,$EAS,$ap) |
|
108 |
## Target strength of EA for volume scatterer |
|
109 |
## $EA = echoamp in dB |
|
110 |
## $R = distance in m |
|
111 |
## $alpha = attenuation dB/m |
|
112 |
## $PL = pulse/bin legth in m |
|
113 |
## $EAS = source level |
|
114 |
## $ap = aperature in degree |
|
115 |
## M. Visbeck 2004 |
|
8 | 116 |
# |
117 |
# Results: |
|
6 | 118 |
# - overall, correction with distance works similarly well to Deines (1999) |
119 |
# - constant bias, which could be taken care of by changing EAS |
|
8 | 120 |
# - however, much more serious UL/DL differences than Deines (1999) |
121 |
#---------------------------------------------------------------------- |
|
6 | 122 |
|
123 |
sub Sv_V04($$$$$) |
|
124 |
{ |
|
125 |
my($temp,$PL,$Er,$R,$EA) = @_; # only uses $R and $EA |
|
126 |
||
127 |
# my($alpha) = 0.039; ## attenuation dB/m for 150 kHz |
|
128 |
my($alpha) = 0.062; ## attenuation dB/m for 300 kHz |
|
8 | 129 |
|
6 | 130 |
my($EAS) = 100; ## source level in dB |
131 |
my($ap) = rad(2); ## beam aperature in DEGREE convert to radian |
|
132 |
||
133 |
my($r1) = tan($ap)*($R-$PL/2); ## radius of top and bottom of each bin |
|
134 |
my($r2) = tan($ap)*($R+$PL/2); |
|
135 |
my($V) = $PI*$PL/3 * ($r1**2+$r2**2+$r1*$r2); ## ensonified volume |
|
136 |
||
137 |
my($TL) = 20*log10($R) + $alpha*$R; ## transmission loss |
|
138 |
||
139 |
my($TS) = 0.45*$EA - $EAS + 2*$TL - 10*log10($V); ## target strength |
|
140 |
my($BCS) = exp($TS/10); ## backscatter cross section |
|
141 |
||
142 |
return $TS; |
|
143 |
} |
|
144 |
||
145 |
||
8 | 146 |
#---------------------------------------------------------------------- |
147 |
# Volume Scattering Coefficient, Thurnherr [2011] |
|
148 |
# |
|
149 |
# in an attempt to improved on Visbeck's code, I made several |
|
150 |
# modifications: |
|
151 |
# - add 5cm to beam radius (transducer radius) |
|
152 |
# - take beam noise into account (as in Deines [1999]) |
|
153 |
# - use different equation for ensonified volume |
|
154 |
# results: |
|
155 |
# - inclusion of beam noise greatly reduces UL/DL differences in IWISE data |
|
156 |
# - constant offset from Deines values, which could be taken care of by changing EAS |
|
157 |
# - remaining changes don't have great effects |
|
158 |
#---------------------------------------------------------------------- |
|
6 | 159 |
|
160 |
sub Sv_T11($$$$$) |
|
161 |
{ |
|
162 |
my($temp,$PL,$Er,$R,$EA) = @_; |
|
163 |
||
8 | 164 |
# my($alpha) = 0.067; # Deines [1999] |
165 |
my($alpha) = 0.062; # Visbeck [2004] |
|
166 |
# my($alpha) = 0.048; # attenuation dB/m for 300 kHz |
|
167 |
my($EAS) = 100; # source level in dB |
|
168 |
my($ap) = rad(2); # beam aperature in DEGREE convert to radian |
|
169 |
my($r0) = 0.05; # beam radius at source (transducer radius) |
|
6 | 170 |
|
8 | 171 |
my($d1) = $R - $PL/2; # distance to top and bottom of bin |
172 |
my($d2) = $R + $PL/2; |
|
173 |
my($r1) = $r0 + $d1*tan($ap); # radius of top and bottom of each bin |
|
174 |
my($r2) = $r0 + $d2*tan($ap); |
|
175 |
||
176 |
my($V) = $PI/3 * ($d2*$r2**2 - $d1*$r1**2); # ensonified volume |
|
6 | 177 |
|
8 | 178 |
my($TL) = 20*log10($R) + $alpha*$R; # transmission loss |
6 | 179 |
|
8 | 180 |
my($TS) = 0.45*($EA-$Er) - $EAS + 2*$TL - 10*log10($V); # target strength |
6 | 181 |
|
182 |
return $TS; |
|
183 |
} |
|
184 |
||
8 | 185 |
#---------------------------------------------------------------------- |
186 |
# no correction for attenuation losses |
|
187 |
# |
|
188 |
# however, noise level is still taken into consideration |
|
189 |
#---------------------------------------------------------------------- |
|
190 |
||
191 |
sub Sv_nocorr($$$$$) |
|
192 |
{ |
|
193 |
my($temp,$PL,$Er,$R,$EA) = @_; |
|
194 |
||
195 |
return 0.45*($EA-$Er); |
|
196 |
} |
|
197 |
||
198 |
#====================================================================== |
|
199 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
200 |
sub mk_backscatter_profs($$) |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
201 |
{ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
202 |
my($LADCP_start,$LADCP_end) = @_; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
203 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
204 |
my(@Er) = (1e99,1e99,1e99,1e99); # echo intensity reference level |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
205 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
3 | 206 |
$Er[$BEAM1] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][$BEAM1] |
207 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][$BEAM1] < $Er[$BEAM1]); |
|
208 |
$Er[$BEAM2] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][$BEAM2] |
|
209 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][$BEAM2] < $Er[$BEAM2]); |
|
210 |
$Er[$BEAM3] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][$BEAM3] |
|
211 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][$BEAM3] < $Er[$BEAM3]); |
|
212 |
$Er[$BEAM4] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][$BEAM4] |
|
213 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][$BEAM4] < $Er[$BEAM4]); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
214 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
215 |
print(STDERR "\n\t\@per-beam noise levels = @Er") if ($opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
216 |
|
28
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
217 |
my($Svfunc); # Sv method |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
218 |
if ($opt_u =~ /^[dD]/) { |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
219 |
$Svfunc = \&Sv_D99; |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
220 |
} elsif ($opt_u =~ /^[vV]/) { |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
221 |
$Svfunc = \&Sv_V04; |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
222 |
} elsif ($opt_u =~ /^[tT]/) { |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
223 |
$Svfunc = \&Sv_T11; |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
224 |
} else { |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
225 |
$Svfunc = \&Sv_nocorr; |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
226 |
} |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
227 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
228 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
229 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
28
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
230 |
my($range_to_bin) = &rangeToBin($ens,$bin); |
6 | 231 |
|
28
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
232 |
for (my($beam)=0; $beam<4; $beam++) { |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
233 |
my($gi) = int(&depthOfBinAlongBeam($ens,$bin,$beam) / $GRID_DZ); |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
234 |
next if ($gi < 0); |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
235 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$beam] = &$Svfunc($LADCP{ENSEMBLE}[$ens]->{CTD_TEMP}, |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
236 |
$LADCP{TRANSMITTED_PULSE_LENGTH}, |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
237 |
$Er[$beam],$range_to_bin, |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
238 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][$beam]); |
6 | 239 |
|
28
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
240 |
$sSv[$gi][$bin] += $LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$beam]; |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
241 |
$nSv[$gi][$bin]++; |
2 | 242 |
|
28
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
243 |
if ($bin>=$Svbin_start && $bin<=$Svbin_end) { |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
244 |
$sSv_prof[$gi] += $LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$beam]; |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
245 |
$nSv_prof[$gi]++; |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
246 |
} # if $bin |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
247 |
} # for $beam |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
248 |
} # for $bin |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
249 |
} # for $end |
79bf60e97208
after merge with laptop version
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
250 |
} # sub |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
251 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
252 |
sub find_backscatter_seabed($) |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
253 |
{ |
12 | 254 |
my($water_depth) = @_; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
255 |
my(@wdepth_gi); # water_depth indices |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
256 |
|
29 | 257 |
my($search_below) = int(max(0,$water_depth-$BT_begin_search_above)); |
12 | 258 |
my($mdgi) = int($search_below/$GRID_DZ); # grid index to begin search |
31 | 259 |
printf(STDERR "\n\t\tlooking for seabed below %d m (gi = [%d..%d])",$search_below,$mdgi,scalar(@nSv)) |
260 |
if ($opt_d); |
|
12 | 261 |
|
262 |
print(STDERR "\n\t\tseabed-max grid indices:") if ($opt_d); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
263 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
264 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { # find backscatter min/max below $search_below in each bin |
12 | 265 |
my($min,$max,$gimax,$firstvalid,$lastvalid) = (1e99,-1e99,-1,-1,-1); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
266 |
for (my($gi)=$mdgi; $gi<@nSv; $gi++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
267 |
next unless ($nSv[$gi][$bin] > 0); |
12 | 268 |
$firstvalid = $gi if ($firstvalid < 0); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
269 |
my($avg) = $sSv[$gi][$bin] / $nSv[$gi][$bin]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
270 |
$lastvalid = $gi; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
271 |
$min = $avg if ($avg < $min); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
272 |
$max = $avg, $gimax = $gi if ($avg > $max); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
273 |
} |
31 | 274 |
if ($max-$min>10 && $gimax!=$firstvalid && $gimax!=$lastvalid) { # ignore boundary maxima & scatter |
275 |
printf(STDERR " %d",$gimax) if ($opt_d); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
276 |
push(@wdepth_gi,$gimax); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
277 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
278 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
279 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
280 |
return (depthOfGI(avg(@wdepth_gi)),stddev(@wdepth_gi)*$GRID_DZ); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
281 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
282 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
283 |
1; |