author | A.M. Thurnherr <ant@ldeo.columbia.edu> |
Sun, 19 Feb 2012 22:49:45 -0500 | |
changeset 7 | e67ddf9937eb |
parent 6 | 2cc7f3b110af |
child 11 | d0af7f7aa23b |
permissions | -rwxr-xr-x |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/perl |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
2 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
3 |
# L A D C P I N T S H |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
4 |
# doc: Thu Oct 14 21:22:50 2010 |
7 | 5 |
# dlm: Sun Feb 19 22:49:28 2012 |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
6 |
# (c) 2010 A.M. Thurnherr & E. Firing |
7 | 7 |
# uE-Info: 50 93 NIL 0 0 72 2 2 4 NIL ofnI |
0
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 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
10 |
$antsSummary = 'integrate LADCP shear'; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
11 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
12 |
# NOTES: |
6 | 13 |
# - the core of this code is a simplified version of avg_sh.m and |
14 |
# int_sh.m written by Eric Firing |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
15 |
# - comments beginning with ## are taken from Eric's code |
6 | 16 |
# - cubic velocity interpolation across PPI gap from Eric's code has |
17 |
# not been implemented (yet?) |
|
18 |
# - low-pass-filtered shear code has not yet been implemented |
|
19 |
# - currently, shear gaps are assumed to have vanishing shear; |
|
7 | 20 |
# better solutions are possible |
21 |
# - elapsed time is simply copied from shear elapsed time (i.e. |
|
22 |
# it is not interpolated onto the new depth grid) |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
23 |
|
6 | 24 |
# WEIRDNESSES IN Eric's CODE: |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
25 |
# - in Eric's [avg_sh.m] the calculation of output shear stddev incorrectly assumes that the 4th column |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
26 |
# in the shear profile is stddev, rather than variance. However, as far as I can tell, this output |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
27 |
# is not used anywhere in Eric's code |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
28 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
29 |
# HISTORY: |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
30 |
# Oct 14, 2010: - created |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
31 |
# Oct 20, 2010: - first working version |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
32 |
# Oct 23, 2010: - added support for -b) |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
33 |
# Oct 24, 2010: - fix spuriously small variances that can occur for BT velocities based on very small |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
34 |
# samples (i.e. primarily when chosing a small -r) |
1 | 35 |
# Dec 9, 2010: - allowed for empty BT file |
2 | 36 |
# Feb 16, 2011: - BUG: gaps in shear data were not handled correctly in baroclinic solution |
3 | 37 |
# Jul 7, 2011: - added -m |
5 | 38 |
# Jul 19, 2011: - added shear sigma output for shear inversion |
39 |
# - BUG: dc/uc v component was not correctly referenced |
|
6 | 40 |
# Jul 24, 2011: - BUG: BT constraint was erroneously assumed to be available for dc,uc only, if it |
41 |
# was available for <dc,uc> combo profile |
|
42 |
# Jul 25, 2011: - BUG: nan in either of ul/dl u_z.sig caused combined u_z.sig to be nan, too |
|
43 |
# Jul 27, 2011: - removed code related to smoothed shear |
|
44 |
# - replaced -r by -n |
|
45 |
# - removed shear sigma output |
|
46 |
# - replaced ndata by nsamp |
|
47 |
# - removed -w (Eric's way of dealing with dc/uc temporal variability) |
|
7 | 48 |
# Feb 19, 2012: - added processing of elapsed time |
49 |
# - adapted to new shear file layout (nsamp instead of nshear) |
|
50 |
# - BUG: uplooker data was not used for downcasts and and only partially for combo data |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
51 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
52 |
($ANTS) = (`which list` =~ m{^(.*)/[^/]*$}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
53 |
require "$ANTS/ants.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
54 |
require "$ANTS/libstats.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
55 |
|
6 | 56 |
&antsUsage('b:dm:n:s:w:u:',0, |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
57 |
'[-d)ebug]', |
3 | 58 |
'[reference with -b)ottom-track <file> [-m)in BT samp[10]]]', |
1 | 59 |
'[-u)plooker <file>]', |
6 | 60 |
'[min -n) <shear samp[10]>]', |
61 |
'[output -s)hear-pro <file>]', |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
62 |
'[LADCP shear file]'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
63 |
|
3 | 64 |
croak("$0: -m requires -b\n") |
65 |
if defined($opt_m) && !defined($opt_b); |
|
66 |
||
6 | 67 |
&antsCardOpt(\$opt_n,10); ## minimum number of samples for shear |
3 | 68 |
&antsCardOpt(\$opt_m,10); # minimum number of samples for BT data |
1 | 69 |
|
70 |
&antsFileOpt($opt_b); # BT file |
|
71 |
||
72 |
&antsFileOpt($opt_u); # UL shear file |
|
73 |
open(ULF,$opt_u) || croak("$opt_u: $!\n") |
|
74 |
if defined($opt_u); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
75 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
76 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
77 |
# Step 1: Read and Average Shear Data |
6 | 78 |
# - depth bins with less than $opt_n values are blanked out |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
79 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
80 |
|
6 | 81 |
sub wavg_sig(@) |
82 |
{ |
|
83 |
my($sumSq) = my($n) = 0; |
|
84 |
for (my($i)=0; $i<$#_; $i+=2) { |
|
85 |
next unless numberp($_[$i+1]); |
|
86 |
$sumSq += $_[$i] * $_[$i+1]**2; |
|
87 |
$n += $_[$i]; |
|
88 |
} |
|
89 |
return ($n>0) ? sqrt($sumSq/$n) : nan; |
|
90 |
} |
|
91 |
||
92 |
||
7 | 93 |
$depthF = fnr('depth'); # layout of [LADCPproc] output |
94 |
$dc_nshF = fnrNoErr('dc_nshear'); |
|
95 |
$dc_nshF = fnr('dc_nsamp') unless defined($dc_nshF); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
96 |
$dc_uzF = fnr('dc_u_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
97 |
$dc_uzsF = fnrNoErr('dc_u_z.sig'); |
7 | 98 |
$dc_uzsF = fnr('dc_u_z_sig') unless defined($dc_uzsF); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
99 |
$dc_vzF = fnr('dc_v_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
100 |
$dc_vzsF = fnrNoErr('dc_v_z.sig'); |
7 | 101 |
$dc_vzsF = fnr('dc_v_z_sig') unless defined($dc_vzsF); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
102 |
$dc_wzF = fnr('dc_w_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
103 |
$dc_wzsF = fnrNoErr('dc_w_z.sig'); |
7 | 104 |
$dc_wzsF = fnr('dc_w_z_sig') unless defined($dc_wzsF); |
105 |
$dc_elapsedF = fnr('dc_elapsed'); |
|
106 |
$uc_nshF = fnrNoErr('uc_nshear'); |
|
107 |
$uc_nshF = fnr('uc_nsamp') unless defined($uc_nshF); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
108 |
$uc_uzF = fnr('uc_u_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
109 |
$uc_uzsF = fnrNoErr('uc_u_z.sig'); |
7 | 110 |
$uc_uzsF = fnr('uc_u_z_sig') unless defined($uc_uzsF); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
111 |
$uc_vzF = fnr('uc_v_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
112 |
$uc_vzsF = fnrNoErr('uc_v_z.sig'); |
7 | 113 |
$uc_vzsF = fnr('uc_v_z_sig') unless defined($uc_vzsF); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
114 |
$uc_wzF = fnr('uc_w_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
115 |
$uc_wzsF = fnrNoErr('uc_w_z.sig'); |
7 | 116 |
$uc_wzsF = fnr('uc_w_z_sig') unless defined($uc_wzsF); |
117 |
$uc_elapsedF = fnr('uc_elapsed'); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
118 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
119 |
my(@gaps); my($curGap) = 0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
120 |
|
1 | 121 |
for (my($r)=0; &antsIn(); $r++) { |
122 |
my(@UL_); |
|
123 |
if (defined($opt_u)) { |
|
5 | 124 |
@UL_ = &antsFileIn(ULF); # read UL shear data |
125 |
undef($opt_u) unless (@UL_); # cheap trick |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
126 |
} |
1 | 127 |
|
128 |
$depth[$r] = $ants_[0][$depthF]; ## depth grid values |
|
129 |
croak("$opt_u: inconsistent depth (DL: $depth[$r]; UL: $UL_[$depthF])\n") |
|
130 |
if defined($opt_u) && ($UL_[$depthF] != $depth[$r]); |
|
131 |
||
6 | 132 |
$dc_nsamp = $ants_[0][$dc_nshF]; # number of shear samples |
133 |
$uc_nsamp = $ants_[0][$uc_nshF]; |
|
1 | 134 |
if (defined($opt_u)) { |
6 | 135 |
$dl_nsamp = $dc_nsamp + $uc_nsamp; |
136 |
$ul_nsamp = $UL_[$dc_nshF] + $UL_[$uc_nshF]; |
|
137 |
$dc_nsamp += $UL_[$dc_nshF]; |
|
138 |
$uc_nsamp += $UL_[$uc_nshF]; |
|
1 | 139 |
} |
6 | 140 |
$dc_nsamp[$r] = $dc_nsamp; |
141 |
$uc_nsamp[$r] = $uc_nsamp; |
|
142 |
$nsamp[$r] = $dc_nsamp + $uc_nsamp; |
|
143 |
if (defined($opt_u)) { |
|
144 |
$ul_nsamp[$r] = $ul_nsamp; |
|
145 |
$dl_nsamp[$r] = $dl_nsamp; |
|
146 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
147 |
|
5 | 148 |
if (defined($opt_u)) { # dual-head instrument |
6 | 149 |
if ($dc_nsamp > 0) { # downcast shear |
150 |
my($DLf) = $ants_[0][$dc_nshF] / $dc_nsamp; |
|
151 |
my($ULf) = $UL_[$dc_nshF] / $dc_nsamp; |
|
7 | 152 |
if ($DLf>0 && $ULf>0) { |
1 | 153 |
$dc_uz[$r] = $DLf*$ants_[0][$dc_uzF] + $ULf*$UL_[$dc_uzF]; |
154 |
$dc_vz[$r] = $DLf*$ants_[0][$dc_vzF] + $ULf*$UL_[$dc_vzF]; |
|
155 |
$dc_wz[$r] = $DLf*$ants_[0][$dc_wzF] + $ULf*$UL_[$dc_wzF]; |
|
7 | 156 |
$dc_elapsed[$r] = $DLf*$ants_[0][$dc_elapsedF] + $ULf*$UL_[$dc_elapsedF]; |
1 | 157 |
} elsif ($DLf > 0) { |
158 |
$dc_uz[$r] = $ants_[0][$dc_uzF]; |
|
159 |
$dc_vz[$r] = $ants_[0][$dc_vzF]; |
|
160 |
$dc_wz[$r] = $ants_[0][$dc_wzF]; |
|
7 | 161 |
$dc_elapsed[$r] = $ants_[0][$dc_elapsedF]; |
1 | 162 |
} else { |
163 |
$dc_uz[$r] = $UL_[$dc_uzF]; |
|
164 |
$dc_vz[$r] = $UL_[$dc_vzF]; |
|
165 |
$dc_wz[$r] = $UL_[$dc_wzF]; |
|
7 | 166 |
$dc_elapsed[$r] = $UL_[$dc_elapsedF]; |
1 | 167 |
} |
168 |
} else { |
|
7 | 169 |
$dc_uz[$r] = $dc_vz[$r] = $dc_wz[$r] = $dc_elapsed[$r] = nan; |
1 | 170 |
} |
6 | 171 |
if ($uc_nsamp > 0) { # upcast shear |
172 |
my($DLf) = $ants_[0][$uc_nshF] / $uc_nsamp; |
|
173 |
my($ULf) = $UL_[$uc_nshF] / $uc_nsamp; |
|
1 | 174 |
if ($DLf>0 && $Ulf>0) { |
175 |
$uc_uz[$r] = $DLf*$ants_[0][$uc_uzF] + $ULf*$UL_[$uc_uzF]; |
|
176 |
$uc_vz[$r] = $DLf*$ants_[0][$uc_vzF] + $ULf*$UL_[$uc_vzF]; |
|
177 |
$uc_wz[$r] = $DLf*$ants_[0][$uc_wzF] + $ULf*$UL_[$uc_wzF]; |
|
7 | 178 |
$uc_elapsed[$r] = $DLf*$ants_[0][$uc_elapsedF] + $ULf*$UL_[$uc_elapsedF]; |
1 | 179 |
} elsif ($DLf > 0) { |
180 |
$uc_uz[$r] = $ants_[0][$uc_uzF]; |
|
181 |
$uc_vz[$r] = $ants_[0][$uc_vzF]; |
|
182 |
$uc_wz[$r] = $ants_[0][$uc_wzF]; |
|
7 | 183 |
$uc_elapsed[$r] = $ants_[0][$uc_elapsedF]; |
1 | 184 |
} else { |
185 |
$uc_uz[$r] = $UL_[$uc_uzF]; |
|
186 |
$uc_vz[$r] = $UL_[$uc_vzF]; |
|
187 |
$uc_wz[$r] = $UL_[$uc_wzF]; |
|
7 | 188 |
$uc_elapsed[$r] = $UL_[$uc_elapsedF]; |
1 | 189 |
} |
190 |
} else { |
|
7 | 191 |
$uc_uz[$r] = $uc_vz[$r] = $uc_wz[$r] = $uc_elapsed[$r] = nan; |
1 | 192 |
} |
5 | 193 |
} else { # downlooker only |
6 | 194 |
if ($dc_nsamp > 0) { # downcast shear |
1 | 195 |
$dc_uz[$r] = $ants_[0][$dc_uzF]; |
196 |
$dc_vz[$r] = $ants_[0][$dc_vzF]; |
|
197 |
$dc_wz[$r] = $ants_[0][$dc_wzF]; |
|
7 | 198 |
$dc_elapsed[$r] = $ants_[0][$dc_elapsedF]; |
1 | 199 |
} else { |
7 | 200 |
$dc_uz[$r] = $dc_vz[$r] = $dc_wz[$r] = $dc_elapsed[$r] = nan; |
1 | 201 |
} |
6 | 202 |
if ($uc_nsamp > 0) { # upcast shear |
1 | 203 |
$uc_uz[$r] = $ants_[0][$uc_uzF]; |
204 |
$uc_vz[$r] = $ants_[0][$uc_vzF]; |
|
205 |
$uc_wz[$r] = $ants_[0][$uc_wzF]; |
|
7 | 206 |
$uc_elapsed[$r] = $ants_[0][$uc_elapsedF]; |
1 | 207 |
} else { |
7 | 208 |
$uc_uz[$r] = $uc_vz[$r] = $uc_wz[$r] = $uc_elapsed[$r] = nan; |
1 | 209 |
} |
210 |
} |
|
211 |
||
6 | 212 |
if ($nsamp[$r] > 0) { |
213 |
my($dcf) = $dc_nsamp / $nsamp[$r]; |
|
214 |
my($ucf) = $uc_nsamp / $nsamp[$r]; |
|
215 |
if ($dcf>0 && $ucf>0) { |
|
216 |
$uz[$r] = $dcf*$dc_uz[$r] + $ucf*$uc_uz[$r]; |
|
217 |
$vz[$r] = $dcf*$dc_vz[$r] + $ucf*$uc_vz[$r]; |
|
218 |
$wz[$r] = $dcf*$dc_wz[$r] + $ucf*$uc_wz[$r]; |
|
7 | 219 |
$elapsed[$r] = $dcf*$dc_elapsed[$r] + $ucf*$uc_elapsed[$r]; |
6 | 220 |
} elsif ($dcf > 0) { |
1 | 221 |
$uz[$r] = $dc_uz[$r]; |
222 |
$vz[$r] = $dc_vz[$r]; |
|
223 |
$wz[$r] = $dc_wz[$r]; |
|
7 | 224 |
$elapsed[$r] = $dc_elapsed[$r]; |
6 | 225 |
} else { |
1 | 226 |
$uz[$r] = $uc_uz[$r]; |
227 |
$vz[$r] = $uc_vz[$r]; |
|
228 |
$wz[$r] = $uc_wz[$r]; |
|
7 | 229 |
$elapsed[$r] = $uc_elapsed[$r]; |
6 | 230 |
} |
231 |
} else { |
|
7 | 232 |
$uz[$r] = $vz[$r] = $wz[$r] = $elapsed[$r] = nan; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
233 |
} |
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 |
if (numberp($uz[$r]) && $curGap>0) { # end of gap |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
236 |
push(@gaps,$curGap) unless ($r == $curGap); # do not report "gap" at beginning of profile |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
237 |
# print(STDERR "$curGap-gap at $depth[$r]m\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
238 |
$curGap = 0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
239 |
} elsif (!numberp($uz[$r])) { # currently in gap |
6 | 240 |
# print(STDERR "in gap at $depth[$r]m (nsamp = $nsamp[$r], $dc_nsamp,$uc_nsamp)\n"); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
241 |
$curGap++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
242 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
243 |
|
6 | 244 |
if ($nsamp[$r] > 0) { |
1 | 245 |
if (defined($opt_u)) { |
6 | 246 |
$uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF], |
247 |
$UL_[$dc_nshF], $UL_[$dc_uzsF], |
|
248 |
$ants_[0][$uc_nshF],$ants_[0][$uc_uzsF], |
|
249 |
$UL_[$uc_nshF], $UL_[$uc_uzsF]); |
|
250 |
$vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF], |
|
251 |
$UL_[$dc_nshF], $UL_[$dc_vzsF], |
|
252 |
$ants_[0][$uc_nshF],$ants_[0][$uc_vzsF], |
|
253 |
$UL_[$uc_nshF], $UL_[$uc_vzsF]); |
|
254 |
$wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF], |
|
255 |
$UL_[$dc_nshF], $UL_[$dc_wzsF], |
|
256 |
$ants_[0][$uc_nshF],$ants_[0][$uc_wzsF], |
|
257 |
$UL_[$uc_nshF], $UL_[$uc_wzsF]); |
|
258 |
} else { # DL only |
|
259 |
$uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF], |
|
260 |
$ants_[0][$uc_nshF],$ants_[0][$uc_uzsF]); |
|
261 |
$vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF], |
|
262 |
$ants_[0][$uc_nshF],$ants_[0][$uc_vzsF]); |
|
263 |
$wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF], |
|
264 |
$ants_[0][$uc_nshF],$ants_[0][$uc_wzsF]); |
|
1 | 265 |
} |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
266 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
267 |
$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
268 |
} |
5 | 269 |
|
6 | 270 |
if ($dc_nsamp > 0) { # same calc for downcast only |
5 | 271 |
if (defined($opt_u)) { |
6 | 272 |
$dc_uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF], |
273 |
$UL_[$dc_nshF], $UL_[$dc_uzsF]); |
|
274 |
$dc_vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF], |
|
275 |
$UL_[$dc_nshF], $UL_[$dc_vzsF]); |
|
276 |
$dc_wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF], |
|
277 |
$UL_[$dc_nshF], $UL_[$dc_wzsF]); |
|
5 | 278 |
} else { |
279 |
$dc_uzsig[$r] = $ants_[0][$dc_uzsF]; |
|
280 |
$dc_vzsig[$r] = $ants_[0][$dc_vzsF]; |
|
281 |
$dc_wzsig[$r] = $ants_[0][$dc_wzsF]; |
|
282 |
} |
|
283 |
} else { |
|
284 |
$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan; |
|
285 |
} |
|
286 |
||
6 | 287 |
if ($uc_nsamp > 0) { # same calc for upcast only |
5 | 288 |
if (defined($opt_u)) { |
6 | 289 |
$uc_uzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_uzsF], |
290 |
$UL_[$uc_nshF], $UL_[$uc_uzsF]); |
|
291 |
$uc_vzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_vzsF], |
|
292 |
$UL_[$uc_nshF], $UL_[$uc_vzsF]); |
|
293 |
$uc_wzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_wzsF], |
|
294 |
$UL_[$uc_nshF], $UL_[$uc_wzsF]); |
|
5 | 295 |
} else { |
296 |
$uc_uzsig[$r] = $ants_[0][$uc_uzsF]; |
|
297 |
$uc_vzsig[$r] = $ants_[0][$uc_vzsF]; |
|
298 |
$uc_wzsig[$r] = $ants_[0][$uc_wzsF]; |
|
299 |
} |
|
300 |
} else { |
|
301 |
$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan; |
|
302 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
303 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
304 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
305 |
if (@gaps) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
306 |
&antsAddParams('shear_gaps',"@gaps"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
307 |
print(STDERR "shear gaps: @gaps\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
308 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
309 |
&antsAddParams('shear_gaps',0); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
310 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
311 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
312 |
#=============================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
313 |
# Step 2: Low-Pass filter high-quality shear data; not yet implemented |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
314 |
#=============================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
315 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
316 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
317 |
# Step 3: Integrate Shear |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
318 |
# - z(vel) = z(sh) + DZ/2 |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
319 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
320 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
321 |
my($DZ) = $depth[1] - $depth[0]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
322 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
323 |
for (my($r)=my($u)=my($v)=my($w)=my($dc_u)=my($dc_v)=my($dc_w)=my($uc_u)=my($uc_v)=my($uc_w)=0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
324 |
$r<@depth; $r++) { |
6 | 325 |
if ($nsamp[$r] >= $opt_n) { |
326 |
$u = $u[$r] = $u + $DZ*$uz[$r]; |
|
327 |
$v = $v[$r] = $v + $DZ*$vz[$r]; |
|
328 |
$w = $w[$r] = $w + $DZ*$wz[$r]; |
|
329 |
} |
|
330 |
if ($dc_nsamp[$r] >= $opt_n) { |
|
331 |
$dc_u = $dc_u[$r] = $dc_u + $DZ*$dc_uz[$r]; |
|
332 |
$dc_v = $dc_v[$r] = $dc_v + $DZ*$dc_vz[$r]; |
|
333 |
$dc_w = $dc_w[$r] = $dc_w + $DZ*$dc_wz[$r]; |
|
334 |
} |
|
335 |
if ($uc_nsamp[$r] >= $opt_n) { |
|
336 |
$uc_u = $uc_u[$r] = $uc_u + $DZ*$uc_uz[$r]; |
|
337 |
$uc_v = $uc_v[$r] = $uc_v + $DZ*$uc_vz[$r]; |
|
338 |
$uc_w = $uc_w[$r] = $uc_w + $DZ*$uc_wz[$r]; |
|
339 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
340 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
341 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
342 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
343 |
# Step 4: Reference Velocities |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
344 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
345 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
346 |
my($refU,$refV,$refW,$dc_refU,$dc_refV,$dc_refW,$uc_refU,$uc_refV,$uc_refW); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
347 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
348 |
if (defined($opt_b)) { # reference to bottom-track profile |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
349 |
print(STDERR "Loading BT data from $opt_b...\n") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
350 |
if ($opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
351 |
open(BTF,$opt_b) || croak("$opt_b: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
352 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
353 |
my(@BTL) = &antsFileLayout(BTF); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
354 |
my($BTdF,$BTndF,$BTuF,$BTvF,$BTwF,$BTusF,$BTvsF,$BTwsF); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
355 |
for (my($f)=0; $f<@BTL; $f++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
356 |
$BTdF = $f if ($BTL[$f] eq 'depth'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
357 |
$BTuF = $f if ($BTL[$f] eq 'u'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
358 |
$BTvF = $f if ($BTL[$f] eq 'v'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
359 |
$BTwF = $f if ($BTL[$f] eq 'w'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
360 |
$BTusF = $f if ($BTL[$f] eq 'u.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
361 |
$BTvsF = $f if ($BTL[$f] eq 'v.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
362 |
$BTwsF = $f if ($BTL[$f] eq 'w.sig'); |
6 | 363 |
$BTndF = $f if ($BTL[$f] eq 'nsamp'); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
364 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
365 |
croak("$opt_b: not a valid BT file\n") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
366 |
unless defined($BTdF) && defined($BTuF) && defined($BTvF) && defined($BTwF) && |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
367 |
defined($BTusF) && defined($BTvsF) && defined($BTwsF) && defined($BTndF); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
368 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
369 |
while (my(@BTr) = &antsFileIn(BTF)) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
370 |
my($gi) = int($BTr[$BTdF] / $DZ); |
3 | 371 |
next unless ($BTr[$BTndF] >= $opt_m); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
372 |
$BT_nsamp[$gi] = $BTr[$BTndF]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
373 |
$BT_u[$gi] = $BTr[$BTuF]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
374 |
$BT_v[$gi] = $BTr[$BTvF]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
375 |
$BT_w[$gi] = $BTr[$BTwF]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
376 |
$BT_u_var[$gi] = $BTr[$BTusF]**2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
377 |
$BT_v_var[$gi] = $BTr[$BTvsF]**2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
378 |
$BT_w_var[$gi] = $BTr[$BTwsF]**2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
379 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
380 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
381 |
&fixLowSampStat(\@BT_u_var,@BT_nsamp); # remove spurious small variances |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
382 |
&fixLowSampStat(\@BT_v_var,@BT_nsamp); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
383 |
&fixLowSampStat(\@BT_w_var,@BT_nsamp); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
384 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
385 |
my($sumU,$sumV,$sumW,$dc_sumU,$dc_sumV,$dc_sumW, # average integrated-shear velocities |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
386 |
$uc_sumU,$uc_sumV,$uc_sumW); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
387 |
my($nSumVel,$dc_nSumVel,$uc_nSumVel); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
388 |
my($wSumBTu,$wSumBTv,$wSumBTw); # weighted sums of BT-ref'd velocities |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
389 |
my($dc_wSumBTu,$dc_wSumBTv,$dc_wSumBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
390 |
my($uc_wSumBTu,$uc_wSumBTv,$uc_wSumBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
391 |
my($sumVarBTu,$sumVarBTv,$sumVarBTw); # sum of variances of BT-ref'd vels |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
392 |
my($dc_sumVarBTu,$dc_sumVarBTv,$dc_sumVarBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
393 |
my($uc_sumVarBTu,$uc_sumVarBTv,$uc_sumVarBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
394 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
395 |
for (my($r)=0; $r<@depth; $r++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
396 |
if (numberp($BT_u[$r]) && numberp($u[$r])) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
397 |
$nSumVel++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
398 |
$sumU += $u[$r]; $sumV += $v[$r]; $sumW += $w[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
399 |
$wSumBTu += $BT_u[$r] / $BT_u_var[$r]; $sumVarBTu += 1/$BT_u_var[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
400 |
# printf(STDERR "v = $BT_v[$r] (w = %.1f)\n",1/$BT_v_var[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
401 |
$wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $sumVarBTv += 1/$BT_v_var[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
402 |
$wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $sumVarBTw += 1/$BT_w_var[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
403 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
404 |
if (numberp($BT_u[$r]) && numberp($dc_u[$r])) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
405 |
$dc_nSumVel++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
406 |
$dc_sumU += $dc_u[$r]; $dc_sumV += $dc_v[$r]; $dc_sumW += $dc_w[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
407 |
$dc_wSumBTu += $BT_u[$r] / $BT_u_var[$r]; $dc_sumVarBTu += 1/$BT_u_var[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
408 |
$dc_wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $dc_sumVarBTv += 1/$BT_v_var[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
409 |
$dc_wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $dc_sumVarBTw += 1/$BT_w_var[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
410 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
411 |
if (numberp($BT_u[$r]) && numberp($uc_u[$r])) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
412 |
$uc_nSumVel++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
413 |
$uc_sumU += $uc_u[$r]; $uc_sumV += $uc_v[$r]; $uc_sumW += $uc_w[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
414 |
$uc_wSumBTu += $BT_u[$r] / $BT_u_var[$r]; $uc_sumVarBTu += 1/$BT_u_var[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
415 |
$uc_wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $uc_sumVarBTv += 1/$BT_v_var[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
416 |
$uc_wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $uc_sumVarBTw += 1/$BT_w_var[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
417 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
418 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
419 |
|
1 | 420 |
if ($nSumVel > 0) { |
421 |
$refU = $sumU/$nSumVel - $wSumBTu/$sumVarBTu; |
|
422 |
$refV = $sumV/$nSumVel - $wSumBTv/$sumVarBTv; |
|
423 |
$refW = $sumW/$nSumVel - $wSumBTw/$sumVarBTw; |
|
424 |
||
6 | 425 |
if ($dc_nSumVel > 0) { |
426 |
$dc_refU = $dc_sumU/$dc_nSumVel - $dc_wSumBTu/$dc_sumVarBTu; |
|
427 |
$dc_refV = $dc_sumV/$dc_nSumVel - $dc_wSumBTv/$dc_sumVarBTv; |
|
428 |
$dc_refW = $dc_sumW/$dc_nSumVel - $dc_wSumBTw/$dc_sumVarBTw; |
|
429 |
} else { |
|
430 |
&antsInfo("$opt_b: insufficient BT data to constrain dc profile --- baroclinic profile only"); |
|
431 |
} |
|
1 | 432 |
|
6 | 433 |
if ($uc_nSumVel > 0) { |
434 |
$uc_refU = $uc_sumU/$uc_nSumVel - $uc_wSumBTu/$uc_sumVarBTu; |
|
435 |
$uc_refV = $uc_sumV/$uc_nSumVel - $uc_wSumBTv/$uc_sumVarBTv; |
|
436 |
$uc_refW = $uc_sumW/$uc_nSumVel - $uc_wSumBTw/$uc_sumVarBTw; |
|
437 |
} else { |
|
438 |
&antsInfo("$opt_b: insufficient BT data to constrain dc profile --- baroclinic profile only"); |
|
439 |
} |
|
1 | 440 |
} else { |
6 | 441 |
&antsInfo("$opt_b: no valid BT data --- baroclinic profiles only"); |
1 | 442 |
} |
443 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
444 |
|
5 | 445 |
unless (defined($refU)) { # no reference velocity => use zero mean |
6 | 446 |
my($sumU,$sumV,$sumW,$nSumVel); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
447 |
for (my($r)=0; $r<@depth; $r++) { |
2 | 448 |
if (numberp($u[$r])) { |
449 |
$nSumVel++; |
|
450 |
$sumU += $u[$r]; $sumV += $v[$r]; $sumW += $w[$r]; |
|
451 |
} |
|
6 | 452 |
} |
453 |
$refU = $sumU / $nSumVel; $refV = $sumV / $nSumVel; $refW = $sumW / $nSumVel; |
|
454 |
} |
|
455 |
unless (defined($dc_refU)) { |
|
456 |
my($dc_sumU,$dc_sumV,$dc_sumW,$dc_nSumVel); |
|
457 |
for (my($r)=0; $r<@depth; $r++) { |
|
2 | 458 |
if (numberp($dc_u[$r])) { |
459 |
$dc_nSumVel++; |
|
460 |
$dc_sumU += $dc_u[$r]; $dc_sumV += $dc_v[$r]; $dc_sumW += $dc_w[$r]; |
|
461 |
} |
|
6 | 462 |
} |
463 |
$dc_refU = $dc_sumU / $dc_nSumVel; $dc_refV = $dc_sumV / $dc_nSumVel; $dc_refW = $dc_sumW / $dc_nSumVel; |
|
464 |
} |
|
465 |
unless (defined($uc_refU)) { |
|
466 |
my($uc_sumU,$uc_sumV,$uc_sumW,$uc_nSumVel); |
|
467 |
for (my($r)=0; $r<@depth; $r++) { |
|
2 | 468 |
if (numberp($uc_u[$r])) { |
469 |
$uc_nSumVel++; |
|
470 |
$uc_sumU += $uc_u[$r]; $uc_sumV += $uc_v[$r]; $uc_sumW += $uc_w[$r]; |
|
471 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
472 |
} |
2 | 473 |
$uc_refU = $uc_sumU / $uc_nSumVel; $uc_refV = $uc_sumV / $uc_nSumVel; $uc_refW = $uc_sumW / $uc_nSumVel; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
474 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
475 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
476 |
for (my($r)=0; $r<@depth; $r++) { # reference velocities |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
477 |
$u[$r] -= $refU if defined($u[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
478 |
$v[$r] -= $refV if defined($v[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
479 |
$w[$r] -= $refW if defined($w[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
480 |
$dc_u[$r] -= $dc_refU if defined($dc_u[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
481 |
$dc_v[$r] -= $dc_refV if defined($dc_v[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
482 |
$dc_w[$r] -= $dc_refW if defined($dc_w[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
483 |
$uc_u[$r] -= $uc_refU if defined($uc_u[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
484 |
$uc_v[$r] -= $uc_refV if defined($uc_v[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
485 |
$uc_w[$r] -= $uc_refW if defined($uc_w[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
486 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
487 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
488 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
489 |
# Determine X Factor |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
490 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
491 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
492 |
my($first_w,$last_w); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
493 |
for (my($r)=0; !defined($first_w) || !defined($last_w); $r++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
494 |
$first_w = $dc_w[$r] unless defined($first_w); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
495 |
$last_w = $uc_w[$r] unless defined($last_w); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
496 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
497 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
498 |
my($X_Factor) = 100 * abs($last_w-$first_w) / sqrt(@depth / $DZ); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
499 |
&antsAddParams('X-Factor',$X_Factor); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
500 |
printf(STDERR "X-Factor = %.1f\n",$X_Factor); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
501 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
502 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
503 |
# Output Velocity Profile |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
504 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
505 |
|
7 | 506 |
@antsNewLayout = ('depth','elapsed','u','v','w','nsamp', |
507 |
'dc_elapsed','dc_u','dc_v','dc_w','dc_nsamp', |
|
508 |
'uc_elapsed','uc_u','uc_v','uc_w','uc_nsamp'); |
|
5 | 509 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
510 |
for (my($r)=0; $r<@depth; $r++) { |
5 | 511 |
&antsOut($depth[$r]+$DZ/2, |
7 | 512 |
$elapsed[$r],$u[$r],$v[$r],$w[$r],$nsamp[$r], |
513 |
$dc_elapsed[$r],$dc_u[$r],$dc_v[$r],$dc_w[$r],$dc_nsamp[$r], |
|
514 |
$uc_elapsed[$r],$uc_u[$r],$uc_v[$r],$uc_w[$r],$uc_nsamp[$r]); |
|
6 | 515 |
} |
516 |
||
517 |
#====================================================================== |
|
518 |
# Output Averaged Shear Profile |
|
519 |
#====================================================================== |
|
520 |
||
521 |
if (defined($opt_s)) { |
|
7 | 522 |
@antsNewLayout = ('depth','elapsed','u_z','v_z','w_z','u_z.sig','v_z.sig','w_z.sig','nsamp', |
523 |
'dc_elapsed','dc_u_z','dc_v_z','dc_w_z','dc_u_z.sig','dc_v_z.sig','dc_w_z.sig','dc_nsamp', |
|
524 |
'uc_elapsed','uc_u_z','uc_v_z','uc_w_z','uc_u_z.sig','uc_v_z.sig','uc_w_z.sig','uc_nsamp'); |
|
6 | 525 |
&antsOut('EOF'); |
526 |
close(STDOUT); |
|
527 |
open(STDOUT,">$opt_s") || croak("$opt_s: $!\n"); |
|
528 |
for (my($r)=0; $r<@depth; $r++) { |
|
7 | 529 |
&antsOut($depth[$r],$elapsed[$r],$uz[$r],$vz[$r],$wz[$r],$uzsig[$r],$vzsig[$r],$wzsig[$r],$nsamp[$r], |
530 |
$dc_elapsed[$r],$dc_uz[$r],$dc_vz[$r],$dc_wz[$r],$dc_uzsig[$r],$dc_vzsig[$r],$dc_wzsig[$r],$dc_nsamp[$r], |
|
531 |
$uc_elapsed[$r],$uc_uz[$r],$uc_vz[$r],$uc_wz[$r],$uc_uzsig[$r],$uc_vzsig[$r],$uc_wzsig[$r],$uc_nsamp[$r]); |
|
6 | 532 |
} |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
533 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
534 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
535 |
&antsExit(); |