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