author | A.M. Thurnherr <athurnherr@yahoo.com> |
Tue, 06 Dec 2022 12:47:21 -0500 | |
changeset 64 | 58ef697c01ae |
parent 57 | 69e39fcb7f41 |
permissions | -rw-r--r-- |
0 | 1 |
#====================================================================== |
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
2 |
# E D I T _ D A T A . P L |
0 | 3 |
# doc: Sat May 22 21:35:55 2010 |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
4 |
# dlm: Mon Oct 18 21:39:56 2021 |
0 | 5 |
# (c) 2010 A.M. Thurnherr |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
6 |
# uE-Info: 55 60 NIL 0 0 72 72 2 4 NIL ofnI |
0 | 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] |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
17 |
# Aug 3, 2011: - added editTruncRange() |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
18 |
# Oct 10, 2011: - added editFalsePositives() |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
19 |
# - BUG: when Earth velocities were edited, all were |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
20 |
# counted, not just those between first and lastBin |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
21 |
# 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:
3
diff
changeset
|
22 |
# Oct 12, 2011: - added &editSurfLayer() |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
23 |
# - BUG: editSideLobes() was slightly loose |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
24 |
# Oct 15, 2011: - added editWOutliers() |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
25 |
# Oct 20, 2011: - added editFarBins() |
6 | 26 |
# Oct 27, 2011: - adapted editTilt() to new call location |
27 |
# - added correctAttitude() |
|
10
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
28 |
# Oct 15, 2012: - BUG: editSurfLayer() counted also ensembles without CTD depth |
13 | 29 |
# Nov 12, 2013: - added comments on editCorr_Earthcoords() |
15 | 30 |
# Mar 4, 2013: - added support for missing PITCH/ROLL (TILT) & HEADING |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
31 |
# May 20, 2014: - added editPPI() |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
32 |
# May 21, 2014: - got it to work correctly |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
16
diff
changeset
|
33 |
# - croak -> error |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
34 |
# Sep 26, 2015: - added $vessel_draft to editSideLobes |
34 | 35 |
# Jan 23, 2016: - added &editBadTimeLagging() |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
36 |
# May 18, 2016: - removed assumption of 1500m/s soundspeed setting |
46 | 37 |
# May 24, 2016: - calc_binDepths() -> binDepths() |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
38 |
# May 28, 2016: - added editResiduals_rmsMax, editResiduals_deltaMax |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
39 |
# Jun 2, 2016: - added applyTiltCorrection() |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
40 |
# - maded editCorr_Earthcoords() less conservative |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
41 |
# - verified that removed velocities are counted correctly |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
42 |
# Jun 3, 2016: - BUG: applyTiltCorrection() did not use gimbal_pitch |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
43 |
# Jun 6, 2016: - removed applyTiltCorrection() |
49 | 44 |
# Oct 13, 2017: - BUG: editPPI() only allowed for nominal transducer frequencies |
45 |
# May 1, 2018: - added editLargeHSpeeds() |
|
46 |
# Nov 17, 2018: - BUG: spurious letter "z" had crept in at some stage |
|
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
47 |
# Mar 23, 2021: - updated PPI doc |
56 | 48 |
# Jul 9, 2021: - added editHighResidualLayers() |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
49 |
# Sep 1, 2021: - added Sv editing to editHighResidualLayers() |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
50 |
# - modified sidelobe editing to include instrument tilt |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
51 |
# Oct 15, 2021: - BUG: new sidelobe editing was stupid, because sidelobe |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
52 |
# contamination works in the time domain and is, therefore, |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
53 |
# independent of tilt |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
54 |
# Oct 18, 2021: - BUG: seabed contamination was missing abs() and did not |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
55 |
# work correctly with missing Sv data |
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
56 |
# END OF HISTORY |
0 | 57 |
|
58 |
# NOTES: |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
59 |
# - all bins must be edited (not just the ones between $LADCP_firstBin |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
60 |
# and $LADCP_lastBin to allow reflr calculations to use bins outside |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
61 |
# this range (ONLY FOR BEAM-COORD EDITS) |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
62 |
# - however, to make the stats work, only the edited velocities |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
63 |
# inside the bin range are counted for those edit functions that |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
64 |
# report their stats wrt $nvw (for those which use $nvv, |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
65 |
# all velocities must be counted) |
0 | 66 |
|
67 |
#====================================================================== |
|
6 | 68 |
# correctAttitude($ens,$pitch_bias,$roll_bias,$heading_bias) |
49 | 69 |
# - attitude bias correction |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
70 |
# - this is called before gimbal_pitch is calculated |
6 | 71 |
#====================================================================== |
72 |
||
73 |
sub correctAttitude($$$$) |
|
74 |
{ |
|
75 |
my($ens,$pitch_bias,$roll_bias,$heading_bias) = @_; |
|
15 | 76 |
$LADCP{ENSEMBLE}[$ens]->{PITCH} -= $pitch_bias if defined($LADCP{ENSEMBLE}[$ens]->{PITCH}); |
77 |
$LADCP{ENSEMBLE}[$ens]->{ROLL} -= $roll_bias if defined($LADCP{ENSEMBLE}[$ens]->{ROLL}); |
|
78 |
$LADCP{ENSEMBLE}[$ens]->{HEADING} -= $heading_bias if defined($LADCP{ENSEMBLE}[$ens]->{HEADING}); |
|
6 | 79 |
} |
80 |
||
81 |
#====================================================================== |
|
0 | 82 |
# $vv = countValidVels($ens) |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
83 |
# |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
84 |
# NOTES: |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
85 |
# - in case of Earth coords, this counts the velocity components |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
86 |
# (including errvel) |
0 | 87 |
#====================================================================== |
88 |
||
89 |
sub countValidBeamVels($) |
|
90 |
{ |
|
91 |
my($ens) = @_; |
|
92 |
||
93 |
my($vv) = 0; |
|
94 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
95 |
$vv += defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][0]); |
|
96 |
$vv += defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][1]); |
|
97 |
$vv += defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][2]); |
|
98 |
$vv += defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][3]); |
|
99 |
} |
|
100 |
return $vv; |
|
101 |
} |
|
102 |
||
103 |
#====================================================================== |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
104 |
# $removed = editCorr($ens,$threshold) |
0 | 105 |
# |
106 |
# NOTES: |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
107 |
# - called before Earth vels are calculated |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
108 |
# - count removed velocities in all bins |
0 | 109 |
#====================================================================== |
110 |
||
111 |
sub editCorr($$) |
|
112 |
{ |
|
113 |
my($ens,$lim) = @_; |
|
114 |
||
115 |
my($nrm) = 0; |
|
116 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
117 |
for (my($beam)=0; $beam<4; $beam++) { |
|
118 |
next if ($LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin][$beam] >= $lim || |
|
119 |
!defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam])); |
|
120 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam]); |
|
121 |
$nrm++; |
|
122 |
} |
|
123 |
} |
|
124 |
return $nrm; |
|
125 |
} |
|
126 |
||
13 | 127 |
#====================================================================== |
128 |
# $removed = editCorr_Earthcoords($ens,$threshold) |
|
129 |
# |
|
130 |
# NOTES: |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
131 |
# - if any of the used correlations is below the threshold, |
13 | 132 |
# the entire velocity is removed |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
133 |
# - for three-beam solutions two correlations must fail the |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
134 |
# test |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
135 |
# - count velocities in all bins |
13 | 136 |
#====================================================================== |
137 |
||
0 | 138 |
sub editCorr_Earthcoords($$) |
139 |
{ |
|
140 |
my($ens,$lim) = @_; |
|
141 |
||
142 |
my($nrm) = 0; |
|
143 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
144 |
my($nBad) = 0; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
145 |
for (my($beam)=0; $beam<4; $beam++) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
146 |
$nBad++ unless ($LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin][$beam] > $lim); |
0 | 147 |
} |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
148 |
if ($nBad-$LADCP{ENSEMBLE}[$ens]->{THREE_BEAM}[$bin] > 0) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
149 |
for (my($beam)=0; $beam<4; $beam++) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
150 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam]); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
151 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam]); |
0 | 152 |
$nrm++; |
153 |
} |
|
154 |
} |
|
155 |
} |
|
156 |
return $nrm; |
|
157 |
} |
|
158 |
||
159 |
#====================================================================== |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
160 |
# $removed = editTilt($ens,$threshold) |
0 | 161 |
# |
162 |
# NOTES: |
|
6 | 163 |
# - called after Earth vels have been calculated |
0 | 164 |
# - sets TILT field for each ensemble as a side-effect |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
165 |
# - count all removed velocities |
0 | 166 |
#====================================================================== |
167 |
||
168 |
sub editTilt($$) |
|
169 |
{ |
|
170 |
my($ens,$lim) = @_; |
|
171 |
||
172 |
$LADCP{ENSEMBLE}[$ens]->{TILT} = |
|
173 |
&angle_from_vertical($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
|
174 |
||
15 | 175 |
return 0 unless ($LADCP{ENSEMBLE}[$ens]->{TILT} > $lim); |
0 | 176 |
|
177 |
my($nrm) = 0; |
|
178 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
6 | 179 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
180 |
undef($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
181 |
$nrm++; |
|
0 | 182 |
} |
183 |
return $nrm; |
|
184 |
} |
|
185 |
||
186 |
#====================================================================== |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
187 |
# $removed = editErrVel($ens,$threshold) |
0 | 188 |
# |
189 |
# NOTES: |
|
190 |
# - call after Earth vels have been calculated |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
191 |
# - count only removed vels in selected bin range |
0 | 192 |
#====================================================================== |
193 |
||
194 |
sub editErrVel($$) |
|
195 |
{ |
|
196 |
my($ens,$lim) = @_; |
|
197 |
||
198 |
my($nrm) = 0; |
|
199 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
200 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
0 | 201 |
next if (abs($LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin]) <= $lim); |
202 |
undef($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
203 |
$nrm++ if ($bin>=$LADCP_firstBin-1 && $bin<=$LADCP_lastBin-1); |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
204 |
} |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
205 |
return $nrm; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
206 |
} |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
207 |
|
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
208 |
#====================================================================== |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
209 |
# $removed = editWOutliers($ens,$lim) |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
210 |
# |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
211 |
# NOTES: |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
212 |
# - call after Earth vels have been calculated |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
213 |
# - count only removed vels in selected bin range |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
214 |
# - lim determines how many times the mad an outlier has to be from median |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
215 |
#====================================================================== |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
216 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
217 |
sub editWOutliers($$) |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
218 |
{ |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
219 |
my($ens,$lim) = @_; |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
220 |
my($medw) = median(@{$LADCP{ENSEMBLE}[$ens]->{W}}); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
221 |
my($madw) = mad2($medw,@{$LADCP{ENSEMBLE}[$ens]->{W}}); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
222 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
223 |
my($nrm) = 0; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
224 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
225 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
226 |
next if (abs($LADCP{ENSEMBLE}[$ens]->{W}[$bin]-$medw) <= $lim*$madw); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
227 |
undef($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
228 |
$nrm++ if ($bin>=$LADCP_firstBin-1 && $bin<=$LADCP_lastBin-1); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
229 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
230 |
return $nrm; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
231 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
232 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
233 |
#====================================================================== |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
234 |
# $removed = editTruncRange($ens,$nbins) |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
235 |
# |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
236 |
# NOTES: |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
237 |
# - call after Earth vels have been calculated |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
238 |
# - count only removed vels in selected bin range |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
239 |
#====================================================================== |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
240 |
|
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
241 |
sub editTruncRange($$) |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
242 |
{ |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
243 |
my($ens,$nbins) = @_; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
244 |
|
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
245 |
my($nrm) = 0; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
246 |
for (my($bin)=$LADCP{N_BINS}-1; $bin>=0 && $nrm<$nbins; $bin--) { |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
247 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
248 |
undef($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
249 |
$nrm++ if ($bin>=$LADCP_firstBin-1 && $bin<=$LADCP_lastBin-1); |
0 | 250 |
} |
251 |
return $nrm; |
|
252 |
} |
|
253 |
||
254 |
#====================================================================== |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
255 |
# $removed = editFarBins($ens,$first_bad_bin) |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
256 |
# |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
257 |
# NOTES: |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
258 |
# - call after Earth vels have been calculated |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
259 |
# - remove data from far bins |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
260 |
# - only bins in valid range are considered here, because |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
261 |
# $per_bin_nsamp is only defined for those |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
262 |
# - only velocities from bins in valid range are counted |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
263 |
#====================================================================== |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
264 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
265 |
sub editFarBins($$) |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
266 |
{ |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
267 |
my($ens,$first_bad_bin) = @_; |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
268 |
|
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
269 |
my($nrm) = 0; |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
270 |
for (my($bin)=$first_bad_bin; $bin<=$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
271 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
272 |
undef($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
273 |
$nrm++; |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
274 |
} |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
275 |
return $nrm; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
276 |
} |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
277 |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
278 |
#=========================================================================================== |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
279 |
# ($nvrm,$nerm) = editSideLobes($fromEns,$toEns,$water_depth) |
0 | 280 |
# |
281 |
# NOTES: |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
282 |
# - When this code is executed the sound speed is known. No attempt is made to correct for |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
283 |
# along-beam soundspeed variation, but the soundspeed at the transducer is accounted for. |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
284 |
# - for surface sidelobes, water_depth == undef; surface sidelobes include the |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
285 |
# vessel draft |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
286 |
# - all velocities are counted, even those outside valid bin range, |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
287 |
# because the %age is not reported |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
288 |
# - while this filter removes the sidelobe contamination in most profiles |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
289 |
# there are still profiles with Sv.diff anomalies near the seabed |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
290 |
# (based on SR1b/2004 data); for these editSeabedContamination has been implemented |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
291 |
#========================================================================================== |
0 | 292 |
|
293 |
sub editSideLobes($$$) |
|
294 |
{ |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
295 |
my($fe,$te,$wd) = @_; # first & last ens to process, water depth for sidelobes near seabed |
0 | 296 |
my($nvrm) = 0; # of velocities removed |
297 |
my($nerm) = 0; # of ensembles affected |
|
298 |
for (my($e)=$fe; $e<=$te; $e++) { |
|
299 |
next unless numberp($LADCP{ENSEMBLE}[$e]->{CTD_DEPTH}); |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
300 |
my($range) = defined($wd) ? $wd - $LADCP{ENSEMBLE}[$e]->{CTD_DEPTH} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
301 |
: $LADCP{ENSEMBLE}[$e]->{CTD_DEPTH} - $vessel_draft; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
302 |
$range = 0 if ($range < 0); |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
303 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
304 |
# from UH code |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
305 |
my($sscorr) = $CTD{SVEL}[$LADCP{ENSEMBLE}[$e]->{CTD_SCAN}] / $LADCP{ENSEMBLE}[$e]->{SPEED_OF_SOUND}; |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
306 |
my($firstBadBin) = ($range - $sscorr*$LADCP{DISTANCE_TO_BIN1_CENTER}) * cos(rad($LADCP{BEAM_ANGLE})) |
0 | 307 |
/ ($sscorr*$LADCP{BIN_LENGTH}) |
308 |
- 1.5; |
|
309 |
||
310 |
my($dirty) = 0; |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
311 |
for (my($bin)=int($firstBadBin); $bin<$LADCP{N_BINS}; $bin++) { |
0 | 312 |
next unless ($bin>=0 && defined($LADCP{ENSEMBLE}[$e]->{W}[$bin])); |
313 |
$dirty = 1; |
|
314 |
$nvrm++; |
|
315 |
undef($LADCP{ENSEMBLE}[$e]->{W}[$bin]); |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
316 |
debugmsg("sidelobe at range=$range firstBadBin=$firstBadBin ens=$e bin=$bin at CTD depth = $LADCP{ENSEMBLE}[$e]->{CTD_DEPTH}\n"); |
0 | 317 |
} |
318 |
||
319 |
$nerm += $dirty; |
|
320 |
} |
|
321 |
return ($nvrm,$nerm); |
|
322 |
} |
|
323 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
324 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
325 |
#====================================================================== |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
326 |
# ($nvrm,$nerm) = editPPI($fromEns,$toEns,$water_depth) |
15 | 327 |
# |
328 |
# NOTES: |
|
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
329 |
# - only velocities in valid-bin-range are edited (and counted) |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
330 |
# - 3rd argument (water_depth) determines whether surface or |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
331 |
# seabed PPI editing is required |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
332 |
# - when this code is executed a suitable depth-average-soundspeed |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
333 |
# profile (@DASSprof at 1m resolution) is available |
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
334 |
# - water_depth defined: DASSprof average is to seabed |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
335 |
# - water_depth not defined: DASSprof average is to sea surface |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
336 |
# - PPI layer is defined by the shortest and longest acoustic paths |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
337 |
# between transducer and seabed that contribute significantly to the |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
338 |
# backscatter |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
339 |
# - shortest path (shallow limit): |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
340 |
# - distance to seabed => sidelobe |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
341 |
# - min_lim = water_depth - DASSprof[CTD_depth]*DeltaT/2 |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
342 |
# - longest path (deep limit): |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
343 |
# - outer edge of main lobe of one of the beams (depending on |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
344 |
# instrument tilt) |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
345 |
# - nominal half-beam apertures at half peak signal strength |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
346 |
# (-3dB), RDI BB Primer, pp. 35f (2ND COLUMN) |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
347 |
# WH1200 1.4 2.4 |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
348 |
# WH600 1.5 2.5 |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
349 |
# WH300 2.2 3.7 |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
350 |
# WH150 4.0 6.7 |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
351 |
# WH75 5.0 8.4 |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
352 |
# - for WH150, Fig. 23 indicates that half-beam-width |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
353 |
# at -5dB (<1% peak signal strength) is about 5/3 of same |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
354 |
# at -3dB => PPI limit choice (3rd column above) |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
355 |
# - [Plots/2014_P16_043.eps]: |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
356 |
# - mean tilt of 2 degrees included in effects |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
357 |
# - finite pulse length means that there actually |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
358 |
# is less elapsed time between the end of the sending |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
359 |
# and the beginning of the reception than the ping |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
360 |
# interval suggests; without it, the PPI peak depth |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
361 |
# does not agree with the prediction |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
362 |
# - note that there is no PPI effect possible above |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
363 |
# the dark blue line --- this is a hard limit |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
364 |
# (I checked ping interval to within 0.001, |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
365 |
# water depth is known better than 2m, sound |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
366 |
# speed is accurately accounted for (as indicated |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
367 |
# by the cyan line), so the variability above |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
368 |
# is due to background variability, which is |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
369 |
# consistent with the shape of the curve outside |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
370 |
# the PPI layer |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
371 |
# => PPI peak can be tightly bracketed but care has to |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
372 |
# be taken to account for finite beam width & |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
373 |
# instrument beam_tilt = max(|pitch|,|roll|) |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
374 |
# - while the upper limit of the PPI layer is unambiguous, this |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
375 |
# is only true if the recorded ping intervals are accurate |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
376 |
# - 2014 CLIVAR P16 #47 shows a slight discontinuity in dc_w near |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
377 |
# the middle of the upper PPI layer (4000m) |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
378 |
# - the discontinuity is slightly more pronounced with PPI editing |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
379 |
# enabled |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
380 |
# - setting $PPI_extend_upper_limit = 1.03 (or 1.04, 1.05, 1.1) |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
381 |
# reduces the discontinuity to the level without PPI filtering, but |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
382 |
# not any better |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
383 |
# - overall I am not convinced that the discontinuity is related |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
384 |
# to PPI; therefore, $PPI_extend_upper_limit is not set by default |
15 | 385 |
#====================================================================== |
386 |
||
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
387 |
{ my($bha); # beam half aperture (static scope) |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
388 |
|
15 | 389 |
sub editPPI($$$) |
390 |
{ |
|
391 |
my($fe,$te,$wd) = @_; # first & last ens to process, water depth for downlooker |
|
392 |
my($nvrm) = 0; # of velocities removed |
|
393 |
my($nerm) = 0; # of ensembles affected |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
394 |
|
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
395 |
unless (defined($bha)) { |
49 | 396 |
if (abs($LADCP{BEAM_FREQUENCY}-1200)/1200 <= 0.1) { $bha = 2.4; } |
397 |
elsif (abs($LADCP{BEAM_FREQUENCY}-600) / 600 <= 0.1) { $bha = 2.5; } |
|
398 |
elsif (abs($LADCP{BEAM_FREQUENCY}-300) / 300 <= 0.1) { $bha = 3.7; } |
|
399 |
elsif (abs($LADCP{BEAM_FREQUENCY}-150) / 150 <= 0.1) { $bha = 6.7; } |
|
400 |
elsif (abs($LADCP{BEAM_FREQUENCY}-75) / 75 <= 0.1) { $bha = 8.4; } |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
16
diff
changeset
|
401 |
else { error("$0: unexpected transducer frequency $LADCP{BEAM_FREQUENCY}\n"); } |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
402 |
} |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
403 |
|
15 | 404 |
for (my($e)=$fe; $e<=$te; $e++) { |
405 |
next unless numberp($LADCP{ENSEMBLE}[$e]->{CTD_DEPTH}); |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
406 |
next unless ($e > 0); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
407 |
|
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
408 |
my($delta_t) = $LADCP{ENSEMBLE}[$e]->{UNIX_TIME} - $LADCP{ENSEMBLE}[$e-1]->{UNIX_TIME}; |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
409 |
my($dz_max) = $DASSprof[int($LADCP{ENSEMBLE}[$e]->{CTD_DEPTH})]*$delta_t / 2; |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
410 |
my($beam_tilt) = max(abs($LADCP{ENSEMBLE}[$e]->{GIMBAL_PITCH}), |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
411 |
abs($LADCP{ENSEMBLE}[$e]->{ROLL})); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
412 |
my($dz_min) = $dz_max * cos(rad($LADCP{BEAM_ANGLE} + $beam_tilt + $bha)); |
46 | 413 |
my(@bd) = binDepths($e); |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
414 |
|
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
415 |
$dz_max *= $PPI_extend_upper_limit |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
416 |
if numberp($PPI_extend_upper_limit); |
15 | 417 |
|
418 |
my($dirty) = 0; |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
419 |
for (my($bin)=$LADCP_firstBin-1; $bin<$LADCP_lastBin; $bin++) { |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
420 |
next unless (defined($LADCP{ENSEMBLE}[$e]->{W}[$bin])); |
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
421 |
if (defined($wd)) { # surface PPI |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
422 |
next unless ($bd[$bin] >= $wd-$dz_max && $bd[$bin] <= $wd-$dz_min); |
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
49
diff
changeset
|
423 |
} else { # seabed PPI |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
424 |
next unless ($bd[$bin] <= $dz_max && $bd[$bin] >= $dz_min); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
425 |
} |
15 | 426 |
$dirty = 1; |
427 |
$nvrm++; |
|
428 |
undef($LADCP{ENSEMBLE}[$e]->{W}[$bin]); |
|
429 |
} |
|
430 |
||
431 |
$nerm += $dirty; |
|
432 |
} |
|
433 |
return ($nvrm,$nerm); |
|
434 |
} |
|
435 |
||
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
436 |
} # static scope for $bha |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
437 |
|
15 | 438 |
|
439 |
#====================================================================== |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
440 |
# $nerm = editSurfLayer($fromEns,$toEns,$surface_layer_depth) |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
441 |
# |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
442 |
# NOTES: |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
443 |
# 1) When this code is executed the fully corrected instrument and |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
444 |
# bin depths are known |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
445 |
# 2) This code was inspired by 2011_IWISE station 8 |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
446 |
# 3) No point in counting the deleted velocities |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
447 |
#====================================================================== |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
448 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
449 |
sub editSurfLayer($$$) |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
450 |
{ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
451 |
my($fe,$te,$sld) = @_; # first & last ens to process |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
452 |
my($nerm) = 0; # of ensembles affected |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
453 |
for (my($e)=$fe; $e<=$te; $e++) { |
10
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
454 |
next unless numberp($LADCP{ENSEMBLE}[$e]->{CTD_DEPTH}); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
455 |
undef($LADCP{ENSEMBLE}[$e]->{CTD_DEPTH}),$nerm++ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
456 |
if ($LADCP{ENSEMBLE}[$e]->{CTD_DEPTH} <= $sld); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
457 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
458 |
return $nerm; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
459 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
460 |
|
34 | 461 |
|
462 |
#=============================================================================== |
|
463 |
# $nerm = editBadTimeLagging($fromEns,$toEns,$good_from_elapsed1,$good_to_elapsed1,...) |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
464 |
# |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
465 |
# NOTES: |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
466 |
# - deleted velocities are not counted |
34 | 467 |
#=============================================================================== |
468 |
||
469 |
sub editBadTimeLagging($$@) |
|
470 |
{ |
|
471 |
my($fe,$te,@elim) = @_; |
|
472 |
||
473 |
my($nerm) = 0; # of ensembles removed |
|
474 |
my($i) = 0; |
|
475 |
||
476 |
if ($elim[0] < 0) { # entire piece is bad |
|
477 |
for (my($e)=$fe; $e<=$te; $e++) { |
|
478 |
undef($LADCP{ENSEMBLE}[$e]->{REFLR_W}); |
|
479 |
$nerm++; |
|
480 |
} |
|
481 |
} elsif (defined($elim[1])) { # limits in elim |
|
482 |
my($e); |
|
483 |
for ($e=$fe; @elim; shift(@elim),shift(@elim)) { |
|
484 |
# print(STDERR "deleting to $elim[0]\n"); |
|
485 |
while ($LADCP{ENSEMBLE}[$e]->{ELAPSED} < $elim[0]) { |
|
486 |
undef($LADCP{ENSEMBLE}[$e]->{REFLR_W}); |
|
487 |
$nerm++; |
|
488 |
$e++; |
|
489 |
} |
|
490 |
# print(STDERR "keeping to $elim[1]\n"); |
|
491 |
while ($LADCP{ENSEMBLE}[$e]->{ELAPSED} < $elim[1]) { $e++; } |
|
492 |
} |
|
493 |
# print(STDERR "deleting to $LADCP{ENSEMBLE}[$te]->{ELAPSED}\n"); |
|
494 |
while ($e <= $te) { |
|
495 |
undef($LADCP{ENSEMBLE}[$e]->{REFLR_W}); |
|
496 |
$nerm++; |
|
497 |
$e++; |
|
498 |
} |
|
499 |
} |
|
500 |
return $nerm; |
|
501 |
} |
|
502 |
||
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
503 |
#====================================================================== |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
504 |
# $nerm = editResiduals_rmsMax($fe,$te,$max_val) |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
505 |
# |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
506 |
# NOTES: |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
507 |
# - removed velocities are not counted |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
508 |
#====================================================================== |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
509 |
|
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
510 |
sub editResiduals_rmsMax($$$) |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
511 |
{ |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
512 |
my($fe,$te,$limit) = @_; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
513 |
my($nerm) = 0; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
514 |
for (my($ens)=$fe; $ens<=$te; $ens++) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
515 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
516 |
my($sum) = my($n) = 0; # calculate rms residual |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
517 |
my(@bindepth) = binDepths($ens); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
518 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
519 |
next unless ($bin+1>=$outGrid_firstBin && $bin+1<=$outGrid_lastBin); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
520 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
521 |
my($bi) = $bindepth[$bin]/$opt_o; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
522 |
my($res) = ($ens < $LADCP_atbottom) ? |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
523 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $DNCAST{MEDIAN_W}[$bi] : |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
524 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $UPCAST{MEDIAN_W}[$bi]; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
525 |
$sum += &SQR($res); $n++; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
526 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
527 |
if ($n == 0 || sqrt($sum/$n) > $limit) { # ensemble is bad |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
528 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
529 |
$nerm++; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
530 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
531 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
532 |
return $nerm; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
533 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
534 |
|
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
535 |
#====================================================================== |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
536 |
# $nerm = editResiduals_deltaMax($fe,$te,$max_val) |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
537 |
# - delta residual = delta beampair w => equal to scaled error velocity? |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
538 |
# - sharp cutoff near 5cm/s for std parameters (0.1 m/s error velocity |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
539 |
# filter) in several data sets |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
540 |
# - samples with large residuals differences are clear outliers in |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
541 |
# the residuals vs tilt plots => obvious to remove |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
542 |
# - how are large delta res possible given the errvel limit??? |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
543 |
# - only valid bin range is edited/counted |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
544 |
#====================================================================== |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
545 |
|
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
546 |
sub editResiduals_deltaMax($$$) |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
547 |
{ |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
548 |
my($fe,$te,$limit) = @_; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
549 |
my($nvrm) = 0; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
550 |
for (my($ens)=$fe; $ens<=$te; $ens++) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
551 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
552 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
553 |
next unless ($bin+1>=$outGrid_firstBin && $bin+1<=$outGrid_lastBin); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
554 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
555 |
my($Dr) = abs($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] - |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
556 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
557 |
if ($Dr > $limit) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
558 |
undef($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
559 |
$nvrm++; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
560 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
561 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
562 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
563 |
return $nvrm; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
564 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
565 |
|
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
566 |
#====================================================================== |
49 | 567 |
# $nerm = editLargeHSpeeds($fe,$te,$max_hspeed) |
568 |
# - filter based on 2018 GO-SHIP LADCP profile #106, where UL |
|
569 |
# velocities become bad when ship starts dragging rosette |
|
570 |
# - only valid bin range is edited/counted |
|
571 |
#====================================================================== |
|
572 |
||
573 |
sub editLargeHSpeeds($$$) |
|
574 |
{ |
|
575 |
my($fe,$te,$limit) = @_; |
|
576 |
my($nerm) = 0; |
|
577 |
for (my($ens)=$fe; $ens<=$te; $ens++) { |
|
578 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
579 |
next unless (vel_speed($LADCP{ENSEMBLE}[$ens]->{REFLR_U}, |
|
580 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_U}) > $limit); |
|
581 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
582 |
$nerm++; |
|
583 |
} |
|
584 |
return $nerm; |
|
585 |
} |
|
586 |
||
587 |
#====================================================================== |
|
56 | 588 |
# $nbrm = editHighResidualLayers($max_lr_res) |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
589 |
# - filter applied after depth binning |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
590 |
# - while filter only removes values from profiles, the corresponding |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
591 |
# samples are not output to .wsamp, because MEDIAN_W is not defined |
56 | 592 |
# - filter based on observation that profiles of beam-pair residuals |
593 |
# are good indicators of bad data, but very noisy |
|
594 |
# - current version uses estimates in 5-bin-thick layers (200m by |
|
595 |
# default) |
|
596 |
# - filter cutoff based on 2021 A20 cruise which crossed region with |
|
597 |
# very weak backscatter |
|
598 |
#====================================================================== |
|
599 |
||
600 |
sub editHighResidualLayers($) |
|
601 |
{ |
|
602 |
my($limit) = @_; |
|
603 |
||
604 |
my($nbrm) = 0; |
|
605 |
for (my($bi)=0; $bi<=$#{$DNCAST{LR_RMS_BP_RESIDUAL}}; $bi++) { |
|
606 |
next unless ($DNCAST{LR_RMS_BP_RESIDUAL}[$bi] > $limit); |
|
607 |
$DNCAST{MEDIAN_W}[$bi] = $DNCAST{MEDIAN_W12}[$bi] = $DNCAST{MEDIAN_W34}[$bi] = nan; |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
608 |
# $DNCAST{SV}[$bi] = nan; |
56 | 609 |
$nbrm++; |
610 |
} |
|
611 |
for (my($bi)=0; $bi<=$#{$UPCAST{LR_RMS_BP_RESIDUAL}}; $bi++) { |
|
612 |
next unless ($UPCAST{LR_RMS_BP_RESIDUAL}[$bi] > $limit); |
|
613 |
$UPCAST{MEDIAN_W}[$bi] = $UPCAST{MEDIAN_W12}[$bi] = $UPCAST{MEDIAN_W34}[$bi] = nan; |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
614 |
# $UPCAST{SV}[$bi] = nan; |
56 | 615 |
$nbrm++; |
616 |
} |
|
617 |
return $nbrm; |
|
618 |
} |
|
619 |
||
620 |
#====================================================================== |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
621 |
# $nbrm = editSeabedContamination($max_lr_res) |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
622 |
# - filter applied after depth binning |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
623 |
# - while filter only removes values from profiles, the corresponding |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
624 |
# samples are not output to .wsamp, because MEDIAN_W is not defined |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
625 |
# - filter based on SR1b/2004 observation that some profiles of Sv |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
626 |
# show clear anomalies near the seabed |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
627 |
# - anomalies are easily detected in dSv/dz plots, with |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
628 |
# $seabed_contamination_Sv_grad_limit = 0.1 being a suitable limiting |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
629 |
# value for WH300 ADCPs |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
630 |
#====================================================================== |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
631 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
632 |
sub editSeabedContamination($) |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
633 |
{ |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
634 |
my($limit) = @_; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
635 |
my($nbrm) = 0; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
636 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
637 |
for (my($bi)=$#{$DNCAST{SV}}; $bi>0; $bi--) { |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
638 |
next unless numberp($DNCAST{SV}[$bi]) && numberp($DNCAST{SV}[$bi-1]); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
639 |
last if (abs($DNCAST{SV}[$bi]-$DNCAST{SV}[$bi-1])/$opt_o < $limit); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
640 |
$DNCAST{MEDIAN_W}[$bi] = $DNCAST{MEDIAN_W12}[$bi] = $DNCAST{MEDIAN_W34}[$bi] = nan; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
641 |
$DNCAST{SV}[$bi] = nan; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
642 |
$nbrm++; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
643 |
} |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
644 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
645 |
for (my($bi)=$#{$UPCAST{SV}}; $bi>0; $bi--) { |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
646 |
next unless numberp($UPCAST{SV}[$bi]) && numberp($UPCAST{SV}[$bi-1]); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
647 |
last if (abs($UPCAST{SV}[$bi]-$UPCAST{SV}[$bi-1])/$opt_o < $limit); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
648 |
$UPCAST{MEDIAN_W}[$bi] = $UPCAST{MEDIAN_W12}[$bi] = $UPCAST{MEDIAN_W34}[$bi] = nan; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
649 |
$UPCAST{SV}[$bi] = nan; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
650 |
$nbrm++; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
651 |
} |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
652 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
653 |
return $nbrm; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
654 |
} |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
655 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
656 |
#====================================================================== |
34 | 657 |
|
0 | 658 |
1; |