author | A.M. Thurnherr <athurnherr@yahoo.com> |
Sun, 27 Jul 2014 16:28:57 -0400 | |
changeset 30 | 8697ba5a88ec |
parent 22 | f6635c0384b7 |
child 31 | af03ca38fc2a |
permissions | -rw-r--r-- |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
1 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
2 |
# L A D C P P R O C . B T |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
3 |
# doc: Wed Oct 20 21:05:37 2010 |
22
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
4 |
# dlm: Thu Sep 19 13:17:41 2013 |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
5 |
# (c) 2010 A.M. Thurnherr |
22
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
6 |
# uE-Info: 119 96 NIL 0 0 72 10 2 4 NIL ofnI |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
7 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
8 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
9 |
# HISTORY: |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
10 |
# Oct 20, 2010: - created |
1 | 11 |
# Jan 10, 2010: - -o => -k |
3 | 12 |
# Jul 7, 2010: - added $DEBUG |
13 |
# - added BTrangeFlag |
|
14 |
# - added $BT processing parameters |
|
15 |
# - changed from echo amplitude to Sv |
|
12 | 16 |
# May 16, 2012: - added support for -r)DI BT data |
22
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
17 |
# Sep 19, 2013: - added support for $BT_range_method |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
18 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
19 |
my($BEAM1) = 0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
20 |
my($BEAM2) = 1; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
21 |
my($BEAM3) = 2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
22 |
my($BEAM4) = 3; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
23 |
|
3 | 24 |
my($nBTfound,$nBTrangeFlag,$nBTdepthFlag,$nBTvalidVelFlag,$nBTwFlag) = (0,0,0,0,0); |
25 |
||
26 |
my($DEBUG) = 0; |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
27 |
|
12 | 28 |
sub CTDvelFromSv($) |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
29 |
{ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
30 |
my($ens) = @_; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
31 |
|
3 | 32 |
my(@Sv_max) = (-9e99,-9e99,-9e99,-9e99); my(@Sv_max_bin) = (nan,nan,nan,nan); |
33 |
for (my($bin)=$BT_bin_start-1; $bin<$LADCP{N_BINS}; $bin++) { |
|
34 |
if (defined($BT_min_depth)) { # manually supplied bottom depth range |
|
35 |
my($dob) = &depthOfBin($ens,$bin); |
|
36 |
next unless ($dob >= $BT_min_depth && $dob <= $BT_max_depth); |
|
37 |
} |
|
38 |
$Sv_max[$BEAM1] = $LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM1], |
|
39 |
$Sv_max_bin[$BEAM1] = $bin |
|
40 |
if ($LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM1] > $Sv_max[$BEAM1]); |
|
41 |
$Sv_max[$BEAM2] = $LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM2], |
|
42 |
$Sv_max_bin[$BEAM2] = $bin |
|
43 |
if ($LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM2] > $Sv_max[$BEAM2]); |
|
44 |
$Sv_max[$BEAM3] = $LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM3], |
|
45 |
$Sv_max_bin[$BEAM3] = $bin |
|
46 |
if ($LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM3] > $Sv_max[$BEAM3]); |
|
47 |
$Sv_max[$BEAM4] = $LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM4], |
|
48 |
$Sv_max_bin[$BEAM4] = $bin |
|
49 |
if ($LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM4] > $Sv_max[$BEAM4]); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
50 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
51 |
|
3 | 52 |
print(STDERR "@Sv_max | @Sv_max_bin\n") if ($DEBUG); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
53 |
$nBTfound++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
54 |
|
3 | 55 |
$nBTrangeFlag++,return # inconsistent range (&, impliclity, large tilt) |
56 |
unless (max(@Sv_max_bin)-min(@Sv_max_bin) <= $BT_max_bin_spread); |
|
57 |
||
58 |
my($range_bin) = round(avg(@Sv_max_bin)); |
|
59 |
printf(STDERR "water_depth = $water_depth; BT peak depth = %d in bin $range_bin\n",depthOfBin($ens,$range_bin)) |
|
60 |
if ($DEBUG); |
|
61 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
62 |
$nBTdepthFlag++,return # BT range inconsistent with water depth |
3 | 63 |
unless defined($BT_min_depth) || |
64 |
(abs($water_depth-depthOfBin($ens,$range_bin)) < $sig_water_depth + $BT_max_depth_error); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
65 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
66 |
my($CTD_u,$CTD_v,$CTD_w); |
22
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
67 |
|
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
68 |
if ($BT_range_method == 0) { # take BT vel from bin with Sv max |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
69 |
|
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
70 |
$nBTvalidVelFlag++,return unless numberp($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$W]); |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
71 |
$CTD_u = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$U]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
72 |
$CTD_v = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$V]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
73 |
$CTD_w = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$W]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
74 |
|
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
75 |
} elsif ($BT_range_method == 1) { # take "best-fit" with w_reflr |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
76 |
|
22
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
77 |
# try bin of max plus one above and below |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
78 |
# this does not really work because, often, only one of the bins has valid velocities |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
79 |
my($w1) = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin-1][$W]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
80 |
my($w2) = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$W]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
81 |
my($w3) = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+1][$W]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
82 |
|
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
83 |
printf(STDERR "w123 = %.1f,%.1f,%.1f\n",$w1,$w2,$w3) |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
84 |
if ($DEBUG); |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
85 |
|
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
86 |
$w1 = 9e99 unless numberp($w1); # no valid velocities |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
87 |
$w2 = 9e99 unless numberp($w1); |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
88 |
$w3 = 9e99 unless numberp($w1); |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
89 |
|
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
90 |
if (abs($LADCP{ENSEMBLE}[$ens]->{W}-$w1) < abs($LADCP{ENSEMBLE}[$ens]->{W}-$w2) && |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
91 |
abs($LADCP{ENSEMBLE}[$ens]->{W}-$w1) < abs($LADCP{ENSEMBLE}[$ens]->{W}-$w3)) { |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
92 |
$CTD_u = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin-1][$U]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
93 |
$CTD_v = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin-1][$V]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
94 |
$CTD_w = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin-1][$W]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
95 |
} elsif (abs($LADCP{ENSEMBLE}[$ens]->{W}-$w1) < abs($LADCP{ENSEMBLE}[$ens]->{W}-$w2)) { |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
96 |
$CTD_u = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+1][$U]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
97 |
$CTD_v = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+1][$V]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
98 |
$CTD_w = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+1][$W]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
99 |
} else { |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
100 |
$nBTvalidVelFlag++,return if ($w2 == 9e99); # none of 3 bins has valid velocity |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
101 |
$CTD_u = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$U]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
102 |
$CTD_v = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$V]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
103 |
$CTD_w = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$W]; |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
104 |
} |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
105 |
|
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
106 |
} elsif ($BT_range_method == 2) { # Visbeck method (median from 3 bins) |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
107 |
croak("$0: need \$BT_range_Visbeck_center\n") |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
108 |
unless defined($BT_range_Visbeck_center); |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
109 |
|
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
110 |
$CTD_u = median($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center+1][$U], |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
111 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center][$U], |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
112 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center-1][$U]); |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
113 |
$nBTvalidVelFlag++,return unless numberp($CTD_u); |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
114 |
$CTD_v = median($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center+1][$V], |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
115 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center][$V], |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
116 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center-1][$V]); |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
117 |
$CTD_w = median($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center+1][$W], |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
118 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center][$W], |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
119 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center-1][$W]); |
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
120 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
121 |
} else { |
22
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
122 |
|
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
123 |
croak("$0: unknown \$BT_range_method == $BT_range_method\n"); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
124 |
} |
22
f6635c0384b7
beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
12
diff
changeset
|
125 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
126 |
|
12 | 127 |
return ($CTD_u,$CTD_v,$CTD_w); |
128 |
} |
|
129 |
||
130 |
sub depthAtRange($$) |
|
131 |
{ |
|
132 |
my($ens,$range) = @_; |
|
133 |
return $LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP} ? |
|
134 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH} - $range : |
|
135 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH} + $range; |
|
136 |
} |
|
137 |
||
138 |
sub CTDvelFromBT($) |
|
139 |
{ |
|
140 |
my($ens) = @_; |
|
141 |
||
142 |
return (undef,undef,undef) |
|
143 |
unless defined($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$W]); |
|
144 |
$nBTfound++; |
|
145 |
||
146 |
$nBTrangeFlag++,return # inconsistent range (&, impliclity, large tilt) |
|
147 |
unless (max(@{$LADCP{ENSEMBLE}[$ens]->{BT_RANGE}})-min(@{$LADCP{ENSEMBLE}[$ens]->{BT_RANGE}}) |
|
148 |
<= $BT_max_bin_spread*$LADCP{BIN_LENGTH}); |
|
149 |
||
150 |
my($range) = round(avg(@{$LADCP{ENSEMBLE}[$ens]->{BT_RANGE}})); |
|
151 |
||
152 |
$nBTdepthFlag++,return # BT range inconsistent with water depth |
|
153 |
unless defined($BT_min_depth) || |
|
154 |
(abs($water_depth-depthAtRange($ens,$range)) < $sig_water_depth + $BT_max_depth_error); |
|
155 |
||
156 |
return ($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$U], |
|
157 |
$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$V], |
|
158 |
$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$W]); |
|
159 |
} |
|
160 |
||
161 |
||
162 |
sub binBTprof($) |
|
163 |
{ |
|
164 |
my($ens) = @_; |
|
165 |
my($CTD_u,$CTD_v,$CTD_w); |
|
166 |
||
167 |
($CTD_u,$CTD_v,$CTD_w) = $opt_r ? CTDvelFromBT($ens) : CTDvelFromSv($ens); |
|
168 |
return unless defined($CTD_w); |
|
169 |
||
3 | 170 |
$nBTwFlag++,return if (abs($CTD_w-$LADCP{ENSEMBLE}[$ens]->{W}) > $BT_max_w_difference); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
171 |
|
3 | 172 |
printf(STDERR "good BT [%5.2f %5.2f %5.2f] found at ens $ens\n",$CTD_u,$CTD_v,$CTD_w) |
173 |
if ($DEBUG); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
174 |
|
1 | 175 |
if ($opt_k) { |
3 | 176 |
for (my($bin)=$BT_bin_start-1; $bin<$LADCP{N_BINS}; $bin++) { |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
177 |
next if ($edit_flags[$ens][$bin]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
178 |
printf(BTF "%d %d %d %f %f %f %f %f %f %f %f %f %f %f\n", |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
179 |
$LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
180 |
depthOfBin($ens,$bin),$LADCP{ENSEMBLE}[$ens]->{DEPTH}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
181 |
$LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
182 |
$CTD_u,$CTD_v,$CTD_w, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
183 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U], |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
184 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V], |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
185 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W], |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
186 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U]-$CTD_u, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
187 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V]-$CTD_v, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
188 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]-$CTD_w); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
189 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
190 |
print(BTF "nan nan nan nan\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
191 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
192 |
|
3 | 193 |
for (my($bin)=$BT_bin_start-1; $bin<$LADCP{N_BINS}; $bin++) { |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
194 |
next if ($edit_flags[$ens][$bin]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
195 |
my($gi) = depthOfBin($ens,$bin) / $GRID_DZ; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
196 |
push(@{$BTu_vals[$gi]},$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U]-$CTD_u); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
197 |
push(@{$BTv_vals[$gi]},$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V]-$CTD_v); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
198 |
push(@{$BTw_vals[$gi]},$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]-$CTD_w); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
199 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
200 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
201 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
202 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
203 |
sub getBTprof($$) |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
204 |
{ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
205 |
my($LADCP_start,$LADCP_end) = @_; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
206 |
|
1 | 207 |
if ($opt_k) { |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
208 |
open(BTF,">BT.profs"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
209 |
print(BTF "#ANTS#FIELDS# {ens} {depth} {CTD_depth} {pitch} {roll} {CTD_u} {CTD_v} {CTD_w} {u} {v} {w} {BT_u} {BT_v} {BT_w}\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
210 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
211 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
212 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
3 | 213 |
next unless ($water_depth-$LADCP{ENSEMBLE}[$ens]->{DEPTH} < $BT_begin_search_above); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
214 |
binBTprof($ens); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
215 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
216 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
217 |
if ($opt_d) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
218 |
print(STDERR "\n\t$nBTfound BT ensembles found\n"); |
3 | 219 |
print(STDERR "\t\t$nBTrangeFlag flagged bad because of inconsistent range to seabed\n"); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
220 |
print(STDERR "\t\t$nBTdepthFlag flagged bad because of wrong bottom depth\n"); |
3 | 221 |
print(STDERR "\t\t$nBTvalidVelFlag flagged bad because of lack of valid velocities\n"); |
222 |
print(STDERR "\t\t$nBTwFlag flagged bad because of incorrect vertical velocities"); |
|
223 |
printf(STDERR "\n\t=> %d velocities from %d BT ensembles used", |
|
224 |
scalar(@BTu_vals), |
|
225 |
$nBTfound-$nBTrangeFlag-$nBTdepthFlag-$nBTvalidVelFlag-$nBTwFlag); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
226 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
227 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
228 |
@BTu = @BTv = @BTw = (); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
229 |
@BTu_sig = @BTv_sig = @BTw_sig = (); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
230 |
@BT_nsamp = (); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
231 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
232 |
for (my($gi)=0; $gi<@BTu_vals; $gi++) { # calc grid means & stddev |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
233 |
my($sum_u,$sum_v,$sum_w); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
234 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
235 |
$BT_nsamp[$gi] = @{$BTu_vals[$gi]}; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
236 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
237 |
for (my($vi)=0; $vi<$BT_nsamp[$gi]; $vi++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
238 |
$sum_u += $BTu_vals[$gi][$vi]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
239 |
$sum_v += $BTv_vals[$gi][$vi]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
240 |
$sum_w += $BTw_vals[$gi][$vi]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
241 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
242 |
$BTu[$gi] = $BT_nsamp[$gi] ? $sum_u/$BT_nsamp[$gi] : nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
243 |
$BTv[$gi] = $BT_nsamp[$gi] ? $sum_v/$BT_nsamp[$gi] : nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
244 |
$BTw[$gi] = $BT_nsamp[$gi] ? $sum_w/$BT_nsamp[$gi] : nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
245 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
246 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
247 |
for (my($gi)=0; $gi<@BTu_vals; $gi++) { # calc & grid stddevs |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
248 |
my($sumsq_u,$sumsq_v,$sumsq_w); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
249 |
for (my($vi)=0; $vi<$BT_nsamp[$gi]; $vi++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
250 |
$sumsq_u += ($BTu_vals[$gi][$vi] - $BTu[$gi])**2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
251 |
$sumsq_v += ($BTv_vals[$gi][$vi] - $BTv[$gi])**2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
252 |
$sumsq_w += ($BTw_vals[$gi][$vi] - $BTw[$gi])**2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
253 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
254 |
$BTu_sig[$gi] = $BT_nsamp[$gi]>1 ? sqrt($sumsq_u/($BT_nsamp[$gi]-1)) : nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
255 |
$BTv_sig[$gi] = $BT_nsamp[$gi]>1 ? sqrt($sumsq_v/($BT_nsamp[$gi]-1)) : nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
256 |
$BTw_sig[$gi] = $BT_nsamp[$gi]>1 ? sqrt($sumsq_w/($BT_nsamp[$gi]-1)) : nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
257 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
258 |
|
1 | 259 |
close(BTF) if ($opt_k); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
260 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
261 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
262 |
1; |