author | A.M. Thurnherr <athurnherr@yahoo.com> |
Sun, 02 Dec 2012 10:55:46 +0000 | |
changeset 11 | 9e5eba6992f7 |
parent 10 | 7e76fdef8953 |
child 12 | 2adcd220b9b4 |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/perl |
2 |
#====================================================================== |
|
3 |
# L A D C P _ W |
|
4 |
# doc: Fri Dec 17 18:11:13 2010 |
|
11 | 5 |
# dlm: Wed Oct 17 12:03:12 2012 |
0 | 6 |
# (c) 2010 A.M. Thurnherr |
11 | 7 |
# uE-Info: 121 63 NIL 0 0 72 2 2 4 NIL ofnI |
0 | 8 |
#====================================================================== |
9 |
||
10 |
# TODO: |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
11 |
# detection so that editing stats make sense |
2 | 12 |
# - own seabed detection (P403) |
13 |
# - make upcast-flag valid for yoyo casts |
|
14 |
# - make diagnostic output 3-beam field work for Earth coordinates |
|
15 |
# - remove water-depth from BT code, which is not really used and a bit of an outlier |
|
16 |
# because mean and stddev are used instead of median/mad |
|
6 | 17 |
# - read assumed ADCP soundspeed from data file, instead of assuming 1500m/s |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
18 |
# ? use instrument tilt in sidelobe editing? |
0 | 19 |
|
20 |
$antsSummary = 'calculate vertical velocities from LADCP & CTD time series'; |
|
21 |
||
22 |
# HISTORY: |
|
23 |
# Dec 17, 2010: - created from [mergeCTD+LADCP] |
|
24 |
# Dec 18, 2010: - made to work |
|
25 |
# Dec 19, 2010: - improved considerably |
|
26 |
# Dec 20, 2010: - onward |
|
27 |
# - BUG: depth-binning was off by 1 bin?! |
|
28 |
# - added binning correction for instrument tilt |
|
29 |
# Dec 21, 2010: - added -h (seafloor depth) |
|
30 |
# Dec 22, 2010: - BUG: had not applied soundspeed-correction to w |
|
31 |
# - debugged opt_d |
|
32 |
# Dec 23, 2010: - continued implementation of soundspeed corrections |
|
33 |
# Dec 24, 2010: - added winch_w, wave_w |
|
34 |
# - removed beampair velocities from code |
|
35 |
# Dec 25, 2010: - adapted for surface-wave correction in terms of acceleration (CTD_w_t) |
|
36 |
# - removed elapsed_mismatch |
|
37 |
# - removed winch_w, wave_w |
|
38 |
# Dec 26, 2010: - made -p output layout independent of -x to avoid Makefile problems |
|
39 |
# Dec 30, 2010: - cleaned up some |
|
40 |
# - folded-in backscatter calculation from shear method |
|
41 |
# - folded-in BT calculation from shear method |
|
42 |
# Dec 31, 2010: - added weighted mean w profile to output |
|
43 |
# Jan 2, 2010: - BUG: BT_w.mad could bomb with division by 0 |
|
44 |
# - BUG: division by zero if no valid data |
|
45 |
# Jan 5, 2010: - adapted to allow for gaps in CTD time series |
|
1 | 46 |
# Feb 16, 2011: - cosmetics |
2 | 47 |
# Jun 22, 2011: - cosmetics |
48 |
# Jun 23, 2011: - disabled error on large rms reflr w |
|
49 |
# - added -l |
|
50 |
# - removed CTD headers from output |
|
51 |
# Jun 26, 2011: - added -u |
|
52 |
# - changed package correction from acceleration to velocity, because of |
|
53 |
# Stan's Antarctic data set where accelerations are zero but package effects are |
|
54 |
# there |
|
55 |
# Jul 2, 2011: - increased tilt default to 15 degrees |
|
56 |
# Jul 3, 2011: - replaced old package-velocity correction -x code by new beamvel correction |
|
57 |
# - removed -p |
|
58 |
# - replaced -d by residual (diagnostics) output |
|
59 |
# Jul 4, 2011: - saved a snapshot in [Jul_04_2011] |
|
60 |
# - removed output of binned profile (but not calculation code, which is required for residual) |
|
61 |
# - BUG: firstGoodEns or lastGoodEns could end up in a reflr_w gap when valid LADCP data begin |
|
62 |
# or end with CTD in water |
|
63 |
# - moved rarely used option -s to -k |
|
64 |
# - added -s)kip <ens> option |
|
65 |
# - had to very very slightly relax an assertion (by 1e-10 seconds...) |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
66 |
# Aug 3, 2011: - added -z)ap to truncate range, based on Stan's 2009 data set (017-019 most clearly) |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
67 |
# obs that final 2 velocities are outliers; could be due to color bar, should check with |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
68 |
# residuals |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
69 |
# Sep 22, 2011: - removed (commented out) CTD acceleration |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
70 |
# - added basename to Parameter File Matching |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
71 |
# Sep 23, 2011: - cosmetics (lots) |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
72 |
# - added -d) |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
73 |
# Oct 6, 2011: - removed old commented-out code (CTD acceleration & old -x) |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
74 |
# - renamed time-series field names |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
75 |
# - added uncorrected reflr w to time-series output |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
76 |
# Oct 10, 2011: - BUG: LADCP_w in .tds output had not been soundspeed corrected |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
77 |
# - removed -x |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
78 |
# - added "false-positives" editing filter |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
79 |
# Oct 11, 2011: - adapted to the new parameter file, removing a few options |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
80 |
# Oct 12, 2011: - added surface-layer editing |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
81 |
# - made %min/max_depth/elapsed more accurate |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
82 |
# Oct 13, 2011: - fiddled |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
83 |
# Oct 14, 2011: - renamed .prof fields from .N to .nsamp |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
84 |
# - added %output_basename |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
85 |
# - removed all ">" from open to allow use in pipelines |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
86 |
# - made <run-label> argument optional |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
87 |
# - replaced stdout output by $w_out |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
88 |
# - renamed _out to out_; output_basename to out_basename |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
89 |
# Oct 15, 2011: - added editWOutliers() |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
90 |
# - added step to remove single-ping noise |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
91 |
# Oct 16, 2011: - BUG: ensemble and bin numbers in output files were off by 1 |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
92 |
# Oct 17, 2011: - added default run label |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
93 |
# - added out_BR |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
94 |
# - BUG: closed STDOUT caused problems with tee in plotting scripts |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
95 |
# - added %run_label |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
96 |
# - added PostProcess.sh |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
97 |
# Oct 18, 2011: - BUG: %{min,max}_ens used ensemble indices, rather than numbers |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
98 |
# - disabled false-positives editing (removes too much good data on 2011_IWISE) |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
99 |
# Oct 19, 2011: - BUG: time-series output included ensembles without valid w |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
100 |
# - increased post-process sleep time to 30s |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
101 |
# - added corr, Sv and echo_amplitude as new fields to w output |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
102 |
# Oct 20, 2011: - added editFarBins() |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
103 |
# - added downcast flag to time-series output |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
104 |
# - added ensemble number to LADCP-time-series output |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
105 |
# Oct 21, 2011: - BUG: Sv code was not enabled for uplooker data |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
106 |
# Oct 24, 2011: - added code to copy %lat/%lon from CTD data |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
107 |
# - added %ADCP_freuquency, %ADCP_blanking_distance |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
108 |
# - %LADCP_bin_length => %ADCP_bin_length |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
109 |
# Oct 26, 2011: - added $first_guess_timelag |
6 | 110 |
# Oct 27, 2011: - added w12, w34, ww (pitch/roll-weighted average) to full output |
111 |
# - removed ww because it apparently does not improve the solutions |
|
112 |
# - moved editTilt() to after time-series calculation to allow |
|
113 |
# time matching to work even with strict tilt limit |
|
114 |
# - added correctAttitude() |
|
10
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
115 |
# May 22, 2012: - adapted to ANTS V5 |
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
116 |
# Oct 15, 2012: - added $edit_data_hook |
11 | 117 |
#--- hg commit |
118 |
# - separated dc/uc time lagging |
|
119 |
# - removed support for TLhist |
|
120 |
# Oct 16, 2012: - added support for dc/uc only solutions |
|
121 |
# Oct 17, 2012: - renamed $edit_data_hook to $post_merge_hook |
|
0 | 122 |
|
123 |
# CTD REQUIREMENTS |
|
124 |
# - elapsed elapsed seconds; see note below |
|
125 |
# - depth |
|
126 |
# - ss sound speed |
|
127 |
# - w ddepth/dt |
|
128 |
# - temp OPTIONAL; used for backscatter calculation (i.e. not very important) |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
129 |
# - %lat/%lon OPTIONAL |
0 | 130 |
|
131 |
# NUMERICAL OPTIONS |
|
132 |
# - the first option in the list cannot be numerical! |
|
133 |
# - if need be, use -v 1 as a dummy option |
|
134 |
||
135 |
# ELAPSED TIMES |
|
136 |
# - there are 2 different elapsed times used in this program: |
|
137 |
# 1) elapsed based on firstgoodens in the LADCP time series |
|
138 |
# 2) CTD elapsed time |
|
139 |
# - CTD elapsed time does not have to start with zero! |
|
140 |
# - do not use the Seabird elapsed field, which is only reported to |
|
141 |
# 3 significant digits, causing significant jitter in dt; however, |
|
142 |
# at least up to 2010 Seabird simply calculates elapsed time by |
|
143 |
# assuming a 24Hz sampling rate and no record drop; therefore, |
|
144 |
# it is best to calculate elapsed time as %RECNO/24 |
|
145 |
# - the elapsed field of the output is the elapsed time from the CTD |
|
146 |
# file; this is required in order to be able to compare the times |
|
147 |
# from the uplooker and downlooker-derived vertical velocity |
|
148 |
# profiles |
|
11 | 149 |
# - the .TL files use the LADCP elapsed time in output; as a result, |
150 |
# the DL/UL .TL files have different time axes! |
|
0 | 151 |
# - as a result, a profile only starts with elapsed==0 if the CTD |
152 |
# is turned on when the LADCP is already in the water |
|
153 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
154 |
# OUTPUT NOTES |
2 | 155 |
# - residuals are calculated with respect to down-/upcast medians in binned profiles |
156 |
# - equivalence, assuming -o 10: |
|
157 |
# 1) 004DL.prof dc_w depth |
|
6 | 158 |
# 2) bindata -Sdowncast:1 -Fw.median,depth -n 20 depth 10 004DL.w |
2 | 159 |
|
0 | 160 |
# VELOCITY AMBIGUITY ERRORS |
161 |
# - quite extensive tests with DIMES US2 station 146, which has a lot of |
|
162 |
# ambiguity velocity errors, reveal that -m 1 catches those errors |
|
163 |
# quite nicely |
|
164 |
# - even when the errors are not filtered with -m 1, they do not |
|
165 |
# affect the w profiles, as long as the median bin values are used |
|
166 |
||
167 |
($WCALC) = ($0 =~ m{^(.*)/[^/]*$}); |
|
10
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
168 |
($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$}); |
0 | 169 |
($PERL_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$}); |
170 |
||
171 |
require "$ANTS/ants.pl"; |
|
172 |
require "$ANTS/libstats.pl"; |
|
173 |
require "$WCALC/edit_data.pl"; |
|
174 |
require "$WCALC/time_series.pl"; |
|
175 |
require "$WCALC/time_lag.pl"; |
|
176 |
require "$WCALC/find_seabed.pl"; |
|
177 |
require "$WCALC/svel_corrections.pl"; |
|
178 |
require "$WCALC/acoustic_backscatter.pl"; |
|
179 |
require "$WCALC/bottom_tracking.pl"; |
|
180 |
require "$PERL_TOOLS/RDI_BB_Read.pl"; |
|
181 |
require "$PERL_TOOLS/RDI_Coords.pl"; |
|
182 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
183 |
use IO::Handle; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
184 |
|
6 | 185 |
my($TINY) = 1e-16; |
186 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
187 |
#------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
188 |
# Usage |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
189 |
#------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
190 |
|
2 | 191 |
@ARGS = @ARGV; # save opts & arguments |
192 |
||
0 | 193 |
$antsParseHeader = 0; |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
194 |
&antsUsage('3:4a:b:c:e:g:h:i:k:m:n:o:qs:t:uv:w:x:',1, |
0 | 195 |
'[-v)erbosity <level[1]>]', |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
196 |
'[-q)uick (no single-ping denoising)]', |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
197 |
'[require -4)-beam solutions]', |
0 | 198 |
'[-c)orrelation <min[70]>] [-t)ilt <max[10deg]> [-e)rr-vel <max[0.1m/s]>]', |
199 |
'[-h water <depth>]', |
|
200 |
'[max LADCP time-series -g)ap <length[60s]>]', |
|
201 |
'[-m)ax vertical <velocity[1m/s]>', |
|
202 |
'[-a)djust CTD depth <by[0m]>]', |
|
2 | 203 |
'[-i)nitial CTD time offset <guestimate> [-u)se as final]]', |
0 | 204 |
'[calculate -n) <lags,lags[10,100]>] [lag -w)indow <sz,sz[240s,20s]>]', |
205 |
'[require top-3) lags to account for <frac[0.6]> of all]', |
|
206 |
'[valid LADCP -b)ins <bin[2],bin[*]>', |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
207 |
'[-o)utput bin <resolution[10m]>] [-k) require <min[20]> samples]', |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
208 |
'[e-x)ecute <perl-expr>]', |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
209 |
'<station-id> [run-label]'); |
0 | 210 |
|
2 | 211 |
&antsUsageError() if ($opt_u && !defined($opt_i)); |
212 |
||
213 |
&antsCardOpt(\$opt_s,0); # skip # initial ensembles |
|
214 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
215 |
$STN = &antsCardArg(); # station id |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
216 |
if (@ARGV) { # run label |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
217 |
$RUN = $ARGV[0]; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
218 |
shift; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
219 |
} else { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
220 |
$RUN = 'default'; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
221 |
} |
0 | 222 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
223 |
#----------------------------- |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
224 |
# Handle Processing Parameters |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
225 |
#----------------------------- |
0 | 226 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
227 |
require "$WCALC/defaults.pl"; # load default/option parameters |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
228 |
require "$processing_param_file"; # load processing parameters |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
229 |
eval($opt_x) if defined($opt_x); # eval cmd-line expression to override anything |
0 | 230 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
231 |
croak("$0: \$out_basename undefined\n") # all plotting routines use this |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
232 |
unless defined($out_basename); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
233 |
&antsAddParams('out_basename',$out_basename); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
234 |
&antsAddParams('run_label',$RUN); |
0 | 235 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
236 |
$out_w = ">$out_w" unless ($out_w =~ /^$|^\s*\|/); # make sure O_CREAT is set unless it's a pipe |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
237 |
$out_BR = ">$out_BR" unless ($out_BR =~ /^$|^\s*\|/); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
238 |
$out_TL = ">$out_TL" unless ($out_TL =~ /^$|^\s*\|/); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
239 |
$out_LADCPtis = ">$out_LADCPtis" unless ($out_LADCPtis =~ /^$|^\s*\|/); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
240 |
$out_profile = ">$out_profile" unless ($out_profile =~ /^$|^\s*\|/); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
241 |
$out_timeseries = ">$out_timeseries" unless ($out_timeseries =~ /^$|^\s*\|/); |
2 | 242 |
|
0 | 243 |
#---------------------------------------------------------------------- |
244 |
# Screen Logging |
|
245 |
# - warning levels: |
|
246 |
# 0 probably unimportant, e.g. nonsensical parameters that probably won't affect solution |
|
247 |
# 1 may be somewhat important |
|
248 |
# 2 important |
|
249 |
#---------------------------------------------------------------------- |
|
250 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
251 |
open(LOGF,">$out_log") || croak("$out_log: $!\n") |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
252 |
if defined($out_log); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
253 |
LOGF->autoflush(1); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
254 |
|
0 | 255 |
sub progress(@) |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
256 |
{ |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
257 |
printf(LOGF @_) if defined($out_log); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
258 |
printf(STDERR @_) if ($verbosity_level > 1); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
259 |
} |
0 | 260 |
|
261 |
sub info(@) |
|
262 |
{ |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
263 |
printf(LOGF "\t",@_) if defined($out_log); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
264 |
print(STDERR ($verbosity_level > 1) ? "\t" : "$LADCP_file: "); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
265 |
printf(STDERR @_) if ($verbosity_level > 0); |
0 | 266 |
} |
267 |
||
268 |
sub warning(@) |
|
269 |
{ |
|
270 |
my($lvl,@msg) = @_; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
271 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
272 |
if (defined($out_log)) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
273 |
print(LOGF "\nWARNING (level $lvl): "); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
274 |
printf(LOGF @msg); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
275 |
print(LOGF "\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
276 |
} |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
277 |
return if ($verbosity_level == 0); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
278 |
print(STDERR "\n") if ($verbosity_level > 1); |
0 | 279 |
print(STDERR "WARNING (level $lvl): "); |
280 |
printf(STDERR @msg); |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
281 |
print(STDERR "\n") if ($verbosity_level > 1); |
0 | 282 |
} |
283 |
||
284 |
sub debugmsg(@) |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
285 |
{ printf(STDERR @_) if ($verbosity_level > 2); } |
0 | 286 |
|
287 |
#---------------- |
|
288 |
# Read LADCP data |
|
289 |
#---------------- |
|
290 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
291 |
progress("Reading LADCP data from <$LADCP_file>...\n"); |
0 | 292 |
readData($LADCP_file,\%LADCP); |
293 |
progress("\t%d ensembles\n",scalar(@{$LADCP{ENSEMBLE}})); |
|
294 |
||
295 |
croak("$LADCP_file: not enough LADCP bins ($LADCP{N_BINS}) for choice of -r\n") |
|
296 |
unless ($LADCP{N_BINS} >= $refLr_lastBin); |
|
297 |
||
298 |
croak("$0: first reference-layer bin outside valid range\n") |
|
299 |
unless ($refLr_firstBin>=1 && $refLr_firstBin<=$LADCP{N_BINS}); |
|
300 |
croak("$0: last reference-layer bin outside valid range\n") |
|
301 |
unless ($refLr_lastBin>=1 && $refLr_lastBin<=$LADCP{N_BINS}); |
|
302 |
croak("$0: first reference-layer bin > last reference-layer bin\n") |
|
303 |
unless ($refLr_firstBin <= $refLr_lastBin); |
|
304 |
||
305 |
$LADCP_lastBin = $LADCP{N_BINS}-1 |
|
306 |
if ($LADCP_lastBin eq '*'); |
|
307 |
croak("$0: first valid LADCP bin outside valid range\n") |
|
308 |
unless ($LADCP_firstBin>=1 && $LADCP_firstBin<=$LADCP{N_BINS}); |
|
309 |
croak("$0: last valid LADCP bin outside valid range\n") |
|
310 |
unless ($LADCP_lastBin>=1 && $LADCP_lastBin<=$LADCP{N_BINS}); |
|
311 |
croak("$0: first valid LADCP bin > last valid LADCP bin\n") |
|
312 |
unless ($LADCP_firstBin <= $LADCP_lastBin); |
|
313 |
||
314 |
warning(0,"first reference-layer bin < first valid LADCP bin\n") |
|
315 |
unless ($refLr_firstBin >= $LADCP_firstBin); |
|
316 |
warning(0,"last reference-layer bin > last valid LADCP bin\n") |
|
317 |
unless ($refLr_lastBin <= $LADCP_lastBin); |
|
318 |
||
319 |
warning(1,"if at all, bin 1 should not be used for short blank-after-transmit values\n") |
|
320 |
if ($LADCP{BLANKING_DISTANCE}<$LADCP{BIN_LENGTH} && $refLr_firstBin==1); |
|
321 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
322 |
&antsAddParams('ADCP_bin_length',$LADCP{BIN_LENGTH}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
323 |
'ADCP_frequency',$LADCP{BEAM_FREQUENCY}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
324 |
'ADCP_blanking_distance',$LADCP{BLANKING_DISTANCE}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
325 |
|
0 | 326 |
#------------------------------------------------------------ |
327 |
# Edit beam-velocity data |
|
328 |
# 1) correlation threshold |
|
329 |
#------------------------------------------------------------ |
|
330 |
||
331 |
if ($LADCP{BEAM_COORDINATES}) { |
|
332 |
progress("Editing beam-velocity data...\n"); |
|
333 |
$nvv = $cte = 0; |
|
334 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
6 | 335 |
correctAttitude($ens,$pitch_bias,$roll_bias,$heading_bias); |
0 | 336 |
$nvv += countValidBeamVels($ens); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
337 |
$cte += editCorr($ens,$min_correlation); |
6 | 338 |
# $pte += editTilt($ens,$max_tilt); |
0 | 339 |
} |
340 |
croak("$LADCP_file: no valid data\n") unless ($nvv > 0); |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
341 |
progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$min_correlation,$cte,round(100*$cte/$nvv)); |
6 | 342 |
# progress("\tattitude threshold (-t %d deg): %d velocites removed (%d%% of total)\n",$max_tilt,$pte,round(100*$pte/$nvv)); |
0 | 343 |
} else { |
344 |
progress("Editing velocity data...\n"); |
|
345 |
$nvv = $cte = 0; |
|
346 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
347 |
$nvv += countValidBeamVels($ens); |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
348 |
$cte += editCorr_Earthcoords($ens,$min_correlation); |
6 | 349 |
# $pte += editTilt($ens,$max_tilt); |
0 | 350 |
} |
351 |
croak("$LADCP_file: no valid data\n") unless ($nvv > 0); |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
352 |
progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$min_correlation,$cte,round(100*$cte/$nvv)); |
6 | 353 |
# progress("\tattitude threshold (-t %d deg): %d velocites removed (%d%% of total)\n",$max_tilt,$pte,round(100*$pte/$nvv)); |
0 | 354 |
} |
355 |
||
356 |
#------------------------------------------------------------------- |
|
357 |
# Calculate earth velocities |
|
358 |
# - this is done for all bins (not just valid ones), to allow |
|
359 |
# useless possibility that invalid bins are used for reflr calcs |
|
360 |
# - also calculate separate beam-pair velocities |
|
361 |
# - the UNEDITED velocities are saved for the BT calculations |
|
362 |
# (W is required, U & V are only used for stats that have not |
|
363 |
# been very useful so far) |
|
364 |
#------------------------------------------------------------------- |
|
365 |
||
366 |
if ($LADCP{BEAM_COORDINATES}) { |
|
6 | 367 |
my($dummy); |
0 | 368 |
progress("Calculating earth-coordinate velocities...\n"); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
369 |
progress("\tdiscarding velocities from beam $discard_velocities_from_beam\n") |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
370 |
if ($discard_velocities_from_beam); |
0 | 371 |
$nvw = 0; |
372 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
373 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
374 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$discard_velocities_from_beam-1]) |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
375 |
if ($discard_velocities_from_beam); |
0 | 376 |
($LADCP{ENSEMBLE}[$ens]->{U}[$bin], |
377 |
$LADCP{ENSEMBLE}[$ens]->{V}[$bin], |
|
378 |
$LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
|
379 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin]) = |
|
380 |
velInstrumentToEarth(\%LADCP,$ens, |
|
381 |
velBeamToInstrument(\%LADCP, |
|
382 |
@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]})); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
383 |
if (defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin])) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
384 |
$per_bin_nsamp[$bin]++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
385 |
$nvw++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
386 |
} |
0 | 387 |
$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH} = |
388 |
gimbal_pitch($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
|
389 |
$LADCP{ENSEMBLE}[$ens]->{U_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{U}[$bin]; |
|
390 |
$LADCP{ENSEMBLE}[$ens]->{V_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{V}[$bin]; |
|
391 |
$LADCP{ENSEMBLE}[$ens]->{W_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin]; |
|
6 | 392 |
|
393 |
($dummy,$LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
|
394 |
$dummy,$LADCP{ENSEMBLE}[$ens]->{W34}[$bin]) = |
|
395 |
velBeamToBPEarth(\%LADCP,$ens,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}); |
|
0 | 396 |
} |
397 |
} |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
398 |
progress("\t$nvw valid velocities in bins $LADCP_firstBin-$LADCP_lastBin\n"); |
0 | 399 |
progress("\t3-beam solutions : $RDI_Coords::threeBeam_1 " . |
400 |
"$RDI_Coords::threeBeam_2 " . |
|
401 |
"$RDI_Coords::threeBeam_3 " . |
|
402 |
"$RDI_Coords::threeBeam_4\n") |
|
403 |
unless ($opt_4); |
|
6 | 404 |
} else { # Earth Coordinates |
0 | 405 |
progress("Counting valid vertical velocities...\n"); |
406 |
$nvw = 0; |
|
407 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
408 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
409 |
($LADCP{ENSEMBLE}[$ens]->{U}[$bin], |
|
410 |
$LADCP{ENSEMBLE}[$ens]->{V}[$bin], |
|
411 |
$LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
|
412 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin]) = @{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
413 |
if (defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin])) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
414 |
$per_bin_nsamp[$bin]++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
415 |
$nvw++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
416 |
} |
0 | 417 |
$LADCP{ENSEMBLE}[$ens]->{U_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{U}[$bin]; |
418 |
$LADCP{ENSEMBLE}[$ens]->{V_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{V}[$bin]; |
|
419 |
$LADCP{ENSEMBLE}[$ens]->{W_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin]; |
|
420 |
} |
|
421 |
} |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
422 |
progress("\t$nvw valid velocities in bins $LADCP_firstBin-$LADCP_lastBin\n"); |
0 | 423 |
} |
424 |
||
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
425 |
croak("$LADCP_file: insufficient valid velocities\n") unless ($nvw > 1000); |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
426 |
|
0 | 427 |
#---------------------------------------------- |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
428 |
# STEP: Edit earth-coordinate -velocity data |
0 | 429 |
# 1) error-velocity threshold |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
430 |
# 2) vertical-velocity outliers |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
431 |
# 3) truncate range by deleting farthest valid velocities (disbled by default) |
0 | 432 |
#---------------------------------------------- |
433 |
||
434 |
progress("Editing earth-coordinate velocity data...\n"); |
|
435 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
436 |
$evrm = $trrm = $worm = 0; |
0 | 437 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
438 |
$evrm += editErrVel($ens,$max_allowed_errvel); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
439 |
$worm += editWOutliers($ens,$per_ens_outliers_mad_limit); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
440 |
$trrm += editTruncRange($ens,$truncate_farthest_valid_bins) if ($truncate_farthest_valid_bins > 0); |
0 | 441 |
} |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
442 |
progress("\terror-velocity threshold (-e %.1f m/s): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n", |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
443 |
$max_allowed_errvel,$evrm,round(100*$evrm/$nvw)); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
444 |
progress("\tvertical-velocity outliers ($per_ens_outliers_mad_limit x mad): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n", |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
445 |
$worm,round(100*$worm/$nvw)); |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
446 |
progress("\trange truncation (-z %d bins): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n", |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
447 |
$truncate_farthest_valid_bins,$trrm,round(100*$trrm/$nvw)) |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
448 |
if ($truncate_farthest_valid_bins > 0); |
0 | 449 |
|
450 |
#---------------------------- |
|
451 |
# Calculate LADCP time series |
|
452 |
#---------------------------- |
|
453 |
||
454 |
progress("Calculating LADCP time-series...\n"); |
|
455 |
||
456 |
($firstGoodEns,$lastGoodEns,$LADCP_atbottom,$LADCP_w_gap_time) = |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
457 |
calcLADCPts(\%LADCP,$opt_s,$refLr_firstBin,$refLr_lastBin,$max_LADCP_reflr_vel_gap); |
0 | 458 |
croak("$LADCP_file: no good ensembles\n") |
459 |
unless defined($firstGoodEns) && ($lastGoodEns-$firstGoodEns > 0); |
|
460 |
||
461 |
my($cast_duration) = $LADCP{ENSEMBLE}[$lastGoodEns]->{ELAPSED} - |
|
462 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{ELAPSED}; |
|
463 |
croak("$0: implausibly short cast ($cast_duration seconds)\n") |
|
464 |
unless ($cast_duration > 600); |
|
465 |
||
466 |
$LADCP{MEAN_DT} = $cast_duration / ($lastGoodEns-$firstGoodEns-1); |
|
467 |
||
468 |
progress("\tStart of cast : %s (#%5d)\n", |
|
469 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{TIME}, |
|
470 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER}); |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
471 |
progress("\tBottom of cast : %s (#%5d) @ dz=%6dm\n", |
0 | 472 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{TIME}, |
473 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{NUMBER}, |
|
474 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{DEPTH}); |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
475 |
progress("\tEnd of cast : %s (#%5d) @ dz=%6dm\n", |
0 | 476 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{TIME}, |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
477 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{NUMBER}, |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
478 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{DEPTH}); |
0 | 479 |
progress("\tCast duration : %.1f hours (pinging for %.1f hours)\n", |
480 |
$cast_duration / 3600, |
|
481 |
($LADCP{ENSEMBLE}[$#{$LADCP{ENSEMBLE}}]->{UNIX_TIME} - |
|
482 |
$LADCP{ENSEMBLE}[0]->{UNIX_TIME}) / 3600); |
|
483 |
progress("\tMean ping interval: %.1f seconds\n",$LADCP{MEAN_DT}); |
|
484 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
485 |
if (defined($out_LADCPtis)) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
486 |
progress("Writing LADCP-timeseries to <$out_LADCPtis>...\n"); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
487 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
488 |
@antsNewLayout = ('ens','elapsed','reflr_w','reflr_w.stddev','reflr_w.nsamp','depth'); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
489 |
open(STDOUT,"$out_LADCPtis") || croak("$out_LADCPtis: $!\n"); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
490 |
for (my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
491 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
492 |
$LADCP{ENSEMBLE}[$ens]->{ELAPSED}, |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
493 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
494 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W_STDDEV}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
495 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W_NSAMP}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
496 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH}); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
497 |
} |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
498 |
&antsOut('EOF'); open(STDOUT,">&2"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
499 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
500 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
501 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
502 |
# More editing |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
503 |
# - this requires ${first,last}GoodEns to be known |
6 | 504 |
# - TILT field is set as a side-effect |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
505 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
506 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
507 |
progress("Editing additional earth-coordinate velocity data...\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
508 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
509 |
my($first_bad_bin); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
510 |
for (my($bin)=$LADCP_firstBin-1; $bin<$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
511 |
next unless ($per_bin_nsamp[$bin]/($lastGoodEns-$firstGoodEns) < $per_bin_valid_frac_lim); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
512 |
$first_bad_bin = $bin; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
513 |
last; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
514 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
515 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
516 |
if (defined($first_bad_bin)) { |
6 | 517 |
$fprm = $pte = 0; |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
518 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
6 | 519 |
$pte += editTilt($ens,$max_tilt); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
520 |
$fprm += editFarBins($ens,$first_bad_bin) if defined($first_bad_bin); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
521 |
} |
6 | 522 |
progress("\tattitude threshold (max_tilt = %d deg): %d velocites removed (%d%% of total)\n", |
523 |
$max_tilt,$pte,round(100*$pte/$nvv)); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
524 |
progress("\tvelocities beyond bin $first_bad_bin (<%d%% valid values): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n", |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
525 |
round(100*$per_bin_valid_frac_lim),$fprm,round(100*$fprm/$nvw)); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
526 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
527 |
|
0 | 528 |
#-------------- |
529 |
# Read CTD data |
|
530 |
#-------------- |
|
531 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
532 |
progress("Reading CTD data from <$CTD_file>...\n"); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
533 |
open(STDIN,$CTD_file) || croak("$CTD_file: $!\n"); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
534 |
croak("$CTD_file: no data\n") unless (&antsIn()); |
2 | 535 |
undef($antsOldHeaders); |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
536 |
($CTD_elapsed,$CTD_depth,$CTD_svel,$CTD_w) = &fnr('elapsed','depth','ss','w'); |
0 | 537 |
$CTD_temp = &fnrNoErr('temp'); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
538 |
&antsAddParams('lat',$P{lat}) if defined($P{lat}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
539 |
&antsAddParams('lon',$P{lon}) if defined($P{lon}); |
0 | 540 |
|
541 |
$CTD_maxdepth = -1; |
|
542 |
||
543 |
do { |
|
544 |
croak("$0: cannot deal with non-numeric CTD elapsed time\n") |
|
545 |
unless &antsNumbers($CTD_elapsed); |
|
546 |
push(@{$CTD{ELAPSED}},$ants_[0][$CTD_elapsed]); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
547 |
push(@{$CTD{DEPTH}}, $ants_[0][$CTD_depth]); |
0 | 548 |
push(@{$CTD{SVEL}}, $ants_[0][$CTD_svel]); |
549 |
push(@{$CTD{W}}, $ants_[0][$CTD_w]); |
|
550 |
push(@{$CTD{TEMP}}, $ants_[0][$CTD_temp]) if defined($CTD_temp); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
551 |
if ($ants_[0][$CTD_depth] > $CTD_maxdepth) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
552 |
$CTD_maxdepth = $ants_[0][$CTD_depth]; |
0 | 553 |
$CTD_atbottom = $#{$CTD{DEPTH}}; |
554 |
} |
|
555 |
} while (&antsIn()); |
|
556 |
||
557 |
$CTD{DT} = ($CTD{ELAPSED}[$#{$CTD{ELAPSED}}] - $CTD{ELAPSED}[0]) / $#{$CTD{ELAPSED}}; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
558 |
progress("\t%d scans at %.1fHz\n",scalar(@{$CTD{DEPTH}}),1/$CTD{DT}); |
0 | 559 |
|
560 |
croak("$0: CTD start depth must be numeric\n") |
|
561 |
unless numberp($CTD{DEPTH}[0]); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
562 |
$CTD_neg_press_offset = -1 * round($CTD{DEPTH}[0]) |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
563 |
if ($CTD{DEPTH}[0] < -$CTD_neg_press_offset); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
564 |
if ($CTD_neg_press_offset > 0) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
565 |
progress("\tadding $CTD_neg_press_offset dbar offset to pressure data\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
566 |
for (my($i)=0; $i<@{$CTD{DEPTH}}; $i++) { $CTD{DEPTH}[$i] += $CTD_neg_press_offset; } |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
567 |
$CTD_maxdepth += $CTD_neg_press_offset; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
568 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
569 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
570 |
progress("\tstart depth = %.1fm\n",$CTD{DEPTH}[0]); |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
571 |
progress("\tmax depth = %dm (# $CTD_atbottom)\n",$CTD_maxdepth); |
0 | 572 |
|
573 |
#-------------------------------------------------------------------- |
|
574 |
# Construct sound-speed correction profile from CTD 1Hz downcast data |
|
575 |
# very simple algorithm that stores the last value found |
|
576 |
# in each 1m bin |
|
577 |
#-------------------------------------------------------------------- |
|
578 |
||
579 |
progress("Constructing sound-speed correction profile\n"); |
|
580 |
||
581 |
my($scans_per_sec) = int(1/$CTD{DT}+0.5); |
|
582 |
for (my($s)=0; $s<=$CTD_atbottom; $s+=$scans_per_sec) { |
|
583 |
next unless ($CTD{DEPTH}[$s] >= 0 && numberp($CTD{SVEL}[$s])); |
|
584 |
$sVelProf[int($CTD{DEPTH}[$s])] = $CTD{SVEL}[$s]; |
|
585 |
} |
|
586 |
||
587 |
#------------------- |
|
588 |
# Determine time lag |
|
589 |
#------------------- |
|
590 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
591 |
if (defined($first_guess_timelag)) { |
0 | 592 |
progress("Setting initial time lag...\n"); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
593 |
$CTD{TIME_LAG} = $first_guess_timelag; |
0 | 594 |
progress("\t-i => elapsed(CTD) ~ elapsed(LADCP) + %.1fs\n",$CTD{TIME_LAG}); |
595 |
} else { |
|
596 |
progress("Guestimating time lag...\n"); |
|
597 |
||
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
598 |
my($CTD_10pct_down) = 0; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
599 |
my($LADCP_10pct_down) = $firstGoodEns; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
600 |
|
0 | 601 |
$CTD_10pct_down++ |
602 |
until ($CTD{DEPTH}[$CTD_10pct_down]-$CTD{DEPTH}[0] >= 0.1*($CTD_maxdepth-$CTD{DEPTH}[0])); |
|
603 |
$LADCP_10pct_down++ |
|
604 |
until ($LADCP{ENSEMBLE}[$LADCP_10pct_down]->{DEPTH} >= 0.1*$LADCP{ENSEMBLE}[$LADCP_atbottom]->{DEPTH}); |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
605 |
|
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
606 |
$CTD{TIME_LAG} = |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
607 |
$CTD{ELAPSED}[$CTD_10pct_down] - $LADCP{ENSEMBLE}[$LADCP_10pct_down]->{ELAPSED}; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
608 |
|
0 | 609 |
progress("\telapsed(dz(CTD)=%.1fm) ~ elapsed(dz(LADCP)=%.1fm) + %.1fs\n", |
610 |
$CTD{DEPTH}[$CTD_10pct_down]-$CTD{DEPTH}[0],$LADCP{ENSEMBLE}[$LADCP_10pct_down]->{DEPTH},$CTD{TIME_LAG}); |
|
611 |
} |
|
612 |
||
2 | 613 |
if ($opt_u) { |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
614 |
progress("\tskipping time lagging (-u)\n"); |
2 | 615 |
} else { |
11 | 616 |
$CTD{TIME_LAG} = # stage 1: dc/uc combined |
617 |
calc_lag($number_of_timelag_windows[0],$length_of_timelag_windows[0],int(1/$CTD{DT}+0.5),0); |
|
618 |
croak("$0: Cannot proceed without valid lag!\n") unless defined($CTD{TIME_LAG}); |
|
2 | 619 |
progress("\telapsed(CTD) ~ elapsed(LADCP) + %.2fs\n",$CTD{TIME_LAG}); |
620 |
||
11 | 621 |
$CTD{TIME_LAG_DC} = calc_lag($number_of_timelag_windows[1],$length_of_timelag_windows[1],1,1); |
622 |
progress("\tdowncast: elapsed(CTD) = elapsed(LADCP) + %.2fs\n",$CTD{TIME_LAG_DC}) |
|
623 |
if defined($CTD{TIME_LAG_DC}); |
|
624 |
$CTD{TIME_LAG_UC} = calc_lag($number_of_timelag_windows[1],$length_of_timelag_windows[1],1,-1); |
|
625 |
progress("\tupcast : elapsed(CTD) = elapsed(LADCP) + %.2fs\n",$CTD{TIME_LAG_UC}) |
|
626 |
if defined($CTD{TIME_LAG_UC}); |
|
627 |
||
628 |
croak("$0: Cannot proceed without either down- or upcast time-lag!\n") |
|
629 |
unless defined($CTD{TIME_LAG_DC}) || defined($CTD{TIME_LAG_UC}); |
|
630 |
$CTD_time_lag_dc = $CTD{TIME_LAG_DC}; # if one lag is missing ... |
|
631 |
$CTD_time_lag_uc = $CTD{TIME_LAG_UC}; # use other for entire ... |
|
632 |
$CTD_time_lag_dc = $CTD_time_lag_uc unless defined($CTD_time_lag_dc); # cast |
|
633 |
$CTD_time_lag_uc = $CTD_time_lag_dc unless defined($CTD_time_lag_uc); |
|
2 | 634 |
} |
0 | 635 |
|
11 | 636 |
&antsAddParams('CTD_time_lag_dc',$CTD{TIME_LAG_DC},'CTD_time_lag_uc',$CTD{TIME_LAG_UC}); |
637 |
undef($CTD{TIME_LAG}); # to avoid confusion |
|
0 | 638 |
|
639 |
#------------------------------------------------ |
|
640 |
# Merge CTD with LADCP data |
|
641 |
# - after this step, reflr w is sound-speed corrected!!! |
|
642 |
#------------------------------------------------ |
|
643 |
||
644 |
progress("Merging CTD with LADCP data...\n"); |
|
645 |
||
646 |
for (my($skipped)=0,my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
|
11 | 647 |
my($scan) = ($ens < $LADCP_atbottom) ? |
648 |
int(($LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $CTD_time_lag_dc - $CTD{ELAPSED}[0]) / $CTD{DT} + 0.5) : |
|
649 |
int(($LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $CTD_time_lag_uc - $CTD{ELAPSED}[0]) / $CTD{DT} + 0.5); |
|
0 | 650 |
if ($scan <= 0) { # NB: must be <=, rather than <, or assertion below sometimes fails |
651 |
$skipped++; |
|
652 |
$firstGoodEns = $ens+1; |
|
653 |
next; |
|
654 |
} |
|
655 |
if ($skipped > 0) { |
|
2 | 656 |
$firstGoodEns++,$skipped++,next # in gap |
657 |
unless defined($LADCP{ENSEMBLE}[$firstGoodEns]->{REFLR_W}); |
|
0 | 658 |
info("$skipped initial LADCP ensembles skipped because CTD data begin with LADCP in water\n"); |
659 |
$skipped = 0; |
|
660 |
} |
|
661 |
if ($scan > $#{$CTD{ELAPSED}}) { |
|
2 | 662 |
while (!defined($LADCP{ENSEMBLE}[$ens-1]->{REFLR_W})) { $ens--; } # in gap |
0 | 663 |
info(sprintf("%d final LADCP ensembles skipped because CTD data end with LADCP in water\n", |
664 |
$lastGoodEns-$ens+1)); |
|
665 |
$lastGoodEns = $ens-1; |
|
666 |
last; |
|
667 |
} |
|
668 |
||
11 | 669 |
if ($ens < $LADCP_atbottom) { |
670 |
die("assertion failed!\n" . |
|
671 |
"\ttest: abs($LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $CTD_time_lag_dc - $CTD{ELAPSED}[$scan]) <= $CTD{DT}/2\n" . |
|
672 |
"\tens = $ens, scan = $scan\n" . |
|
673 |
sprintf("\tadjusted LADCP time = %f\n",$LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $CTD_time_lag_dc) . |
|
674 |
sprintf("\tCTD($scan) time = %f\n",$CTD{ELAPSED}[$scan]) . |
|
675 |
"=> Did you use SeaBird elapsed time? Don't!" |
|
676 |
) unless (abs($LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $CTD_time_lag_dc - $CTD{ELAPSED}[$scan]) <= $CTD{DT}/2 + 1e-10); |
|
677 |
} else { |
|
678 |
die("assertion failed!\n" . |
|
679 |
"\ttest: abs($LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $CTD_time_lag_uc - $CTD{ELAPSED}[$scan]) <= $CTD{DT}/2\n" . |
|
680 |
"\tens = $ens, scan = $scan\n" . |
|
681 |
sprintf("\tadjusted LADCP time = %f\n",$LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $CTD_time_lag_uc) . |
|
682 |
sprintf("\tCTD($scan) time = %f\n",$CTD{ELAPSED}[$scan]) . |
|
683 |
"=> Did you use SeaBird elapsed time? Don't!" |
|
684 |
) unless (abs($LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $CTD_time_lag_uc - $CTD{ELAPSED}[$scan]) <= $CTD{DT}/2 + 1e-10); |
|
685 |
} |
|
0 | 686 |
|
687 |
$LADCP{ENSEMBLE}[$ens]->{CTD_ELAPSED} = $CTD{ELAPSED}[$scan]; # elapsed field for output |
|
688 |
||
689 |
if (defined($LADCP{ENSEMBLE}[$ens]->{REFLR_W}) # not a gap |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
690 |
&& numberp($CTD{DEPTH}[$scan])) { |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
691 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W_NOSSCORR} = $LADCP{ENSEMBLE}[$ens]->{REFLR_W}; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
692 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W} *= $CTD{SVEL}[$scan]/1500; # correct for sound-speed variations at source |
0 | 693 |
croak(sprintf("\n$0: negative depth (%.1fm) in CTD file at elapsed(CTD) = %.1fs (use -a?)\n", |
694 |
$CTD{DEPTH}[$scan],$CTD{ELAPSED}[$scan])) |
|
695 |
unless ($CTD{DEPTH}[$scan] >= 0); |
|
696 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} = $CTD{DEPTH}[$scan]; |
|
697 |
$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN} = $scan; |
|
698 |
my($reflr_ocean_w) = $LADCP{ENSEMBLE}[$ens]->{REFLR_W} - $CTD{W}[$scan]; |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
699 |
if (abs($reflr_ocean_w) <= $max_allowed_w) { |
0 | 700 |
$sumWsq += &SQR($reflr_ocean_w); |
701 |
$nWsq++; |
|
702 |
if ($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} > 100 && |
|
703 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} < $LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH}-100) { |
|
704 |
$sumWsqI += &SQR($reflr_ocean_w); |
|
705 |
$nWsqI++; |
|
706 |
} |
|
707 |
} else { |
|
708 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); # DON'T USE THIS ENSEMBLE LATER |
|
709 |
} |
|
710 |
} else{ |
|
711 |
undef($LADCP{ENSEMBLE}[$ens]->{REFLR_W}); # don't output in time-series file |
|
10
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
712 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); # old DEPTH from calcLADCPts() must be removed |
0 | 713 |
} |
714 |
} |
|
715 |
||
716 |
if ($nWsq > 0 && $nWsqI > 0) { |
|
717 |
&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',sqrt($sumWsqI/$nWsqI)); |
|
718 |
progress("\t%.2f cm/s rms reference-layer w_ocean, %.2f cm/s away from boundaries\n", |
|
719 |
100*sqrt($sumWsq/$nWsq),100*sqrt($sumWsqI/$nWsqI)); |
|
720 |
warning(0,"%.2f cm/s reference-layer w_ocean away from boundaries\n",100*sqrt($sumWsqI/$nWsqI)) |
|
721 |
if (sqrt($sumWsqI/$nWsqI) > 0.05); |
|
2 | 722 |
# croak("$0: rms reference-layer w_ocean is too large\n") |
723 |
# unless (sqrt($sumWsqI/$nWsqI) < 0.07); |
|
0 | 724 |
} elsif ($nWsq > 0) { |
725 |
&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',nan); |
|
726 |
progress("\t%.2f cm/s rms reference-layer w_ocean\n",100*sqrt($sumWsq/$nWsq)); |
|
727 |
} else { |
|
728 |
croak("$0: no valid vertical velocities\n"); |
|
729 |
} |
|
730 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
731 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
732 |
# Calculate Volume Scattering Coefficients |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
733 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
734 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
735 |
progress("Calculating volume-scattering coefficients...\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
736 |
calc_backscatter_profs($firstGoodEns,$lastGoodEns); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
737 |
|
0 | 738 |
#---------------------------------------------------------------------------- |
739 |
# Remove data contaminated by sidelobe reflection from seabed and sea surface |
|
740 |
#---------------------------------------------------------------------------- |
|
741 |
||
742 |
if ($LADCP{ENSEMBLE}[$LADCP_atbottom]->{XDUCER_FACING_DOWN}) { |
|
743 |
&antsAddParams('ADCP_orientation','downlooker'); |
|
744 |
||
745 |
if (numberp($opt_h)) { |
|
746 |
progress("Setting water depth (-h)\n"); |
|
747 |
$water_depth = $opt_h; |
|
748 |
$sig_water_depth = 0; |
|
749 |
} else { |
|
750 |
progress("Finding seabed...\n"); |
|
751 |
($water_depth,$sig_water_depth) = |
|
752 |
find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH}); |
|
753 |
($water_depth_BT,$sig_water_depth_BT) = |
|
754 |
find_seabed(\%LADCP,$LADCP_atbottom,$LADCP{BEAM_COORDINATES}); |
|
755 |
if (defined($water_depth_BT)) { |
|
756 |
my($dd) = abs($water_depth_BT - $water_depth); |
|
757 |
warning(2,sprintf("Large RDI vs. own water-depth difference (%.1fm)\n",$dd)) |
|
758 |
if ($dd > 5); |
|
759 |
} |
|
760 |
} |
|
761 |
||
762 |
&antsAddParams('water_depth',$water_depth,'water_depth.sig',$sig_water_depth); |
|
763 |
||
764 |
if (defined($water_depth)) { |
|
765 |
if (defined($water_depth_BT)) { |
|
766 |
progress("\t%.1f(%.1f) m water depth (%.1f(%.1f)m from BT)\n", |
|
767 |
$water_depth,$sig_water_depth,$water_depth_BT,$sig_water_depth_BT); |
|
768 |
} else { |
|
769 |
progress("\t%.1f(%.1f) m water depth\n",$water_depth,$sig_water_depth); |
|
770 |
} |
|
771 |
warning(1,sprintf("large uncertainty in water-depth estimation (%.1fm)\n",$sig_water_depth)) |
|
772 |
if ($sig_water_depth > $LADCP{BIN_LENGTH}); |
|
773 |
||
774 |
progress("Editing data to remove sidelobe interference from seabed...\n"); |
|
775 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,$water_depth); |
|
776 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
|
777 |
||
778 |
} else { |
|
779 |
info("no seabed found in backscatter profiles --- no sidelobe editing done\n"); |
|
780 |
} |
|
781 |
||
782 |
} else { |
|
783 |
&antsAddParams('ADCP_orientation','uplooker'); |
|
784 |
progress("Editing data to remove sidelobe interference from sea surface...\n"); |
|
785 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,undef); |
|
786 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
|
787 |
} |
|
788 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
789 |
#---------------------------------------------------------------------- |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
790 |
# Data Editing after LADCP and CTD data have been merged |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
791 |
# 1) surface layer editing |
10
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
792 |
# 2) user-supplied $edit_data_hook |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
793 |
#---------------------------------------------------------------------- |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
794 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
795 |
progress("Removing data from instrument at surface...\n"); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
796 |
$nerm = editSurfLayer($firstGoodEns,$lastGoodEns,$surface_layer_depth); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
797 |
progress("\t$nerm ensembles removed\n"); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
798 |
|
11 | 799 |
if (defined($post_merge_hook)) { |
800 |
progress("Executing user-supplied \$post_merge_hook...\n"); |
|
801 |
&{$post_merge_hook}($firstGoodEns,$lastGoodEns); |
|
10
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
802 |
} |
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
803 |
|
0 | 804 |
#--------------------------------------------------------------------------- |
805 |
# Depth-bin LADCP velocity data |
|
806 |
# |
|
807 |
# NOTES: |
|
808 |
# 1) ensemble and bin numbers are saved for maximum flexibility |
|
809 |
# 2) only ensemble/bins with valid vertical velocities are saved |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
810 |
# 3) applying the full soundspeed correction to w is pointless in |
0 | 811 |
# practice, but hey!, CPU cycles are cheap; [in a cast in the Gulf of Mexico |
812 |
# which has fairly pronounce soundspeed gradients, the max value of Kn |
|
813 |
# is 1.00004160558372, which gives rise to a correction of less than 0.2mm/s |
|
814 |
# at a winch+wave speed of 3m/s....] |
|
815 |
# 4) as far as I can tell, the soundspeed correction for bin length also |
|
816 |
# has only a minute effect |
|
817 |
#--------------------------------------------------------------------------- |
|
818 |
||
819 |
progress("Binning velocities...\n"); |
|
820 |
||
2 | 821 |
my($min_depth) = 9e99; |
822 |
my($max_depth) = 0; |
|
823 |
||
0 | 824 |
progress("\tdowncast...\n"); |
825 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { # downcast |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
826 |
unless (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH})) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
827 |
$firstGoodEns++ if ($ens == $firstGoodEns); # start has been edited away |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
828 |
next; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
829 |
} |
0 | 830 |
my(@bindepth) = calc_binDepths($ens); |
831 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
832 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
2 | 833 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
834 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
835 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] = |
|
0 | 836 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
837 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
838 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
839 |
$bindepth[$bin]); |
|
6 | 840 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] = |
841 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
|
842 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
843 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
844 |
$bindepth[$bin]) |
|
845 |
if numberp($LADCP{ENSEMBLE}[$ens]->{W12}[$bin]); |
|
846 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] = |
|
847 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W34}[$bin], |
|
848 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
849 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
850 |
$bindepth[$bin]) |
|
851 |
if numberp($LADCP{ENSEMBLE}[$ens]->{W34}[$bin]); |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
852 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin] = |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
853 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] + $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
854 |
my($bi) = $bindepth[$bin]/$output_bin_size; |
0 | 855 |
push(@{$DNCAST{ENSEMBLE}[$bi]},$ens); |
856 |
push(@{$DNCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
857 |
push(@{$DNCAST{CTD_W}[$bi]},$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
858 |
push(@{$DNCAST{BIN}[$bi]},$bin); |
|
859 |
push(@{$DNCAST{DEPTH}[$bi]},$bindepth[$bin]); |
|
2 | 860 |
push(@{$DNCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
0 | 861 |
} |
862 |
} |
|
863 |
||
6 | 864 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { # bin data into profile |
0 | 865 |
$DNCAST{MEAN_DEPTH}[$bi] = avg(@{$DNCAST{DEPTH}[$bi]}); |
866 |
$DNCAST{MEAN_ELAPSED}[$bi] = avg(@{$DNCAST{ELAPSED}[$bi]}); |
|
867 |
$DNCAST{MEDIAN_W}[$bi] = median(@{$DNCAST{W}[$bi]}); |
|
868 |
$DNCAST{MAD_W}[$bi] = mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]}); |
|
869 |
$DNCAST{N_SAMP}[$bi] = @{$DNCAST{W}[$bi]}; |
|
870 |
} |
|
871 |
||
2 | 872 |
progress("\tupcast...\n"); # upcast |
0 | 873 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
874 |
my($realLastGoodEns); |
0 | 875 |
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) { |
876 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
877 |
$realLastGoodEns = $ens; |
0 | 878 |
my(@bindepth) = calc_binDepths($ens); |
879 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
880 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
2 | 881 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
882 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
883 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] = |
|
0 | 884 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
885 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
886 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
887 |
$bindepth[$bin]); |
|
6 | 888 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] = |
889 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
|
890 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
891 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
892 |
$bindepth[$bin]) |
|
893 |
if numberp($LADCP{ENSEMBLE}[$ens]->{W12}[$bin]); |
|
894 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] = |
|
895 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W34}[$bin], |
|
896 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
897 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
898 |
$bindepth[$bin]) |
|
899 |
if numberp($LADCP{ENSEMBLE}[$ens]->{W34}[$bin]); |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
900 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin] = |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
901 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] + $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
902 |
my($bi) = $bindepth[$bin]/$output_bin_size; |
0 | 903 |
push(@{$UPCAST{ENSEMBLE}[$bi]},$ens); |
904 |
push(@{$UPCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
905 |
push(@{$UPCAST{CTD_W}[$bi]},$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
906 |
push(@{$UPCAST{BIN}[$bi]},$bin); |
|
907 |
push(@{$UPCAST{DEPTH}[$bi]},$bindepth[$bin]); |
|
2 | 908 |
push(@{$UPCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
0 | 909 |
} |
910 |
} |
|
911 |
||
912 |
for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) { |
|
913 |
$UPCAST{MEAN_DEPTH}[$bi] = avg(@{$UPCAST{DEPTH}[$bi]}); |
|
914 |
$UPCAST{MEAN_ELAPSED}[$bi] = avg(@{$UPCAST{ELAPSED}[$bi]}); |
|
915 |
$UPCAST{MEDIAN_W}[$bi] = median(@{$UPCAST{W}[$bi]}); |
|
916 |
$UPCAST{MAD_W}[$bi] = mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]}); |
|
917 |
$UPCAST{N_SAMP}[$bi] = @{$UPCAST{W}[$bi]}; |
|
918 |
} |
|
919 |
||
6 | 920 |
&antsAddParams('min_depth',$min_depth,'max_depth',$max_depth, # plot area |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
921 |
'min_ens',$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
922 |
'max_ens',$LADCP{ENSEMBLE}[$realLastGoodEns]->{NUMBER}, |
2 | 923 |
'min_elapsed',$LADCP{ENSEMBLE}[$firstGoodEns]->{CTD_ELAPSED}, |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
924 |
'max_elapsed',$LADCP{ENSEMBLE}[$realLastGoodEns]->{CTD_ELAPSED}); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
925 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
926 |
#------------------------------------------------------------------------------------------------------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
927 |
# remove single-ping noise |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
928 |
# - based on observation that without this step raw velocities tend to be strongly vertically striped |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
929 |
# => residual CTD/LADCP mismatch errors & ADCP single-ping errors |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
930 |
# - remove ensemble-median residual from all vertical velocities; new residual calculated below |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
931 |
# - improves solution but can introduce errors in ensembles with strong outliers => median instead of |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
932 |
# mean, and outlier filter above |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
933 |
#------------------------------------------------------------------------------------------------------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
934 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
935 |
unless ($opt_q) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
936 |
progress("Removing single-ping residual noise...\n"); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
937 |
|
11 | 938 |
my($fe) = defined($CTD{TIME_LAG_DC}) ? $firstGoodEns : $LADCP_atbottom; |
939 |
my($le) = defined($CTD{TIME_LAG_UC}) ? $realLastGoodEns : $LADCP_atbottom; |
|
940 |
||
941 |
for ($ens=$fe; $ens<=$le; $ens++) { |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
942 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
943 |
my(@residuals) = (); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
944 |
my(@bindepth) = calc_binDepths($ens); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
945 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
946 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
947 |
my($bi) = $bindepth[$bin]/$output_bin_size; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
948 |
push(@residuals, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
949 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
950 |
(($ens < $LADCP_atbottom) ? $DNCAST{MEDIAN_W}[$bi] |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
951 |
: $UPCAST{MEDIAN_W}[$bi])); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
952 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
953 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} = median(@residuals); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
954 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
955 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
956 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] -= |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
957 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W}; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
958 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
959 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
960 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
961 |
progress("\tre-calculating profile mad...\n"); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
962 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
963 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { # bin data |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
964 |
for (my($i)=0; $i<@{$DNCAST{W}[$bi]}; $i++) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
965 |
$DNCAST{W}[$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W}; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
966 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
967 |
$DNCAST{MAD_W}[$bi] = mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]}); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
968 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
969 |
for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
970 |
for (my($i)=0; $i<@{$UPCAST{W}[$bi]}; $i++) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
971 |
$UPCAST{W}[$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W}; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
972 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
973 |
$UPCAST{MAD_W}[$bi] = mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]}); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
974 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
975 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
976 |
} # unless ($opt_q); |
2 | 977 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
978 |
#------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
979 |
# Output Per-Bin Resiudals |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
980 |
#------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
981 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
982 |
if (defined($out_BR)) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
983 |
my(@dc_nres,@uc_nres,@dc_bres,@uc_bres); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
984 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
985 |
progress("Writing per-bin residual data to $out_BR...\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
986 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
987 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { # downcast |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
988 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
989 |
my(@bindepth) = calc_binDepths($ens); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
990 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
991 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
992 |
push(@{$dc_bres[$bin]}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
993 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
994 |
- $DNCAST{MEDIAN_W}[$bindepth[$bin]/$output_bin_size]); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
995 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
996 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
997 |
for ($ens=$LADCP_atbottom; $ens<=$realLastGoodEns; $ens++) { # upcast |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
998 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
999 |
my(@bindepth) = calc_binDepths($ens); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1000 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1001 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1002 |
push(@{$uc_bres[$bin]}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1003 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1004 |
- $UPCAST{MEDIAN_W}[$bindepth[$bin]/$output_bin_size]); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1005 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1006 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1007 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1008 |
my($saveParams) = $antsCurParams; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1009 |
@antsNewLayout = ('bin','dc_residual','dc_residual.sig','dc_residual.nsamp', |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1010 |
,'uc_residual','uc_residual.sig','uc_residual.nsamp'); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1011 |
open(STDOUT,"$out_BR") || croak("$out_BR: $!\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1012 |
&antsAddParams('BR_max_bin',max(scalar(@dc_bres),scalar(@uc_bres))); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1013 |
for (my($bin)=0; $bin<max(scalar(@dc_bres),scalar(@uc_bres)); $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1014 |
my($dc_avg) = avg(@{$dc_bres[$bin]}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1015 |
my($uc_avg) = avg(@{$uc_bres[$bin]}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1016 |
&antsOut($bin+1,$dc_avg,stddev2($dc_avg,@{$dc_bres[$bin]}),scalar(@{$dc_bres[$bin]}), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1017 |
$uc_avg,stddev2($uc_avg,@{$uc_bres[$bin]}),scalar(@{$uc_bres[$bin]})); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1018 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1019 |
&antsOut('EOF'); open(STDOUT,">&2"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1020 |
$antsCurParams = $saveParams; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1021 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1022 |
|
0 | 1023 |
#-------------------------------------------------- |
1024 |
# Calculate BT-referenced vertical-velocity profile |
|
1025 |
#-------------------------------------------------- |
|
1026 |
||
1027 |
if (defined($water_depth)) { |
|
1028 |
progress("Calculating BT-referenced vertical velocities\n"); |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1029 |
calc_BTprof($firstGoodEns,$realLastGoodEns,$water_depth,$sig_water_depth); |
0 | 1030 |
|
1031 |
my($sumSq) = my($n) = 0; |
|
1032 |
for (my($bi)=0; $bi<=$#{$BT{MEDIAN_W}}; $bi++) { |
|
1033 |
next unless defined($BT{MEDIAN_W}[$bi]); |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1034 |
next unless ($BT{N_SAMP}[$bi]>=$min_w_nsamp && $DNCAST{N_SAMP}[$bi]>=$min_w_nsamp && $UPCAST{N_SAMP}[$bi]>=$min_w_nsamp); |
0 | 1035 |
$sumSq += ($BT{MEDIAN_W}[$bi] - $DNCAST{MEDIAN_W}[$bi]/2 - $UPCAST{MEDIAN_W}[$bi]/2)**2; |
1036 |
$n++; |
|
1037 |
} |
|
1038 |
if ($n > 0) { |
|
1039 |
my($rms) = round(sqrt($sumSq/$n),0.001); |
|
1040 |
&antsAddParams('BT_rms_w_discrepancy',$rms); |
|
1041 |
progress("\t$rms m/s rms vertical-velocity discrepancy\n"); |
|
1042 |
} |
|
1043 |
} |
|
1044 |
||
2 | 1045 |
#------------ |
1046 |
# full output |
|
1047 |
#------------ |
|
1048 |
||
1049 |
# NB: residual field is calculated with respect to down-/upcast medians in -o-size bins |
|
1050 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1051 |
if (defined($out_w)) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1052 |
progress("Writing vertical-velocity data to $out_w...\n"); |
2 | 1053 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1054 |
@antsNewLayout = ('ensemble','bin','elapsed','depth','CTD_depth','downcast', |
6 | 1055 |
'w','w12','w34','residual','CTD_w','LADCP_w','errvel', |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1056 |
'correlation','echo_amplitude','volume_scattering_coeff', |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1057 |
'pitch','roll','tilt','heading','3_beam','svel'); |
2 | 1058 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1059 |
open(STDOUT,"$out_w") || croak("$out_w: $!\n"); |
11 | 1060 |
|
1061 |
if (defined($CTD{TIME_LAG_DC})) { |
|
1062 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { # downcast |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1063 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1064 |
my(@bindepth) = calc_binDepths($ens); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1065 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1066 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1067 |
my($bi) = $bindepth[$bin]/$output_bin_size; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1068 |
&antsOut( |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1069 |
$LADCP{ENSEMBLE}[$ens]->{NUMBER},$bin+1, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1070 |
$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1071 |
$bindepth[$bin],$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},1, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1072 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin], |
6 | 1073 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] : nan, |
1074 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] : nan, |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1075 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $DNCAST{MEDIAN_W}[$bi], |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1076 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1077 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin], |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1078 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin], |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1079 |
median(@{$LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin]}), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1080 |
median(@{$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin]}), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1081 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin], |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1082 |
$LADCP{ENSEMBLE}[$ens]->{PITCH}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1083 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1084 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1085 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1086 |
(defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][0]) + # only works for beam coords |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1087 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][1]) + |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1088 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][2]) + |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1089 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][3])) < 4 ? 1 : 0, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1090 |
$CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1091 |
); |
11 | 1092 |
} # for $bin |
1093 |
} # for $ens |
|
1094 |
} # if defined dc time lag |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1095 |
|
11 | 1096 |
if (defined($CTD{TIME_LAG_UC})) { |
1097 |
for ($ens=$LADCP_atbottom; $ens<=$realLastGoodEns; $ens++) { # upcast |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1098 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1099 |
my(@bindepth) = calc_binDepths($ens); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1100 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1101 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1102 |
my($bi) = $bindepth[$bin]/$output_bin_size; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1103 |
&antsOut( |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1104 |
$LADCP{ENSEMBLE}[$ens]->{NUMBER},$bin+1, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1105 |
$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1106 |
$bindepth[$bin],$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},0, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1107 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin], |
6 | 1108 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] : nan, |
1109 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] : nan, |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1110 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $UPCAST{MEDIAN_W}[$bi], |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1111 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1112 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin], |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1113 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin], |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1114 |
median(@{$LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin]}), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1115 |
median(@{$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin]}), |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1116 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin], |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1117 |
$LADCP{ENSEMBLE}[$ens]->{PITCH}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1118 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1119 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1120 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1121 |
(defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][0]) + # only works for beam coords |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1122 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][1]) + |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1123 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][2]) + |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1124 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][3])) < 4 ? 1 : 0, |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1125 |
$CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1126 |
); |
11 | 1127 |
} # for $bin |
1128 |
} # for $ens |
|
1129 |
} # if defined uc time-lag |
|
2 | 1130 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1131 |
&antsOut('EOF'); open(STDOUT,">&2"); |
2 | 1132 |
} |
1133 |
||
0 | 1134 |
#--------------- |
1135 |
# Output profile |
|
1136 |
#--------------- |
|
1137 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1138 |
if (defined($out_profile)) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1139 |
progress("Writing vertical-velocity profiles to <$out_profile>...\n"); |
0 | 1140 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1141 |
@antsNewLayout = ('depth','dc_depth','dc_elapsed','dc_w','dc_w.mad','dc_w.nsamp', |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1142 |
'uc_depth','uc_elapsed','uc_w','uc_w.mad','uc_w.nsamp', |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1143 |
'elapsed','w','w.mad','w.nsamp', |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1144 |
'BT_w','BT_w.mad','BT_w.nsamp'); |
0 | 1145 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1146 |
open(STDOUT,"$out_profile") || croak("$out_profile: $!\n"); |
2 | 1147 |
|
11 | 1148 |
undef(%DNCAST) unless defined($CTD{TIME_LAG_DC}); |
1149 |
undef(%UPCAST) unless defined($CTD{TIME_LAG_UC}); |
|
2 | 1150 |
for (my($bi)=0; $bi<=max($#{$DNCAST{ENSEMBLE}},$#{$UPCAST{ENSEMBLE}},$#{$BT{NSAMP}}); $bi++) { |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1151 |
&antsOut(($bi+0.5)*$output_bin_size, # nominal depth |
2 | 1152 |
$DNCAST{MEAN_DEPTH}[$bi],$DNCAST{MEAN_ELAPSED}[$bi], |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1153 |
$DNCAST{N_SAMP}[$bi]>=$min_w_nsamp?$DNCAST{MEDIAN_W}[$bi]:nan, |
2 | 1154 |
$DNCAST{MAD_W}[$bi],$DNCAST{N_SAMP}[$bi], |
1155 |
$UPCAST{MEAN_DEPTH}[$bi],$UPCAST{MEAN_ELAPSED}[$bi], |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1156 |
$UPCAST{N_SAMP}[$bi]>=$min_w_nsamp?$UPCAST{MEDIAN_W}[$bi]:nan, |
2 | 1157 |
$UPCAST{MAD_W}[$bi],$UPCAST{N_SAMP}[$bi], |
1158 |
$DNCAST{MEAN_ELAPSED}[$bi]/2+$UPCAST{MEAN_ELAPSED}[$bi]/2, |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1159 |
$DNCAST{N_SAMP}[$bi]+$UPCAST{N_SAMP}[$bi]>=$min_w_nsamp ? |
2 | 1160 |
($DNCAST{MEDIAN_W}[$bi]*$DNCAST{N_SAMP}[$bi]+$UPCAST{MEDIAN_W}[$bi]*$UPCAST{N_SAMP}[$bi]) / ($DNCAST{N_SAMP}[$bi]+$UPCAST{N_SAMP}[$bi]) : |
1161 |
nan, |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1162 |
$DNCAST{N_SAMP}[$bi]+$UPCAST{N_SAMP}[$bi]>=$min_w_nsamp ? |
2 | 1163 |
($DNCAST{MAD_W}[$bi]*$DNCAST{N_SAMP}[$bi]+$UPCAST{MAD_W}[$bi]*$UPCAST{N_SAMP}[$bi]) / ($DNCAST{N_SAMP}[$bi]+$UPCAST{N_SAMP}[$bi]) : |
1164 |
nan, |
|
1165 |
$DNCAST{N_SAMP}[$bi]+$UPCAST{N_SAMP}[$bi], |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1166 |
$BT{N_SAMP}[$bi]>=$min_w_nsamp?$BT{MEDIAN_W}[$bi]:nan, |
2 | 1167 |
$BT{MAD_W}[$bi],$BT{N_SAMP}[$bi] |
1168 |
); |
|
0 | 1169 |
} |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1170 |
&antsOut('EOF'); open(STDOUT,">&2"); |
0 | 1171 |
} |
1172 |
||
1173 |
#-------------------------------------- |
|
1174 |
# write time-series output if requested |
|
1175 |
#-------------------------------------- |
|
1176 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1177 |
if (defined($out_timeseries)) { |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1178 |
progress("Writing time-series data to <$out_timeseries>...\n"); |
0 | 1179 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1180 |
@antsNewLayout = ('ens','elapsed','downcast', |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1181 |
'depth','xducer_sound_speed','pitch','gimbal_pitch','roll','tilt','heading', |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1182 |
'CTD_w','LADCP_reflr_w','LADCP_reflr_w_err','LADCP_reflr_w_nosscorr', |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1183 |
'reflr_ocean_w'); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1184 |
open(STDOUT,"$out_timeseries") || croak("$out_timeseries: $!\n"); |
0 | 1185 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1186 |
for ($ens=$firstGoodEns; $ens<=$realLastGoodEns; $ens++) { |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1187 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1188 |
my($reflr_oc_w) = defined($LADCP{ENSEMBLE}[$ens]->{REFLR_W}) |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1189 |
? $LADCP{ENSEMBLE}[$ens]->{REFLR_W} - $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}] |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1190 |
: undef; |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1191 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1192 |
$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1193 |
($ens < $LADCP_atbottom) ? 1 : 0, |
0 | 1194 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
1195 |
$CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1196 |
$LADCP{ENSEMBLE}[$ens]->{PITCH}, |
|
1197 |
$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH}, |
|
1198 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
|
1199 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
|
1200 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
|
1201 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1202 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W}, |
|
1203 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W_ERR}, |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1204 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W_NOSSCORR}, |
0 | 1205 |
$reflr_w); |
1206 |
} |
|
1207 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1208 |
&antsOut('EOF'); open(STDOUT,">&2"); |
0 | 1209 |
} |
1210 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1211 |
system("{ sleep 30; ./PostProcess.sh $out_basename $RUN $data_subdir $plot_subdir $log_subdir; }&") |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1212 |
if (-x 'PostProcess.sh'); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1213 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1214 |
exit(0); |