0
|
1 |
#======================================================================
|
|
2 |
# M E R G E C T D + L A D C P . E D I T D A T A
|
|
3 |
# doc: Sat May 22 21:35:55 2010
|
|
4 |
# dlm: Fri Oct 29 23:01:13 2010
|
|
5 |
# (c) 2010 A.M. Thurnherr
|
|
6 |
# uE-Info: 75 0 NIL 0 0 72 2 2 4 NIL ofnI
|
|
7 |
#======================================================================
|
|
8 |
|
|
9 |
# HISTORY:
|
|
10 |
# May 22, 2010: - created
|
|
11 |
# May 24, 2010: - added editSideLobesFromSeabed()
|
|
12 |
# Oct 29, 2010: - added editCorr_Earthcoords
|
|
13 |
|
|
14 |
# NOTES:
|
|
15 |
# - all bins must be edited (not just valid ones), to allow
|
|
16 |
# reflr calculations to use invalid bins
|
|
17 |
|
|
18 |
#======================================================================
|
|
19 |
# $vv = countValidVels($ens)
|
|
20 |
#======================================================================
|
|
21 |
|
|
22 |
sub countValidBeamVels($)
|
|
23 |
{
|
|
24 |
my($ens) = @_;
|
|
25 |
|
|
26 |
my($vv) = 0;
|
|
27 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
|
|
28 |
$vv += defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][0]);
|
|
29 |
$vv += defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][1]);
|
|
30 |
$vv += defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][2]);
|
|
31 |
$vv += defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][3]);
|
|
32 |
}
|
|
33 |
return $vv;
|
|
34 |
}
|
|
35 |
|
|
36 |
#======================================================================
|
|
37 |
# $edited = editCorr($ens,$threshold)
|
|
38 |
#
|
|
39 |
# NOTES:
|
|
40 |
# - called before Earth vels have been calculated
|
|
41 |
#======================================================================
|
|
42 |
|
|
43 |
sub editCorr($$)
|
|
44 |
{
|
|
45 |
my($ens,$lim) = @_;
|
|
46 |
|
|
47 |
my($nrm) = 0;
|
|
48 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
|
|
49 |
for (my($beam)=0; $beam<4; $beam++) {
|
|
50 |
next if ($LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin][$beam] >= $lim ||
|
|
51 |
!defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam]));
|
|
52 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam]);
|
|
53 |
$nrm++;
|
|
54 |
}
|
|
55 |
}
|
|
56 |
return $nrm;
|
|
57 |
}
|
|
58 |
|
|
59 |
sub editCorr_Earthcoords($$)
|
|
60 |
{
|
|
61 |
my($ens,$lim) = @_;
|
|
62 |
|
|
63 |
my($nrm) = 0;
|
|
64 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
|
|
65 |
my($beam);
|
|
66 |
for ($beam=0; $beam<4; $beam++) {
|
|
67 |
last unless ($LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin][$beam] >= $lim);
|
|
68 |
}
|
|
69 |
if ($beam < 4) {
|
|
70 |
for (my($c)=0; $c<4; $c++) {
|
|
71 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$c]);
|
|
72 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$c]);
|
|
73 |
$nrm++;
|
|
74 |
}
|
|
75 |
}
|
|
76 |
}
|
|
77 |
return $nrm;
|
|
78 |
}
|
|
79 |
|
|
80 |
#======================================================================
|
|
81 |
# $edited = editPitchRoll($ens,$threshold)
|
|
82 |
#
|
|
83 |
# NOTES:
|
|
84 |
# - called before Earth vels have been calculated
|
|
85 |
# - for consistency with editCorr() the individual velocities are counted
|
|
86 |
#======================================================================
|
|
87 |
|
|
88 |
sub editPitchRoll($$)
|
|
89 |
{
|
|
90 |
my($ens,$lim) = @_;
|
|
91 |
|
|
92 |
return 0 if (abs($LADCP{ENSEMBLE}[$ens]->{PITCH}) <= $lim &&
|
|
93 |
abs($LADCP{ENSEMBLE}[$ens]->{ROLL}) <= $lim);
|
|
94 |
|
|
95 |
my($nrm) = 0;
|
|
96 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
|
|
97 |
for (my($beam)=0; $beam<4; $beam++) {
|
|
98 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam]);
|
|
99 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam]);
|
|
100 |
$nrm++;
|
|
101 |
}
|
|
102 |
}
|
|
103 |
return $nrm;
|
|
104 |
}
|
|
105 |
|
|
106 |
#======================================================================
|
|
107 |
# $edited = editErrVel($ens,$threshold)
|
|
108 |
#
|
|
109 |
# NOTES:
|
|
110 |
# - call after Earth vels have been calculated
|
|
111 |
#======================================================================
|
|
112 |
|
|
113 |
sub editErrVel($$)
|
|
114 |
{
|
|
115 |
my($ens,$lim) = @_;
|
|
116 |
|
|
117 |
my($nrm) = 0;
|
|
118 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
|
|
119 |
next if (abs($LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin]) <= $lim);
|
|
120 |
undef($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
|
|
121 |
$nrm++
|
|
122 |
}
|
|
123 |
return $nrm;
|
|
124 |
}
|
|
125 |
|
|
126 |
#======================================================================
|
|
127 |
# ($nvrm,$nerm) = editSideLobes($fromEns,$toEns,$range)
|
|
128 |
#
|
|
129 |
# NOTES:
|
|
130 |
# 1) When this code is executed the sound speed is known. No attempt is made to correct for
|
|
131 |
# along-beam soundspeed variation, but the soundspeed at the transducer is accounted for.
|
|
132 |
#======================================================================
|
|
133 |
|
|
134 |
sub editSideLobes($$$)
|
|
135 |
{
|
|
136 |
my($fe,$te,$wd) = @_; # first & last ens to process, water depth for downlooker
|
|
137 |
my($nvrm) = 0; # of velocities removed
|
|
138 |
my($nerm) = 0; # of ensembles affected
|
|
139 |
for (my($e)=$fe; $e<=$te; $e++) {
|
|
140 |
next unless numberp($LADCP{ENSEMBLE}[$e]->{DEPTH})
|
|
141 |
&& numberp($LADCP{ENSEMBLE}[$e]->{SOUND_SPEED});
|
|
142 |
my($range) = $LADCP{ENSEMBLE}[$e]->{XDUCER_FACING_UP}
|
|
143 |
? $LADCP{ENSEMBLE}[$e]->{DEPTH}
|
|
144 |
: $wd - $LADCP{ENSEMBLE}[$e]->{DEPTH};
|
|
145 |
my($sscorr) = $LADCP{ENSEMBLE}[$e]->{SOUND_SPEED} / 1500;
|
|
146 |
my($goodBins) = ($range - $sscorr*$LADCP{DISTANCE_TO_BIN1_CENTER}*cos(rad($LADCP{BEAM_ANGLE})))
|
|
147 |
/ ($sscorr*$LADCP{BIN_LENGTH}*cos(rad($LADCP{BEAM_ANGLE})))
|
|
148 |
- 1.5;
|
|
149 |
|
|
150 |
my($dirty) = 0;
|
|
151 |
for (my($bin)=int($goodBins); $bin<$LADCP{N_BINS}; $bin++) { # NB: 2 good bins implies that bin 2 is bad
|
|
152 |
next unless ($bin>=0 && defined($LADCP{ENSEMBLE}[$e]->{W}[$bin]));
|
|
153 |
$dirty = 1;
|
|
154 |
$nvrm++;
|
|
155 |
undef($LADCP{ENSEMBLE}[$e]->{W}[$bin]);
|
|
156 |
}
|
|
157 |
|
|
158 |
$nerm += $dirty;
|
|
159 |
}
|
|
160 |
return ($nvrm,$nerm);
|
|
161 |
}
|
|
162 |
|
|
163 |
1;
|