author | A.M. Thurnherr <athurnherr@yahoo.com> |
Thu, 16 Apr 2015 14:50:59 +0000 | |
changeset 27 | 2053d8de8d6b |
parent 18 | 8818acdcd587 |
child 28 | b07b23485336 |
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 |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
18
diff
changeset
|
4 |
# dlm: Thu Apr 16 14:40:22 2015 |
0 | 5 |
# (c) 2010 A.M. Thurnherr |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
18
diff
changeset
|
6 |
# uE-Info: 141 0 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 |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
18
diff
changeset
|
21 |
# Apr 16, 2015: - added min samp criterion for seabed search |
0 | 22 |
|
23 |
#---------------------------------------------------------------------- |
|
24 |
# Volume Scattering Coefficient, following Deines (IEEE 1999) |
|
25 |
# NOTES: |
|
26 |
# - instrument specific! (300kHz Workhorse) |
|
27 |
# - no sound-speed correction applied |
|
28 |
# - R in bin center, instead of last quarter |
|
29 |
# - transmit power assumes 33V batteries |
|
30 |
#---------------------------------------------------------------------- |
|
31 |
||
32 |
# NB: |
|
33 |
# - correction seems to work for a subset of bins (~bins 3-9 for |
|
34 |
# 2010 P403 station 46) |
|
35 |
# - this may imply that noise level depends on bin |
|
36 |
# - far bins are important for seabed detection, i.e. cannot simply |
|
37 |
# be discarded at this stage |
|
38 |
||
39 |
sub Sv($$$$$) |
|
40 |
{ |
|
41 |
my($temp,$PL,$Er,$R,$EA) = @_; |
|
42 |
my($C) = -143; # RDI Workhorse monitor |
|
43 |
my($Ldbm) = 10 * log10($PL); |
|
44 |
my($PdbW) = 14.0; |
|
45 |
my($alpha) = 0.069; |
|
46 |
my($Kc) = 0.45; |
|
47 |
||
48 |
return $C + 10*log10(($temp+273)*$R**2) - $Ldbm - $PdbW |
|
49 |
+ 2*$alpha*$R + $Kc*($EA-$Er); |
|
50 |
} |
|
51 |
||
52 |
#---------------------------------------------------------------------- |
|
53 |
# Calculate per-bin backscatter profiles |
|
54 |
# input: first and last valid LADCP ensemble |
|
55 |
# output: sSv[$depth][$bin] sum of volume scattering coefficients |
|
56 |
# nSv[$depth][$bin] number of samples in bin |
|
57 |
#---------------------------------------------------------------------- |
|
58 |
||
59 |
my(@sSv,@nSv); |
|
60 |
||
61 |
sub calc_backscatter_profs($$) |
|
62 |
{ |
|
63 |
my($LADCP_start,$LADCP_end) = @_; |
|
64 |
||
65 |
my(@Er) = (1e99,1e99,1e99,1e99); # echo intensity reference level |
|
66 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
|
67 |
$Er[0] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][0] |
|
68 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][0] < $Er[0]); |
|
69 |
$Er[1] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][1] |
|
70 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][1] < $Er[1]); |
|
71 |
$Er[2] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][2] |
|
72 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][2] < $Er[2]); |
|
73 |
$Er[3] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][3] |
|
74 |
if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][3] < $Er[3]); |
|
75 |
} |
|
76 |
debugmsg("per-beam noise levels = @Er\n"); |
|
77 |
||
78 |
my($cosBeamAngle) = cos(rad($LADCP{BEAM_ANGLE})); |
|
79 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
|
18 | 80 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
0 | 81 |
my(@bd) = calc_binDepths($ens); |
82 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
83 |
my($depth) = int($bd[$bin]); |
|
15 | 84 |
next if ($depth<0 || !defined($LADCP{ENSEMBLE}[$ens]->{TILT})); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
85 |
my($range_to_bin) = abs($bd[$bin] - $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}) |
0 | 86 |
/ cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})) |
87 |
/ $cosBeamAngle; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
88 |
next |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
89 |
if ($range_to_bin < $SS_min_allowed_range || |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
90 |
$range_to_bin > $SS_max_allowed_range); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
91 |
my($temp) = defined($CTD_temp) |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
92 |
? $CTD{TEMP}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
93 |
: $LADCP{ENSEMBLE}[$ens]->{TEMPERATURE}; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
94 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin] = |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
95 |
median( |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
96 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[0],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
97 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][0] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
98 |
), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
99 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[1],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
100 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][1] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
101 |
), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
102 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[2],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
103 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][2] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
104 |
), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
105 |
Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[3],$range_to_bin, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
106 |
$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][3] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
107 |
) |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
108 |
); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
109 |
$sSv[$depth][$bin] += $LADCP{ENSEMBLE}[$ens]->{SV}[$bin]; |
0 | 110 |
$nSv[$depth][$bin]++; |
111 |
} |
|
112 |
} |
|
113 |
} |
|
114 |
||
115 |
#---------------------------------------------------------------------- |
|
116 |
# 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
|
117 |
# input: depth below which seabed can possibly be (e.g. max CTD depth) |
0 | 118 |
# output: median/mad of estimated water depth |
119 |
#---------------------------------------------------------------------- |
|
120 |
||
121 |
sub find_backscatter_seabed($) |
|
122 |
{ |
|
123 |
my($search_below) = int($_[0]); # grid index to begin search |
|
124 |
my(@wdepth); # list of water_depth indices |
|
125 |
||
126 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { # find backscatter min/max below $search_below in each bin |
|
127 |
my($minSv,$maxSv,$depthmaxSv,$lastvalid) = (1e99,-1e99,-1,-1); |
|
128 |
for (my($depth)=$search_below; $depth<@nSv; $depth++) { |
|
129 |
next unless ($nSv[$depth][$bin] > 0); |
|
130 |
my($Sv) = $sSv[$depth][$bin] / $nSv[$depth][$bin]; |
|
131 |
$lastvalid = $depth; |
|
132 |
$minSv = $Sv if ($Sv < $minSv); |
|
133 |
$maxSv = $Sv, $depthmaxSv = $depth if ($Sv > $maxSv); |
|
134 |
} |
|
135 |
if ($maxSv-$minSv>10 && $depthmax!=$lastvalid) { # ignore boundary maxima & scatter |
|
136 |
push(@wdepth,$depthmaxSv); |
|
137 |
} |
|
138 |
} |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
18
diff
changeset
|
139 |
|
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
18
diff
changeset
|
140 |
info("%d seabed samples found\n",scalar(@wdepth)); |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
18
diff
changeset
|
141 |
return (undef,undef) if (scalar(@wdepth) < $SS_min_samp); # require min number of samples |
0 | 142 |
|
143 |
my($wd) = median(@wdepth); |
|
144 |
return ($wd,mad2($wd,@wdepth)); |
|
145 |
||
146 |
} |
|
147 |
||
148 |
1; |