author | A.M. Thurnherr <athurnherr@yahoo.com> |
Mon, 20 Apr 2015 14:04:04 +0000 | |
changeset 28 | b07b23485336 |
parent 27 | 2053d8de8d6b |
child 29 | c1ff35103176 |
permissions | -rw-r--r-- |
0 | 1 |
#====================================================================== |
2 |
# A C O U S T I C _ B A C K S C A T T E R . P L |
|
3 |
# doc: Wed Oct 20 13:02:27 2010 |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
4 |
# dlm: Mon Apr 20 13:56:56 2015 |
0 | 5 |
# (c) 2010 A.M. Thurnherr |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
6 |
# uE-Info: 24 71 NIL 0 0 72 0 2 4 NIL ofnI |
0 | 7 |
#====================================================================== |
8 |
||
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 |
|
13 |
# Dec 30, 2010: - adapted for use with [LADCP_w] |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
14 |
# Oct 19, 2011: - added support for $SS_{min,max}_allowed_range |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
15 |
# - BUG: acoustic-backscatter assumed 0 deg C |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
16 |
# - SV now saved in ensemble |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
17 |
# Oct 21, 2011: - BUG: made code work for uplooker again |
15 | 18 |
# Mar 4, 2014: - added support for missing PITCH/ROLL (TILT) |
18 | 19 |
# Apr 17, 2014: - BUG: missing ; |
20 |
# Nov 7, 2014: - BUG: calc_binDepths() was called without valid CTD depth |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
21 |
# - added $SS_use_BT, $SS_min_signal, $SS_min_samp |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
22 |
# Apr 20, 2015: - added comments |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
23 |
# - removed SS_{min,max}_allowed_range from calc_backscatter_profs() |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
24 |
# - added correct_backscatter() & linterp() from laptop |
0 | 25 |
|
26 |
#---------------------------------------------------------------------- |
|
27 |
# Volume Scattering Coefficient, following Deines (IEEE 1999) |
|
28 |
# NOTES: |
|
29 |
# - instrument specific! (300kHz Workhorse) |
|
30 |
# - no sound-speed correction applied |
|
31 |
# - R in bin center, instead of last quarter |
|
32 |
# - transmit power assumes 33V batteries |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
33 |
# EMPIRICAL FINDINGS (after applying the empirical correction) |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
34 |
# - Sv(WH300) ~ Sv(WH150)/1.4-34 |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
35 |
# - based on DoMORE-1: 004, 005 |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
36 |
# - identical instrument setup (0/8/8m) |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
37 |
# - 003, with higher scattering is somewhat different |
0 | 38 |
#---------------------------------------------------------------------- |
39 |
||
40 |
# NB: |
|
41 |
# - correction seems to work for a subset of bins (~bins 3-9 for |
|
42 |
# 2010 P403 station 46) |
|
43 |
# - this may imply that noise level depends on bin |
|
44 |
# - far bins are important for seabed detection, i.e. cannot simply |
|
45 |
# be discarded at this stage |
|
46 |
||
47 |
sub Sv($$$$$) |
|
48 |
{ |
|
49 |
my($temp,$PL,$Er,$R,$EA) = @_; |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
50 |
my($C) = -143; # RDI WHM300 (from Deines) |
0 | 51 |
my($Ldbm) = 10 * log10($PL); |
52 |
my($PdbW) = 14.0; |
|
53 |
my($alpha) = 0.069; |
|
54 |
my($Kc) = 0.45; |
|
55 |
||
56 |
return $C + 10*log10(($temp+273)*$R**2) - $Ldbm - $PdbW |
|
57 |
+ 2*$alpha*$R + $Kc*($EA-$Er); |
|
58 |
} |
|
59 |
||
60 |
#---------------------------------------------------------------------- |
|
61 |
# Calculate per-bin backscatter profiles |
|
62 |
# input: first and last valid LADCP ensemble |
|
63 |
# output: sSv[$depth][$bin] sum of volume scattering coefficients |
|
64 |
# nSv[$depth][$bin] number of samples in bin |
|
65 |
#---------------------------------------------------------------------- |
|
66 |
||
67 |
my(@sSv,@nSv); |
|
68 |
||
69 |
sub calc_backscatter_profs($$) |
|
70 |
{ |
|
71 |
my($LADCP_start,$LADCP_end) = @_; |
|
72 |
||
73 |
my(@Er) = (1e99,1e99,1e99,1e99); # echo intensity reference level |
|
74 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
|
75 |
$Er[0] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][0] |
|
76 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][0] < $Er[0]); |
|
77 |
$Er[1] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][1] |
|
78 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][1] < $Er[1]); |
|
79 |
$Er[2] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][2] |
|
80 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][2] < $Er[2]); |
|
81 |
$Er[3] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][3] |
|
82 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][3] < $Er[3]); |
|
83 |
} |
|
84 |
debugmsg("per-beam noise levels = @Er\n"); |
|
85 |
||
86 |
my($cosBeamAngle) = cos(rad($LADCP{BEAM_ANGLE})); |
|
87 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
|
18 | 88 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
0 | 89 |
my(@bd) = calc_binDepths($ens); |
90 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
91 |
my($depth) = int($bd[$bin]); |
|
15 | 92 |
next if ($depth<0 || !defined($LADCP{ENSEMBLE}[$ens]->{TILT})); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
93 |
my($range_to_bin) = abs($bd[$bin] - $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}) |
0 | 94 |
/ cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})) |
95 |
/ $cosBeamAngle; |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
96 |
# next |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
97 |
# if ($range_to_bin < $SS_min_allowed_range || |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
98 |
# $range_to_bin > $SS_max_allowed_range); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
99 |
my($temp) = defined($CTD_temp) |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
100 |
? $CTD{TEMP}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
101 |
: $LADCP{ENSEMBLE}[$ens]->{TEMPERATURE}; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
102 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin] = |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
103 |
median( |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
104 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[0],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
105 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][0] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
106 |
), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
107 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[1],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
108 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][1] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
109 |
), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
110 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[2],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
111 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][2] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
112 |
), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
113 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[3],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
114 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][3] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
115 |
) |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
116 |
); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
117 |
$sSv[$depth][$bin] += $LADCP{ENSEMBLE}[$ens]->{SV}[$bin]; |
0 | 118 |
$nSv[$depth][$bin]++; |
119 |
} |
|
120 |
} |
|
121 |
} |
|
122 |
||
123 |
#---------------------------------------------------------------------- |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
124 |
# empirically adjust Sv in far bins for consistency with nearest |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
125 |
# valid bin |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
126 |
# - based on bin-to-bin differences of 100m vertically averaged Sv |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
127 |
# profiles |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
128 |
# - algorithm can leave artifacts in the near bins near bottom |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
129 |
# turn-around (DM1#001) |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
130 |
#---------------------------------------------------------------------- |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
131 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
132 |
sub linterp($$$$$) |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
133 |
{ |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
134 |
my($x,$mix,$max,$miy,$may) = @_; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
135 |
return $miy + ($x-$mix)/($max-$mix)*($may-$miy); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
136 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
137 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
138 |
$Sv_ref_bin = 1; # bin 2 is slightly better than bin 5 => use closest bin as reference as originally intended |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
139 |
# default setting choses first bin with data; do not set to values below 1 |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
140 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
141 |
sub correct_backscatter($$) |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
142 |
{ |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
143 |
my($LADCP_start,$LADCP_end) = @_; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
144 |
my($bin) = $LADCP_firstBin-1; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
145 |
my(@refSvProf,@refSvSamp,$depth,$i); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
146 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
147 |
RETRY: |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
148 |
for ($depth=0; $depth<@nSv; $depth++) { # create reference profile |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
149 |
next unless ($nSv[$depth][$Sv_ref_bin-1] > 0); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
150 |
$refSvProf[int($depth/100)] += $sSv[$depth][$Sv_ref_bin-1] / $nSv[$depth][$Sv_ref_bin-1]; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
151 |
$refSvSamp[int($depth/100)]++; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
152 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
153 |
$Sv_ref_bin++,goto RETRY |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
154 |
unless (@refSvSamp); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
155 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
156 |
for ($i=0; $i<@refSvSamp; $i++) { |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
157 |
next unless ($refSvSamp[$i] > 0); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
158 |
$refSvProf[$i] /= $refSvSamp[$i]; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
159 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
160 |
for ($i=0; $i<5; $i++) { # extrapolate bottom value by 500m |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
161 |
push(@refSvProf,$refSvProf[$#refSvProf]); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
162 |
push(@refSvSamp,$refSvSamp[$#refSvSamp]); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
163 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
164 |
info("\tusing bin %d as reference\n",$Sv_ref_bin); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
165 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
166 |
my(@dSvProf); # create profiles for all bins |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
167 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
168 |
my(@dSvSamp); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
169 |
for ($depth=0; $depth<@nSv; $depth++) { # create Sv-difference profile for current bin |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
170 |
next unless ($nSv[$depth][$bin] > 0); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
171 |
$dSvProf[int($depth/100)][$bin] += $sSv[$depth][$bin] / $nSv[$depth][$bin]; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
172 |
$dSvSamp[int($depth/100)]++; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
173 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
174 |
for ($i=0; $i<@dSvSamp; $i++) { |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
175 |
next unless ($refSvSamp[$i] > 0) && ($dSvSamp[$i] > 0); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
176 |
$dSvProf[$i][$bin] = $dSvProf[$i][$bin]/$dSvSamp[$i] - $refSvProf[$i]; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
177 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
178 |
$dSvProf[$i][$bin] = $dSvProf[$i-1][$bin]; # extrapolate 100m |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
179 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
180 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
181 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { # correct Sv data |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
182 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
183 |
my(@bd) = calc_binDepths($ens); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
184 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
185 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{SV}[$bin]); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
186 |
my($depth) = int($bd[$bin]); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
187 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin] -= $dSvProf[int($depth/100)][$bin]; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
188 |
linterp($depth,100*int($depth/100),100*int($depth/100)+100, |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
189 |
$dSvProf[int($depth/100)][$bin],$dSvProf[int($depth/100)+1][$bin]); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
190 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
191 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
192 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
193 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
194 |
#---------------------------------------------------------------------- |
0 | 195 |
# determine location of seabed from backscatter profiles |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
18
diff
changeset
|
196 |
# input: depth below which seabed can possibly be (e.g. max CTD depth) |
0 | 197 |
# output: median/mad of estimated water depth |
198 |
#---------------------------------------------------------------------- |
|
199 |
||
200 |
sub find_backscatter_seabed($) |
|
201 |
{ |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
202 |
my($search_below) = int($_[0]); # grid index to begin search |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
203 |
my(@wdepth,@Sv_rng); # list of water_depth indices |
0 | 204 |
|
205 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { # find backscatter min/max below $search_below in each bin |
|
206 |
my($minSv,$maxSv,$depthmaxSv,$lastvalid) = (1e99,-1e99,-1,-1); |
|
207 |
for (my($depth)=$search_below; $depth<@nSv; $depth++) { |
|
208 |
next unless ($nSv[$depth][$bin] > 0); |
|
209 |
my($Sv) = $sSv[$depth][$bin] / $nSv[$depth][$bin]; |
|
210 |
$lastvalid = $depth; |
|
211 |
$minSv = $Sv if ($Sv < $minSv); |
|
212 |
$maxSv = $Sv, $depthmaxSv = $depth if ($Sv > $maxSv); |
|
213 |
} |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
214 |
if ($maxSv-$minSv >= $SS_min_signal) { # ignore scatter |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
215 |
push(@Sv_rng,round($maxSv-$minSv)); |
0 | 216 |
push(@wdepth,$depthmaxSv); |
217 |
} |
|
218 |
} |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
18
diff
changeset
|
219 |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
220 |
if (@wdepth) { |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
221 |
info("%d bins with seabed signatures found (\@Sv_rng: @Sv_rng)\n",scalar(@wdepth)); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
222 |
} else { |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
223 |
info("no bins with seabed signatures found\n"); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
224 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
225 |
return (undef,undef) if (scalar(@wdepth) < $SS_min_samp); # require min number of samples |
0 | 226 |
|
227 |
my($wd) = median(@wdepth); |
|
228 |
return ($wd,mad2($wd,@wdepth)); |
|
229 |
||
230 |
} |
|
231 |
||
232 |
1; |