author | A.M. Thurnherr <athurnherr@yahoo.com> |
Sat, 23 Dec 2017 16:13:52 -0500 | |
changeset 42 | 80d039881d2c |
parent 40 | 6a46e9d31106 |
child 43 | b63fa355644c |
child 44 | b7654ea68af6 |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/perl |
2 |
#====================================================================== |
|
3 |
# L I S T B I N S |
|
4 |
# doc: Fri Aug 25 15:57:05 2006 |
|
42 | 5 |
# dlm: Sat Dec 23 16:10:11 2017 |
0 | 6 |
# (c) 2006 A.M. Thurnherr |
42 | 7 |
# uE-Info: 104 28 NIL 0 0 72 0 2 4 NIL ofnI |
0 | 8 |
#====================================================================== |
9 |
||
10 |
# Split data file into per-bin time series. |
|
11 |
||
12 |
# HISTORY: |
|
13 |
# Aug 25, 2006: - created from [listEns] |
|
14 |
# Aug 26, 2006: - added -M)agdecl |
|
15 |
# - changed -b to -f |
|
16 |
# Aug 27, 2006: - added %bin |
|
17 |
# Aug 28, 2006: - BUG: options were confused |
|
18 |
# Jan 4, 2007: - improved usage message for -a |
|
19 |
# - added %mag_decl |
|
20 |
# - BUG: roundoff error in %pct_good_vels |
|
21 |
# Sep 19, 2007: - adapted to new [RDI_BB_Read.pl] |
|
22 |
# Feb 7, 2008: - added sound-speed correction |
|
23 |
# - enabled 3-beam solutions |
|
24 |
# Feb 8, 2008: - added -d)iscard <beam> |
|
25 |
# - added -b)eam coordinate output |
|
26 |
# Feb 12, 2008: - modified 3-beam output |
|
27 |
# - added -p)ct_good <min> |
|
28 |
# Feb 13, 2008: - various improvements |
|
29 |
# Feb 19, 2008: - BUG: division by zero |
|
30 |
# BUG: min() did not work with 1st elt undef |
|
31 |
# Feb 21, 2008: - BUG: had forgotten to undo debugging changes |
|
32 |
# - removed missing magdecl warning on -b |
|
33 |
# Feb 22, 2008: - moved ssCorr() to [RDI_Utils.pl] |
|
34 |
# - BUG: %d complete ensembles was written to STDOUT |
|
35 |
# - BUG: %N_ensembles was total number of ensembles, not |
|
36 |
# only the ones used |
|
37 |
# - BUG: 0 errvel was output for 3-beam solutions => |
|
38 |
# wrong time-average statistics |
|
39 |
# May 19, 2009: - added -w to calculate vertical velocities from |
|
40 |
# two beam pairs separately |
|
41 |
# May 21, 2009: - added horizontal beampair velocities on -w |
|
42 |
# - -P)itchRoll <bias/bias> |
|
43 |
# May 22, 2009: - added -B) <bias/bias/bias/bias> |
|
44 |
# May 23, 2009: - adapted to changed beampair-velocity fun name |
|
1 | 45 |
# Aug 22, 2010: - added -R |
12 | 46 |
# Apr 29, 2013: - cosmetics |
47 |
# - added warning on missing -S |
|
13
b176da8559b3
before implementing WBWens (PD0 writing)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
48 |
# Aug 7, 2013: - BUG: -w did not respect -d |
18 | 49 |
# Mar 4, 2014: - added support for missing PITCH/ROLL/HEADING |
50 |
# Apr 22, 2014: - BUG: extraneous semicolon |
|
21 | 51 |
# Nov 24, 2014: - enabled -w always |
23
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
52 |
# Mar 22, 2015: - replaced -f by -o (allowing for pipes) |
24 | 53 |
# Jun 16, 2015: - BUG: velocity bias code did not respect bad velocities |
28 | 54 |
# Jan 5, 2016: - adapted to [ANTS_tools_lib.pl] |
55 |
# - adapted to calculation of w12, w34 from earth-coordinate data |
|
56 |
# - several other changes to the code that should not affect the results |
|
32 | 57 |
# Jan 6, 2016: - -b removed (always output beamvels) |
58 |
# Jan 31, 2016: - started debugging the obviously wrong Earth2Beam() transformation |
|
59 |
# Feb 29, 2016: - continued debugging; removed debugging code |
|
33 | 60 |
# Mar 17, 2016: - adapted to new Getopt library |
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
61 |
# Jun 9, 2016: - minor improvements |
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
62 |
# - BUG: velBeamToEarth() has new interface |
37 | 63 |
# Jan 27, 2017: - BUG: earth-coordinate label was wrong |
64 |
# - changed semantics to include all %-good fields of earth-coordinate data |
|
65 |
# and also report total pcg (3+4 beam) in min_pcg |
|
66 |
# - BUG: 3-beam %ages were incorrect: 1) they were based on goodvels instead of the |
|
67 |
# entire ensemble range; 2) pings-per-ensemble were not considered |
|
68 |
# - BUG: output layout was all messed up for non-valid velocities |
|
0 | 69 |
|
70 |
# General Notes: |
|
71 |
# - everything (e.g. beams) is numbered from 1 |
|
72 |
# - no support for BT data |
|
73 |
||
23
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
74 |
# Post-Processing: |
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
75 |
# - e.g. in a Makefile, |
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
76 |
# BFILT = | list -Lconv ensemble elapsed dn12='str2dec_time(\$$date,\$$time,2012)' heading pitch roll temp u v w err_vel w12 w34 corr1 corr2 corr3 corr4 amp1 amp2 amp3 amp4 > `basename $@ .b1`.b%d |
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
77 |
# - used as follows |
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
78 |
# listBins -o "${BFILT}" |
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
79 |
# - this writes only the interesting fields and calculates a 2012-referenced decimal day field |
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
80 |
|
0 | 81 |
# Soundspeed Correction: |
82 |
# - applied as described in the RDI coord-trans manual |
|
83 |
# - sound-speed variation over range is ignored (valid for small gradients) |
|
84 |
# => - same simple correction for all velocity components |
|
85 |
# - simple correction for cell depths |
|
86 |
||
87 |
# Min %-good (min_pcg): |
|
88 |
# - nan for records w/o valid velocities |
|
89 |
# - min(%-good) of the beams used for the velocity solution |
|
90 |
# - min_pcg does not have to decrease monotonically with distance, |
|
91 |
# at least when 3-beam solutions are allowed and when -p is used to |
|
92 |
# edit the data |
|
93 |
# - non-monotonic min_pcg is particularly obvious with the DYNAMUCK BM_ADCP |
|
94 |
# data, where one of the beams performed much worse than the others |
|
95 |
||
37 | 96 |
# %-good of earth-coordinate data: |
97 |
# pcg1 3-beam (correlation threshold) |
|
98 |
# pcg2 bad (errvel threshold) |
|
99 |
# pcg3 bad (>1 bad beam) |
|
100 |
# pcg4 4-beam |
|
101 |
||
33 | 102 |
use Getopt::Std; |
28 | 103 |
|
42 | 104 |
$ADCP_tools_minVersion = 2.1; |
28 | 105 |
($ADCP_TOOLS) = ($0 =~ m{(.*/)[^/]+}); |
106 |
require "$ADCP_TOOLS/ADCP_tools_lib.pl"; |
|
0 | 107 |
|
1 | 108 |
die("Usage: $0 [-r)ange <first_ens,last_ens>] [-R)enumber ensembles] " . |
23
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
109 |
"[-o)utput <redirection[>bin%d.raw]>] " . |
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
110 |
"[output -a)ll ens (not just those with good vels)] " . |
0 | 111 |
"[-M)agnetic <declination>] " . |
112 |
"[-S)oundspeed correction <salin|*,temp|*,depth|*> " . |
|
113 |
"[-P)itch/Roll <bias/bias>] [-B)eamvel <bias/bias/bias/bias>] " . |
|
114 |
"[require -4)-beam solutions] [-d)iscard <beam#>] " . |
|
12 | 115 |
"[-p)ct-good <min>] " . |
0 | 116 |
"<RDI file>\n") |
33 | 117 |
unless (&getopts("4aB:d:M:o:p:r:P:RS:") && @ARGV == 1); |
0 | 118 |
|
119 |
($P{pitch_bias},$P{roll_bias}) = split('[,/]',$opt_P); |
|
120 |
($P{velbias_b1},$P{velbias_b2},$P{velbias_b3},$P{velbias_b4}) = split('[,/]',$opt_B); |
|
121 |
||
122 |
die("$0: -4 and -d are mutually exclusive\n") |
|
123 |
if ($opt_4 && defined($opt_d)); |
|
124 |
||
125 |
$opt_p = 0 unless defined($opt_p); |
|
126 |
||
127 |
$RDI_Coords::minValidVels = 4 if ($opt_4); # no 3-beam solutions |
|
128 |
||
129 |
print(STDERR "WARNING: magnetic declination not set!\n") |
|
28 | 130 |
unless defined($opt_M); |
0 | 131 |
|
23
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
132 |
$opt_o = '>bin%d.raw' unless defined($opt_o); |
0 | 133 |
$ifn = $ARGV[0]; |
134 |
||
135 |
($first_ens,$last_ens) = split(',',$opt_r) |
|
136 |
if defined($opt_r); |
|
137 |
||
12 | 138 |
if (defined($opt_S)) { |
139 |
($SS_salin,$SS_temp,$SS_depth) = split(',',$opt_S); |
|
140 |
$variable_ssCorr = ($SS_salin eq '*' || $SS_temp eq '*' || $SS_depth eq '*'); |
|
141 |
} else { |
|
142 |
print(STDERR "WARNING: no soundspeed correction applied!\n"); |
|
143 |
} |
|
0 | 144 |
|
145 |
#---------------------------------------------------------------------- |
|
146 |
||
147 |
sub min(@) # return minimum |
|
148 |
{ |
|
149 |
my($min) = 99e99; |
|
150 |
for (my($i)=0; $i<=$#_; $i++) { |
|
151 |
$min = $_[$i] if defined($_[$i]) && ($_[$i] < $min); |
|
152 |
} |
|
153 |
return ($min == 99e99) ? nan : $min; |
|
154 |
} |
|
155 |
||
156 |
sub dumpBin($$$) # write time series of single bin |
|
157 |
{ |
|
158 |
my($b,$fe,$le) = @_; |
|
23
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
159 |
my($out) = sprintf($opt_o,$b+1); |
0 | 160 |
|
23
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
161 |
open(P,"$out") || die("$out: $!\n"); |
0 | 162 |
print(P "#ANTS#PARAMS# "); |
163 |
foreach my $k (keys(%P)) { |
|
164 |
print(P "$k\{$P{$k}\} "); |
|
165 |
} |
|
37 | 166 |
my($pct3b) = 100*$three_beam[$b]/(($le-$fe+1) * $dta{PINGS_PER_ENSEMBLE}); |
40
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
37
diff
changeset
|
167 |
# die("assertion failed ($pct3b > 100): gv[$b] = $good_vels[$b]; 3b = $three_beam[$b]; ens=$fe..$le; ") |
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
37
diff
changeset
|
168 |
# if ($pct3b > 100); |
37 | 169 |
printf(STDERR "%02d:%.0f%%/%.0f%% ",$b+1,100*$good_vels[$b]/($le-$fe+1),$pct3b); |
28 | 170 |
|
171 |
printf(P "pct_3_beam{%.0f} ",$pct3b); |
|
0 | 172 |
printf(P "pct_good_vels{%.0f} ",100*$good_vels[$b]/($le-$fe+1)); |
173 |
printf(P "bin{%d}",$b+1); |
|
174 |
printf(P " soundspeed_correction{%s}",defined($opt_S) ? $opt_S : 'NONE!'); |
|
175 |
printf(P " dz{%g}",$dz[$b] * |
|
176 |
(defined($opt_S) ? ssCorr($dta{ENSEMBLE}[$fe],$SS_salin,$SS_temp,$SS_depth) : 1) |
|
177 |
) unless ($variable_ssCorr); |
|
178 |
print( P "\n"); |
|
179 |
||
180 |
print(P "#ANTS#FIELDS# " . |
|
181 |
"{ensemble} {date} {time} {elapsed} " . |
|
182 |
"{heading} {pitch} {roll} " . |
|
183 |
"{sig_heading} {sig_pitch} {sig_roll} " . |
|
184 |
"{xmit_current} {xmit_voltage} " . |
|
185 |
"{temp} " . |
|
28 | 186 |
"{bv1} {bv2} {bv3} {bv4} {u} {v} {w} {err_vel} " . |
21 | 187 |
"{v12} {w12} {v34} {w34} " . |
0 | 188 |
"{corr1} {corr2} {corr3} {corr4} " . |
189 |
"{amp1} {amp2} {amp3} {amp4} " . |
|
28 | 190 |
"{pcg1} {pcg2} {pcg3} {pcg4} {3_beam} {min_pcg}" |
0 | 191 |
); |
192 |
print(P " {dz}") if ($variable_ssCorr); |
|
193 |
print(P "\n"); |
|
194 |
||
195 |
my($t0) = $dta{ENSEMBLE}[$fe]->{UNIX_TIME}; |
|
196 |
for (my($e)=$fe; $e<=$le; $e++) { |
|
197 |
next unless ($opt_a || $dta{ENSEMBLE}[$e]->{GOOD_VEL}[$b]); |
|
198 |
||
199 |
my($ssCorr) = defined($opt_S) ? ssCorr($dta{ENSEMBLE}[$e],$SS_salin,$SS_temp,$SS_depth) : 1; |
|
200 |
||
201 |
print(P "$dta{ENSEMBLE}[$e]->{NUMBER} "); |
|
202 |
print(P "$dta{ENSEMBLE}[$e]->{DATE} "); |
|
203 |
print(P "$dta{ENSEMBLE}[$e]->{TIME} "); |
|
23
fb0c269b1eaa
V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
21
diff
changeset
|
204 |
printf(P "%d ",$dta{ENSEMBLE}[$e]->{UNIX_TIME}-$t0); # elapsed time |
18 | 205 |
print(P defined($dta{ENSEMBLE}[$e]->{HEADING}) ? "$dta{ENSEMBLE}[$e]->{HEADING} " : 'nan '); |
206 |
print(P defined($dta{ENSEMBLE}[$e]->{PITCH}) ? "$dta{ENSEMBLE}[$e]->{PITCH} " : 'nan '); |
|
207 |
print(P defined($dta{ENSEMBLE}[$e]->{ROLL}) ? "$dta{ENSEMBLE}[$e]->{ROLL} " : 'nan '); |
|
0 | 208 |
print(P "$dta{ENSEMBLE}[$e]->{HEADING_STDDEV} "); |
209 |
print(P "$dta{ENSEMBLE}[$e]->{PITCH_STDDEV} "); |
|
210 |
print(P "$dta{ENSEMBLE}[$e]->{ROLL_STDDEV} "); |
|
211 |
print(P "$dta{ENSEMBLE}[$e]->{ADC_XMIT_CURRENT} "); |
|
212 |
print(P "$dta{ENSEMBLE}[$e]->{ADC_XMIT_VOLTAGE} "); |
|
213 |
print(P "$dta{ENSEMBLE}[$e]->{TEMPERATURE} "); |
|
214 |
if ($dta{ENSEMBLE}[$e]->{GOOD_VEL}[$b]) { |
|
28 | 215 |
printf(P "%g %g %g %g ",@{$dta{ENSEMBLE}[$e]->{BEAM_VELOCITY}[$b]}); |
0 | 216 |
printf(P "%g ",$dta{ENSEMBLE}[$e]->{VELOCITY}[$b][0] * $ssCorr); |
217 |
printf(P "%g ",$dta{ENSEMBLE}[$e]->{VELOCITY}[$b][1] * $ssCorr); |
|
218 |
printf(P "%g ",$dta{ENSEMBLE}[$e]->{VELOCITY}[$b][2] * $ssCorr); |
|
219 |
if ($dta{ENSEMBLE}[$e]->{THREE_BEAM}[$b]) { |
|
220 |
print(P "nan "); |
|
221 |
} else { |
|
222 |
printf(P "%g ",$dta{ENSEMBLE}[$e]->{VELOCITY}[$b][3] * $ssCorr); |
|
223 |
} |
|
21 | 224 |
printf(P defined($dta{ENSEMBLE}[$e]->{BEAMPAIR_VELOCITY}[$b][0]) ? "%g " : "nan ", |
225 |
$dta{ENSEMBLE}[$e]->{BEAMPAIR_VELOCITY}[$b][0]); |
|
226 |
printf(P defined($dta{ENSEMBLE}[$e]->{BEAMPAIR_VELOCITY}[$b][1]) ? "%g " : "nan ", |
|
227 |
$dta{ENSEMBLE}[$e]->{BEAMPAIR_VELOCITY}[$b][1]); |
|
228 |
printf(P defined($dta{ENSEMBLE}[$e]->{BEAMPAIR_VELOCITY}[$b][2]) ? "%g " : "nan ", |
|
229 |
$dta{ENSEMBLE}[$e]->{BEAMPAIR_VELOCITY}[$b][2]); |
|
230 |
printf(P defined($dta{ENSEMBLE}[$e]->{BEAMPAIR_VELOCITY}[$b][3]) ? "%g " : "nan ", |
|
231 |
$dta{ENSEMBLE}[$e]->{BEAMPAIR_VELOCITY}[$b][3]); |
|
0 | 232 |
} else { |
233 |
print(P "nan nan nan nan "); |
|
21 | 234 |
print(P "nan nan nan nan "); |
37 | 235 |
print(P "nan nan nan nan "); |
0 | 236 |
} |
237 |
print(P "@{$dta{ENSEMBLE}[$e]->{CORRELATION}[$b]} "); |
|
238 |
print(P "@{$dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b]} "); |
|
37 | 239 |
if ($dta{ENSEMBLE}[$e]->{GOOD_VEL}[$b]) { |
240 |
print(P "@{$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b]} "); |
|
241 |
} else { |
|
242 |
print(P "nan nan nan nan "); |
|
243 |
} |
|
28 | 244 |
if ($beamCoords) { |
0 | 245 |
printf(P "%d ",$dta{ENSEMBLE}[$e]->{THREE_BEAM}[$b]); |
246 |
printf(P "%s ",min(@{$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b]})); |
|
28 | 247 |
} else { |
37 | 248 |
if ($dta{ENSEMBLE}[$e]->{GOOD_VEL}[$b]) { |
249 |
print(P "$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][0] "); |
|
250 |
} else { |
|
251 |
print(P "nan "); |
|
252 |
} |
|
253 |
printf(P "%g ",$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][0]+$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][3]); |
|
0 | 254 |
} |
255 |
printf(P "%g ",$dz[$b]*$ssCorr) if ($variable_ssCorr); |
|
256 |
print(P "\n"); |
|
257 |
} |
|
258 |
close(P); |
|
259 |
} |
|
260 |
||
261 |
#---------------------------------------------------------------------- |
|
262 |
# MAIN |
|
263 |
#---------------------------------------------------------------------- |
|
264 |
||
265 |
$P{RDI_file} = $ifn; |
|
266 |
$P{mag_decl} = $opt_M if defined($opt_M); |
|
267 |
||
268 |
readData($ifn,\%dta); |
|
269 |
printf(STDERR "%d complete ensembles...\n",scalar(@{$dta{ENSEMBLE}})); |
|
270 |
$dta{HEADING_BIAS} = -$opt_M; # magnetic declination |
|
271 |
||
272 |
if ($dta{BEAM_COORDINATES}) { # coords |
|
273 |
$beamCoords = 1; |
|
274 |
} else { |
|
28 | 275 |
die("$ifn: only beam and earth coordinates supported\n") |
0 | 276 |
if (!$dta{EARTH_COORDINATES}); |
28 | 277 |
die("$ifn: -p requires beam-coordinate data\n") |
278 |
if ($opt_p > 0); |
|
279 |
die("$ifn: -d requires beam-coordinate data\n") |
|
280 |
if defined($opt_d); |
|
281 |
die("$ifn: -B requires beam-coordinate data\n") |
|
282 |
if defined($opt_B); |
|
0 | 283 |
} |
284 |
||
285 |
for (my($b)=0; $b<$dta{N_BINS}; $b++) { # calc dz |
|
286 |
$dz[$b] = $dta{DISTANCE_TO_BIN1_CENTER} + $b*$dta{BIN_LENGTH}; |
|
287 |
} |
|
288 |
||
289 |
$lastGoodBin = 0; |
|
1 | 290 |
for ($e=0; $e<=$#{$dta{ENSEMBLE}}; $e++) { # check/transform velocities |
291 |
$dta{ENSEMBLE}[$e]->{NUMBER} = $e+1 if ($opt_R); # renumber ensembles |
|
0 | 292 |
next if (defined($first_ens) && |
293 |
$dta{ENSEMBLE}[$e]->{NUMBER} < $first_ens); |
|
294 |
||
18 | 295 |
$dta{ENSEMBLE}[$e]->{PITCH} -= $P{pitch_bias} |
296 |
if defined($dta{ENSEMBLE}[$e]->{PITCH}); |
|
297 |
$dta{ENSEMBLE}[$e]->{ROLL} -= $P{roll_bias} |
|
298 |
if defined($dta{ENSEMBLE}[$e]->{ROLL}); |
|
0 | 299 |
|
300 |
$P{first_ens} = $dta{ENSEMBLE}[$e]->{NUMBER},$fe = $e |
|
301 |
unless defined($P{first_ens}); |
|
302 |
last if (defined($last_ens) && |
|
303 |
$dta{ENSEMBLE}[$e]->{NUMBER} > $last_ens); |
|
304 |
$P{last_ens} = $dta{ENSEMBLE}[$e]->{NUMBER}; |
|
305 |
$le = $e; |
|
306 |
||
307 |
die("3-beams used in ensemble #$dta{ENSEMBLE}[$e]->{NUMBER}\n") |
|
308 |
if ($dta{ENSEMBLE}[$e]->{N_BEAMS_USED} < 4); |
|
309 |
die("BIT error in ensemble $dta{ENSEMBLE}[$e]->{NUMBER}\n") |
|
310 |
if defined($dta{ENSEMBLE}[$e]->{BUILT_IN_TEST_ERROR}); |
|
311 |
die("Low gain in ensemble #$dta{ENSEMBLE}[$e]->{NUMBER}\n") |
|
312 |
if ($dta{ENSEMBLE}[$e]->{LOW_GAIN}); |
|
313 |
||
314 |
for (my($b)=0; $b<$dta{N_BINS}; $b++) { |
|
28 | 315 |
if ($beamCoords) { |
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
316 |
for (my($i)=0; $i<4; $i++) { # percent-good editing (-p) |
28 | 317 |
if ($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][$i] < $opt_p) { |
318 |
undef($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][$i]); |
|
319 |
undef($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][$i]); |
|
320 |
} |
|
321 |
} |
|
322 |
||
323 |
$dta{ENSEMBLE}[$e]->{VELOCITY}[$b][0] -= $P{velbias_b1} # beam-velocity biases (-B) |
|
324 |
if defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][0]); |
|
325 |
$dta{ENSEMBLE}[$e]->{VELOCITY}[$b][1] -= $P{velbias_b2} |
|
326 |
if defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][1]); |
|
327 |
$dta{ENSEMBLE}[$e]->{VELOCITY}[$b][2] -= $P{velbias_b3} |
|
328 |
if defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][2]); |
|
329 |
$dta{ENSEMBLE}[$e]->{VELOCITY}[$b][3] -= $P{velbias_b4} |
|
330 |
if defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][3]); |
|
331 |
||
332 |
if (defined($opt_d)) { # discard data from given beam (-d) |
|
333 |
undef($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][$opt_d-1]); |
|
334 |
undef($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][$opt_d-1]); |
|
335 |
} |
|
336 |
||
337 |
@{$dta{ENSEMBLE}[$e]->{BEAM_VELOCITY}[$b]} = # save beam velocities |
|
338 |
@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]}; |
|
339 |
||
340 |
@{$dta{ENSEMBLE}[$e]->{BEAMPAIR_VELOCITY}[$b]} = # calculate w12, w34 |
|
341 |
velBeamToBPEarth(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{BEAM_VELOCITY}[$b]}); |
|
342 |
||
343 |
@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]} = # calculate earth velocities |
|
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
344 |
velBeamToEarth(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{BEAM_VELOCITY}[$b]}); |
28 | 345 |
$dta{ENSEMBLE}[$e]->{THREE_BEAM}[$b] = $RDI_Coords::threeBeamFlag; |
346 |
$three_beam[$b] += $RDI_Coords::threeBeamFlag; |
|
347 |
||
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
348 |
unless (defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][0])) { # not a valid transformation |
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
349 |
undef(@{$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b]}); |
28 | 350 |
next; |
351 |
} |
|
352 |
} else { # Earth coordinates |
|
353 |
@{$dta{ENSEMBLE}[$e]->{BEAM_VELOCITY}[$b]} = # calculate beam velocities |
|
32 | 354 |
velEarthToBeam(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]}); |
28 | 355 |
|
356 |
@{$dta{ENSEMBLE}[$e]->{BEAMPAIR_VELOCITY}[$b]} = # calculate w12, w34 |
|
357 |
velBeamToBPEarth(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{BEAM_VELOCITY}[$b]}); |
|
358 |
||
359 |
@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]} = # correct for heading bias |
|
360 |
velApplyHdgBias(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]}); |
|
361 |
||
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
362 |
$three_beam[$b] += ($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][0]/100 * $dta{PINGS_PER_ENSEMBLE}); |
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
363 |
unless (defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][0])) { # no valid velocity |
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
33
diff
changeset
|
364 |
undef(@{$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b]}); |
28 | 365 |
next; |
366 |
} |
|
367 |
||
13
b176da8559b3
before implementing WBWens (PD0 writing)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
368 |
} |
28 | 369 |
|
0 | 370 |
$dta{ENSEMBLE}[$e]->{GOOD_VEL}[$b] = 1; |
371 |
$good_vels[$b]++; |
|
372 |
$lastGoodBin = $b if ($b > $lastGoodBin); |
|
373 |
$firstGoodEns = $e unless defined($firstGoodEns); |
|
374 |
$lastGoodEns = $e; |
|
375 |
} |
|
376 |
} |
|
377 |
||
378 |
unless (defined($opt_r)) { |
|
379 |
$fe = $firstGoodEns; |
|
380 |
$le = $lastGoodEns; |
|
381 |
} |
|
382 |
||
383 |
$P{N_ensembles} = $le - $fe + 1; |
|
384 |
||
385 |
$firstBin = 0; |
|
386 |
$lastBin = $lastGoodBin; |
|
387 |
||
388 |
print( STDERR "Start : $dta{ENSEMBLE}[$fe]->{DATE} $dta{ENSEMBLE}[$fe]->{TIME}\n"); |
|
389 |
print( STDERR "End : $dta{ENSEMBLE}[$le]->{DATE} $dta{ENSEMBLE}[$le]->{TIME}\n"); |
|
390 |
printf(STDERR "Bins : %d-%d\n",$firstBin+1,$lastBin+1); |
|
28 | 391 |
if ($beamCoords) { |
0 | 392 |
printf(STDERR "3-Beam : %d %d %d %d\n",$RDI_Coords::threeBeam_1, |
393 |
$RDI_Coords::threeBeam_2, |
|
394 |
$RDI_Coords::threeBeam_3, |
|
395 |
$RDI_Coords::threeBeam_4); |
|
396 |
||
397 |
} |
|
37 | 398 |
print(STDERR "Good/3-Beam: "); |
0 | 399 |
for ($b=$firstBin; $b<=$lastBin; $b++) { # generate output |
400 |
dumpBin($b,$fe,$le); |
|
401 |
} |
|
402 |
print(STDERR "\n"); |
|
403 |
||
404 |
exit(0); |