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