author | A.M. Thurnherr <ant@ldeo.columbia.edu> |
Fri, 14 Jan 2011 21:38:18 +0000 | |
changeset 1 | 54222c82435f |
parent 0 | de00d0f32431 |
child 2 | 16726a31a399 |
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 |
1 | 5 |
# dlm: Fri Dec 10 04:57:50 2010 |
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 |
1 | 7 |
# uE-Info: 207 1 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: |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
13 |
# - THE CORE OF THIS CODE IS A SIMPLE TRANSCRIPTION OF AVG_SH.M AND INT_SH.M WRITTEN BY ERIC FIRING |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
14 |
# - comments beginning with ## are taken from Eric's code |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
15 |
# - cubic velocity interpolation across PPI gap from Eric's code has not been implemented (yet?) |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
16 |
# - Eric's ndata criteria had to be scaled by 5/8 due to the different gridding used; I decided, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
17 |
# conservatively, to scale only the -s criterion (n1 in Eric's code) |
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 |
# WEIRDNESSES: |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
20 |
# - 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
|
21 |
# 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
|
22 |
# is not used anywhere in Eric's code |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
23 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
24 |
# HISTORY: |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
25 |
# Oct 14, 2010: - created |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
26 |
# Oct 20, 2010: - first working version |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
27 |
# Oct 23, 2010: - added support for -b) |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
28 |
# 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
|
29 |
# samples (i.e. primarily when chosing a small -r) |
1 | 30 |
# Dec 9, 2010: - allowed for empty BT file |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
31 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
32 |
($ANTS) = (`which list` =~ m{^(.*)/[^/]*$}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
33 |
require "$ANTS/ants.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
34 |
require "$ANTS/libstats.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
35 |
|
1 | 36 |
&antsUsage('b:dr:s:w:u:',0, |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
37 |
'[-d)ebug]', |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
38 |
'[reference with -b)ottom-track <file>]', |
1 | 39 |
'[-u)plooker <file>]', |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
40 |
'[min -r)aw <shear samp[10]>] [min -s)moothed <shear samp[20]>]', |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
41 |
'[-w)eighted avg <below[1200]>]', |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
42 |
'[LADCP shear file]'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
43 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
44 |
&antsCardOpt(\$opt_r,10); ## minimum number of samples for shear |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
45 |
&antsCardOpt(\$opt_s,20); ## minimum number of samples for smoothed shear |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
46 |
&antsCardOpt(\$opt_w,1200); ## probably 1200 for midlatitude-equatorial, 2400 for high lat |
1 | 47 |
|
48 |
&antsFileOpt($opt_b); # BT file |
|
49 |
||
50 |
&antsFileOpt($opt_u); # UL shear file |
|
51 |
open(ULF,$opt_u) || croak("$opt_u: $!\n") |
|
52 |
if defined($opt_u); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
53 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
54 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
55 |
# Step 1: Read and Average Shear Data |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
56 |
# - depth bins with less than $opt_r values are blanked out |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
57 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
58 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
59 |
$depthF = fnr('depth'); # layout of [LADCPproc] output |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
60 |
$dc_nshF = fnr('dc_nshear'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
61 |
$dc_uzF = fnr('dc_u_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
62 |
$dc_uzsF = fnrNoErr('dc_u_z.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
63 |
$dc_uzsF = fnr('dc_u_z_sig') |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
64 |
unless defined($dc_uzsF); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
65 |
$dc_vzF = fnr('dc_v_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
66 |
$dc_vzsF = fnrNoErr('dc_v_z.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
67 |
$dc_vzsF = fnr('dc_v_z_sig') |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
68 |
unless defined($dc_vzsF); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
69 |
$dc_wzF = fnr('dc_w_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
70 |
$dc_wzsF = fnrNoErr('dc_w_z.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
71 |
$dc_wzsF = fnr('dc_w_z_sig') |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
72 |
unless defined($dc_wzsF); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
73 |
$uc_nshF = fnr('uc_nshear'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
74 |
$uc_uzF = fnr('uc_u_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
75 |
$uc_uzsF = fnrNoErr('uc_u_z.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
76 |
$uc_uzsF = fnr('uc_u_z_sig') |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
77 |
unless defined($uc_uzsF); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
78 |
$uc_vzF = fnr('uc_v_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
79 |
$uc_vzsF = fnrNoErr('uc_v_z.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
80 |
$uc_vzsF = fnr('uc_v_z_sig') |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
81 |
unless defined($uc_vzsF); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
82 |
$uc_wzF = fnr('uc_w_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
83 |
$uc_wzsF = fnrNoErr('uc_w_z.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
84 |
$uc_wzsF = fnr('uc_w_z_sig') |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
85 |
unless defined($uc_wzsF); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
86 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
87 |
my(@gaps); my($curGap) = 0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
88 |
|
1 | 89 |
for (my($r)=0; &antsIn(); $r++) { |
90 |
my(@UL_); |
|
91 |
if (defined($opt_u)) { |
|
92 |
@UL_ = &antsFileIn(ULF); # read UL shear data |
|
93 |
undef($opt_u) unless (@UL_); # cheap trick |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
94 |
} |
1 | 95 |
|
96 |
$depth[$r] = $ants_[0][$depthF]; ## depth grid values |
|
97 |
croak("$opt_u: inconsistent depth (DL: $depth[$r]; UL: $UL_[$depthF])\n") |
|
98 |
if defined($opt_u) && ($UL_[$depthF] != $depth[$r]); |
|
99 |
||
100 |
$dc_ndata = $ants_[0][$dc_nshF]; # number of shear samples |
|
101 |
$uc_ndata = $ants_[0][$uc_nshF]; |
|
102 |
if (defined($opt_u)) { |
|
103 |
$dc_ndata += $UL_[$dc_nshF]; |
|
104 |
$uc_ndata += $UL_[$uc_nshF]; |
|
105 |
} |
|
106 |
$ndata[$r] = $dc_ndata + $uc_ndata; |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
107 |
|
1 | 108 |
if (defined($opt_u)) { |
109 |
if ($dc_ndata > 0) { # downcast shear |
|
110 |
my($DLf) = $ants_[0][$dc_nshF] / $dc_ndata; |
|
111 |
my($ULf) = $UL_[$dc_nshF] / $dc_ndata; |
|
112 |
if ($DLf>0 && $Ulf>0) { |
|
113 |
$dc_uz[$r] = $DLf*$ants_[0][$dc_uzF] + $ULf*$UL_[$dc_uzF]; |
|
114 |
$dc_vz[$r] = $DLf*$ants_[0][$dc_vzF] + $ULf*$UL_[$dc_vzF]; |
|
115 |
$dc_wz[$r] = $DLf*$ants_[0][$dc_wzF] + $ULf*$UL_[$dc_wzF]; |
|
116 |
} elsif ($DLf > 0) { |
|
117 |
$dc_uz[$r] = $ants_[0][$dc_uzF]; |
|
118 |
$dc_vz[$r] = $ants_[0][$dc_vzF]; |
|
119 |
$dc_wz[$r] = $ants_[0][$dc_wzF]; |
|
120 |
} else { |
|
121 |
$dc_uz[$r] = $UL_[$dc_uzF]; |
|
122 |
$dc_vz[$r] = $UL_[$dc_vzF]; |
|
123 |
$dc_wz[$r] = $UL_[$dc_wzF]; |
|
124 |
} |
|
125 |
} else { |
|
126 |
$dc_uz[$r] = $dc_vz[$r] = $dc_wz[$r] = nan; |
|
127 |
} |
|
128 |
if ($uc_ndata > 0) { # upcast shear |
|
129 |
my($DLf) = $ants_[0][$uc_nshF] / $uc_ndata; |
|
130 |
my($ULf) = $UL_[$uc_nshF] / $uc_ndata; |
|
131 |
if ($DLf>0 && $Ulf>0) { |
|
132 |
$uc_uz[$r] = $DLf*$ants_[0][$uc_uzF] + $ULf*$UL_[$uc_uzF]; |
|
133 |
$uc_vz[$r] = $DLf*$ants_[0][$uc_vzF] + $ULf*$UL_[$uc_vzF]; |
|
134 |
$uc_wz[$r] = $DLf*$ants_[0][$uc_wzF] + $ULf*$UL_[$uc_wzF]; |
|
135 |
} elsif ($DLf > 0) { |
|
136 |
$uc_uz[$r] = $ants_[0][$uc_uzF]; |
|
137 |
$uc_vz[$r] = $ants_[0][$uc_vzF]; |
|
138 |
$uc_wz[$r] = $ants_[0][$uc_wzF]; |
|
139 |
} else { |
|
140 |
$uc_uz[$r] = $UL_[$uc_uzF]; |
|
141 |
$uc_vz[$r] = $UL_[$uc_vzF]; |
|
142 |
$uc_wz[$r] = $UL_[$uc_wzF]; |
|
143 |
} |
|
144 |
} else { |
|
145 |
$uc_uz[$r] = $uc_vz[$r] = $uc_wz[$r] = nan; |
|
146 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
147 |
} else { |
1 | 148 |
if ($dc_ndata >= $opt_r) { # downcast shear |
149 |
$dc_uz[$r] = $ants_[0][$dc_uzF]; |
|
150 |
$dc_vz[$r] = $ants_[0][$dc_vzF]; |
|
151 |
$dc_wz[$r] = $ants_[0][$dc_wzF]; |
|
152 |
} else { |
|
153 |
$dc_uz[$r] = $dc_vz[$r] = $dc_wz[$r] = nan; |
|
154 |
} |
|
155 |
if ($uc_ndata >= $opt_r) { # upcast shear |
|
156 |
$uc_uz[$r] = $ants_[0][$uc_uzF]; |
|
157 |
$uc_vz[$r] = $ants_[0][$uc_vzF]; |
|
158 |
$uc_wz[$r] = $ants_[0][$uc_wzF]; |
|
159 |
} else { |
|
160 |
$uc_uz[$r] = $uc_vz[$r] = $uc_wz[$r] = nan; |
|
161 |
} |
|
162 |
} |
|
163 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
164 |
if ($depth[$r] < $opt_w) { ## use average of up and down casts at top of profile |
1 | 165 |
if ($dc_ndata>0 && $uc_ndata>0 && $ndata[$r]>=$opt_r) { |
166 |
$uz[$r] = $dc_uz[$r]/2 + $uc_uz[$r]/2; |
|
167 |
$vz[$r] = $dc_vz[$r]/2 + $uc_vz[$r]/2; |
|
168 |
$wz[$r] = $dc_wz[$r]/2 + $uc_wz[$r]/2; |
|
169 |
} elsif ($dc_ndata >= $opt_r) { |
|
170 |
$uz[$r] = $dc_uz[$r]; |
|
171 |
$vz[$r] = $dc_vz[$r]; |
|
172 |
$wz[$r] = $dc_wz[$r]; |
|
173 |
} elsif ($uc_ndata >= $opt_r) { |
|
174 |
$uz[$r] = $uc_uz[$r]; |
|
175 |
$vz[$r] = $uc_vz[$r]; |
|
176 |
$wz[$r] = $uc_wz[$r]; |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
177 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
178 |
$uz[$r] = $vz[$r] = $wz[$r] = nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
179 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
180 |
} else { ## use weighted average of up and down cast data at bottom of profile |
1 | 181 |
if ($ndata[$r] >= $opt_r) { |
182 |
my($dcf) = $dc_ndata / $ndata[$r]; |
|
183 |
my($ucf) = $uc_ndata / $ndata[$r]; |
|
184 |
if ($dcf>0 && $ucf>0) { |
|
185 |
$uz[$r] = $dcf*$dc_uz[$r] + $ucf*$uc_uz[$r]; |
|
186 |
$vz[$r] = $dcf*$dc_vz[$r] + $ucf*$uc_vz[$r]; |
|
187 |
$wz[$r] = $dcf*$dc_wz[$r] + $ucf*$uc_wz[$r]; |
|
188 |
} elsif ($dcf > 0) { |
|
189 |
$uz[$r] = $dc_uz[$r]; |
|
190 |
$vz[$r] = $dc_vz[$r]; |
|
191 |
$wz[$r] = $dc_wz[$r]; |
|
192 |
} else { |
|
193 |
$uz[$r] = $uc_uz[$r]; |
|
194 |
$vz[$r] = $uc_vz[$r]; |
|
195 |
$wz[$r] = $uc_wz[$r]; |
|
196 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
197 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
198 |
$uz[$r] = $vz[$r] = $wz[$r] = nan; |
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 |
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
|
203 |
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
|
204 |
# 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
|
205 |
$curGap = 0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
206 |
} elsif (!numberp($uz[$r])) { # currently in gap |
1 | 207 |
# print(STDERR "in gap at $depth[$r]m (ndata = $ndata[$r], $dc_ndata,$uc_ndata)\n"); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
208 |
$curGap++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
209 |
} |
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 |
if ($ndata[$r] >= $opt_r) { ## back to sum of squares |
1 | 212 |
if (defined($opt_u)) { |
213 |
$uzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_uzsF]**2 + |
|
214 |
$UL_[$dc_nshF] * $UL_[$dc_uzsF]**2 + |
|
215 |
$ants_[0][$uc_nshF] * $ants_[0][$uc_uzsF]**2 + |
|
216 |
$UL_[$uc_nshF] * $UL_[$uc_uzsF]**2) / $ndata[$r]); |
|
217 |
$vzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_vzsF]**2 + |
|
218 |
$UL_[$dc_nshF] * $UL_[$dc_vzsF]**2 + |
|
219 |
$ants_[0][$uc_nshF] * $ants_[0][$uc_vzsF]**2 + |
|
220 |
$UL_[$uc_nshF] * $UL_[$uc_vzsF]**2) / $ndata[$r]); |
|
221 |
$wzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_wzsF]**2 + |
|
222 |
$UL_[$dc_nshF] * $UL_[$dc_wzsF]**2 + |
|
223 |
$ants_[0][$uc_nshF] * $ants_[0][$uc_wzsF]**2 + |
|
224 |
$UL_[$uc_nshF] * $UL_[$uc_wzsF]**2) / $ndata[$r]); |
|
225 |
} else { |
|
226 |
$uzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_uzsF]**2 + |
|
227 |
$ants_[0][$uc_nshF] * $ants_[0][$uc_uzsF]**2) / $ndata[$r]); |
|
228 |
$vzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_vzsF]**2 + |
|
229 |
$ants_[0][$uc_nshF] * $ants_[0][$uc_vzsF]**2) / $ndata[$r]); |
|
230 |
$wzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_wzsF]**2 + |
|
231 |
$ants_[0][$uc_nshF] * $ants_[0][$uc_wzsF]**2) / $ndata[$r]); |
|
232 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
233 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
234 |
$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
235 |
} |
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 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
238 |
if (@gaps) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
239 |
&antsAddParams('shear_gaps',"@gaps"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
240 |
print(STDERR "shear gaps: @gaps\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
241 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
242 |
&antsAddParams('shear_gaps',0); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
243 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
244 |
|
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 |
# 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
|
247 |
#=============================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
248 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
249 |
for (my($r)=0; $r<@depth; $r++) { # create high-quality shear profile |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
250 |
if ($ndata[$r] >= $opt_s) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
251 |
$hq_uz[$r] = $uz[$r]; $hq_vz[$r] = $vz[$r]; $hq_wz[$r] = $wz[$r]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
252 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
253 |
$hq_uz[$r] = $hq_vz[$r] = $hq_wz[$r] = nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
254 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
255 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
256 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
257 |
#@antsNewLayout = ('depth','u_z','hq_u_z','v_z','hq_v_z','w_z','hq_w_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
258 |
#for (my($r)=0; $r<@depth; $r++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
259 |
# &antsOut($depth[$r],$uz[$r],$hq_uz[$r],$vz[$r],$hq_vz[$r],$wz[$r],$hq_wz[$r]); |
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 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
263 |
# Step 3: Integrate Shear |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
264 |
# - z(vel) = z(sh) + DZ/2 |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
265 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
266 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
267 |
my($DZ) = $depth[1] - $depth[0]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
268 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
269 |
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
|
270 |
$r<@depth; $r++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
271 |
$u = $u[$r] = $u + $DZ*$uz[$r] if numberp($uz[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
272 |
$v = $v[$r] = $v + $DZ*$vz[$r] if numberp($vz[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
273 |
$w = $w[$r] = $w + $DZ*$wz[$r] if numberp($wz[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
274 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
275 |
$dc_u = $dc_u[$r] = $dc_u + $DZ*$dc_uz[$r] if numberp($dc_uz[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
276 |
$dc_v = $dc_v[$r] = $dc_v + $DZ*$dc_vz[$r] if numberp($dc_vz[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
277 |
$dc_w = $dc_w[$r] = $dc_w + $DZ*$dc_wz[$r] if numberp($dc_wz[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
278 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
279 |
$uc_u = $uc_u[$r] = $uc_u + $DZ*$uc_uz[$r] if numberp($uc_uz[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
280 |
$uc_v = $uc_v[$r] = $uc_v + $DZ*$uc_vz[$r] if numberp($uc_vz[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
281 |
$uc_w = $uc_w[$r] = $uc_w + $DZ*$uc_wz[$r] if numberp($uc_wz[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
282 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
283 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
284 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
285 |
# Step 4: Reference Velocities |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
286 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
287 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
288 |
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
|
289 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
290 |
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
|
291 |
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
|
292 |
if ($opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
293 |
open(BTF,$opt_b) || croak("$opt_b: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
294 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
295 |
my(@BTL) = &antsFileLayout(BTF); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
296 |
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
|
297 |
for (my($f)=0; $f<@BTL; $f++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
298 |
$BTdF = $f if ($BTL[$f] eq 'depth'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
299 |
$BTuF = $f if ($BTL[$f] eq 'u'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
300 |
$BTvF = $f if ($BTL[$f] eq 'v'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
301 |
$BTwF = $f if ($BTL[$f] eq 'w'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
302 |
$BTusF = $f if ($BTL[$f] eq 'u.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
303 |
$BTvsF = $f if ($BTL[$f] eq 'v.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
304 |
$BTwsF = $f if ($BTL[$f] eq 'w.sig'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
305 |
$BTndF = $f if ($BTL[$f] eq 'ndata'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
306 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
307 |
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
|
308 |
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
|
309 |
defined($BTusF) && defined($BTvsF) && defined($BTwsF) && defined($BTndF); |
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 |
while (my(@BTr) = &antsFileIn(BTF)) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
312 |
my($gi) = int($BTr[$BTdF] / $DZ); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
313 |
next unless ($BTr[$BTndF] >= $opt_r); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
314 |
$BT_nsamp[$gi] = $BTr[$BTndF]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
315 |
$BT_u[$gi] = $BTr[$BTuF]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
316 |
$BT_v[$gi] = $BTr[$BTvF]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
317 |
$BT_w[$gi] = $BTr[$BTwF]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
318 |
$BT_u_var[$gi] = $BTr[$BTusF]**2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
319 |
$BT_v_var[$gi] = $BTr[$BTvsF]**2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
320 |
$BT_w_var[$gi] = $BTr[$BTwsF]**2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
321 |
} |
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 |
&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
|
324 |
&fixLowSampStat(\@BT_v_var,@BT_nsamp); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
325 |
&fixLowSampStat(\@BT_w_var,@BT_nsamp); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
326 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
327 |
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
|
328 |
$uc_sumU,$uc_sumV,$uc_sumW); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
329 |
my($nSumVel,$dc_nSumVel,$uc_nSumVel); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
330 |
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
|
331 |
my($dc_wSumBTu,$dc_wSumBTv,$dc_wSumBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
332 |
my($uc_wSumBTu,$uc_wSumBTv,$uc_wSumBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
333 |
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
|
334 |
my($dc_sumVarBTu,$dc_sumVarBTv,$dc_sumVarBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
335 |
my($uc_sumVarBTu,$uc_sumVarBTv,$uc_sumVarBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
336 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
337 |
for (my($r)=0; $r<@depth; $r++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
338 |
if (numberp($BT_u[$r]) && numberp($u[$r])) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
339 |
$nSumVel++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
340 |
$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
|
341 |
$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
|
342 |
# 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
|
343 |
$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
|
344 |
$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
|
345 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
346 |
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
|
347 |
$dc_nSumVel++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
348 |
$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
|
349 |
$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
|
350 |
$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
|
351 |
$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
|
352 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
353 |
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
|
354 |
$uc_nSumVel++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
355 |
$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
|
356 |
$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
|
357 |
$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
|
358 |
$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
|
359 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
360 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
361 |
|
1 | 362 |
if ($nSumVel > 0) { |
363 |
$refU = $sumU/$nSumVel - $wSumBTu/$sumVarBTu; |
|
364 |
$refV = $sumV/$nSumVel - $wSumBTv/$sumVarBTv; |
|
365 |
$refW = $sumW/$nSumVel - $wSumBTw/$sumVarBTw; |
|
366 |
||
367 |
$dc_refU = $dc_sumU/$dc_nSumVel - $dc_wSumBTu/$dc_sumVarBTu; |
|
368 |
$dc_refV = $dc_sUmV/$dc_nSumVel - $dc_wSumBTv/$dc_sumVarBTv; |
|
369 |
$dc_refW = $dc_sumW/$dc_nSumVel - $dc_wSumBTw/$dc_sumVarBTw; |
|
370 |
||
371 |
$uc_refU = $uc_sumU/$uc_nSumVel - $uc_wSumBTu/$uc_sumVarBTu; |
|
372 |
$uc_refV = $uc_sUmV/$uc_nSumVel - $uc_wSumBTv/$uc_sumVarBTv; |
|
373 |
$uc_refW = $uc_sumW/$uc_nSumVel - $uc_wSumBTw/$uc_sumVarBTw; |
|
374 |
} else { |
|
375 |
&antsInfo("$opt_b: no valid BT data --- calculating baroclinic solution only"); |
|
376 |
} |
|
377 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
378 |
|
1 | 379 |
unless (defined($refU)) { |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
380 |
my($sumU,$sumV,$sumW,$dc_sumU,$dc_sumV,$dc_sumW,$uc_sumU,$uc_sumV,$uc_sumW); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
381 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
382 |
for (my($r)=0; $r<@depth; $r++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
383 |
$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
|
384 |
$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
|
385 |
$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
|
386 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
387 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
388 |
$refU = $sumU / @depth; $refV = $sumV / @depth; $refW = $sumW / @depth; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
389 |
$dc_refU = $dc_sumU / @depth; $dc_refV = $dc_sumV / @depth; $dc_refW = $dc_sumW / @depth; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
390 |
$uc_refU = $uc_sumU / @depth; $uc_refV = $uc_sumV / @depth; $uc_refW = $uc_sumW / @depth; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
391 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
392 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
393 |
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
|
394 |
$u[$r] -= $refU if defined($u[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
395 |
$v[$r] -= $refV if defined($v[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
396 |
$w[$r] -= $refW if defined($w[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
397 |
$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
|
398 |
$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
|
399 |
$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
|
400 |
$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
|
401 |
$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
|
402 |
$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
|
403 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
404 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
405 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
406 |
# Determine X Factor |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
407 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
408 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
409 |
my($first_w,$last_w); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
410 |
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
|
411 |
$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
|
412 |
$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
|
413 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
414 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
415 |
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
|
416 |
&antsAddParams('X-Factor',$X_Factor); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
417 |
printf(STDERR "X-Factor = %.1f\n",$X_Factor); |
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 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
420 |
# Output Velocity Profile |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
421 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
422 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
423 |
@antsNewLayout = ('depth','u','v','w','dc_u','dc_v','dc_w','uc_u','uc_v','uc_w'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
424 |
for (my($r)=0; $r<@depth; $r++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
425 |
&antsOut($depth[$r]+$DZ/2,$u[$r],$v[$r],$w[$r], |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
426 |
$dc_u[$r],$dc_v[$r],$dc_w[$r], |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
427 |
$uc_u[$r],$uc_v[$r],$uc_w[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
428 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
429 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
430 |
&antsExit(); |