author | A.M. Thurnherr <athurnherr@yahoo.com> |
Sun, 21 Oct 2018 19:52:56 -0400 | |
changeset 43 | b63fa355644c |
parent 33 | 307630665c6c |
child 45 | 5767cbe470a0 |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/perl |
2 |
#====================================================================== |
|
3 |
# M E A N P R O F |
|
4 |
# doc: Fri Feb 22 08:40:18 2008 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
5 |
# dlm: Tue Apr 10 09:01:50 2018 |
0 | 6 |
# (c) 2008 A.M. Thurnherr |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
7 |
# uE-Info: 19 35 NIL 0 0 72 0 2 4 NIL ofnI |
0 | 8 |
#====================================================================== |
9 |
||
10 |
# extract time-averaged mean profile from ADCP data |
|
11 |
||
12 |
# HISTORY: |
|
13 |
# Feb 22, 2008: - created from [listBins] |
|
33 | 14 |
# Mar 16, 2016: - adapted to new Getopt library |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
15 |
# Apr 2, 2018: - BUG: velBeamToInstrument() used old usage |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
16 |
# Apr 9, 2018: - adapted to "new" readData() ensemble limits |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
17 |
# - added -l to set final bin |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
18 |
# - BUG: division by zero in empty bins |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
19 |
# Apr 10, 2018: - activate output |
0 | 20 |
|
21 |
# Soundspeed Correction: |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
22 |
# - based on first ensemble only |
0 | 23 |
# - applied as described in the RDI coord-trans manual |
24 |
# - sound-speed variation over range is ignored (valid for small gradients) |
|
25 |
# => - same simple correction for all velocity components |
|
26 |
# - simple correction for cell depths |
|
27 |
||
33 | 28 |
use Getopt::Std; |
29 |
||
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
30 |
$ADCP_tools_minVersion = 2.2; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
31 |
($ADCP_TOOLS) = ($0 =~ m{(.*/)[^/]+}); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
32 |
require "$ADCP_TOOLS/ADCP_tools_lib.pl"; |
0 | 33 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
34 |
die("Usage: $0 [-r)ange <first_ens,last_ens>] [-l)ast <bin>] " . |
0 | 35 |
"[-Q)uiet (stats only)] " . |
36 |
"[-S)oundspeed correction <salin|*,temp|*,depth|*> " . |
|
37 |
"[require -4)-beam solutions] [-d)iscard <beam#>] " . |
|
38 |
"[-%)good <min>] " . |
|
39 |
"[output -b)eam coordinates] " . |
|
40 |
"[-M)agnetic <declination>] " . |
|
41 |
"[-D)epth <depth>] " . |
|
42 |
"<RDI file>\n") |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
43 |
unless (&getopts("4bd:D:l:M:p:r:QS:") && @ARGV == 1); |
0 | 44 |
|
45 |
die("$0: -4 and -d are mutually exclusive\n") |
|
46 |
if ($opt_4 && defined($opt_d)); |
|
47 |
||
48 |
die("$0: -p and -b are mutually exclusive\n") |
|
49 |
if ($opt_b && defined($opt_p)); |
|
50 |
||
51 |
$opt_p = 0 unless defined($opt_p); |
|
52 |
||
53 |
$RDI_Coords::minValidVels = 4 if ($opt_4); # no 3-beam solutions |
|
54 |
||
55 |
print(STDERR "WARNING: magnetic declination not set!\n") |
|
56 |
unless defined($opt_M) || defined($opt_b); |
|
57 |
||
58 |
$ifn = $ARGV[0]; |
|
59 |
||
60 |
($SS_salin,$SS_temp,$SS_depth) = split(',',$opt_S) |
|
61 |
if defined($opt_S); |
|
62 |
die("$0: Cannot do variable soundspeed correction (implementation restriction)\n") |
|
63 |
if ($SS_salin eq '*' || $SS_temp eq '*' || $SS_depth eq '*'); |
|
64 |
||
65 |
#---------------------------------------------------------------------- |
|
66 |
# Read & Check Data, Transform Velocities |
|
67 |
#---------------------------------------------------------------------- |
|
68 |
||
69 |
$P{RDI_file} = $ifn; |
|
70 |
$P{mag_decl} = $opt_M if defined($opt_M); |
|
71 |
||
72 |
print(STDERR "reading $ifn: "); |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
73 |
if (defined($opt_r)) { # read selected range |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
74 |
my($fe,$le) = split(',',$opt_r); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
75 |
readData($ifn,\%dta,$fe,$le,$opt_l); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
76 |
} else { # read entire file |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
77 |
readData($ifn,\%dta,undef,undef,$opt_l); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
78 |
} |
0 | 79 |
printf(STDERR "%d complete ensembles.\n",scalar(@{$dta{ENSEMBLE}})); |
80 |
$dta{HEADING_BIAS} = -$opt_M; # magnetic declination |
|
81 |
||
82 |
if ($dta{BEAM_COORDINATES}) { # coords |
|
83 |
$beamCoords = 1; |
|
84 |
} else { |
|
85 |
die("$0: -b requires input in beam coordinates\n") |
|
86 |
if ($opt_b); |
|
87 |
die("$ifn: only beam and earth coordinates implemented so far\n") |
|
88 |
if (!$dta{EARTH_COORDINATES}); |
|
89 |
} |
|
90 |
||
91 |
for (my($b)=0; $b<$dta{N_BINS}; $b++) { # calc dz |
|
92 |
$dz[$b] = $dta{DISTANCE_TO_BIN1_CENTER} + $b*$dta{BIN_LENGTH}; |
|
93 |
} |
|
94 |
||
95 |
$lastGoodBin = 0; |
|
96 |
for ($e=0; $e<=$#{$dta{ENSEMBLE}}; $e++) { # check/transform velocities |
|
97 |
$P{first_ens} = $dta{ENSEMBLE}[$e]->{NUMBER},$fe = $e |
|
98 |
unless defined($P{first_ens}); |
|
99 |
$P{last_ens} = $dta{ENSEMBLE}[$e]->{NUMBER}; |
|
100 |
$le = $e; |
|
101 |
||
102 |
die("3-beams used in ensemble #$dta{ENSEMBLE}[$e]->{NUMBER}\n") |
|
103 |
if ($dta{ENSEMBLE}[$e]->{N_BEAMS_USED} < 4); |
|
104 |
die("BIT error in ensemble $dta{ENSEMBLE}[$e]->{NUMBER}\n") |
|
105 |
if defined($dta{ENSEMBLE}[$e]->{BUILT_IN_TEST_ERROR}); |
|
106 |
die("Low gain in ensemble #$dta{ENSEMBLE}[$e]->{NUMBER}\n") |
|
107 |
if ($dta{ENSEMBLE}[$e]->{LOW_GAIN}); |
|
108 |
||
109 |
for (my($b)=0; $b<$dta{N_BINS}; $b++) { |
|
110 |
if (defined($opt_d)) { |
|
111 |
undef($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][$opt_d-1]); |
|
112 |
undef($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][$opt_d-1]); |
|
113 |
} |
|
114 |
for (my($i)=0; $i<4; $i++) { |
|
115 |
if ($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][$i] < $opt_p) { |
|
116 |
undef($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][$i]); |
|
117 |
undef($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][$i]); |
|
118 |
} |
|
119 |
} |
|
120 |
@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]} = $beamCoords |
|
121 |
? velInstrumentToEarth(\%dta,$e, |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
122 |
velBeamToInstrument(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]}) |
0 | 123 |
) |
124 |
: velApplyHdgBias(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]}) |
|
125 |
unless ($opt_b); |
|
126 |
||
127 |
$sum_corr1[$b] += $dta{ENSEMBLE}[$e]->{CORRELATION}[$b][0]; |
|
128 |
$sum_corr2[$b] += $dta{ENSEMBLE}[$e]->{CORRELATION}[$b][1]; |
|
129 |
$sum_corr3[$b] += $dta{ENSEMBLE}[$e]->{CORRELATION}[$b][2]; |
|
130 |
$sum_corr4[$b] += $dta{ENSEMBLE}[$e]->{CORRELATION}[$b][3]; |
|
131 |
||
132 |
$sum_amp1[$b] += $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b][0]; |
|
133 |
$sum_amp2[$b] += $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b][1]; |
|
134 |
$sum_amp3[$b] += $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b][2]; |
|
135 |
$sum_amp4[$b] += $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b][3]; |
|
136 |
||
137 |
unless (defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][0])) { |
|
138 |
undef(@{$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b]}); |
|
139 |
next; |
|
140 |
} |
|
141 |
||
142 |
$dta{ENSEMBLE}[$e]->{THREE_BEAM}[$b] = $RDI_Coords::threeBeamFlag; |
|
143 |
$three_beam[$b] += $RDI_Coords::threeBeamFlag; |
|
144 |
$dta{ENSEMBLE}[$e]->{GOOD_VEL}[$b] = 1; |
|
145 |
$good_vels[$b]++; |
|
146 |
$lastGoodBin = $b if ($b > $lastGoodBin); |
|
147 |
$firstGoodEns = $e unless defined($firstGoodEns); |
|
148 |
$lastGoodEns = $e; |
|
149 |
||
150 |
$sum_u[$b] += $dta{ENSEMBLE}[$e]->{VELOCITY}[$b][0]; |
|
151 |
$sum_v[$b] += $dta{ENSEMBLE}[$e]->{VELOCITY}[$b][1]; |
|
152 |
$sum_w[$b] += $dta{ENSEMBLE}[$e]->{VELOCITY}[$b][2]; |
|
153 |
$sum_e[$b] += $dta{ENSEMBLE}[$e]->{VELOCITY}[$b][3] |
|
154 |
unless ($RDI_Coords::threeBeamFlag); |
|
155 |
||
156 |
$sum_pcg1[$b] += $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][0]; |
|
157 |
$n_pcg1[$b]++ if defined($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][0]); |
|
158 |
$sum_pcg2[$b] += $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][1]; |
|
159 |
$n_pcg2[$b]++ if defined($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][1]); |
|
160 |
$sum_pcg3[$b] += $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][2]; |
|
161 |
$n_pcg3[$b]++ if defined($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][2]); |
|
162 |
$sum_pcg4[$b] += $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][3]; |
|
163 |
$n_pcg4[$b]++ if defined($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][3]); |
|
164 |
} |
|
165 |
} |
|
166 |
||
167 |
unless (defined($opt_r)) { |
|
168 |
$fe = $firstGoodEns; |
|
169 |
$le = $lastGoodEns; |
|
170 |
} |
|
171 |
$nEns = $le - $fe + 1; |
|
172 |
die("$0: insufficient data\n") if ($nEns < 2); |
|
173 |
$P{N_ensembles} = $nEns; |
|
174 |
||
175 |
$firstBin = 0; |
|
176 |
$lastBin = $lastGoodBin; |
|
177 |
||
178 |
print( STDERR "Start : $dta{ENSEMBLE}[$fe]->{DATE} $dta{ENSEMBLE}[$fe]->{TIME}\n"); |
|
179 |
print( STDERR "End : $dta{ENSEMBLE}[$le]->{DATE} $dta{ENSEMBLE}[$le]->{TIME}\n"); |
|
180 |
printf(STDERR "Bins : %d-%d\n",$firstBin+1,$lastBin+1); |
|
181 |
printf(STDERR "3-Beam : %d %d %d %d\n",$RDI_Coords::threeBeam_1, |
|
182 |
$RDI_Coords::threeBeam_2, |
|
183 |
$RDI_Coords::threeBeam_3, |
|
184 |
$RDI_Coords::threeBeam_4) |
|
185 |
unless ($opt_b); |
|
186 |
||
187 |
#---------------------------------------------------------------------- |
|
188 |
# Calculate Stddevs |
|
189 |
#---------------------------------------------------------------------- |
|
190 |
||
191 |
for ($b=0; $b<=$lastGoodBin; $b++) { |
|
192 |
$mean_corr1[$b] = $sum_corr1[$b] / $nEns; $mean_corr2[$b] = $sum_corr2[$b] / $nEns; |
|
193 |
$mean_corr3[$b] = $sum_corr3[$b] / $nEns; $mean_corr4[$b] = $sum_corr4[$b] / $nEns; |
|
194 |
$mean_amp1[$b] = $sum_amp1[$b] / $nEns; $mean_amp2[$b] = $sum_amp2[$b] / $nEns; |
|
195 |
$mean_amp3[$b] = $sum_amp3[$b] / $nEns; $mean_amp4[$b] = $sum_amp4[$b] / $nEns; |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
196 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
197 |
$mean_pcg1[$b] = $sum_pcg1[$b] / $n_pcg1[$b] if ($n_pcg1[$b] > 0); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
198 |
$mean_pcg2[$b] = $sum_pcg2[$b] / $n_pcg2[$b] if ($n_pcg2[$b] > 0); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
199 |
$mean_pcg3[$b] = $sum_pcg3[$b] / $n_pcg3[$b] if ($n_pcg3[$b] > 0); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
200 |
$mean_pcg4[$b] = $sum_pcg4[$b] / $n_pcg4[$b] if ($n_pcg4[$b] > 0); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
201 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
202 |
next unless ($good_vels[$b] > 0); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
203 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
204 |
$mean_u[$b] = $sum_u[$b] / $good_vels[$b]; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
205 |
$mean_v[$b] = $sum_v[$b] / $good_vels[$b]; |
0 | 206 |
$mean_w[$b] = $sum_w[$b] / $good_vels[$b]; |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
207 |
$mean_e[$b] = ($good_vels[$b] - $three_beam[$b] > 0) ? $sum_e[$b] / ($good_vels[$b] - $three_beam[$b]) : undef; |
0 | 208 |
} |
209 |
||
210 |
for ($e=$fe; $e<=$le; $e++) { |
|
211 |
for ($b=0; $b<=$lastGoodBin; $b++) { |
|
212 |
$sumsq_corr1[$b] += ($mean_corr1[$b] - $dta{ENSEMBLE}[$e]->{CORRELATION}[$b][0])**2; |
|
213 |
$sumsq_corr2[$b] += ($mean_corr2[$b] - $dta{ENSEMBLE}[$e]->{CORRELATION}[$b][1])**2; |
|
214 |
$sumsq_corr3[$b] += ($mean_corr3[$b] - $dta{ENSEMBLE}[$e]->{CORRELATION}[$b][2])**2; |
|
215 |
$sumsq_corr4[$b] += ($mean_corr4[$b] - $dta{ENSEMBLE}[$e]->{CORRELATION}[$b][3])**2; |
|
216 |
||
217 |
$sumsq_amp1[$b] += ($mean_amp1[$b] - $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b][0])**2; |
|
218 |
$sumsq_amp2[$b] += ($mean_amp2[$b] - $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b][1])**2; |
|
219 |
$sumsq_amp3[$b] += ($mean_amp3[$b] - $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b][2])**2; |
|
220 |
$sumsq_amp4[$b] += ($mean_amp4[$b] - $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b][3])**2; |
|
221 |
||
222 |
$sumsq_pcg1[$b] += ($mean_pcg1[$b] - $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][0])**2 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
223 |
if defined($mean_pcg1[$b]) && defined($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][0]); |
0 | 224 |
$sumsq_pcg2[$b] += ($mean_pcg2[$b] - $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][1])**2 |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
225 |
if defined($mean_pcg2[$b]) && defined($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][1]); |
0 | 226 |
$sumsq_pcg3[$b] += ($mean_pcg3[$b] - $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][2])**2 |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
227 |
if defined($mean_pcg3[$b]) && defined($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][2]); |
0 | 228 |
$sumsq_pcg4[$b] += ($mean_pcg4[$b] - $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][3])**2 |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
229 |
if defined($mean_pcg4[$b]) && defined($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][3]); |
0 | 230 |
|
231 |
next unless ($dta{ENSEMBLE}[$e]->{GOOD_VEL}[$b]); |
|
232 |
||
233 |
$sumsq_u[$b] += ($mean_u[$b] - $dta{ENSEMBLE}[$e]->{VELOCITY}[$b][0])**2; |
|
234 |
$sumsq_v[$b] += ($mean_v[$b] - $dta{ENSEMBLE}[$e]->{VELOCITY}[$b][1])**2; |
|
235 |
$sumsq_w[$b] += ($mean_w[$b] - $dta{ENSEMBLE}[$e]->{VELOCITY}[$b][2])**2; |
|
236 |
||
237 |
next if ($dta{ENSEMBLE}[$e]->{THREE_BEAM}[$b]); |
|
238 |
||
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
239 |
$sumsq_e[$b] += ($mean_e[$b] - $dta{ENSEMBLE}[$e]->{VELOCITY}[$b][3])**2 |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
240 |
if defined($mean_e[$b]); |
0 | 241 |
} |
242 |
} |
|
243 |
||
244 |
for ($b=0; $b<=$lastGoodBin; $b++) { |
|
245 |
$var_corr1[$b] = $sumsq_corr1[$b] / ($nEns-1); $var_corr2[$b] = $sumsq_corr2[$b] / ($nEns-1); |
|
246 |
$var_corr3[$b] = $sumsq_corr3[$b] / ($nEns-1); $var_corr4[$b] = $sumsq_corr4[$b] / ($nEns-1); |
|
247 |
$var_amp1[$b] = $sumsq_amp1[$b] / ($nEns-1); $var_amp2[$b] = $sumsq_amp2[$b] / ($nEns-1); |
|
248 |
$var_amp3[$b] = $sumsq_amp3[$b] / ($nEns-1); $var_amp4[$b] = $sumsq_amp4[$b] / ($nEns-1); |
|
249 |
$var_pcg1[$b] = $sumsq_pcg1[$b] / ($n_pcg1[$b]-1) if ($n_pcg1[$b] > 1); |
|
250 |
$var_pcg2[$b] = $sumsq_pcg2[$b] / ($n_pcg2[$b]-1) if ($n_pcg2[$b] > 1); |
|
251 |
$var_pcg3[$b] = $sumsq_pcg3[$b] / ($n_pcg3[$b]-1) if ($n_pcg3[$b] > 1); |
|
252 |
$var_pcg4[$b] = $sumsq_pcg4[$b] / ($n_pcg4[$b]-1) if ($n_pcg4[$b] > 1); |
|
253 |
next unless ($good_vels[$b] > 1); |
|
254 |
$var_u[$b] = $sumsq_u[$b] / ($good_vels[$b]-1); |
|
255 |
$var_v[$b] = $sumsq_v[$b] / ($good_vels[$b]-1); |
|
256 |
$var_w[$b] = $sumsq_w[$b] / ($good_vels[$b]-1); |
|
257 |
next unless ($good_vels[$b] - $three_beam[$b] > 1); |
|
258 |
$var_e[$b] = $sumsq_e[$b] / ($good_vels[$b] - $three_beam[$b] - 1); |
|
259 |
} |
|
260 |
||
261 |
#---------------------------------------------------------------------- |
|
262 |
# Calculate Beam Statistics |
|
263 |
#---------------------------------------------------------------------- |
|
264 |
||
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
265 |
# not implemented yet |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
266 |
|
0 | 267 |
#---------------------------------------------------------------------- |
268 |
# Produce Output |
|
269 |
#---------------------------------------------------------------------- |
|
270 |
||
271 |
unless ($opt_Q) { |
|
272 |
my($ssCorr) = defined($opt_S) |
|
273 |
? ssCorr($dta{ENSEMBLE}[$fe],$SS_salin,$SS_temp,$SS_depth) |
|
274 |
: 1; |
|
275 |
||
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
276 |
print("#!/usr/bin/perl -S list\n"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
277 |
chmod(0777&~umask,*STDOUT); |
0 | 278 |
print("#ANTS#PARAMS# "); |
279 |
foreach my $k (keys(%P)) { |
|
280 |
print("$k\{$P{$k}\} "); |
|
281 |
} |
|
282 |
printf("soundspeed_correction{%s}",defined($opt_S) ? $opt_S : 'NONE!'); |
|
283 |
print("\n"); |
|
284 |
||
285 |
print("#ANTS#FIELDS# " . |
|
286 |
"{bin} {dz} " . |
|
287 |
(defined($opt_D) ? "{depth} " : "") . |
|
288 |
($opt_b ? "{v1} {v2} {v3} {v4} " : "{u} {v} {w} {err_vel} ") . |
|
289 |
($opt_b ? "{sig_v1} {sig_v2} {sig_v3} {sig_v4} " : "{sig_u} {sig_v} {sig_w} {sig_err_vel} ") . |
|
290 |
"{corr1} {corr2} {corr3} {corr4} " . |
|
291 |
"{sig_corr1} {sig_corr2} {sig_corr3} {sig_corr4} " . |
|
292 |
"{amp1} {amp2} {amp3} {amp4} " . |
|
293 |
"{sig_amp1} {sig_amp2} {sig_amp3} {sig_amp4} " . |
|
294 |
"{pcg1} {pcg2} {pcg3} {pcg4} " . |
|
295 |
"{sig_pcg1} {sig_pcg2} {sig_pcg3} {sig_pcg4}" . |
|
296 |
"\n" |
|
297 |
); |
|
298 |
||
299 |
for ($b=$firstBin; $b<=$lastBin; $b++) { |
|
300 |
printf("%d %.1f ",$b+1,$dz[$b]*$ssCorr); |
|
301 |
printf("%.1f ",$opt_D - $dz[$b]*$ssCorr) |
|
302 |
if defined($opt_D); |
|
303 |
||
304 |
printf("%s ",defined($mean_u[$b]) ? $mean_u[$b] : nan); |
|
305 |
printf("%s ",defined($mean_v[$b]) ? $mean_v[$b] : nan); |
|
306 |
printf("%s ",defined($mean_w[$b]) ? $mean_w[$b] : nan); |
|
307 |
printf("%s ",defined($mean_e[$b]) ? $mean_e[$b] : nan); |
|
308 |
||
309 |
printf("%s ",defined($var_u[$b]) ? sqrt($var_u[$b]) : nan); |
|
310 |
printf("%s ",defined($var_v[$b]) ? sqrt($var_v[$b]) : nan); |
|
311 |
printf("%s ",defined($var_w[$b]) ? sqrt($var_w[$b]) : nan); |
|
312 |
printf("%s ",defined($var_e[$b]) ? sqrt($var_e[$b]) : nan); |
|
313 |
||
314 |
printf("%g %g %g %g ",$mean_corr1[$b],$mean_corr2[$b], |
|
315 |
$mean_corr3[$b],$mean_corr4[$b]); |
|
316 |
printf("%g %g %g %g ",sqrt($var_corr1[$b]),sqrt($var_corr2[$b]), |
|
317 |
sqrt($var_corr3[$b]),sqrt($var_corr4[$b])); |
|
318 |
||
319 |
printf("%g %g %g %g ",$mean_amp1[$b],$mean_amp2[$b], |
|
320 |
$mean_amp3[$b],$mean_amp4[$b]); |
|
321 |
printf("%g %g %g %g ",sqrt($var_amp1[$b]),sqrt($var_amp2[$b]), |
|
322 |
sqrt($var_amp3[$b]),sqrt($var_amp4[$b])); |
|
323 |
||
324 |
if ($good_vels[$b] > 0) { |
|
325 |
printf("%g %g %g %g ",$mean_pcg1[$b],$mean_pcg2[$b], |
|
326 |
$mean_pcg3[$b],$mean_pcg4[$b]); |
|
327 |
printf("%g %g %g %g\n",sqrt($var_pcg1[$b]),sqrt($var_pcg2[$b]), |
|
328 |
sqrt($var_pcg3[$b]),sqrt($var_pcg4[$b])); |
|
329 |
} else { |
|
330 |
print("nan nan nan nan "); |
|
331 |
print("nan nan nan nan\n"); |
|
332 |
} |
|
333 |
} |
|
334 |
} |
|
335 |
||
336 |
exit(0); |