author | A.M. Thurnherr <athurnherr@yahoo.com> |
Tue, 20 May 2014 09:08:19 -0400 | |
changeset 27 | ec8873454890 |
parent 26 | d778b73f2a43 |
child 29 | f72cd642972c |
child 30 | 8697ba5a88ec |
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 |
26
d778b73f2a43
before beginning to use instrument tilt in distance calculations
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
5 |
# dlm: Thu Mar 20 12:14:53 2014 |
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 |
26
d778b73f2a43
before beginning to use instrument tilt in distance calculations
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
7 |
# uE-Info: 266 0 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 |
|
11 | 51 |
# May 16, 2012: - adapted to ANTSlib V5.0 |
15 | 52 |
# May 25, 2012: - added code to read LDEO_IX bottom-track data |
16 | 53 |
# Jun 14, 2012: - noticed that -b now works also with LDEO SADCP files :-); renamed -b option to -r |
20 | 54 |
# Jun 5, 2013: - BUG: code bombed when either UC or DC was missing |
55 |
# Jun 28, 2013: - adapated to new :: convention |
|
56 |
# - make sure LADCP DUL metadata are dealt with correctly |
|
57 |
# Jul 12, 2013: - clarified -u usage with better messages |
|
25
91bd907db97f
before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
20
diff
changeset
|
58 |
# Mar 20, 2014: - fiddled while debugging [LADCPproc] |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
59 |
|
11 | 60 |
($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$}); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
61 |
require "$ANTS/ants.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
62 |
require "$ANTS/libstats.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
63 |
|
16 | 64 |
&antsUsage('dm:n:r:s:w:u:',0, |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
65 |
'[-d)ebug]', |
16 | 66 |
'[-r)eference with <BT or SADCP file> [-m)in <samp[10]>]]', |
20 | 67 |
'[secondary -u)plooker <shear file>]', |
6 | 68 |
'[min -n) <shear samp[10]>]', |
69 |
'[output -s)hear-pro <file>]', |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
70 |
'[LADCP shear file]'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
71 |
|
16 | 72 |
croak("$0: -m meaningless without -r\n") |
73 |
if defined($opt_m) && !defined($opt_r); |
|
3 | 74 |
|
15 | 75 |
&antsCardOpt(\$opt_n,10); # minimum number of samples for shear |
76 |
$minBTsamp = &antsCardOpt($opt_m,10); # minimum number of samples for BT data |
|
1 | 77 |
|
16 | 78 |
&antsFileOpt($opt_r); # reference velocity file |
1 | 79 |
|
80 |
&antsFileOpt($opt_u); # UL shear file |
|
20 | 81 |
if (defined($opt_u)) { |
82 |
open(ULF,$opt_u) || croak("$opt_u: $!\n"); |
|
83 |
%UL_P = &antsFileParams(ULF); |
|
84 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
85 |
|
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 |
# Step 1: Read and Average Shear Data |
6 | 88 |
# - 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
|
89 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
90 |
|
6 | 91 |
sub wavg_sig(@) |
92 |
{ |
|
93 |
my($sumSq) = my($n) = 0; |
|
94 |
for (my($i)=0; $i<$#_; $i+=2) { |
|
95 |
next unless numberp($_[$i+1]); |
|
96 |
$sumSq += $_[$i] * $_[$i+1]**2; |
|
97 |
$n += $_[$i]; |
|
98 |
} |
|
99 |
return ($n>0) ? sqrt($sumSq/$n) : nan; |
|
100 |
} |
|
101 |
||
102 |
||
20 | 103 |
#-------------------- |
104 |
# Handle Metadata |
|
105 |
#-------------------- |
|
106 |
||
107 |
if (%UL_P) { |
|
108 |
croak("$0: inconsistent vertical resolution\n") |
|
109 |
unless ($P{LADCPproc::vertical_resolution} == $UL_P{LADCPproc::vertical_resolution}); |
|
110 |
||
111 |
unless ($P{LADCPproc::bin_length} == $UL_P{LADCPproc::bin_length}) { |
|
112 |
&antsInfo("Warnining: different DL/UL bin lengths; derived spectra cannot be corrected"); |
|
113 |
&antsAddParams('LADCPproc::bin_length','', |
|
114 |
'LADCPproc::DL_bin_length',$P{LADCPproc::bin_length}, |
|
115 |
'LADCPproc::UL_bin_length',$UL_P{LADCPproc::bin_length}); |
|
116 |
} |
|
117 |
} |
|
118 |
||
119 |
$depthF = fnrNoErr('depth'); # layout of [LADCPproc] output |
|
120 |
unless (defined($depthF)) { |
|
121 |
if (defined($opt_u)) { |
|
122 |
croak("No 'depth' field in primary shear file (extraneous -u?)\n"); |
|
123 |
} else { |
|
124 |
croak("No 'depth' field in primary shear file\n"); |
|
125 |
} |
|
126 |
} |
|
127 |
||
7 | 128 |
$dc_nshF = fnrNoErr('dc_nshear'); |
129 |
$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
|
130 |
$dc_uzF = fnr('dc_u_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
131 |
$dc_uzsF = fnrNoErr('dc_u_z.sig'); |
7 | 132 |
$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
|
133 |
$dc_vzF = fnr('dc_v_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
134 |
$dc_vzsF = fnrNoErr('dc_v_z.sig'); |
7 | 135 |
$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
|
136 |
$dc_wzF = fnr('dc_w_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
137 |
$dc_wzsF = fnrNoErr('dc_w_z.sig'); |
7 | 138 |
$dc_wzsF = fnr('dc_w_z_sig') unless defined($dc_wzsF); |
139 |
$dc_elapsedF = fnr('dc_elapsed'); |
|
140 |
$uc_nshF = fnrNoErr('uc_nshear'); |
|
141 |
$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
|
142 |
$uc_uzF = fnr('uc_u_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
143 |
$uc_uzsF = fnrNoErr('uc_u_z.sig'); |
7 | 144 |
$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
|
145 |
$uc_vzF = fnr('uc_v_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
146 |
$uc_vzsF = fnrNoErr('uc_v_z.sig'); |
7 | 147 |
$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
|
148 |
$uc_wzF = fnr('uc_w_z'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
149 |
$uc_wzsF = fnrNoErr('uc_w_z.sig'); |
7 | 150 |
$uc_wzsF = fnr('uc_w_z_sig') unless defined($uc_wzsF); |
151 |
$uc_elapsedF = fnr('uc_elapsed'); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
152 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
153 |
my(@gaps); my($curGap) = 0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
154 |
|
1 | 155 |
for (my($r)=0; &antsIn(); $r++) { |
156 |
my(@UL_); |
|
157 |
if (defined($opt_u)) { |
|
5 | 158 |
@UL_ = &antsFileIn(ULF); # read UL shear data |
159 |
undef($opt_u) unless (@UL_); # cheap trick |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
160 |
} |
20 | 161 |
|
1 | 162 |
$depth[$r] = $ants_[0][$depthF]; ## depth grid values |
18 | 163 |
croak("$opt_u: inconsistent depth record $r (DL: $depth[$r]; UL: $UL_[$depthF])\n") |
1 | 164 |
if defined($opt_u) && ($UL_[$depthF] != $depth[$r]); |
165 |
||
6 | 166 |
$dc_nsamp = $ants_[0][$dc_nshF]; # number of shear samples |
167 |
$uc_nsamp = $ants_[0][$uc_nshF]; |
|
1 | 168 |
if (defined($opt_u)) { |
6 | 169 |
$dl_nsamp = $dc_nsamp + $uc_nsamp; |
170 |
$dc_nsamp += $UL_[$dc_nshF]; |
|
171 |
$uc_nsamp += $UL_[$uc_nshF]; |
|
25
91bd907db97f
before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
20
diff
changeset
|
172 |
$ul_nsamp = $dc_nsamp + $uc_nsamp; |
1 | 173 |
} |
25
91bd907db97f
before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
20
diff
changeset
|
174 |
|
91bd907db97f
before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
20
diff
changeset
|
175 |
$dc_nsamp[$r] = $dc_nsamp; # save for each record |
6 | 176 |
$uc_nsamp[$r] = $uc_nsamp; |
177 |
$nsamp[$r] = $dc_nsamp + $uc_nsamp; |
|
178 |
if (defined($opt_u)) { |
|
179 |
$ul_nsamp[$r] = $ul_nsamp; |
|
180 |
$dl_nsamp[$r] = $dl_nsamp; |
|
181 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
182 |
|
5 | 183 |
if (defined($opt_u)) { # dual-head instrument |
6 | 184 |
if ($dc_nsamp > 0) { # downcast shear |
185 |
my($DLf) = $ants_[0][$dc_nshF] / $dc_nsamp; |
|
186 |
my($ULf) = $UL_[$dc_nshF] / $dc_nsamp; |
|
7 | 187 |
if ($DLf>0 && $ULf>0) { |
1 | 188 |
$dc_uz[$r] = $DLf*$ants_[0][$dc_uzF] + $ULf*$UL_[$dc_uzF]; |
189 |
$dc_vz[$r] = $DLf*$ants_[0][$dc_vzF] + $ULf*$UL_[$dc_vzF]; |
|
190 |
$dc_wz[$r] = $DLf*$ants_[0][$dc_wzF] + $ULf*$UL_[$dc_wzF]; |
|
7 | 191 |
$dc_elapsed[$r] = $DLf*$ants_[0][$dc_elapsedF] + $ULf*$UL_[$dc_elapsedF]; |
1 | 192 |
} elsif ($DLf > 0) { |
193 |
$dc_uz[$r] = $ants_[0][$dc_uzF]; |
|
194 |
$dc_vz[$r] = $ants_[0][$dc_vzF]; |
|
195 |
$dc_wz[$r] = $ants_[0][$dc_wzF]; |
|
7 | 196 |
$dc_elapsed[$r] = $ants_[0][$dc_elapsedF]; |
1 | 197 |
} else { |
198 |
$dc_uz[$r] = $UL_[$dc_uzF]; |
|
199 |
$dc_vz[$r] = $UL_[$dc_vzF]; |
|
200 |
$dc_wz[$r] = $UL_[$dc_wzF]; |
|
7 | 201 |
$dc_elapsed[$r] = $UL_[$dc_elapsedF]; |
1 | 202 |
} |
203 |
} else { |
|
7 | 204 |
$dc_uz[$r] = $dc_vz[$r] = $dc_wz[$r] = $dc_elapsed[$r] = nan; |
1 | 205 |
} |
6 | 206 |
if ($uc_nsamp > 0) { # upcast shear |
207 |
my($DLf) = $ants_[0][$uc_nshF] / $uc_nsamp; |
|
208 |
my($ULf) = $UL_[$uc_nshF] / $uc_nsamp; |
|
1 | 209 |
if ($DLf>0 && $Ulf>0) { |
210 |
$uc_uz[$r] = $DLf*$ants_[0][$uc_uzF] + $ULf*$UL_[$uc_uzF]; |
|
211 |
$uc_vz[$r] = $DLf*$ants_[0][$uc_vzF] + $ULf*$UL_[$uc_vzF]; |
|
212 |
$uc_wz[$r] = $DLf*$ants_[0][$uc_wzF] + $ULf*$UL_[$uc_wzF]; |
|
7 | 213 |
$uc_elapsed[$r] = $DLf*$ants_[0][$uc_elapsedF] + $ULf*$UL_[$uc_elapsedF]; |
1 | 214 |
} elsif ($DLf > 0) { |
215 |
$uc_uz[$r] = $ants_[0][$uc_uzF]; |
|
216 |
$uc_vz[$r] = $ants_[0][$uc_vzF]; |
|
217 |
$uc_wz[$r] = $ants_[0][$uc_wzF]; |
|
7 | 218 |
$uc_elapsed[$r] = $ants_[0][$uc_elapsedF]; |
1 | 219 |
} else { |
220 |
$uc_uz[$r] = $UL_[$uc_uzF]; |
|
221 |
$uc_vz[$r] = $UL_[$uc_vzF]; |
|
222 |
$uc_wz[$r] = $UL_[$uc_wzF]; |
|
7 | 223 |
$uc_elapsed[$r] = $UL_[$uc_elapsedF]; |
1 | 224 |
} |
225 |
} else { |
|
7 | 226 |
$uc_uz[$r] = $uc_vz[$r] = $uc_wz[$r] = $uc_elapsed[$r] = nan; |
1 | 227 |
} |
5 | 228 |
} else { # downlooker only |
6 | 229 |
if ($dc_nsamp > 0) { # downcast shear |
1 | 230 |
$dc_uz[$r] = $ants_[0][$dc_uzF]; |
231 |
$dc_vz[$r] = $ants_[0][$dc_vzF]; |
|
232 |
$dc_wz[$r] = $ants_[0][$dc_wzF]; |
|
7 | 233 |
$dc_elapsed[$r] = $ants_[0][$dc_elapsedF]; |
1 | 234 |
} else { |
7 | 235 |
$dc_uz[$r] = $dc_vz[$r] = $dc_wz[$r] = $dc_elapsed[$r] = nan; |
1 | 236 |
} |
6 | 237 |
if ($uc_nsamp > 0) { # upcast shear |
1 | 238 |
$uc_uz[$r] = $ants_[0][$uc_uzF]; |
239 |
$uc_vz[$r] = $ants_[0][$uc_vzF]; |
|
240 |
$uc_wz[$r] = $ants_[0][$uc_wzF]; |
|
7 | 241 |
$uc_elapsed[$r] = $ants_[0][$uc_elapsedF]; |
1 | 242 |
} else { |
7 | 243 |
$uc_uz[$r] = $uc_vz[$r] = $uc_wz[$r] = $uc_elapsed[$r] = nan; |
1 | 244 |
} |
245 |
} |
|
246 |
||
6 | 247 |
if ($nsamp[$r] > 0) { |
248 |
my($dcf) = $dc_nsamp / $nsamp[$r]; |
|
249 |
my($ucf) = $uc_nsamp / $nsamp[$r]; |
|
250 |
if ($dcf>0 && $ucf>0) { |
|
251 |
$uz[$r] = $dcf*$dc_uz[$r] + $ucf*$uc_uz[$r]; |
|
252 |
$vz[$r] = $dcf*$dc_vz[$r] + $ucf*$uc_vz[$r]; |
|
253 |
$wz[$r] = $dcf*$dc_wz[$r] + $ucf*$uc_wz[$r]; |
|
7 | 254 |
$elapsed[$r] = $dcf*$dc_elapsed[$r] + $ucf*$uc_elapsed[$r]; |
6 | 255 |
} elsif ($dcf > 0) { |
1 | 256 |
$uz[$r] = $dc_uz[$r]; |
257 |
$vz[$r] = $dc_vz[$r]; |
|
258 |
$wz[$r] = $dc_wz[$r]; |
|
7 | 259 |
$elapsed[$r] = $dc_elapsed[$r]; |
6 | 260 |
} else { |
1 | 261 |
$uz[$r] = $uc_uz[$r]; |
262 |
$vz[$r] = $uc_vz[$r]; |
|
263 |
$wz[$r] = $uc_wz[$r]; |
|
7 | 264 |
$elapsed[$r] = $uc_elapsed[$r]; |
6 | 265 |
} |
266 |
} else { |
|
7 | 267 |
$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
|
268 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
269 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
270 |
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
|
271 |
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
|
272 |
# 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
|
273 |
$curGap = 0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
274 |
} elsif (!numberp($uz[$r])) { # currently in gap |
6 | 275 |
# 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
|
276 |
$curGap++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
277 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
278 |
|
6 | 279 |
if ($nsamp[$r] > 0) { |
1 | 280 |
if (defined($opt_u)) { |
6 | 281 |
$uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF], |
282 |
$UL_[$dc_nshF], $UL_[$dc_uzsF], |
|
283 |
$ants_[0][$uc_nshF],$ants_[0][$uc_uzsF], |
|
284 |
$UL_[$uc_nshF], $UL_[$uc_uzsF]); |
|
285 |
$vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF], |
|
286 |
$UL_[$dc_nshF], $UL_[$dc_vzsF], |
|
287 |
$ants_[0][$uc_nshF],$ants_[0][$uc_vzsF], |
|
288 |
$UL_[$uc_nshF], $UL_[$uc_vzsF]); |
|
289 |
$wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF], |
|
290 |
$UL_[$dc_nshF], $UL_[$dc_wzsF], |
|
291 |
$ants_[0][$uc_nshF],$ants_[0][$uc_wzsF], |
|
292 |
$UL_[$uc_nshF], $UL_[$uc_wzsF]); |
|
293 |
} else { # DL only |
|
294 |
$uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF], |
|
295 |
$ants_[0][$uc_nshF],$ants_[0][$uc_uzsF]); |
|
296 |
$vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF], |
|
297 |
$ants_[0][$uc_nshF],$ants_[0][$uc_vzsF]); |
|
298 |
$wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF], |
|
299 |
$ants_[0][$uc_nshF],$ants_[0][$uc_wzsF]); |
|
1 | 300 |
} |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
301 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
302 |
$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
303 |
} |
5 | 304 |
|
6 | 305 |
if ($dc_nsamp > 0) { # same calc for downcast only |
5 | 306 |
if (defined($opt_u)) { |
6 | 307 |
$dc_uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF], |
308 |
$UL_[$dc_nshF], $UL_[$dc_uzsF]); |
|
309 |
$dc_vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF], |
|
310 |
$UL_[$dc_nshF], $UL_[$dc_vzsF]); |
|
311 |
$dc_wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF], |
|
312 |
$UL_[$dc_nshF], $UL_[$dc_wzsF]); |
|
5 | 313 |
} else { |
314 |
$dc_uzsig[$r] = $ants_[0][$dc_uzsF]; |
|
315 |
$dc_vzsig[$r] = $ants_[0][$dc_vzsF]; |
|
316 |
$dc_wzsig[$r] = $ants_[0][$dc_wzsF]; |
|
317 |
} |
|
318 |
} else { |
|
319 |
$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan; |
|
320 |
} |
|
321 |
||
6 | 322 |
if ($uc_nsamp > 0) { # same calc for upcast only |
5 | 323 |
if (defined($opt_u)) { |
6 | 324 |
$uc_uzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_uzsF], |
325 |
$UL_[$uc_nshF], $UL_[$uc_uzsF]); |
|
326 |
$uc_vzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_vzsF], |
|
327 |
$UL_[$uc_nshF], $UL_[$uc_vzsF]); |
|
328 |
$uc_wzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_wzsF], |
|
329 |
$UL_[$uc_nshF], $UL_[$uc_wzsF]); |
|
5 | 330 |
} else { |
331 |
$uc_uzsig[$r] = $ants_[0][$uc_uzsF]; |
|
332 |
$uc_vzsig[$r] = $ants_[0][$uc_vzsF]; |
|
333 |
$uc_wzsig[$r] = $ants_[0][$uc_wzsF]; |
|
334 |
} |
|
335 |
} else { |
|
336 |
$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan; |
|
337 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
338 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
339 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
340 |
if (@gaps) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
341 |
&antsAddParams('shear_gaps',"@gaps"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
342 |
print(STDERR "shear gaps: @gaps\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
343 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
344 |
&antsAddParams('shear_gaps',0); |
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 |
|
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 |
# 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
|
349 |
#=============================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
350 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
351 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
352 |
# Step 3: Integrate Shear |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
353 |
# - z(vel) = z(sh) + DZ/2 |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
354 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
355 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
356 |
my($DZ) = $depth[1] - $depth[0]; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
357 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
358 |
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
|
359 |
$r<@depth; $r++) { |
6 | 360 |
if ($nsamp[$r] >= $opt_n) { |
361 |
$u = $u[$r] = $u + $DZ*$uz[$r]; |
|
362 |
$v = $v[$r] = $v + $DZ*$vz[$r]; |
|
363 |
$w = $w[$r] = $w + $DZ*$wz[$r]; |
|
364 |
} |
|
365 |
if ($dc_nsamp[$r] >= $opt_n) { |
|
366 |
$dc_u = $dc_u[$r] = $dc_u + $DZ*$dc_uz[$r]; |
|
367 |
$dc_v = $dc_v[$r] = $dc_v + $DZ*$dc_vz[$r]; |
|
368 |
$dc_w = $dc_w[$r] = $dc_w + $DZ*$dc_wz[$r]; |
|
369 |
} |
|
370 |
if ($uc_nsamp[$r] >= $opt_n) { |
|
371 |
$uc_u = $uc_u[$r] = $uc_u + $DZ*$uc_uz[$r]; |
|
372 |
$uc_v = $uc_v[$r] = $uc_v + $DZ*$uc_vz[$r]; |
|
373 |
$uc_w = $uc_w[$r] = $uc_w + $DZ*$uc_wz[$r]; |
|
374 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
375 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
376 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
377 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
378 |
# Step 4: Reference Velocities |
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 |
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
|
382 |
|
25
91bd907db97f
before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
20
diff
changeset
|
383 |
if (defined($opt_r)) { # reference using velocity profile |
16 | 384 |
print(STDERR "Loading reference-velocity data from $opt_r...\n") |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
385 |
if ($opt_d); |
16 | 386 |
open(BTF,$opt_r) || croak("$opt_r: $!\n"); |
0
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 |
my(@BTL) = &antsFileLayout(BTF); |
15 | 389 |
if (@BTL) { # valid ANTS file |
390 |
my($BTdF,$BTndF,$BTuF,$BTvF,$BTwF,$BTusF,$BTvsF,$BTwsF); |
|
391 |
for (my($f)=0; $f<@BTL; $f++) { |
|
392 |
$BTdF = $f if ($BTL[$f] eq 'depth'); |
|
393 |
$BTuF = $f if ($BTL[$f] eq 'u'); |
|
394 |
$BTvF = $f if ($BTL[$f] eq 'v'); |
|
395 |
$BTwF = $f if ($BTL[$f] eq 'w'); |
|
396 |
$BTusF = $f if ($BTL[$f] eq 'u.sig'); |
|
397 |
$BTvsF = $f if ($BTL[$f] eq 'v.sig'); |
|
398 |
$BTwsF = $f if ($BTL[$f] eq 'w.sig'); |
|
399 |
$BTndF = $f if ($BTL[$f] eq 'nsamp'); |
|
400 |
$BTerrF= $f if ($BTL[$f] eq 'err'); |
|
401 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
402 |
|
15 | 403 |
if (defined($BTdF) && defined($BTuF) && # from LADCPproc |
404 |
defined($BTvF) && defined($BTwF) && |
|
405 |
defined($BTusF) && defined($BTvsF) && |
|
406 |
defined($BTwsF) && defined($BTndF)) { |
|
407 |
while (my(@BTr) = &antsFileIn(BTF)) { |
|
408 |
my($gi) = int($BTr[$BTdF] / $DZ); |
|
409 |
next unless ($BTr[$BTndF] >= $minBTsamp); |
|
410 |
$BT_nsamp[$gi] = $BTr[$BTndF]; |
|
411 |
$BT_u[$gi] = $BTr[$BTuF]; |
|
412 |
$BT_v[$gi] = $BTr[$BTvF]; |
|
413 |
$BT_w[$gi] = $BTr[$BTwF]; |
|
414 |
$BT_u_var[$gi] = $BTr[$BTusF]**2; |
|
415 |
$BT_v_var[$gi] = $BTr[$BTvsF]**2; |
|
416 |
$BT_w_var[$gi] = $BTr[$BTwsF]**2; |
|
417 |
} |
|
418 |
&fixLowSampStat(\@BT_u_var,@BT_nsamp); # remove spurious small variances |
|
419 |
&fixLowSampStat(\@BT_v_var,@BT_nsamp); |
|
420 |
&fixLowSampStat(\@BT_w_var,@BT_nsamp); |
|
421 |
} elsif (defined($BTdF) && defined($BTuF) && # LDEO_IX ANTS format |
|
422 |
defined($BTvF) && defined($BTerrF)) { |
|
423 |
croak("$0: -m not supported for this BT file format\n") |
|
424 |
if defined($opt_m); |
|
425 |
while (my(@BTr) = &antsFileIn(BTF)) { |
|
426 |
my($gi) = int($BTr[$BTdF] / $DZ); |
|
427 |
$BT_u[$gi] = $BTr[$BTuF]; |
|
428 |
$BT_v[$gi] = $BTr[$BTvF]; |
|
429 |
$BT_u_var[$gi] = $BTr[$BTerrF]**2; |
|
430 |
$BT_v_var[$gi] = $BTr[$BTerrF]**2; |
|
431 |
# print(STDERR "$gi $BT_u[$gi] $BT_v[$gi] $BT_u_var[$gi] $BT_v_var[$gi]\n"); |
|
432 |
} |
|
433 |
} else { |
|
16 | 434 |
croak("$opt_r: not a valid reference-velocity file (ANTS format)\n"); |
15 | 435 |
} |
436 |
} else { # non-ANTS file (LDEO_IX assumed) |
|
437 |
croak("$0: -m not supported for this BT file format\n") |
|
438 |
if defined($opt_m); |
|
439 |
while (<BTF>) { |
|
440 |
last if /^Columns\s+=\s+z:u:v:err/; |
|
441 |
} |
|
16 | 442 |
croak("$opt_r: not a valid reference-velocity file (non-ANTS format)\n") |
15 | 443 |
unless /^Columns\s+=\s+z:u:v:err/; |
444 |
while (<BTF>) { |
|
445 |
my($depth,$u,$v,$err) = split; |
|
446 |
croak("$0: cannot handle non-numeric BT data (implementation restriction)\n") |
|
447 |
unless numberp($depth) && numberp($u) && numberp($v) && numberp($err); |
|
448 |
my($gi) = int($depth / $DZ); |
|
449 |
$BT_u[$gi] = $u; |
|
450 |
$BT_v[$gi] = $v; |
|
451 |
$BT_u_var[$gi] = $err**2; |
|
452 |
$BT_v_var[$gi] = $err**2; |
|
453 |
# print(STDERR "$gi $BT_u[$gi] $BT_v[$gi] $BT_u_var[$gi] $BT_v_var[$gi]\n"); |
|
454 |
} |
|
455 |
} |
|
456 |
close(BTF); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
457 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
458 |
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
|
459 |
$uc_sumU,$uc_sumV,$uc_sumW); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
460 |
my($nSumVel,$dc_nSumVel,$uc_nSumVel); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
461 |
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
|
462 |
my($dc_wSumBTu,$dc_wSumBTv,$dc_wSumBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
463 |
my($uc_wSumBTu,$uc_wSumBTv,$uc_wSumBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
464 |
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
|
465 |
my($dc_sumVarBTu,$dc_sumVarBTv,$dc_sumVarBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
466 |
my($uc_sumVarBTu,$uc_sumVarBTv,$uc_sumVarBTw); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
467 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
468 |
for (my($r)=0; $r<@depth; $r++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
469 |
if (numberp($BT_u[$r]) && numberp($u[$r])) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
470 |
$nSumVel++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
471 |
$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
|
472 |
$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
|
473 |
$wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $sumVarBTv += 1/$BT_v_var[$r]; |
15 | 474 |
if (@BT_w) { |
475 |
$wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $sumVarBTw += 1/$BT_w_var[$r]; |
|
476 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
477 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
478 |
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
|
479 |
$dc_nSumVel++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
480 |
$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
|
481 |
$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
|
482 |
$dc_wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $dc_sumVarBTv += 1/$BT_v_var[$r]; |
15 | 483 |
if (@BT_w) { |
484 |
$dc_wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $dc_sumVarBTw += 1/$BT_w_var[$r]; |
|
485 |
} |
|
0
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 |
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
|
488 |
$uc_nSumVel++; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
489 |
$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
|
490 |
$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
|
491 |
$uc_wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $uc_sumVarBTv += 1/$BT_v_var[$r]; |
15 | 492 |
if (@BT_w) { |
493 |
$uc_wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $uc_sumVarBTw += 1/$BT_w_var[$r]; |
|
494 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
495 |
} |
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 |
|
1 | 498 |
if ($nSumVel > 0) { |
499 |
$refU = $sumU/$nSumVel - $wSumBTu/$sumVarBTu; |
|
500 |
$refV = $sumV/$nSumVel - $wSumBTv/$sumVarBTv; |
|
15 | 501 |
$refW = $sumW/$nSumVel - $wSumBTw/$sumVarBTw if (@BT_w); |
502 |
||
6 | 503 |
if ($dc_nSumVel > 0) { |
504 |
$dc_refU = $dc_sumU/$dc_nSumVel - $dc_wSumBTu/$dc_sumVarBTu; |
|
505 |
$dc_refV = $dc_sumV/$dc_nSumVel - $dc_wSumBTv/$dc_sumVarBTv; |
|
15 | 506 |
$dc_refW = $dc_sumW/$dc_nSumVel - $dc_wSumBTw/$dc_sumVarBTw if (@BT_w); |
6 | 507 |
} else { |
25
91bd907db97f
before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
20
diff
changeset
|
508 |
&antsInfo("$opt_r: insufficient reference-velocity data to constrain DC profile --- baroclinic profile only"); |
6 | 509 |
} |
1 | 510 |
|
6 | 511 |
if ($uc_nSumVel > 0) { |
512 |
$uc_refU = $uc_sumU/$uc_nSumVel - $uc_wSumBTu/$uc_sumVarBTu; |
|
513 |
$uc_refV = $uc_sumV/$uc_nSumVel - $uc_wSumBTv/$uc_sumVarBTv; |
|
15 | 514 |
$uc_refW = $uc_sumW/$uc_nSumVel - $uc_wSumBTw/$uc_sumVarBTw if (@BT_w); |
6 | 515 |
} else { |
25
91bd907db97f
before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
20
diff
changeset
|
516 |
&antsInfo("$opt_r: insufficient reference-velocity data to constrain UC profile --- baroclinic profile only"); |
6 | 517 |
} |
1 | 518 |
} else { |
16 | 519 |
&antsInfo("$opt_r: no valid reference-velocity data --- baroclinic profiles only"); |
1 | 520 |
} |
521 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
522 |
|
5 | 523 |
unless (defined($refU)) { # no reference velocity => use zero mean |
6 | 524 |
my($sumU,$sumV,$sumW,$nSumVel); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
525 |
for (my($r)=0; $r<@depth; $r++) { |
2 | 526 |
if (numberp($u[$r])) { |
527 |
$nSumVel++; |
|
15 | 528 |
$sumU += $u[$r]; $sumV += $v[$r]; $sumW += $w[$r] if (@BT_w); |
2 | 529 |
} |
6 | 530 |
} |
15 | 531 |
$refU = $sumU / $nSumVel; $refV = $sumV / $nSumVel; $refW = $sumW / $nSumVel if (@BT_w); |
6 | 532 |
} |
533 |
unless (defined($dc_refU)) { |
|
534 |
my($dc_sumU,$dc_sumV,$dc_sumW,$dc_nSumVel); |
|
535 |
for (my($r)=0; $r<@depth; $r++) { |
|
2 | 536 |
if (numberp($dc_u[$r])) { |
537 |
$dc_nSumVel++; |
|
15 | 538 |
$dc_sumU += $dc_u[$r]; $dc_sumV += $dc_v[$r]; $dc_sumW += $dc_w[$r] if (@BT_w); |
2 | 539 |
} |
6 | 540 |
} |
20 | 541 |
if ($dc_nSumVel) { |
542 |
$dc_refU = $dc_sumU / $dc_nSumVel; $dc_refV = $dc_sumV / $dc_nSumVel; |
|
543 |
$dc_refW = $dc_sumW / $dc_nSumVel if (@BT_w); |
|
544 |
} |
|
6 | 545 |
} |
546 |
unless (defined($uc_refU)) { |
|
547 |
my($uc_sumU,$uc_sumV,$uc_sumW,$uc_nSumVel); |
|
548 |
for (my($r)=0; $r<@depth; $r++) { |
|
2 | 549 |
if (numberp($uc_u[$r])) { |
550 |
$uc_nSumVel++; |
|
15 | 551 |
$uc_sumU += $uc_u[$r]; $uc_sumV += $uc_v[$r]; $uc_sumW += $uc_w[$r] if (@BT_w); |
2 | 552 |
} |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
553 |
} |
20 | 554 |
if ($uc_nSumVel) { |
555 |
$uc_refU = $uc_sumU / $uc_nSumVel; $uc_refV = $uc_sumV / $uc_nSumVel; |
|
556 |
$uc_refW = $uc_sumW / $uc_nSumVel if (@BT_w); |
|
557 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
558 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
559 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
560 |
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
|
561 |
$u[$r] -= $refU if defined($u[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
562 |
$v[$r] -= $refV if defined($v[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
563 |
$w[$r] -= $refW if defined($w[$r]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
564 |
$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
|
565 |
$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
|
566 |
$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
|
567 |
$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
|
568 |
$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
|
569 |
$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
|
570 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
571 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
572 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
573 |
# Determine X Factor |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
574 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
575 |
|
20 | 576 |
if ($dc_nSumVel && $uc_nSumVel) { |
577 |
my($first_w,$last_w); |
|
578 |
for (my($r)=0; !defined($first_w) || !defined($last_w); $r++) { |
|
579 |
$first_w = $dc_w[$r] unless defined($first_w); |
|
580 |
$last_w = $uc_w[$r] unless defined($last_w); |
|
581 |
} |
|
582 |
||
583 |
my($X_Factor) = 100 * abs($last_w-$first_w) / sqrt(@depth / $DZ); |
|
584 |
&antsAddParams('X-Factor',$X_Factor); |
|
585 |
printf(STDERR "X-Factor = %.1f\n",$X_Factor); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
586 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
587 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
588 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
589 |
# Output Velocity Profile |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
590 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
591 |
|
7 | 592 |
@antsNewLayout = ('depth','elapsed','u','v','w','nsamp', |
593 |
'dc_elapsed','dc_u','dc_v','dc_w','dc_nsamp', |
|
594 |
'uc_elapsed','uc_u','uc_v','uc_w','uc_nsamp'); |
|
5 | 595 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
596 |
for (my($r)=0; $r<@depth; $r++) { |
5 | 597 |
&antsOut($depth[$r]+$DZ/2, |
7 | 598 |
$elapsed[$r],$u[$r],$v[$r],$w[$r],$nsamp[$r], |
599 |
$dc_elapsed[$r],$dc_u[$r],$dc_v[$r],$dc_w[$r],$dc_nsamp[$r], |
|
600 |
$uc_elapsed[$r],$uc_u[$r],$uc_v[$r],$uc_w[$r],$uc_nsamp[$r]); |
|
6 | 601 |
} |
602 |
||
603 |
#====================================================================== |
|
604 |
# Output Averaged Shear Profile |
|
605 |
#====================================================================== |
|
606 |
||
607 |
if (defined($opt_s)) { |
|
7 | 608 |
@antsNewLayout = ('depth','elapsed','u_z','v_z','w_z','u_z.sig','v_z.sig','w_z.sig','nsamp', |
609 |
'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', |
|
610 |
'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 | 611 |
&antsOut('EOF'); |
612 |
close(STDOUT); |
|
613 |
open(STDOUT,">$opt_s") || croak("$opt_s: $!\n"); |
|
614 |
for (my($r)=0; $r<@depth; $r++) { |
|
7 | 615 |
&antsOut($depth[$r],$elapsed[$r],$uz[$r],$vz[$r],$wz[$r],$uzsig[$r],$vzsig[$r],$wzsig[$r],$nsamp[$r], |
616 |
$dc_elapsed[$r],$dc_uz[$r],$dc_vz[$r],$dc_wz[$r],$dc_uzsig[$r],$dc_vzsig[$r],$dc_wzsig[$r],$dc_nsamp[$r], |
|
617 |
$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 | 618 |
} |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
619 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
620 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
621 |
&antsExit(); |