author | A.M. Thurnherr <athurnherr@yahoo.com> |
Sat, 24 Jul 2021 10:35:41 -0400 | |
changeset 56 | 8f120b9f795a |
parent 46 | cc6c4309828a |
child 57 | 69e39fcb7f41 |
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 |
|
56 | 4 |
# dlm: Thu Jul 1 09:37:40 2021 |
0 | 5 |
# (c) 2010 A.M. Thurnherr |
56 | 6 |
# uE-Info: 32 46 NIL 0 0 72 2 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 |
29 | 25 |
# Apr 21, 2015: - added debug statements |
26 |
# May 14, 2015: - BUG: code did not work for partial-depth casts |
|
27 |
# Jun 18, 2015: - removed assertion marked by ##???, which bombed on P16N1#41 DL |
|
42 | 28 |
# Jan 26, 2016: - added %PARAMs |
29 |
# Mar 26, 2016: - BUG: nSv was declared local to this scope even though it is used outside |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
30 |
# May 18, 2016: - improved logging |
46 | 31 |
# May 24, 2016: - calc_binDepths() -> binDepths() |
56 | 32 |
# Jul 1, 2021: - made %PARAMs more standard |
33 |
# HISTORY END |
|
34 |
||
0 | 35 |
|
36 |
#---------------------------------------------------------------------- |
|
37 |
# Volume Scattering Coefficient, following Deines (IEEE 1999) |
|
38 |
# NOTES: |
|
39 |
# - instrument specific! (300kHz Workhorse) |
|
40 |
# - no sound-speed correction applied |
|
41 |
# - R in bin center, instead of last quarter |
|
42 |
# - 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
|
43 |
# 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
|
44 |
# - 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
|
45 |
# - 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
|
46 |
# - 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
|
47 |
# - 003, with higher scattering is somewhat different |
0 | 48 |
#---------------------------------------------------------------------- |
49 |
||
50 |
# NB: |
|
51 |
# - correction seems to work for a subset of bins (~bins 3-9 for |
|
52 |
# 2010 P403 station 46) |
|
53 |
# - this may imply that noise level depends on bin |
|
54 |
# - far bins are important for seabed detection, i.e. cannot simply |
|
55 |
# be discarded at this stage |
|
56 |
||
57 |
sub Sv($$$$$) |
|
58 |
{ |
|
59 |
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
|
60 |
my($C) = -143; # RDI WHM300 (from Deines) |
0 | 61 |
my($Ldbm) = 10 * log10($PL); |
62 |
my($PdbW) = 14.0; |
|
63 |
my($alpha) = 0.069; |
|
64 |
my($Kc) = 0.45; |
|
65 |
||
66 |
return $C + 10*log10(($temp+273)*$R**2) - $Ldbm - $PdbW |
|
67 |
+ 2*$alpha*$R + $Kc*($EA-$Er); |
|
68 |
} |
|
69 |
||
70 |
#---------------------------------------------------------------------- |
|
71 |
# Calculate per-bin backscatter profiles |
|
72 |
# input: first and last valid LADCP ensemble |
|
73 |
# output: sSv[$depth][$bin] sum of volume scattering coefficients |
|
74 |
# nSv[$depth][$bin] number of samples in bin |
|
75 |
#---------------------------------------------------------------------- |
|
76 |
||
42 | 77 |
# my(@sSv,@nSv); BAD: nSv is referenced in [LADCP_w_ocean] |
0 | 78 |
|
79 |
sub calc_backscatter_profs($$) |
|
80 |
{ |
|
81 |
my($LADCP_start,$LADCP_end) = @_; |
|
82 |
||
83 |
my(@Er) = (1e99,1e99,1e99,1e99); # echo intensity reference level |
|
84 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
|
85 |
$Er[0] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][0] |
|
86 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][0] < $Er[0]); |
|
87 |
$Er[1] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][1] |
|
88 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][1] < $Er[1]); |
|
89 |
$Er[2] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][2] |
|
90 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][2] < $Er[2]); |
|
91 |
$Er[3] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][3] |
|
92 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][3] < $Er[3]); |
|
93 |
} |
|
94 |
debugmsg("per-beam noise levels = @Er\n"); |
|
95 |
||
96 |
my($cosBeamAngle) = cos(rad($LADCP{BEAM_ANGLE})); |
|
97 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
|
18 | 98 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
46 | 99 |
my(@bd) = binDepths($ens); |
0 | 100 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
101 |
my($depth) = int($bd[$bin]); |
|
15 | 102 |
next if ($depth<0 || !defined($LADCP{ENSEMBLE}[$ens]->{TILT})); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
103 |
my($range_to_bin) = abs($bd[$bin] - $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}) |
0 | 104 |
/ cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})) |
105 |
/ $cosBeamAngle; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
106 |
my($temp) = defined($CTD_temp) |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
107 |
? $CTD{TEMP}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
108 |
: $LADCP{ENSEMBLE}[$ens]->{TEMPERATURE}; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
109 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin] = |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
110 |
median( |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
111 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[0],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
112 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][0] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
113 |
), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
114 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[1],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
115 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][1] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
116 |
), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
117 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[2],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
118 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][2] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
119 |
), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
120 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[3],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
121 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][3] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
122 |
) |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
123 |
); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
124 |
$sSv[$depth][$bin] += $LADCP{ENSEMBLE}[$ens]->{SV}[$bin]; |
0 | 125 |
$nSv[$depth][$bin]++; |
126 |
} |
|
127 |
} |
|
128 |
} |
|
129 |
||
130 |
#---------------------------------------------------------------------- |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
131 |
# 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
|
132 |
# valid bin |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
133 |
# - 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
|
134 |
# profiles |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
135 |
# - 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
|
136 |
# turn-around (DM1#001) |
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 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
139 |
sub linterp($$$$$) |
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 |
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
|
142 |
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
|
143 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
144 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
145 |
sub correct_backscatter($$) |
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 |
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
|
148 |
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
|
149 |
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
|
150 |
|
34 | 151 |
&antsAddParams('Sv_ref_bin',$Sv_ref_bin); |
152 |
||
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
153 |
RETRY: |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
154 |
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
|
155 |
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
|
156 |
$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
|
157 |
$refSvSamp[int($depth/100)]++; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
158 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
159 |
$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
|
160 |
unless (@refSvSamp); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
161 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
162 |
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
|
163 |
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
|
164 |
$refSvProf[$i] /= $refSvSamp[$i]; |
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 |
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
|
167 |
push(@refSvProf,$refSvProf[$#refSvProf]); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
168 |
push(@refSvSamp,$refSvSamp[$#refSvSamp]); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
169 |
} |
29 | 170 |
for ($i=$#refSvProf-1; $i>=0; $i--) { # extrapolate upward to surface |
171 |
next if ($refSvSamp[$i] > 0); |
|
172 |
$refSvProf[$i] = $refSvProf[$i+1]; |
|
173 |
$refSvSamp[$i] = $refSvSamp[$i+1]; |
|
174 |
} |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
175 |
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
|
176 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
177 |
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
|
178 |
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
|
179 |
my(@dSvSamp); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
180 |
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
|
181 |
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
|
182 |
$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
|
183 |
$dSvSamp[int($depth/100)]++; |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
184 |
} |
29 | 185 |
# print(STDERR "dSvProf[bin$bin] = "); |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
186 |
for ($i=0; $i<@dSvSamp; $i++) { |
29 | 187 |
next unless ($dSvSamp[$i] > 0); |
188 |
die("assertion failed (refSvSamp[$i] = $refSvSamp[$i])") unless ($refSvSamp[$i] > 0); |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
189 |
$dSvProf[$i][$bin] = $dSvProf[$i][$bin]/$dSvSamp[$i] - $refSvProf[$i]; |
29 | 190 |
$dSvProf[$i][$bin] = $dSvProf[$i-1][$bin] |
191 |
if (abs($dSvProf[$i][$bin]) > 10); |
|
192 |
# printf(STDERR "%.1f ",$dSvProf[$i][$bin]); |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
193 |
} |
29 | 194 |
$i--; # trim deepest, often anomalous, value |
195 |
# print(STDERR "[delete] "); |
|
196 |
while ($i <= int(scalar(@nSv)/100)+1) { |
|
197 |
$dSvProf[$i][$bin] = $dSvProf[$i-1][$bin]; # extrapolate 100m |
|
198 |
# printf(STDERR "[%.1f] ",$dSvProf[$i][$bin]); |
|
199 |
$i++; |
|
200 |
} |
|
201 |
# print(STDERR "\n"); |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
202 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
203 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
204 |
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
|
205 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
46 | 206 |
my(@bd) = binDepths($ens); |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
207 |
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
|
208 |
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
|
209 |
my($depth) = int($bd[$bin]); |
29 | 210 |
if (numberp($dSvProf[int($depth/100)][$bin]) && numberp($dSvProf[int($depth/100)+1][$bin])) { |
211 |
# print(STDERR "\n$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]? $dSvProf[int($depth/100)][$bin] $dSvProf[int($depth/100)+1][$bin] int($depth/100)+1[$bin]"); |
|
212 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin] -= # $dSvProf[int($depth/100)][$bin]; |
|
213 |
linterp($depth,100*int($depth/100),100*int($depth/100)+100, |
|
214 |
$dSvProf[int($depth/100)][$bin],$dSvProf[int($depth/100)+1][$bin]); |
|
215 |
} else { |
|
216 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin] = nan; |
|
217 |
} |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
218 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
219 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
220 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
221 |
|
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
222 |
#---------------------------------------------------------------------- |
0 | 223 |
# 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
|
224 |
# input: depth below which seabed can possibly be (e.g. max CTD depth) |
0 | 225 |
# output: median/mad of estimated water depth |
226 |
#---------------------------------------------------------------------- |
|
227 |
||
228 |
sub find_backscatter_seabed($) |
|
229 |
{ |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
230 |
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
|
231 |
my(@wdepth,@Sv_rng); # list of water_depth indices |
0 | 232 |
|
56 | 233 |
&antsAddParams('SS_signal.min',$SS_min_signal,'SS_samp.min',$SS_min_samp, |
234 |
'SS_allowed_depth_range.max',$SS_max_allowed_depth_range); |
|
34 | 235 |
|
0 | 236 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { # find backscatter min/max below $search_below in each bin |
237 |
my($minSv,$maxSv,$depthmaxSv,$lastvalid) = (1e99,-1e99,-1,-1); |
|
238 |
for (my($depth)=$search_below; $depth<@nSv; $depth++) { |
|
239 |
next unless ($nSv[$depth][$bin] > 0); |
|
240 |
my($Sv) = $sSv[$depth][$bin] / $nSv[$depth][$bin]; |
|
241 |
$lastvalid = $depth; |
|
242 |
$minSv = $Sv if ($Sv < $minSv); |
|
243 |
$maxSv = $Sv, $depthmaxSv = $depth if ($Sv > $maxSv); |
|
244 |
} |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
245 |
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
|
246 |
push(@Sv_rng,round($maxSv-$minSv)); |
0 | 247 |
push(@wdepth,$depthmaxSv); |
248 |
} |
|
249 |
} |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
18
diff
changeset
|
250 |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
251 |
if (@wdepth) { |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
252 |
info("\t%d bins with seabed signatures found (\@Sv_rng: @Sv_rng)\n",scalar(@wdepth)); |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
253 |
} else { |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
254 |
info("\tno bins with seabed signatures found\n"); |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
255 |
} |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
256 |
return (undef,undef) if (scalar(@wdepth) < $SS_min_samp); # require min number of samples |
0 | 257 |
|
258 |
my($wd) = median(@wdepth); |
|
259 |
return ($wd,mad2($wd,@wdepth)); |
|
260 |
||
261 |
} |
|
262 |
||
263 |
1; |