author | A.M. Thurnherr <athurnherr@yahoo.com> |
Sun, 27 Jul 2014 16:28:57 -0400 | |
changeset 30 | 8697ba5a88ec |
child 31 | af03ca38fc2a |
permissions | -rw-r--r-- |
30
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
1 |
#====================================================================== |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
2 |
# L A D C P P R O C . S H E A R M E T H O D |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
3 |
# doc: Fri Sep 17 20:27:53 2010 |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
4 |
# dlm: Sun Jul 27 16:25:56 2014 |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
5 |
# (c) 2010 A.M. Thurnherr & E. Firing |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
6 |
# uE-Info: 314 0 NIL 0 0 72 2 2 4 NIL ofnI |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
7 |
#====================================================================== |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
8 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
9 |
# PERLified functions from E. Firing's [merge.c], modified by A.M. Thurnherr |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
10 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
11 |
# NOTES: |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
12 |
# - velocity integration removed |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
13 |
# - percent-good flag removed (no point for single-ping ensembles) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
14 |
# - need the following per-ensemble fields from previous steps: |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
15 |
# DEPTH |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
16 |
# CTD_SVEL |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
17 |
# - negative depths are not allowed (should not happen given DEPTH) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
18 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
19 |
# WEIRDNESSES IN ERIC'S CODE: |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
20 |
# - w reference layer in set_misc_flags is calculated without taking |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
21 |
# the ref layer bins into account |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
22 |
# - u,v ref lr vels in set_wake_flag use w ref layer bins |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
23 |
# - distance to bin 1 center is not sound-speed corrected [WEIRDNESS CORRECTED] |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
24 |
# - $tilt calculation is wrong. I do not understand this comment in 2014. |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
25 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
26 |
# HISTORY: |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
27 |
# Sep 17, 2010: - created |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
28 |
# Oct 13, 2010: - first working version |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
29 |
# Oct 14, 2010: - renamed from LADCPshear.UHcode |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
30 |
# Oct 15, 2010: - added support for -pPI edit suppresion |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
31 |
# Oct 19, 2010: - reversed semantics of -p |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
32 |
# Oct 25, 2010: - added W_CTD_BIT, renamed W_BIT to W_OUTLIER_BIT |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
33 |
# Oct 26, 2010: - added TILT_BIT |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
34 |
# Dec 10, 2010: - modified assertion to allow processing of UL data |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
35 |
# Jul 10, 2011: - added outTDseries() call |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
36 |
# Jul 12, 2011: - replaced -p by $PPI_editing_enabled flag |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
37 |
# Feb 19, 2012: - added elapsed time to binned shear output |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
38 |
# Apr 11, 2012: - added MISSING_CTD_DATA_BIT |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
39 |
# Sep 25, 2013: - added code to calc gridded lat/lon info |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
40 |
# Nov 12, 2013: - BUG: correlation editing removed most (all?) 3-beam |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
41 |
# solutions |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
42 |
# - BUG: set_shear_flag() calculated shdev (slightly?) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
43 |
# wrongly |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
44 |
# Mar 4, 2014: - added support for missing PITCH/ROLL (TILT) & HEADING |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
45 |
# Mar 21, 2014: - moved depthOfBin() to [LADCPproc.utils] |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
46 |
# Jul 15, 2014: - BUG: occasional missing w values were used in w_ref calc; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
47 |
# (potentially useless) tests for missing w were added wherever |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
48 |
# edit_flags is tested or w is used; this change greatly |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
49 |
# increase the number of shear samples available in case of |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
50 |
# DoMORE1 tow-yo#1 data |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
51 |
# - disabled two assertions about depths of shear bins, one of |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
52 |
# which was violated by DoMORE1 uplooker data (apparently |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
53 |
# valid data above the sea surface in the uplooker) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
54 |
# Jul 27, 2014: - renamed from [LADCPproc.UHmethod] because the code has |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
55 |
# diverged quite a bit from the original mplementation. However, |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
56 |
# the shear editing core remains as in the UH code |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
57 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
58 |
#====================================================================== |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
59 |
# VELOCITY EDITING |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
60 |
#====================================================================== |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
61 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
62 |
my($BADVEL_BIT) = 0x01; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
63 |
my($ERRVEL_BIT) = 0x02; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
64 |
my($CORREL_BIT) = 0x04; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
65 |
my($W_OUTLIER_BIT) = 0x08; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
66 |
my($SHEAR_BIT) = 0x10; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
67 |
my($SIDELOBE_BIT) = 0x20; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
68 |
my($WAKE_BIT) = 0x40; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
69 |
my($PPI_BIT) = 0x80; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
70 |
my($W_CTD_BIT) = 0x100; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
71 |
my($TILT_BIT) = 0x200; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
72 |
my($DELTA_TILT_BIT) = 0x400; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
73 |
my($MISSING_CTD_DATA_BIT) = 0x800; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
74 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
75 |
my(%flag_count); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
76 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
77 |
sub set_wake_flag($$) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
78 |
{ |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
79 |
my($ens,$De) = @_; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
80 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
81 |
my($n) = 0; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
82 |
my($uref) = my($vref) = my($wref) = 0; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
83 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
84 |
for (my($bin)=$wbin_start-1; $bin<$wbin_end; $bin++) { # calc crude ref lr vel from all data |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
85 |
next if ($edit_flags[$ens][$bin] || $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]==0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
86 |
$uref += $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U]; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
87 |
$vref += $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V]; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
88 |
$wref += $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
89 |
$n++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
90 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
91 |
return if ($n==0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
92 |
$uref /= $n; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
93 |
$vref /= $n; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
94 |
$wref /= $n; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
95 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
96 |
## if upward (=negative) velocity greater than minimum, calculate wake |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
97 |
## heading and inclination |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
98 |
if (defined($LADCP{ENSEMBLE}[$ens]->{HEADING}) && $wref<-$min_wake_w) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
99 |
my($wake_hd) = 180 / 3.14159265358979 * atan2($uref,$vref); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
100 |
my($speed) = sqrt($uref*$uref + $vref*$vref); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
101 |
my($wake_ang)= abs(180 / 3.14159265358979 * atan($speed/$wref)); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
102 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
103 |
$wake_hd += 360 |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
104 |
if ($wake_hd < 0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
105 |
$LADCP{ENSEMBLE}[$ens]->{HEADING} += 360 |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
106 |
if ($LADCP{ENSEMBLE}[$ens]->{HEADING} < 0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
107 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
108 |
my($wake_mod) = $wake_hd % 90; # % returns integer part of remainder, but that's sufficient |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
109 |
my($adcp_mod) = $LADCP{ENSEMBLE}[$ens]->{HEADING} % 90; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
110 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
111 |
if (((abs($wake_mod - $adcp_mod) < $wake_hd_dif) || |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
112 |
(abs($wake_mod - $adcp_mod) > (90 - $wake_hd_dif))) && |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
113 |
($wake_ang > $wake_ang_min)) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
114 |
for (my($bin)=0; $bin<$n_wake_bins; $bin++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
115 |
$flag_count{$WAKE_BIT}[$bin]++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
116 |
$edit_flags[$ens][$bin] |= $WAKE_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
117 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
118 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
119 |
} ## if ($wref < -min_wake_w) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
120 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
121 |
## This does not make a lot of sense, because it trims points |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
122 |
## on only one side of the wake error, and that side depends |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
123 |
## on whether the integration is forward or backward. |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
124 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
125 |
if (($edit_flags[$ens+$De][0]&$WAKE_BIT) && |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
126 |
($edit_flags[$ens][0]&$WAKE_BIT == 0)) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
127 |
for (my($bin)=0; $bin<$n_wake_bins; $bin++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
128 |
$flag_count{$WAKE_BIT}[$bin]++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
129 |
$edit_flags[$ens][$bin] |= $WAKE_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
130 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
131 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
132 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
133 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
134 |
sub set_misc_flags($$) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
135 |
{ |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
136 |
my($ens,$De) = @_; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
137 |
my($ww) = my($n) = 0; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
138 |
my($SLIfac) = 1 - cos(rad($LADCP{BEAM_ANGLE})); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
139 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
140 |
for (my($bin)=0; $bin<$w_ref_bin; $bin++) { # ref-lr w |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
141 |
next if ($edit_flags[$ens][$bin] || $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]==0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
142 |
$ww += $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
143 |
$n++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
144 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
145 |
$ww /= $n if ($n > 0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
146 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
147 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
148 |
next if ($edit_flags[$ens][$bin] || $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]==0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
149 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
150 |
## We use the standard criterion for bottom interference; e.g. for |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
151 |
## 30-degree beams, the last 15% of the profile is contaminated |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
152 |
## by the sidelobe bounce. 1.5 bin length is added to allow for |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
153 |
## the length of the bin and pulse, that is, contamination of part of a |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
154 |
## bin. Profiler tilt does not require a more stringent criterion. |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
155 |
if ($LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_DOWN}) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
156 |
if (numberp($water_depth) && |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
157 |
$water_depth - &depthOfBin($ens,$bin) <= |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
158 |
$SLIfac * ($water_depth - $LADCP{ENSEMBLE}[$ens]->{DEPTH}) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
159 |
+ 1.5 * $LADCP{BIN_LENGTH}) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
160 |
$edit_flags[$ens][$bin] |= $SIDELOBE_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
161 |
$flag_count{$SIDELOBE_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
162 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
163 |
} else { ## upward-looking |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
164 |
if (&depthOfBin($ens,$bin) <= |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
165 |
$SLIfac * $LADCP{ENSEMBLE}[$ens]->{DEPTH} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
166 |
+ 1.5 * $LADCP{BIN_LENGTH}) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
167 |
$edit_flags[$ens][$bin] |= $SIDELOBE_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
168 |
$flag_count{$SIDELOBE_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
169 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
170 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
171 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
172 |
if ($ww != 0 && |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
173 |
abs($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W] - $ww) > $w_dif) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
174 |
$flag_count{$W_OUTLIER_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
175 |
$edit_flags[$ens][$bin] |= $W_OUTLIER_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
176 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
177 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
178 |
if (abs($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$E]) > $e_max) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
179 |
$flag_count{$ERRVEL_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
180 |
$edit_flags[$ens][$bin] |= $ERRVEL_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
181 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
182 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
183 |
my($nBadCorr) = 0; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
184 |
for (my($beam)=0; $beam<=3; $beam++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
185 |
$nBadCorr++ |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
186 |
if ($LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin][$beam] < $min_cor); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
187 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
188 |
if (abs($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$E]) > 0) { # 4-beam solution |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
189 |
if ($nBadCorr > 0) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
190 |
$flag_count{$CORREL_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
191 |
$edit_flags[$ens][$bin] |= $CORREL_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
192 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
193 |
} else { # 3-beam solution |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
194 |
if ($nBadCorr > 1) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
195 |
$flag_count{$CORREL_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
196 |
$edit_flags[$ens][$bin] |= $CORREL_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
197 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
198 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
199 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
200 |
if ($bin < $shbin_start-1 || $bin >= $shbin_end) { # manually remove vels outside shear bin range |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
201 |
$edit_flags[$ens][$bin] |= $BADVEL_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
202 |
$flag_count{$BADVEL_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
203 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
204 |
} # for ($bin=0... |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
205 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
206 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
207 |
## The following is for editing out the second bottom bounce. |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
208 |
# - in the UH code, tilt = max(pitch,roll) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
209 |
# - using the real tilt (here) implies that PPI editing is too conservative |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
210 |
# in case of large tilts |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
211 |
# - since, however, the sound speed at the transducer is used instead |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
212 |
# of the mean soundspeed below the ADCP, the difference is unlikely |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
213 |
# to matter |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
214 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
215 |
sub set_PPI_flags($$) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
216 |
{ |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
217 |
my($ens,$De) = @_; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
218 |
my($clip_z0,$clip_z1); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
219 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
220 |
my($dt_ping) = $LADCP{ENSEMBLE}[$ens]->{UNIX_TIME} - $LADCP{ENSEMBLE}[$ens-1]->{UNIX_TIME}; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
221 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
222 |
if ($LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_DOWN}) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
223 |
if (numberp($water_depth)) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
224 |
$clip_z1 = $water_depth |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
225 |
- $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL}/2 * $dt_ping |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
226 |
* cos(rad($LADCP{BEAM_ANGLE} + $LADCP{ENSEMBLE}[$ens]->{TILT})) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
227 |
+ $clip_margin; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
228 |
$clip_z0 = $water_depth |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
229 |
- $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL}/2 * $dt_ping |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
230 |
* cos(rad($LADCP{BEAM_ANGLE} - $LADCP{ENSEMBLE}[$ens]->{TILT})) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
231 |
- $clip_margin; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
232 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
233 |
} else { # upward-looking |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
234 |
$clip_z1 = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL}/2 * $dt_ping |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
235 |
* cos(rad($LADCP{BEAM_ANGLE} - $LADCP{ENSEMBLE}[$ens]->{TILT})) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
236 |
+ $clip_margin; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
237 |
$clip_z0 = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL}/2 * $dt_ping |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
238 |
* cos(rad($LADCP{BEAM_ANGLE} + $LADCP{ENSEMBLE}[$ens]->{TILT})) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
239 |
- $clip_margin; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
240 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
241 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
242 |
for (my($bin)=$first_clip_bin-1; $bin<$LADCP{N_BINS}; $bin++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
243 |
next if ($edit_flags[$ens][$bin] || $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]==0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
244 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
245 |
my($dob) = depthOfBin($ens,$bin); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
246 |
if (!defined($LADCP{ENSEMBLE}[$ens]->{TILT}) || ($dob>=$clip_z0 && $dob<=$clip_z1)) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
247 |
$edit_flags[$ens][$bin] |= $PPI_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
248 |
$flag_count{$PPI_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
249 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
250 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
251 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
252 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
253 |
sub edit_velocity($$) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
254 |
{ |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
255 |
my($start,$end) = @_; # ensemble indices |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
256 |
my($De) = $start<$end ? 1 : -1; # downcast: De = 1; upcast: De = -1 |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
257 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
258 |
$flag_count{$WAKE_BIT} = $flag_count{$W_OUTLIER_BIT} = $flag_count{$ERRVEL_BIT} = |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
259 |
$flag_count{$CORREL_BIT} = $flag_count{$SHEAR_BIT} = $flag_count{$BADVEL_BIT} = |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
260 |
$flag_count{$SIDELOBE_BIT} = $flag_count{$PPI_BIT} = $flag_count{$W_CTD_BIT} = |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
261 |
$flag_count{$TILT_BIT} = $flag_count{$DELTA_TILT_BIT} = $flag_count{$MISSING_CTD_DATA_BIT} = 0; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
262 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
263 |
for (my($ens)=$start; $ens!=$end+$De; $ens+=$De) { # loop over all ens from start to end |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
264 |
next unless ($LADCP{ENSEMBLE}[$ens]->{W}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
265 |
if (abs($LADCP{ENSEMBLE}[$ens]->{CTD_W}-$LADCP{ENSEMBLE}[$ens]->{W}) > $w_max_err) { # get rid of aliased vels (ambiguity) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
266 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
267 |
$edit_flags[$ens][$bin] |= $W_CTD_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
268 |
$flag_count{$W_CTD_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
269 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
270 |
next; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
271 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
272 |
if (!defined($LADCP{ENSEMBLE}[$ens]->{TILT}) || |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
273 |
$LADCP{ENSEMBLE}[$ens]->{TILT}>$max_tilt) { # get rid ensembles with large tilt |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
274 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
275 |
$edit_flags[$ens][$bin] |= $TILT_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
276 |
$flag_count{$TILT_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
277 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
278 |
next; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
279 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
280 |
unless (numberp($LADCP{ENSEMBLE}[$ens]->{DEPTH}) && # get rid of ensembles with insufficient CTD info |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
281 |
numberp($LADCP{ENSEMBLE}[$ens]->{CTD_SVEL})) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
282 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
283 |
$edit_flags[$ens][$bin] |= $MISSING_CTD_DATA_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
284 |
$flag_count{$MISSING_CTD_DATA_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
285 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
286 |
next; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
287 |
} # get rid ensembles after large rotation |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
288 |
if (defined($LADCP{ENSEMBLE}[$ens]->{TILT}) && |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
289 |
defined($LADCP{ENSEMBLE}[$ens-$De]->{TILT}) && |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
290 |
abs($LADCP{ENSEMBLE}[$ens]->{TILT}-$LADCP{ENSEMBLE}[$ens-$De]->{TILT}) > $max_delta_tilt) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
291 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
292 |
$edit_flags[$ens][$bin] |= $DELTA_TILT_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
293 |
$flag_count{$DELTA_TILT_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
294 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
295 |
next; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
296 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
297 |
for (my($bin)=$shbin_start-1; $bin<$shbin_end; $bin++) { # flag bad velocities |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
298 |
$edit_flags[$ens][$bin] |= $BADVEL_BIT,$flag_count{$BADVEL_BIT}++ |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
299 |
unless defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
300 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
301 |
set_wake_flag($ens,$De); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
302 |
set_misc_flags($ens,$De); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
303 |
set_PPI_flags($ens,$De) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
304 |
if $PPI_editing_enabled && ($clip_margin > 0); # PPI editing is off by default |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
305 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
306 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
307 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
308 |
#============================================================================== |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
309 |
# CALCULATE VELOCITY SHEAR |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
310 |
# - final output in @ush_mu,@vsh_mu,@wsh_mu,@ush_sig,@vsh_sig,@wsh_sig |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
311 |
# NEW (ant): elapsed time output in @esh_mu |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
312 |
# lat/lon output in @lash_mu, @losh_mu |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
313 |
# - @sh_i0, @sh_i1, @dsh, @ush, @vsh, @wsh are defined "local" in &calc_shear |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
314 |
#============================================================================== |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
315 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
316 |
#---------------------------------------------------------------------- |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
317 |
# uv_to_shear(ens) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
318 |
# - sets @sh_i0, @sh_i1, @dsh, @ush, @vsh, @wsh for a given ensemble |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
319 |
#---------------------------------------------------------------------- |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
320 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
321 |
sub uv_to_shear($) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
322 |
{ |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
323 |
my($ens) = @_; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
324 |
my($nvel) = 0; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
325 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
326 |
@sh_i0 = @sh_i1 = (); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
327 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
328 |
next if ($edit_flags[$ens][$bin] || $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]==0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
329 |
$nvel++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
330 |
push(@sh_i1,$bin) if (@sh_i0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
331 |
push(@sh_i0,$bin) if ($bin < $LADCP{N_BINS}-1); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
332 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
333 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
334 |
@dsh = (); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
335 |
for (my($i)=0; $i<@sh_i1; $i++) { # calc and bin shears |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
336 |
my($d0) = &depthOfBin($ens,$sh_i0[$i]); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
337 |
my($d1) = &depthOfBin($ens,$sh_i1[$i]); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
338 |
next unless ($d0>=0 && $d1>=0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
339 |
# die("$0: assertion failed (ens=$ens i=$i depth=$LADCP{ENSEMBLE}[$ens]->{DEPTH} sh_i0[$i]=$sh_i0[$i] sh_i1[$i]=$sh_i1[$i] d0=$d0 d1=$d1)") |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
340 |
# unless ($d0>=0 && $d1>=0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
341 |
# die("$0: assertion failed (ens=$ens i=$i sh_i0[$i]=$sh_i0[$i] sh_i1[$i]=$sh_i1[$i] d0=$d0 d1=$d1)") |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
342 |
# unless (($LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_DOWN} && $d1-$d0>0) || |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
343 |
# ($LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP} && $d1-$d0<0)); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
344 |
$dsh[$i] = ($d1 + $d0) / 2; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
345 |
$ush[$i] = ($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$sh_i1[$i]][$U] - |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
346 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$sh_i0[$i]][$U]) / ($d1-$d0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
347 |
$vsh[$i] = ($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$sh_i1[$i]][$V] - |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
348 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$sh_i0[$i]][$V]) / ($d1-$d0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
349 |
$wsh[$i] = ($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$sh_i1[$i]][$W] - |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
350 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$sh_i0[$i]][$W]) / ($d1-$d0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
351 |
$ens[$i] = $ens; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
352 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
353 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
354 |
return $nvel; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
355 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
356 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
357 |
# here ush_mu, sh_n, etc are still set from the pre-gridding pass |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
358 |
sub set_shear_flag($) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
359 |
{ |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
360 |
my($ens) = @_; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
361 |
my(@ibad,@ush_dev,@vsh_dev); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
362 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
363 |
for (my($i)=0; $i<@dsh; $i++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
364 |
die("$0: assertion failed") unless numberp($dsh[$i]); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
365 |
my($bsgi) = int($dsh[$i] / $SHEAR_PREGRID_DZ); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
366 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
367 |
$ush_dev[$i] = $ush[$i] - $ush_mu[$bsgi]; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
368 |
$vsh_dev[$i] = $vsh[$i] - $vsh_mu[$bsgi]; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
369 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
370 |
push(@ibad,$i) if ($ush_sig[$i] > 0 && |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
371 |
(abs($ush_dev[$i]/$ush_sig[$i]) > $max_shdev || |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
372 |
abs($vsh_dev[$i]/$vsh_sig[$i]) > $max_shdev)); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
373 |
} ## end of loop through shears |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
374 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
375 |
## Look for internal glitches: a positive shear followed |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
376 |
## immediately by a compensating negative shear, for |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
377 |
## example. When one is found, flag the common velocity |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
378 |
## sample, and untag the two shears by setting each ibad |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
379 |
## to -1. |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
380 |
for (my($bi)=0; $bi<@ibad-1; $bi++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
381 |
next unless ($ibad[$bi]+1 == $ibad[$bi+1]); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
382 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
383 |
my($i) = $ibad[$bi]; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
384 |
my($bsgi) = int($dsh[$i] / $SHEAR_PREGRID_DZ); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
385 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
386 |
if ($ush_sig[$bsgi] > 0 && $vsh_sig[$bsgi] > 0 && |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
387 |
sqrt(($ush_dev[$i]+$ush_dev[$i+1])**2/$ush_sig[$bsgi]**2) < $max_shdev_sum && |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
388 |
sqrt(($vsh_dev[$i]+$vsh_dev[$i+1])**2/$vsh_sig[$bsgi]**2) < $max_shdev_sum) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
389 |
$flag_count{$SHEAR_BIT}++; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
390 |
$edit_flags[$ens][$sh_i1[$i]] |= $SHEAR_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
391 |
$ibad[$bi] = $ibad[$bi+1] = -1; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
392 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
393 |
} ## end of first loop through bad shears |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
394 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
395 |
## Now flag all remaining velocities involved in the shears |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
396 |
## listed by ibad. |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
397 |
for (my($bi)=0; $bi<@ibad; $bi++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
398 |
next if ($ibad[$bi] < 0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
399 |
$flag_count{$SHEAR_BIT} += 2; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
400 |
$edit_flags[$ens][$sh_i0[$ibad[$bi]]] |= $SHEAR_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
401 |
$edit_flags[$ens][$sh_i1[$ibad[$bi]]] |= $SHEAR_BIT; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
402 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
403 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
404 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
405 |
sub calc_shear($$$$) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
406 |
{ |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
407 |
my($start,$end,$grid_dz,$edit_shear) = @_; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
408 |
my($De) = $start<$end ? 1 : -1; # downcast: De = 1; upcast: De = -1 |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
409 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
410 |
local(@ush_vals,@vsh_vals,@wsh_vals,@ens_vals); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
411 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
412 |
my($nvel,$nsh) = (0,0); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
413 |
for (my($ens)=$start; $ens!=$end+$De; $ens+=$De) { # loop over all ens from start to end |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
414 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
415 |
local(@sh_i0,@sh_i1); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
416 |
local(@dsh,@ush,@vsh,@wsh,@ens); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
417 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
418 |
uv_to_shear($ens); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
419 |
if ($edit_shear) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
420 |
set_shear_flag($ens); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
421 |
$nvel += uv_to_shear($ens); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
422 |
$nsh += @dsh; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
423 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
424 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
425 |
for (my($i)=0; $i<@dsh; $i++) { # save shears for binning calculations |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
426 |
my($gi) = int($dsh[$i] / $grid_dz); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
427 |
push(@{$ush_vals[$gi]},$ush[$i]); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
428 |
push(@{$vsh_vals[$gi]},$vsh[$i]); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
429 |
push(@{$wsh_vals[$gi]},$wsh[$i]); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
430 |
push(@{$ens_vals[$gi]},$ens[$i]); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
431 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
432 |
} # $ens loop |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
433 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
434 |
outTDseries($De==1) if ($edit_shear); # output depth-time time series |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
435 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
436 |
@ush_mu = @vsh_mu = @wsh_mu = @esh_mu = @lash_mu = @losh_mu = (); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
437 |
@ush_sig = @vsh_sig = @wsh_sig = (); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
438 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
439 |
for (my($gi)=0; $gi<@ush_vals; $gi++) { # calc grid means & stddev |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
440 |
my($sum_ush,$sum_vsh,$sum_wsh,$sum_esh,$sum_lash,$sum_losh); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
441 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
442 |
$sh_n[$gi] = @{$ush_vals[$gi]}; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
443 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
444 |
for (my($vi)=0; $vi<$sh_n[$gi]; $vi++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
445 |
$sum_ush += $ush_vals[$gi][$vi]; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
446 |
$sum_vsh += $vsh_vals[$gi][$vi]; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
447 |
$sum_wsh += $wsh_vals[$gi][$vi]; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
448 |
$sum_esh += $LADCP{ENSEMBLE}[$ens_vals[$gi][$vi]]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
449 |
$sum_lash += $LADCP{ENSEMBLE}[$ens_vals[$gi][$vi]]->{CTD_LAT}; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
450 |
$sum_losh += $LADCP{ENSEMBLE}[$ens_vals[$gi][$vi]]->{CTD_LON}; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
451 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
452 |
$ush_mu[$gi] = $sh_n[$gi] ? $sum_ush/$sh_n[$gi] : nan; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
453 |
$vsh_mu[$gi] = $sh_n[$gi] ? $sum_vsh/$sh_n[$gi] : nan; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
454 |
$wsh_mu[$gi] = $sh_n[$gi] ? $sum_wsh/$sh_n[$gi] : nan; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
455 |
$esh_mu[$gi] = $sh_n[$gi] ? $sum_esh/$sh_n[$gi] : nan; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
456 |
$lash_mu[$gi] = $sh_n[$gi] ? $sum_lash/$sh_n[$gi] : nan; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
457 |
$losh_mu[$gi] = $sh_n[$gi] ? $sum_losh/$sh_n[$gi] : nan; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
458 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
459 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
460 |
for (my($gi)=0; $gi<@ush_vals; $gi++) { # calc & grid stddevs |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
461 |
my($sumsq_ush,$sumsq_vsh,$sumsq_wsh); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
462 |
for (my($vi)=0; $vi<$sh_n[$gi]; $vi++) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
463 |
$sumsq_ush += ($ush_vals[$gi][$vi] - $ush_mu[$gi])**2; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
464 |
$sumsq_vsh += ($vsh_vals[$gi][$vi] - $vsh_mu[$gi])**2; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
465 |
$sumsq_wsh += ($wsh_vals[$gi][$vi] - $wsh_mu[$gi])**2; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
466 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
467 |
$ush_sig[$gi] = $sh_n[$gi]>1 ? sqrt($sumsq_ush/($sh_n[$gi]-1)) : nan; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
468 |
$vsh_sig[$gi] = $sh_n[$gi]>1 ? sqrt($sumsq_vsh/($sh_n[$gi]-1)) : nan; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
469 |
$wsh_sig[$gi] = $sh_n[$gi]>1 ? sqrt($sumsq_wsh/($sh_n[$gi]-1)) : nan; |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
470 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
471 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
472 |
if ($edit_shear && $opt_d) { |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
473 |
print(STDERR "\n\t\t$nvel valid velocities"); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
474 |
print(STDERR "\n\t\t$nsh valid shears"); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
475 |
print(STDERR "\n\t\tflag counts:"); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
476 |
print(STDERR "\n\t\t\tBADVEL_BIT = $flag_count{$BADVEL_BIT}") |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
477 |
if ($flag_count{$BADVEL_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
478 |
print(STDERR "\n\t\t\tERRVEL_BIT = $flag_count{$ERRVEL_BIT}") |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
479 |
if ($flag_count{$ERRVEL_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
480 |
print(STDERR "\n\t\t\tCORREL_BIT = $flag_count{$CORREL_BIT}") |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
481 |
if ($flag_count{$W_OUTLIER_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
482 |
print(STDERR "\n\t\t\tW_OUTLIER_BIT = $flag_count{$W_OUTLIER_BIT}") |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
483 |
if ($flag_count{$W_OUTLIER_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
484 |
print(STDERR "\n\t\t\tSHEAR_BIT = $flag_count{$SHEAR_BIT}") |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
485 |
if ($flag_count{$SIDELOBE_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
486 |
print(STDERR "\n\t\t\tSIDELOBE_BIT = $flag_count{$SIDELOBE_BIT}") |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
487 |
if ($flag_count{$SIDELOBE_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
488 |
print(STDERR "\n\t\t\tWAKE_BIT = $flag_count{$WAKE_BIT}") |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
489 |
if ($flag_count{$WAKE_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
490 |
print(STDERR "\n\t\t\tPPI_BIT = $flag_count{$PPI_BIT}") |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
491 |
if ($flag_count{$PPI_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
492 |
printf(STDERR "\n\t\t\tW_CTD_BIT = $flag_count{$W_CTD_BIT} (%d ensembles)", |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
493 |
$flag_count{$W_CTD_BIT}/$LADCP{N_BINS}) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
494 |
if ($flag_count{$W_CTD_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
495 |
printf(STDERR "\n\t\t\tTILT_BIT = $flag_count{$TILT_BIT} (%d ensembles)", |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
496 |
$flag_count{$TILT_BIT}/$LADCP{N_BINS}) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
497 |
if ($flag_count{$TILT_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
498 |
printf(STDERR "\n\t\t\tDELTA_TILT_BIT = $flag_count{$DELTA_TILT_BIT} (%d ensembles)", |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
499 |
$flag_count{$DELTA_TILT_BIT}/$LADCP{N_BINS}) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
500 |
if ($flag_count{$DELTA_TILT_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
501 |
printf(STDERR "\n\t\t\tMISSING_CTD_DATA_BIT = $flag_count{$MISSING_CTD_DATA_BIT} (%d ensembles)", |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
502 |
$flag_count{$MISSING_CTD_DATA_BIT}/$LADCP{N_BINS}) |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
503 |
if ($flag_count{$MISSING_CTD_DATA_BIT}); |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
504 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
505 |
} |
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
506 |
|
8697ba5a88ec
before beginning to add code to calculate package velocity
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
507 |
1; |