author | A.M. Thurnherr <athurnherr@yahoo.com> |
Mon, 12 Oct 2015 16:57:30 +0000 | |
changeset 32 | 6041a20feb39 |
parent 5 | 509cc9966b68 |
child 34 | e550db661c17 |
permissions | -rw-r--r-- |
0 | 1 |
#====================================================================== |
2 |
# F I N D _ S E A B E D . P L |
|
3 |
# doc: Sun May 23 20:26:11 2010 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
4 |
# dlm: Wed Oct 19 14:25:27 2011 |
0 | 5 |
# (c) 2010 A.M. Thurnherr |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
6 |
# uE-Info: 15 0 NIL 0 0 72 0 2 4 NIL ofnI |
0 | 7 |
#====================================================================== |
8 |
||
9 |
# HISTORY: |
|
10 |
# May 23, 2010: - adapted from [perl-tools/RDI_Utils.pl] |
|
11 |
# Dec 25, 2010: - adapted to changes in [LADCP_w] |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
12 |
# Oct 11, 2011: - moved defaults to [defaults.pl] |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
13 |
# - increased z_offset from 10km to 15km |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
14 |
# Oct 19, 2011: - added $SS_max_allowed_range |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
15 |
# - renamed $SS_min_allowed_hab to *_range |
0 | 16 |
|
17 |
# NOTES: |
|
18 |
# 1) BT range is corrected for sound speed at the transducer. This is not |
|
19 |
# accurate, but unlikely to be very wrong, at least for deep casts, |
|
20 |
# because the vertical sound speed variability near the seabed tends |
|
21 |
# to be small. The seabed depth is only used for sidelobe editing, |
|
22 |
# which is done with a generous safety margin (from the UH shear |
|
23 |
# method implementation). |
|
24 |
# 2) Acquisition sound speed of 1500m/s assumed. |
|
25 |
# 3) To be reasonably accurate, DEPTH must be from the CTD at this stage. |
|
26 |
||
27 |
#====================================================================== |
|
28 |
# (seabed median depth, mad) = find_seabed(dta ptr, btm ensno, coord flag) |
|
29 |
#====================================================================== |
|
30 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
31 |
my($z_offset) = 15000; # shift z to ensure +ve array indices |
0 | 32 |
|
33 |
sub find_seabed($$$) |
|
34 |
{ |
|
35 |
my($d,$be,$beamCoords) = @_; |
|
36 |
my($i,$dd,$sd,$nd); |
|
37 |
my(@guesses); |
|
38 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
39 |
return undef unless ($be-$SS_search_window_halfwidth >= 0 && |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
40 |
$be+$SS_search_window_halfwidth <= $#{$d->{ENSEMBLE}}); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
41 |
for ($i=$be-$SS_search_window_halfwidth; $i<=$be+$SS_search_window_halfwidth; $i++) { |
0 | 42 |
next unless (defined($d->{ENSEMBLE}[$i]->{CTD_DEPTH}) && |
43 |
defined($d->{ENSEMBLE}[$i]->{BT_RANGE}[0]) && |
|
44 |
defined($d->{ENSEMBLE}[$i]->{BT_RANGE}[1]) && |
|
45 |
defined($d->{ENSEMBLE}[$i]->{BT_RANGE}[2]) && |
|
46 |
defined($d->{ENSEMBLE}[$i]->{BT_RANGE}[3])); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
47 |
|
0 | 48 |
my(@BT) = $beamCoords |
49 |
? velInstrumentToEarth($d,$i, |
|
50 |
velBeamToInstrument($d, |
|
51 |
@{$d->{ENSEMBLE}[$i]->{BT_VELOCITY}})) |
|
52 |
: velApplyHdgBias($d,$i,@{$d->{ENSEMBLE}[$i]->{BT_VELOCITY}}); |
|
53 |
next unless (abs($BT[3]) < 0.05); |
|
54 |
$d->{ENSEMBLE}[$i]->{DEPTH_BT} = |
|
55 |
$d->{ENSEMBLE}[$i]->{BT_RANGE}[0]/4 + |
|
56 |
$d->{ENSEMBLE}[$i]->{BT_RANGE}[1]/4 + |
|
57 |
$d->{ENSEMBLE}[$i]->{BT_RANGE}[2]/4 + |
|
58 |
$d->{ENSEMBLE}[$i]->{BT_RANGE}[3]/4; |
|
59 |
$d->{ENSEMBLE}[$i]->{DEPTH_BT} *= cos(rad($d->{BEAM_ANGLE})); |
|
60 |
$d->{ENSEMBLE}[$i]->{DEPTH_BT} *= $CTD{SVEL}[$d->{ENSEMBLE}[$i]->{CTD_SCAN}]/1500; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
61 |
next unless ($d->{ENSEMBLE}[$i]->{DEPTH_BT} >= $SS_min_allowed_range && |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
62 |
$d->{ENSEMBLE}[$i]->{DEPTH_BT} <= $SS_max_allowed_range); |
0 | 63 |
$d->{ENSEMBLE}[$i]->{DEPTH_BT} *= -1 |
64 |
if ($d->{ENSEMBLE}[$i]->{XDUCER_FACING_UP}); |
|
65 |
$d->{ENSEMBLE}[$i]->{DEPTH_BT} += $d->{ENSEMBLE}[$i]->{CTD_DEPTH}; |
|
66 |
if ($d->{ENSEMBLE}[$i]->{DEPTH_BT} > $d->{ENSEMBLE}[$be]->{CTD_DEPTH}) { |
|
67 |
$guesses[int($d->{ENSEMBLE}[$i]->{DEPTH_BT})+$z_offset]++; |
|
68 |
$nd++; |
|
69 |
} else { |
|
70 |
undef($d->{ENSEMBLE}[$i]->{DEPTH_BT}); |
|
71 |
} |
|
72 |
} |
|
73 |
return undef unless ($nd>5); |
|
74 |
||
75 |
my($mode,$nmax); |
|
76 |
for ($i=0; $i<=$#guesses; $i++) { # find mode |
|
77 |
$nmax=$guesses[$i],$mode=$i-$z_offset |
|
78 |
if ($guesses[$i] > $nmax); |
|
79 |
} |
|
80 |
||
81 |
$nd = 0; |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
82 |
for ($i=$be-$SS_search_window_halfwidth; $i<=$be+$SS_search_window_halfwidth; $i++) { |
0 | 83 |
next unless defined($d->{ENSEMBLE}[$i]->{DEPTH_BT}); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
84 |
if (abs($d->{ENSEMBLE}[$i]->{DEPTH_BT}-$mode) <= $SS_max_allowed_depth_range) { |
0 | 85 |
$dd += $d->{ENSEMBLE}[$i]->{DEPTH_BT}; |
86 |
$nd++; |
|
87 |
} else { |
|
88 |
undef($d->{ENSEMBLE}[$i]->{DEPTH_BT}); |
|
89 |
} |
|
90 |
} |
|
91 |
return undef unless ($nd >= 2); |
|
92 |
||
93 |
$dd /= $nd; |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
94 |
for ($i=$be-$SS_search_window_halfwidth; $i<=$be+$SS_search_window_halfwidth; $i++) { |
0 | 95 |
next unless defined($d->{ENSEMBLE}[$i]->{DEPTH_BT}); |
96 |
$sd += ($d->{ENSEMBLE}[$i]->{DEPTH_BT}-$dd)**2; |
|
97 |
} |
|
98 |
||
99 |
return ($dd, sqrt($sd/($nd-1))); |
|
100 |
} |
|
101 |