author | A.M. Thurnherr <ant@ldeo.columbia.edu> |
Thu, 21 Nov 2013 09:07:17 -0500 | |
changeset 13 | 2788bf1bf1de |
parent 12 | 2adcd220b9b4 |
child 15 | dfcb6bef9d42 |
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 |
|
13 | 5 |
# dlm: Thu Sep 5 16:23:16 2013 |
0 | 6 |
# (c) 2010 A.M. Thurnherr |
13 | 7 |
# uE-Info: 495 0 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 |
12
2adcd220b9b4
before attempting to implement piece-wise time-lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
117 |
# - HG COMMIT |
11 | 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 |
|
12
2adcd220b9b4
before attempting to implement piece-wise time-lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
122 |
# - HG COMMIT |
2adcd220b9b4
before attempting to implement piece-wise time-lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
123 |
# Feb 13, 2013: - BUG: CTD_neg_press_offset did not work for CTD time series with -ve starting depth |
2adcd220b9b4
before attempting to implement piece-wise time-lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
124 |
# Mar 23, 2013: - cosmetics |
2adcd220b9b4
before attempting to implement piece-wise time-lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
125 |
# - HG COMMIT |
13 | 126 |
# Apr 22, 2013: - removed opt_? variable aliases |
127 |
# May 8, 2013: - replaced default run label (default to profiles) to make more readable directory structure |
|
128 |
# May 14, 2013: - opt_m => w_max_lim |
|
129 |
# - BUG: time-series output had two messed-up fields |
|
130 |
# May 15, 2013: - added w12 and w34 (2-beam solutions) to profile output |
|
131 |
# May 16, 2013: - added CTD_w_tt to time-series & all-sample outputs |
|
132 |
# - -a => -d (CTD depth offset) |
|
133 |
# - implemented pressure-sensor acceleration correction (-a) |
|
134 |
# - added re-gridding of full profile after ping-coherent error removal |
|
135 |
# Jun 5, 2013: - renamed $discard_velocities_from_beam to $bad_beam |
|
136 |
# - BUG: $bad_beam did not discard BT_VELOCITY data |
|
137 |
# Jun 6, 2013: - BUG: error message had -a instead of -d |
|
138 |
# Sep 5, 2013: - BUG: w12/w34 do not work for earth-coordinate data, of course |
|
0 | 139 |
|
140 |
# CTD REQUIREMENTS |
|
141 |
# - elapsed elapsed seconds; see note below |
|
142 |
# - depth |
|
143 |
# - ss sound speed |
|
144 |
# - w ddepth/dt |
|
145 |
# - temp OPTIONAL; used for backscatter calculation (i.e. not very important) |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
146 |
# - %lat/%lon OPTIONAL |
0 | 147 |
|
13 | 148 |
# 2-BEAM SOLUTIONS |
149 |
# - for beam-coordinate data, two separate two-beam solutions (w12 & w34) are calculated |
|
150 |
# - discrepancies can be indicative of package wake effects (e.g. MIXET data) |
|
151 |
# - for earth-coordinate data, w12 and w34 are simply copies of w |
|
152 |
||
0 | 153 |
# NUMERICAL OPTIONS |
154 |
# - the first option in the list cannot be numerical! |
|
155 |
# - if need be, use -v 1 as a dummy option |
|
156 |
||
157 |
# ELAPSED TIMES |
|
158 |
# - there are 2 different elapsed times used in this program: |
|
159 |
# 1) elapsed based on firstgoodens in the LADCP time series |
|
160 |
# 2) CTD elapsed time |
|
161 |
# - CTD elapsed time does not have to start with zero! |
|
162 |
# - do not use the Seabird elapsed field, which is only reported to |
|
163 |
# 3 significant digits, causing significant jitter in dt; however, |
|
164 |
# at least up to 2010 Seabird simply calculates elapsed time by |
|
165 |
# assuming a 24Hz sampling rate and no record drop; therefore, |
|
166 |
# it is best to calculate elapsed time as %RECNO/24 |
|
167 |
# - the elapsed field of the output is the elapsed time from the CTD |
|
168 |
# file; this is required in order to be able to compare the times |
|
169 |
# from the uplooker and downlooker-derived vertical velocity |
|
170 |
# profiles |
|
11 | 171 |
# - the .TL files use the LADCP elapsed time in output; as a result, |
172 |
# the DL/UL .TL files have different time axes! |
|
0 | 173 |
# - as a result, a profile only starts with elapsed==0 if the CTD |
174 |
# is turned on when the LADCP is already in the water |
|
175 |
||
13 | 176 |
# BINNED-PROFILE OUTPUT NOTES |
177 |
# - residuals are calculated with respect to down-/upcast medians |
|
178 |
# - w12 and w34 2-beam solutions are reported without considering |
|
179 |
# -k (min samples) |
|
2 | 180 |
# - equivalence, assuming -o 10: |
181 |
# 1) 004DL.prof dc_w depth |
|
6 | 182 |
# 2) bindata -Sdowncast:1 -Fw.median,depth -n 20 depth 10 004DL.w |
2 | 183 |
|
0 | 184 |
# VELOCITY AMBIGUITY ERRORS |
185 |
# - quite extensive tests with DIMES US2 station 146, which has a lot of |
|
186 |
# ambiguity velocity errors, reveal that -m 1 catches those errors |
|
187 |
# quite nicely |
|
188 |
# - even when the errors are not filtered with -m 1, they do not |
|
189 |
# affect the w profiles, as long as the median bin values are used |
|
190 |
||
191 |
($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
|
192 |
($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$}); |
0 | 193 |
($PERL_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$}); |
194 |
||
195 |
require "$ANTS/ants.pl"; |
|
196 |
require "$ANTS/libstats.pl"; |
|
197 |
require "$WCALC/edit_data.pl"; |
|
198 |
require "$WCALC/time_series.pl"; |
|
199 |
require "$WCALC/time_lag.pl"; |
|
200 |
require "$WCALC/find_seabed.pl"; |
|
201 |
require "$WCALC/svel_corrections.pl"; |
|
202 |
require "$WCALC/acoustic_backscatter.pl"; |
|
203 |
require "$WCALC/bottom_tracking.pl"; |
|
204 |
require "$PERL_TOOLS/RDI_BB_Read.pl"; |
|
205 |
require "$PERL_TOOLS/RDI_Coords.pl"; |
|
206 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
207 |
use IO::Handle; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
208 |
|
6 | 209 |
my($TINY) = 1e-16; |
210 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
211 |
#------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
212 |
# Usage |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
213 |
#------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
214 |
|
2 | 215 |
@ARGS = @ARGV; # save opts & arguments |
216 |
||
0 | 217 |
$antsParseHeader = 0; |
13 | 218 |
&antsUsage('3:4a:b:c:e:g:h:i:k:m:n:o:p:qs:t:uv:w:x:',1, |
0 | 219 |
'[-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
|
220 |
'[-q)uick (no single-ping denoising)]', |
13 | 221 |
'[require -4)-beam solutions] [apply beamvel-m)ask <file> if it exists]', |
222 |
'[valid LADCP -b)ins <bin[2],bin[*]>', |
|
0 | 223 |
'[-c)orrelation <min[70]>] [-t)ilt <max[10deg]> [-e)rr-vel <max[0.1m/s]>]', |
224 |
'[-h water <depth>]', |
|
225 |
'[max LADCP time-series -g)ap <length[60s]>]', |
|
13 | 226 |
'[offset CTD -d)epth <by[0m]>]', |
2 | 227 |
'[-i)nitial CTD time offset <guestimate> [-u)se as final]]', |
13 | 228 |
'[calculate -n) <lags,lags[10,100]>] [lag -w)indow <sz,sz[240s,20s]>] [lag-p)iece <CTD_elapsed_min|+[,...]>]', |
0 | 229 |
'[require top-3) lags to account for <frac[0.6]> of all]', |
13 | 230 |
'[pressure-sensor -a)cceleration correction <residual/CTD_w_tt>]', |
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 |
'[-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
|
232 |
'[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
|
233 |
'<station-id> [run-label]'); |
0 | 234 |
|
2 | 235 |
&antsUsageError() if ($opt_u && !defined($opt_i)); |
236 |
||
237 |
&antsCardOpt(\$opt_s,0); # skip # initial ensembles |
|
13 | 238 |
$opt_p = '+' unless defined($opt_p); # separate uc/dc time lagging |
239 |
||
240 |
&antsFloatOpt(\$opt_a,1); # pressure acceleration correction |
|
2 | 241 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
242 |
$STN = &antsCardArg(); # station id |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
243 |
if (@ARGV) { # run label |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
244 |
$RUN = $ARGV[0]; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
245 |
shift; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
246 |
} else { |
13 | 247 |
$RUN = 'profiles'; |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
248 |
} |
0 | 249 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
250 |
#----------------------------- |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
251 |
# 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
|
252 |
#----------------------------- |
0 | 253 |
|
13 | 254 |
require "$WCALC/defaults.pl"; # load default/option parameters |
255 |
require "$processing_param_file"; # load processing parameters |
|
256 |
eval($opt_x) if defined($opt_x); # eval cmd-line expression to override anything |
|
0 | 257 |
|
13 | 258 |
$RDI_Coords::minValidVels = 4 if ($opt_4); # decode cmd-line arguments |
259 |
($LADCP_firstBin,$LADCP_lastBin) = split(',',$opt_b); |
|
260 |
croak("$0: cannot decode -b $opt_b\n") |
|
261 |
unless (numberp($LADCP_firstBin) && |
|
262 |
($LADCP_lastBin eq '*' || numberp($LADCP_lastBin))); |
|
263 |
@number_of_timelag_windows = split(',',$opt_n); |
|
264 |
croak("$0: cannot decode -n $opt_n\n") |
|
265 |
unless numberp($number_of_timelag_windows[0]) && numberp($number_of_timelag_windows[1]); |
|
266 |
@length_of_timelag_windows = split(',',$opt_w); |
|
267 |
croak("$0: cannot decode -w $opt_w\n") |
|
268 |
unless numberp($length_of_timelag_windows[0]) && numberp($length_of_timelag_windows[1]); |
|
269 |
||
270 |
||
271 |
||
272 |
||
273 |
croak("$0: \$out_basename undefined\n") # all plotting routines use this |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
274 |
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
|
275 |
&antsAddParams('out_basename',$out_basename); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
276 |
&antsAddParams('run_label',$RUN); |
0 | 277 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
278 |
$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
|
279 |
$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
|
280 |
$out_TL = ">$out_TL" unless ($out_TL =~ /^$|^\s*\|/); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
281 |
$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
|
282 |
$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
|
283 |
$out_timeseries = ">$out_timeseries" unless ($out_timeseries =~ /^$|^\s*\|/); |
2 | 284 |
|
0 | 285 |
#---------------------------------------------------------------------- |
286 |
# Screen Logging |
|
287 |
# - warning levels: |
|
288 |
# 0 probably unimportant, e.g. nonsensical parameters that probably won't affect solution |
|
289 |
# 1 may be somewhat important |
|
290 |
# 2 important |
|
291 |
#---------------------------------------------------------------------- |
|
292 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
293 |
open(LOGF,">$out_log") || croak("$out_log: $!\n") |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
294 |
if defined($out_log); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
295 |
LOGF->autoflush(1); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
296 |
|
0 | 297 |
sub progress(@) |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
298 |
{ |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
299 |
printf(LOGF @_) if defined($out_log); |
13 | 300 |
printf(STDERR @_) if ($opt_v > 1); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
301 |
} |
0 | 302 |
|
303 |
sub info(@) |
|
304 |
{ |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
305 |
printf(LOGF "\t",@_) if defined($out_log); |
13 | 306 |
print(STDERR ($opt_v > 1) ? "\t" : "$LADCP_file: "); |
307 |
printf(STDERR @_) if ($opt_v > 0); |
|
0 | 308 |
} |
309 |
||
310 |
sub warning(@) |
|
311 |
{ |
|
312 |
my($lvl,@msg) = @_; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
313 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
314 |
if (defined($out_log)) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
315 |
print(LOGF "\nWARNING (level $lvl): "); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
316 |
printf(LOGF @msg); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
317 |
print(LOGF "\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
318 |
} |
13 | 319 |
return if ($opt_v == 0); |
320 |
print(STDERR "\n") if ($opt_v > 1); |
|
0 | 321 |
print(STDERR "WARNING (level $lvl): "); |
322 |
printf(STDERR @msg); |
|
13 | 323 |
print(STDERR "\n") if ($opt_v > 1); |
0 | 324 |
} |
325 |
||
326 |
sub debugmsg(@) |
|
13 | 327 |
{ printf(STDERR @_) if ($opt_v > 2); } |
0 | 328 |
|
329 |
#---------------- |
|
330 |
# Read LADCP data |
|
331 |
#---------------- |
|
332 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
333 |
progress("Reading LADCP data from <$LADCP_file>...\n"); |
0 | 334 |
readData($LADCP_file,\%LADCP); |
335 |
progress("\t%d ensembles\n",scalar(@{$LADCP{ENSEMBLE}})); |
|
336 |
||
337 |
croak("$LADCP_file: not enough LADCP bins ($LADCP{N_BINS}) for choice of -r\n") |
|
338 |
unless ($LADCP{N_BINS} >= $refLr_lastBin); |
|
339 |
||
340 |
croak("$0: first reference-layer bin outside valid range\n") |
|
341 |
unless ($refLr_firstBin>=1 && $refLr_firstBin<=$LADCP{N_BINS}); |
|
342 |
croak("$0: last reference-layer bin outside valid range\n") |
|
343 |
unless ($refLr_lastBin>=1 && $refLr_lastBin<=$LADCP{N_BINS}); |
|
344 |
croak("$0: first reference-layer bin > last reference-layer bin\n") |
|
345 |
unless ($refLr_firstBin <= $refLr_lastBin); |
|
346 |
||
347 |
$LADCP_lastBin = $LADCP{N_BINS}-1 |
|
348 |
if ($LADCP_lastBin eq '*'); |
|
349 |
croak("$0: first valid LADCP bin outside valid range\n") |
|
350 |
unless ($LADCP_firstBin>=1 && $LADCP_firstBin<=$LADCP{N_BINS}); |
|
351 |
croak("$0: last valid LADCP bin outside valid range\n") |
|
352 |
unless ($LADCP_lastBin>=1 && $LADCP_lastBin<=$LADCP{N_BINS}); |
|
353 |
croak("$0: first valid LADCP bin > last valid LADCP bin\n") |
|
354 |
unless ($LADCP_firstBin <= $LADCP_lastBin); |
|
355 |
||
356 |
warning(0,"first reference-layer bin < first valid LADCP bin\n") |
|
357 |
unless ($refLr_firstBin >= $LADCP_firstBin); |
|
358 |
warning(0,"last reference-layer bin > last valid LADCP bin\n") |
|
359 |
unless ($refLr_lastBin <= $LADCP_lastBin); |
|
360 |
||
361 |
warning(1,"if at all, bin 1 should not be used for short blank-after-transmit values\n") |
|
362 |
if ($LADCP{BLANKING_DISTANCE}<$LADCP{BIN_LENGTH} && $refLr_firstBin==1); |
|
363 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
364 |
&antsAddParams('ADCP_bin_length',$LADCP{BIN_LENGTH}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
365 |
'ADCP_frequency',$LADCP{BEAM_FREQUENCY}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
366 |
'ADCP_blanking_distance',$LADCP{BLANKING_DISTANCE}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
367 |
|
0 | 368 |
#------------------------------------------------------------ |
369 |
# Edit beam-velocity data |
|
13 | 370 |
# 0) beam-vel mask on -m |
0 | 371 |
# 1) correlation threshold |
372 |
#------------------------------------------------------------ |
|
373 |
||
374 |
if ($LADCP{BEAM_COORDINATES}) { |
|
375 |
progress("Editing beam-velocity data...\n"); |
|
13 | 376 |
|
377 |
if (defined($opt_m) && -r $opt_m) { |
|
378 |
progress("\tmasking beam velocities according to $opt_m:"); |
|
379 |
||
380 |
my($nee) = 0; |
|
381 |
open(BVM,$opt_m) || die("$opt_m: $!\n"); |
|
382 |
while (<BVM>) { |
|
383 |
s/#.*//; |
|
384 |
s/^\s*$//; |
|
385 |
next if ($_ eq ''); |
|
386 |
my($fe,$te,$db) = split; |
|
387 |
die("$opt_m: cannot decode $_\n") |
|
388 |
unless (numberp($fe) && numberp($te) && $te>=$fe && $db>=1 && $db<=4); |
|
389 |
die("$0: assertion failed") |
|
390 |
unless ($LADCP{ENSEMBLE}[$fe-1]->{NUMBER} == $fe && |
|
391 |
$LADCP{ENSEMBLE}[$te-1]->{NUMBER} == $te); |
|
392 |
for (my($ens)=$fe-1; $ens<=$te-1; $ens++) { |
|
393 |
$nee++; |
|
394 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
395 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$db-1]); |
|
396 |
} |
|
397 |
} |
|
398 |
} |
|
399 |
print(STDERR " $nee ensembles edited\n"); |
|
400 |
close(BVM); |
|
401 |
} |
|
402 |
||
0 | 403 |
$nvv = $cte = 0; |
404 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
6 | 405 |
correctAttitude($ens,$pitch_bias,$roll_bias,$heading_bias); |
0 | 406 |
$nvv += countValidBeamVels($ens); |
13 | 407 |
$cte += editCorr($ens,$opt_c); |
408 |
# $pte += editTilt($ens,$opt_t); |
|
0 | 409 |
} |
410 |
croak("$LADCP_file: no valid data\n") unless ($nvv > 0); |
|
13 | 411 |
progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$opt_c,$cte,round(100*$cte/$nvv)); |
412 |
# progress("\tattitude threshold (-t %d deg): %d velocites removed (%d%% of total)\n",$opt_t,$pte,round(100*$pte/$nvv)); |
|
0 | 413 |
} else { |
414 |
progress("Editing velocity data...\n"); |
|
13 | 415 |
croak("$LADCP_file: cannot apply beamvel-mask $opt_m to earth-coordinate data\n") |
416 |
if defined($opt_m); |
|
0 | 417 |
$nvv = $cte = 0; |
418 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
419 |
$nvv += countValidBeamVels($ens); |
|
13 | 420 |
$cte += editCorr_Earthcoords($ens,$opt_c); |
421 |
# $pte += editTilt($ens,$opt_t); |
|
0 | 422 |
} |
423 |
croak("$LADCP_file: no valid data\n") unless ($nvv > 0); |
|
13 | 424 |
progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$opt_c,$cte,round(100*$cte/$nvv)); |
425 |
# progress("\tattitude threshold (-t %d deg): %d velocites removed (%d%% of total)\n",$opt_t,$pte,round(100*$pte/$nvv)); |
|
0 | 426 |
} |
427 |
||
428 |
#------------------------------------------------------------------- |
|
429 |
# Calculate earth velocities |
|
430 |
# - this is done for all bins (not just valid ones), to allow |
|
431 |
# useless possibility that invalid bins are used for reflr calcs |
|
432 |
# - also calculate separate beam-pair velocities |
|
433 |
# - the UNEDITED velocities are saved for the BT calculations |
|
434 |
# (W is required, U & V are only used for stats that have not |
|
435 |
# been very useful so far) |
|
436 |
#------------------------------------------------------------------- |
|
437 |
||
438 |
if ($LADCP{BEAM_COORDINATES}) { |
|
6 | 439 |
my($dummy); |
0 | 440 |
progress("Calculating earth-coordinate velocities...\n"); |
13 | 441 |
progress("\tdiscarding velocities from beam $bad_beam\n") |
442 |
if ($bad_beam); |
|
0 | 443 |
$nvw = 0; |
444 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
445 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
13 | 446 |
if ($bad_beam) { |
447 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$bad_beam-1]); |
|
448 |
undef($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$bin][$bad_beam-1]); |
|
449 |
} |
|
0 | 450 |
($LADCP{ENSEMBLE}[$ens]->{U}[$bin], |
451 |
$LADCP{ENSEMBLE}[$ens]->{V}[$bin], |
|
452 |
$LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
|
453 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin]) = |
|
454 |
velInstrumentToEarth(\%LADCP,$ens, |
|
455 |
velBeamToInstrument(\%LADCP, |
|
456 |
@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]})); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
457 |
if (defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin])) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
458 |
$per_bin_nsamp[$bin]++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
459 |
$nvw++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
460 |
} |
0 | 461 |
$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH} = |
462 |
gimbal_pitch($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
|
463 |
$LADCP{ENSEMBLE}[$ens]->{U_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{U}[$bin]; |
|
464 |
$LADCP{ENSEMBLE}[$ens]->{V_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{V}[$bin]; |
|
465 |
$LADCP{ENSEMBLE}[$ens]->{W_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin]; |
|
6 | 466 |
|
467 |
($dummy,$LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
|
468 |
$dummy,$LADCP{ENSEMBLE}[$ens]->{W34}[$bin]) = |
|
469 |
velBeamToBPEarth(\%LADCP,$ens,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}); |
|
0 | 470 |
} |
471 |
} |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
472 |
progress("\t$nvw valid velocities in bins $LADCP_firstBin-$LADCP_lastBin\n"); |
0 | 473 |
progress("\t3-beam solutions : $RDI_Coords::threeBeam_1 " . |
474 |
"$RDI_Coords::threeBeam_2 " . |
|
475 |
"$RDI_Coords::threeBeam_3 " . |
|
476 |
"$RDI_Coords::threeBeam_4\n") |
|
477 |
unless ($opt_4); |
|
6 | 478 |
} else { # Earth Coordinates |
0 | 479 |
progress("Counting valid vertical velocities...\n"); |
480 |
$nvw = 0; |
|
481 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
482 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
483 |
($LADCP{ENSEMBLE}[$ens]->{U}[$bin], |
|
484 |
$LADCP{ENSEMBLE}[$ens]->{V}[$bin], |
|
485 |
$LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
|
486 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin]) = @{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
487 |
if (defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin])) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
488 |
$per_bin_nsamp[$bin]++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
489 |
$nvw++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
490 |
} |
0 | 491 |
$LADCP{ENSEMBLE}[$ens]->{U_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{U}[$bin]; |
492 |
$LADCP{ENSEMBLE}[$ens]->{V_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{V}[$bin]; |
|
493 |
$LADCP{ENSEMBLE}[$ens]->{W_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin]; |
|
13 | 494 |
|
495 |
$LADCP{ENSEMBLE}[$ens]->{W12}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W34}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin]; |
|
0 | 496 |
} |
497 |
} |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
498 |
progress("\t$nvw valid velocities in bins $LADCP_firstBin-$LADCP_lastBin\n"); |
0 | 499 |
} |
500 |
||
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
501 |
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
|
502 |
|
0 | 503 |
#---------------------------------------------- |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
504 |
# STEP: Edit earth-coordinate -velocity data |
0 | 505 |
# 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
|
506 |
# 2) vertical-velocity outliers |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
507 |
# 3) truncate range by deleting farthest valid velocities (disbled by default) |
0 | 508 |
#---------------------------------------------- |
509 |
||
510 |
progress("Editing earth-coordinate velocity data...\n"); |
|
511 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
512 |
$evrm = $trrm = $worm = 0; |
0 | 513 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
13 | 514 |
$evrm += editErrVel($ens,$opt_e); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
515 |
$worm += editWOutliers($ens,$per_ens_outliers_mad_limit); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
516 |
$trrm += editTruncRange($ens,$truncate_farthest_valid_bins) if ($truncate_farthest_valid_bins > 0); |
0 | 517 |
} |
13 | 518 |
progress("\terror-velocity threshold (-e %.2f m/s): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n", |
519 |
$opt_e,$evrm,round(100*$evrm/$nvw)); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
520 |
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
|
521 |
$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
|
522 |
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
|
523 |
$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
|
524 |
if ($truncate_farthest_valid_bins > 0); |
0 | 525 |
|
526 |
#---------------------------- |
|
527 |
# Calculate LADCP time series |
|
528 |
#---------------------------- |
|
529 |
||
530 |
progress("Calculating LADCP time-series...\n"); |
|
531 |
||
532 |
($firstGoodEns,$lastGoodEns,$LADCP_atbottom,$LADCP_w_gap_time) = |
|
13 | 533 |
calcLADCPts(\%LADCP,$opt_s,$refLr_firstBin,$refLr_lastBin,$opt_g); |
0 | 534 |
croak("$LADCP_file: no good ensembles\n") |
535 |
unless defined($firstGoodEns) && ($lastGoodEns-$firstGoodEns > 0); |
|
536 |
||
537 |
my($cast_duration) = $LADCP{ENSEMBLE}[$lastGoodEns]->{ELAPSED} - |
|
538 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{ELAPSED}; |
|
539 |
croak("$0: implausibly short cast ($cast_duration seconds)\n") |
|
540 |
unless ($cast_duration > 600); |
|
541 |
||
542 |
$LADCP{MEAN_DT} = $cast_duration / ($lastGoodEns-$firstGoodEns-1); |
|
543 |
||
544 |
progress("\tStart of cast : %s (#%5d)\n", |
|
545 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{TIME}, |
|
546 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER}); |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
547 |
progress("\tBottom of cast : %s (#%5d) @ dz=%6dm\n", |
0 | 548 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{TIME}, |
549 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{NUMBER}, |
|
550 |
$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
|
551 |
progress("\tEnd of cast : %s (#%5d) @ dz=%6dm\n", |
0 | 552 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{TIME}, |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
553 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{NUMBER}, |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
554 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{DEPTH}); |
0 | 555 |
progress("\tCast duration : %.1f hours (pinging for %.1f hours)\n", |
556 |
$cast_duration / 3600, |
|
557 |
($LADCP{ENSEMBLE}[$#{$LADCP{ENSEMBLE}}]->{UNIX_TIME} - |
|
558 |
$LADCP{ENSEMBLE}[0]->{UNIX_TIME}) / 3600); |
|
559 |
progress("\tMean ping interval: %.1f seconds\n",$LADCP{MEAN_DT}); |
|
560 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
561 |
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
|
562 |
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
|
563 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
564 |
@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
|
565 |
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
|
566 |
for (my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
567 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
568 |
$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
|
569 |
$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
|
570 |
$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
|
571 |
$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
|
572 |
$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
|
573 |
} |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
574 |
&antsOut('EOF'); open(STDOUT,">&2"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
575 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
576 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
577 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
578 |
# More editing |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
579 |
# - this requires ${first,last}GoodEns to be known |
6 | 580 |
# - TILT field is set as a side-effect |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
581 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
582 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
583 |
progress("Editing additional earth-coordinate velocity data...\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
584 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
585 |
my($first_bad_bin); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
586 |
for (my($bin)=$LADCP_firstBin-1; $bin<$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
587 |
next unless ($per_bin_nsamp[$bin]/($lastGoodEns-$firstGoodEns) < $per_bin_valid_frac_lim); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
588 |
$first_bad_bin = $bin; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
589 |
last; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
590 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
591 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
592 |
if (defined($first_bad_bin)) { |
6 | 593 |
$fprm = $pte = 0; |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
594 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
13 | 595 |
$pte += editTilt($ens,$opt_t); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
596 |
$fprm += editFarBins($ens,$first_bad_bin) if defined($first_bad_bin); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
597 |
} |
6 | 598 |
progress("\tattitude threshold (max_tilt = %d deg): %d velocites removed (%d%% of total)\n", |
13 | 599 |
$opt_t,$pte,round(100*$pte/$nvv)); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
600 |
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
|
601 |
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
|
602 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
603 |
|
0 | 604 |
#-------------- |
605 |
# Read CTD data |
|
606 |
#-------------- |
|
607 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
608 |
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
|
609 |
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
|
610 |
croak("$CTD_file: no data\n") unless (&antsIn()); |
2 | 611 |
undef($antsOldHeaders); |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
612 |
($CTD_elapsed,$CTD_depth,$CTD_svel,$CTD_w) = &fnr('elapsed','depth','ss','w'); |
0 | 613 |
$CTD_temp = &fnrNoErr('temp'); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
614 |
&antsAddParams('lat',$P{lat}) if defined($P{lat}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
615 |
&antsAddParams('lon',$P{lon}) if defined($P{lon}); |
0 | 616 |
|
617 |
$CTD_maxdepth = -1; |
|
618 |
||
13 | 619 |
do { # read data |
0 | 620 |
croak("$0: cannot deal with non-numeric CTD elapsed time\n") |
621 |
unless &antsNumbers($CTD_elapsed); |
|
622 |
push(@{$CTD{ELAPSED}},$ants_[0][$CTD_elapsed]); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
623 |
push(@{$CTD{DEPTH}}, $ants_[0][$CTD_depth]); |
0 | 624 |
push(@{$CTD{SVEL}}, $ants_[0][$CTD_svel]); |
625 |
push(@{$CTD{W}}, $ants_[0][$CTD_w]); |
|
626 |
push(@{$CTD{TEMP}}, $ants_[0][$CTD_temp]) if defined($CTD_temp); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
627 |
if ($ants_[0][$CTD_depth] > $CTD_maxdepth) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
628 |
$CTD_maxdepth = $ants_[0][$CTD_depth]; |
0 | 629 |
$CTD_atbottom = $#{$CTD{DEPTH}}; |
630 |
} |
|
631 |
} while (&antsIn()); |
|
632 |
||
633 |
$CTD{DT} = ($CTD{ELAPSED}[$#{$CTD{ELAPSED}}] - $CTD{ELAPSED}[0]) / $#{$CTD{ELAPSED}}; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
634 |
progress("\t%d scans at %.1fHz\n",scalar(@{$CTD{DEPTH}}),1/$CTD{DT}); |
0 | 635 |
|
13 | 636 |
$CTD{W_t}[0] = $CTD{W_t} [@{$CTD{ELAPSED}}] = nan; # calculate w-derivatives |
637 |
$CTD{W_tt}[0] = $CTD{W_tt}[@{$CTD{ELAPSED}}] = nan; |
|
638 |
for (my($s)=1; $s<@{$CTD{ELAPSED}}-1; $s++) { # centered differences for both |
|
639 |
$CTD{W_t} [$s] = ($CTD{W}[$s+1] - $CTD{W}[$s-1]) / (2*$CTD{DT}); |
|
640 |
$CTD{W_tt}[$s] = ($CTD{W}[$s+1] + $CTD{W}[$s-1] - 2*$CTD{W}[$s]) / $CTD{DT}**2; |
|
641 |
} |
|
642 |
||
0 | 643 |
croak("$0: CTD start depth must be numeric\n") |
644 |
unless numberp($CTD{DEPTH}[0]); |
|
13 | 645 |
if (($CTD{DEPTH}[0] < -$opt_d) && !defined($opt_d)) { |
646 |
$opt_d = -1 * round($CTD{DEPTH}[0]); |
|
12
2adcd220b9b4
before attempting to implement piece-wise time-lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
647 |
} |
13 | 648 |
if ($opt_d > 0) { |
649 |
progress("\tadding $opt_d dbar offset to pressure data\n"); |
|
650 |
for (my($i)=0; $i<@{$CTD{DEPTH}}; $i++) { $CTD{DEPTH}[$i] += $opt_d; } |
|
651 |
$CTD_maxdepth += $opt_d; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
652 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
653 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
654 |
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
|
655 |
progress("\tmax depth = %dm (# $CTD_atbottom)\n",$CTD_maxdepth); |
0 | 656 |
|
657 |
#-------------------------------------------------------------------- |
|
658 |
# Construct sound-speed correction profile from CTD 1Hz downcast data |
|
659 |
# very simple algorithm that stores the last value found |
|
660 |
# in each 1m bin |
|
661 |
#-------------------------------------------------------------------- |
|
662 |
||
663 |
progress("Constructing sound-speed correction profile\n"); |
|
664 |
||
665 |
my($scans_per_sec) = int(1/$CTD{DT}+0.5); |
|
666 |
for (my($s)=0; $s<=$CTD_atbottom; $s+=$scans_per_sec) { |
|
667 |
next unless ($CTD{DEPTH}[$s] >= 0 && numberp($CTD{SVEL}[$s])); |
|
668 |
$sVelProf[int($CTD{DEPTH}[$s])] = $CTD{SVEL}[$s]; |
|
669 |
} |
|
670 |
||
671 |
#------------------- |
|
672 |
# Determine time lag |
|
673 |
#------------------- |
|
674 |
||
13 | 675 |
if (defined($opt_i)) { |
0 | 676 |
progress("Setting initial time lag...\n"); |
13 | 677 |
$CTD{TIME_LAG} = $opt_i; |
0 | 678 |
progress("\t-i => elapsed(CTD) ~ elapsed(LADCP) + %.1fs\n",$CTD{TIME_LAG}); |
679 |
} else { |
|
680 |
progress("Guestimating time lag...\n"); |
|
681 |
||
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
682 |
my($CTD_10pct_down) = 0; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
683 |
my($LADCP_10pct_down) = $firstGoodEns; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
684 |
|
0 | 685 |
$CTD_10pct_down++ |
686 |
until ($CTD{DEPTH}[$CTD_10pct_down]-$CTD{DEPTH}[0] >= 0.1*($CTD_maxdepth-$CTD{DEPTH}[0])); |
|
687 |
$LADCP_10pct_down++ |
|
688 |
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
|
689 |
|
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
690 |
$CTD{TIME_LAG} = |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
691 |
$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
|
692 |
|
0 | 693 |
progress("\telapsed(dz(CTD)=%.1fm) ~ elapsed(dz(LADCP)=%.1fm) + %.1fs\n", |
694 |
$CTD{DEPTH}[$CTD_10pct_down]-$CTD{DEPTH}[0],$LADCP{ENSEMBLE}[$LADCP_10pct_down]->{DEPTH},$CTD{TIME_LAG}); |
|
695 |
} |
|
696 |
||
2 | 697 |
if ($opt_u) { |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
698 |
progress("\tskipping time lagging (-u)\n"); |
2 | 699 |
} else { |
13 | 700 |
|
701 |
#------------------------ |
|
702 |
# stage 1: 1Hz; full cast |
|
703 |
#------------------------ |
|
704 |
||
705 |
$CTD{TIME_LAG} = |
|
706 |
calc_lag($number_of_timelag_windows[0],$length_of_timelag_windows[0], |
|
707 |
int(1/$CTD{DT}+0.5),$firstGoodEns,$lastGoodEns); |
|
11 | 708 |
croak("$0: Cannot proceed without valid lag!\n") unless defined($CTD{TIME_LAG}); |
2 | 709 |
progress("\telapsed(CTD) ~ elapsed(LADCP) + %.2fs\n",$CTD{TIME_LAG}); |
13 | 710 |
|
711 |
#--------------------------------- |
|
712 |
# stage 2: piece-wise time lagging |
|
713 |
#--------------------------------- |
|
714 |
||
715 |
my(@splits); |
|
716 |
push(@splits,$firstGoodEns); |
|
717 |
foreach my $s (split(/,/,$opt_p)) { |
|
718 |
if ($s eq '+') { |
|
719 |
push(@splits,$LADCP_atbottom); |
|
720 |
} elsif (numberp($s)) { # find ens for given LADCP elapsed time in min |
|
721 |
my($ela) = $s*60; |
|
722 |
my($ens) = $firstGoodEns + round($ela / $LADCP{MEAN_DT}); # first, guess |
|
723 |
while ($LADCP{ENSEMBLE}[$ens]->{ELAPSED} > $ela) { $ens--; } # then, correct |
|
724 |
while ($LADCP{ENSEMBLE}[$ens]->{ELAPSED} < $ela) { $ens++; } |
|
725 |
push(@splits,$ens); |
|
726 |
} else { |
|
727 |
warning(2,"ignoring non-numeric -p argument %s",$s); |
|
728 |
} |
|
729 |
} |
|
730 |
push(@splits,$lastGoodEns); |
|
11 | 731 |
|
13 | 732 |
my($valid_lag); # determine piece-wise lags |
733 |
while (@splits > 1) { |
|
734 |
push(@CTD_tl_fromEns,$splits[0]); |
|
735 |
push(@CTD_tl_toEns,$splits[1]); |
|
736 |
my($lag) = calc_lag($number_of_timelag_windows[1],$length_of_timelag_windows[1], |
|
737 |
1,$splits[0],$splits[1]); |
|
738 |
debugmsg("lag($splits[0],$splits[1]) = $lag\n"); |
|
739 |
if (defined($lag)) { |
|
740 |
progress("\tcast-piece: elapsed(CTD) = elapsed(LADCP) + %.2fs\n",$lag); |
|
741 |
push(@CTD_time_lag,$lag); |
|
742 |
$valid_lag = $#CTD_time_lag; |
|
743 |
} else { |
|
744 |
progress("\tcast-piece: time-lagging failed\n"); |
|
745 |
push(@CTD_time_lag,nan); |
|
746 |
} |
|
747 |
shift(@splits); |
|
748 |
} |
|
749 |
||
750 |
croak("$0: Cannot proceed without at least one lag!\n") # fill failed lag with surrounding data |
|
751 |
unless defined($valid_lag); |
|
752 |
while ($valid_lag < $#CTD_time_lag) { # forward |
|
753 |
$CTD_time_lag[$valid_lag+1] = $CTD_time_lag[$valid_lag]; |
|
754 |
$valid_lag++; |
|
755 |
} |
|
756 |
while ($valid_lag > 0) { # backward |
|
757 |
$CTD_time_lag[$valid_lag-1] = $CTD_time_lag[$valid_lag] |
|
758 |
unless (numberp($CTD_time_lag[$valid_lag-1])); |
|
759 |
$valid_lag--; |
|
760 |
} |
|
2 | 761 |
} |
0 | 762 |
|
13 | 763 |
&antsAddParams('CTD_time_lags',"@CTD_time_lag"); |
764 |
undef($CTD{TIME_LAG}); # to avoid confusion, clear old 1Hz-based lag |
|
0 | 765 |
|
766 |
#------------------------------------------------ |
|
767 |
# Merge CTD with LADCP data |
|
768 |
# - after this step, reflr w is sound-speed corrected!!! |
|
769 |
#------------------------------------------------ |
|
770 |
||
771 |
progress("Merging CTD with LADCP data...\n"); |
|
772 |
||
13 | 773 |
my($cli) = 0; # current-lag index |
774 |
my($lag) = $CTD_time_lag[$cli]; # current lag |
|
775 |
||
0 | 776 |
for (my($skipped)=0,my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
13 | 777 |
|
778 |
if ($ens > $CTD_tl_toEns[$cli]) { # use correct lag piece |
|
779 |
$cli++; |
|
780 |
die("assertion failed!\n\ttest: \$cli(=$cli) <= \$#CTD_time_lag\n") |
|
781 |
unless ($cli <= $#CTD_time_lag); |
|
782 |
$lag = $CTD_time_lag[$cli]; |
|
783 |
} |
|
784 |
||
785 |
my($scan) = |
|
786 |
int(($LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $lag - $CTD{ELAPSED}[0]) / $CTD{DT} + 0.5); |
|
0 | 787 |
if ($scan <= 0) { # NB: must be <=, rather than <, or assertion below sometimes fails |
788 |
$skipped++; |
|
789 |
$firstGoodEns = $ens+1; |
|
790 |
next; |
|
791 |
} |
|
792 |
if ($skipped > 0) { |
|
13 | 793 |
$firstGoodEns++,$skipped++,next # in gap |
2 | 794 |
unless defined($LADCP{ENSEMBLE}[$firstGoodEns]->{REFLR_W}); |
0 | 795 |
info("$skipped initial LADCP ensembles skipped because CTD data begin with LADCP in water\n"); |
796 |
$skipped = 0; |
|
797 |
} |
|
798 |
if ($scan > $#{$CTD{ELAPSED}}) { |
|
13 | 799 |
while (!defined($LADCP{ENSEMBLE}[$ens-1]->{REFLR_W})) { $ens--; } # in gap |
0 | 800 |
info(sprintf("%d final LADCP ensembles skipped because CTD data end with LADCP in water\n", |
801 |
$lastGoodEns-$ens+1)); |
|
802 |
$lastGoodEns = $ens-1; |
|
803 |
last; |
|
804 |
} |
|
805 |
||
806 |
$LADCP{ENSEMBLE}[$ens]->{CTD_ELAPSED} = $CTD{ELAPSED}[$scan]; # elapsed field for output |
|
807 |
||
808 |
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
|
809 |
&& numberp($CTD{DEPTH}[$scan])) { |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
810 |
$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
|
811 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W} *= $CTD{SVEL}[$scan]/1500; # correct for sound-speed variations at source |
13 | 812 |
croak(sprintf("\n$0: negative depth (%.1fm) in CTD file at elapsed(CTD) = %.1fs (use -d?)\n", |
0 | 813 |
$CTD{DEPTH}[$scan],$CTD{ELAPSED}[$scan])) |
814 |
unless ($CTD{DEPTH}[$scan] >= 0); |
|
815 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} = $CTD{DEPTH}[$scan]; |
|
816 |
$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN} = $scan; |
|
817 |
my($reflr_ocean_w) = $LADCP{ENSEMBLE}[$ens]->{REFLR_W} - $CTD{W}[$scan]; |
|
13 | 818 |
if (abs($reflr_ocean_w) <= $w_max_lim) { |
0 | 819 |
$sumWsq += &SQR($reflr_ocean_w); |
820 |
$nWsq++; |
|
821 |
if ($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} > 100 && |
|
822 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} < $LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH}-100) { |
|
823 |
$sumWsqI += &SQR($reflr_ocean_w); |
|
824 |
$nWsqI++; |
|
825 |
} |
|
826 |
} else { |
|
827 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); # DON'T USE THIS ENSEMBLE LATER |
|
828 |
} |
|
829 |
} else{ |
|
830 |
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
|
831 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); # old DEPTH from calcLADCPts() must be removed |
0 | 832 |
} |
833 |
} |
|
834 |
||
835 |
if ($nWsq > 0 && $nWsqI > 0) { |
|
836 |
&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',sqrt($sumWsqI/$nWsqI)); |
|
837 |
progress("\t%.2f cm/s rms reference-layer w_ocean, %.2f cm/s away from boundaries\n", |
|
838 |
100*sqrt($sumWsq/$nWsq),100*sqrt($sumWsqI/$nWsqI)); |
|
839 |
warning(0,"%.2f cm/s reference-layer w_ocean away from boundaries\n",100*sqrt($sumWsqI/$nWsqI)) |
|
840 |
if (sqrt($sumWsqI/$nWsqI) > 0.05); |
|
2 | 841 |
# croak("$0: rms reference-layer w_ocean is too large\n") |
842 |
# unless (sqrt($sumWsqI/$nWsqI) < 0.07); |
|
0 | 843 |
} elsif ($nWsq > 0) { |
844 |
&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',nan); |
|
845 |
progress("\t%.2f cm/s rms reference-layer w_ocean\n",100*sqrt($sumWsq/$nWsq)); |
|
846 |
} else { |
|
847 |
croak("$0: no valid vertical velocities\n"); |
|
848 |
} |
|
849 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
850 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
851 |
# Calculate Volume Scattering Coefficients |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
852 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
853 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
854 |
progress("Calculating volume-scattering coefficients...\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
855 |
calc_backscatter_profs($firstGoodEns,$lastGoodEns); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
856 |
|
0 | 857 |
#---------------------------------------------------------------------------- |
858 |
# Remove data contaminated by sidelobe reflection from seabed and sea surface |
|
859 |
#---------------------------------------------------------------------------- |
|
860 |
||
861 |
if ($LADCP{ENSEMBLE}[$LADCP_atbottom]->{XDUCER_FACING_DOWN}) { |
|
862 |
&antsAddParams('ADCP_orientation','downlooker'); |
|
863 |
||
864 |
if (numberp($opt_h)) { |
|
865 |
progress("Setting water depth (-h)\n"); |
|
866 |
$water_depth = $opt_h; |
|
867 |
$sig_water_depth = 0; |
|
868 |
} else { |
|
869 |
progress("Finding seabed...\n"); |
|
870 |
($water_depth,$sig_water_depth) = |
|
871 |
find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH}); |
|
872 |
($water_depth_BT,$sig_water_depth_BT) = |
|
873 |
find_seabed(\%LADCP,$LADCP_atbottom,$LADCP{BEAM_COORDINATES}); |
|
874 |
if (defined($water_depth_BT)) { |
|
875 |
my($dd) = abs($water_depth_BT - $water_depth); |
|
876 |
warning(2,sprintf("Large RDI vs. own water-depth difference (%.1fm)\n",$dd)) |
|
877 |
if ($dd > 5); |
|
878 |
} |
|
879 |
} |
|
880 |
||
881 |
&antsAddParams('water_depth',$water_depth,'water_depth.sig',$sig_water_depth); |
|
882 |
||
883 |
if (defined($water_depth)) { |
|
884 |
if (defined($water_depth_BT)) { |
|
885 |
progress("\t%.1f(%.1f) m water depth (%.1f(%.1f)m from BT)\n", |
|
886 |
$water_depth,$sig_water_depth,$water_depth_BT,$sig_water_depth_BT); |
|
887 |
} else { |
|
888 |
progress("\t%.1f(%.1f) m water depth\n",$water_depth,$sig_water_depth); |
|
889 |
} |
|
890 |
warning(1,sprintf("large uncertainty in water-depth estimation (%.1fm)\n",$sig_water_depth)) |
|
891 |
if ($sig_water_depth > $LADCP{BIN_LENGTH}); |
|
892 |
||
893 |
progress("Editing data to remove sidelobe interference from seabed...\n"); |
|
894 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,$water_depth); |
|
895 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
|
896 |
||
897 |
} else { |
|
898 |
info("no seabed found in backscatter profiles --- no sidelobe editing done\n"); |
|
899 |
} |
|
900 |
||
901 |
} else { |
|
902 |
&antsAddParams('ADCP_orientation','uplooker'); |
|
903 |
progress("Editing data to remove sidelobe interference from sea surface...\n"); |
|
904 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,undef); |
|
905 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
|
906 |
} |
|
907 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
908 |
#---------------------------------------------------------------------- |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
909 |
# 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
|
910 |
# 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
|
911 |
# 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
|
912 |
#---------------------------------------------------------------------- |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
913 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
914 |
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
|
915 |
$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
|
916 |
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
|
917 |
|
11 | 918 |
if (defined($post_merge_hook)) { |
919 |
progress("Executing user-supplied \$post_merge_hook...\n"); |
|
920 |
&{$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
|
921 |
} |
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
922 |
|
13 | 923 |
#---------------------------------------------------------------------- |
924 |
# apply pressure-sensor acceleration correction (-a) |
|
925 |
# - valid, but useless except for troubleshooting data sets (e.g. DIMES UK2) |
|
926 |
# - useless, because ping-coherent error removal below does same job but better |
|
927 |
# - it does not make sense to to use this with ping-coherent error removal enabled |
|
928 |
#---------------------------------------------------------------------- |
|
929 |
||
930 |
if ($opt_a != 1) { |
|
931 |
progress("Applying pressure-sensor acceleration correction...\n"); |
|
932 |
for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
|
933 |
next unless numberp($CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
934 |
my($acorr) = $opt_a * $CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
|
935 |
if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH})) { |
|
936 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
937 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
938 |
$LADCP{ENSEMBLE}[$ens]->{W}[$bin] -= $acorr; |
|
939 |
} |
|
940 |
} |
|
941 |
if (numberp($LADCP{ENSEMBLE}[$ens]->{REFLR_W})) { |
|
942 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W} -= $acorr; |
|
943 |
} |
|
944 |
} |
|
945 |
} |
|
946 |
||
0 | 947 |
#--------------------------------------------------------------------------- |
948 |
# Depth-bin LADCP velocity data |
|
949 |
# |
|
950 |
# NOTES: |
|
951 |
# 1) ensemble and bin numbers are saved for maximum flexibility |
|
952 |
# 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
|
953 |
# 3) applying the full soundspeed correction to w is pointless in |
0 | 954 |
# practice, but hey!, CPU cycles are cheap; [in a cast in the Gulf of Mexico |
955 |
# which has fairly pronounce soundspeed gradients, the max value of Kn |
|
956 |
# is 1.00004160558372, which gives rise to a correction of less than 0.2mm/s |
|
957 |
# at a winch+wave speed of 3m/s....] |
|
958 |
# 4) as far as I can tell, the soundspeed correction for bin length also |
|
959 |
# has only a minute effect |
|
960 |
#--------------------------------------------------------------------------- |
|
961 |
||
13 | 962 |
progress("Creating binned profiles at ${opt_o}m resolution...\n"); |
0 | 963 |
|
2 | 964 |
my($min_depth) = 9e99; |
965 |
my($max_depth) = 0; |
|
966 |
||
0 | 967 |
progress("\tdowncast...\n"); |
968 |
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
|
969 |
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
|
970 |
$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
|
971 |
next; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
972 |
} |
0 | 973 |
my(@bindepth) = calc_binDepths($ens); |
974 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
975 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
2 | 976 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
977 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
978 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] = |
|
0 | 979 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
980 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
981 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
982 |
$bindepth[$bin]); |
|
6 | 983 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] = |
984 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
|
985 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
986 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
987 |
$bindepth[$bin]) |
|
988 |
if numberp($LADCP{ENSEMBLE}[$ens]->{W12}[$bin]); |
|
989 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] = |
|
990 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W34}[$bin], |
|
991 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
992 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
993 |
$bindepth[$bin]) |
|
994 |
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
|
995 |
$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
|
996 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] + $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
13 | 997 |
my($bi) = $bindepth[$bin]/$opt_o; |
0 | 998 |
push(@{$DNCAST{ENSEMBLE}[$bi]},$ens); |
999 |
push(@{$DNCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1000 |
push(@{$DNCAST{CTD_W}[$bi]},$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
13 | 1001 |
push(@{$DNCAST{CTD_W_tt}[$bi]},$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
0 | 1002 |
push(@{$DNCAST{BIN}[$bi]},$bin); |
1003 |
push(@{$DNCAST{DEPTH}[$bi]},$bindepth[$bin]); |
|
2 | 1004 |
push(@{$DNCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
13 | 1005 |
push(@{$DNCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
1006 |
push(@{$DNCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
0 | 1007 |
} |
1008 |
} |
|
1009 |
||
6 | 1010 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { # bin data into profile |
0 | 1011 |
$DNCAST{MEAN_DEPTH}[$bi] = avg(@{$DNCAST{DEPTH}[$bi]}); |
1012 |
$DNCAST{MEAN_ELAPSED}[$bi] = avg(@{$DNCAST{ELAPSED}[$bi]}); |
|
1013 |
$DNCAST{MEDIAN_W}[$bi] = median(@{$DNCAST{W}[$bi]}); |
|
13 | 1014 |
$DNCAST{MEDIAN_W12}[$bi] = median(@{$DNCAST{W12}[$bi]}); |
1015 |
$DNCAST{MEDIAN_W34}[$bi] = median(@{$DNCAST{W34}[$bi]}); |
|
0 | 1016 |
$DNCAST{MAD_W}[$bi] = mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]}); |
1017 |
$DNCAST{N_SAMP}[$bi] = @{$DNCAST{W}[$bi]}; |
|
1018 |
} |
|
1019 |
||
2 | 1020 |
progress("\tupcast...\n"); # upcast |
0 | 1021 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1022 |
my($realLastGoodEns); |
0 | 1023 |
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) { |
1024 |
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
|
1025 |
$realLastGoodEns = $ens; |
0 | 1026 |
my(@bindepth) = calc_binDepths($ens); |
1027 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1028 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
2 | 1029 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
1030 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
1031 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] = |
|
0 | 1032 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
1033 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1034 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
1035 |
$bindepth[$bin]); |
|
6 | 1036 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] = |
1037 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
|
1038 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1039 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
1040 |
$bindepth[$bin]) |
|
1041 |
if numberp($LADCP{ENSEMBLE}[$ens]->{W12}[$bin]); |
|
1042 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] = |
|
1043 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W34}[$bin], |
|
1044 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1045 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
1046 |
$bindepth[$bin]) |
|
1047 |
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
|
1048 |
$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
|
1049 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] + $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
13 | 1050 |
my($bi) = $bindepth[$bin]/$opt_o; |
0 | 1051 |
push(@{$UPCAST{ENSEMBLE}[$bi]},$ens); |
1052 |
push(@{$UPCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1053 |
push(@{$UPCAST{CTD_W}[$bi]},$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
13 | 1054 |
push(@{$UPCAST{CTD_W_tt}[$bi]},$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
0 | 1055 |
push(@{$UPCAST{BIN}[$bi]},$bin); |
1056 |
push(@{$UPCAST{DEPTH}[$bi]},$bindepth[$bin]); |
|
2 | 1057 |
push(@{$UPCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
13 | 1058 |
push(@{$UPCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
1059 |
push(@{$UPCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
0 | 1060 |
} |
1061 |
} |
|
1062 |
||
1063 |
for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) { |
|
1064 |
$UPCAST{MEAN_DEPTH}[$bi] = avg(@{$UPCAST{DEPTH}[$bi]}); |
|
1065 |
$UPCAST{MEAN_ELAPSED}[$bi] = avg(@{$UPCAST{ELAPSED}[$bi]}); |
|
1066 |
$UPCAST{MEDIAN_W}[$bi] = median(@{$UPCAST{W}[$bi]}); |
|
13 | 1067 |
$UPCAST{MEDIAN_W12}[$bi] = median(@{$UPCAST{W12}[$bi]}); |
1068 |
$UPCAST{MEDIAN_W34}[$bi] = median(@{$UPCAST{W34}[$bi]}); |
|
0 | 1069 |
$UPCAST{MAD_W}[$bi] = mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]}); |
1070 |
$UPCAST{N_SAMP}[$bi] = @{$UPCAST{W}[$bi]}; |
|
1071 |
} |
|
1072 |
||
13 | 1073 |
&antsAddParams('min_depth',$min_depth,'max_depth',$max_depth, # plot range limits |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1074 |
'min_ens',$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1075 |
'max_ens',$LADCP{ENSEMBLE}[$realLastGoodEns]->{NUMBER}, |
2 | 1076 |
'min_elapsed',$LADCP{ENSEMBLE}[$firstGoodEns]->{CTD_ELAPSED}, |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1077 |
'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
|
1078 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1079 |
#------------------------------------------------------------------------------------------------------ |
13 | 1080 |
# remove ping-coherent errors |
1081 |
# - error sources: |
|
1082 |
# 1) acceleration-dependence of Paroscientific pressure measurements; O(10cm/s) [IWISE 28] |
|
1083 |
# 2) residual CTD/LADCP mismatch errors; O(1cm/s) [Thurnherr, CWTMC 2011] |
|
1084 |
# 3) ADCP short-term variability; O(1cm/s) for vertical? |
|
1085 |
# - two steps: |
|
1086 |
# - remove ensemble-median residual from all ocean vertical velocities |
|
1087 |
# - re-bin profiles |
|
1088 |
# - calculate new residuals |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1089 |
# - 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
|
1090 |
# 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
|
1091 |
#------------------------------------------------------------------------------------------------------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1092 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1093 |
unless ($opt_q) { |
13 | 1094 |
progress("Removing ping-coherent errors...\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
|
1095 |
|
13 | 1096 |
for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
1097 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
11 | 1098 |
|
13 | 1099 |
my(@residuals) = (); # calc median of residuals |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1100 |
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
|
1101 |
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
|
1102 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
13 | 1103 |
my($bi) = $bindepth[$bin]/$opt_o; |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1104 |
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
|
1105 |
$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
|
1106 |
(($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
|
1107 |
: $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
|
1108 |
} |
13 | 1109 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} = median(@residuals); # NB: can be nan! |
1110 |
||
1111 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { # remove from ocean velocities |
|
1112 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); # also ensures that MEDIAN_RESIDUAL_W is not 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
|
1113 |
$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
|
1114 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W}; |
13 | 1115 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] -= |
1116 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} |
|
1117 |
if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
1118 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] -= |
|
1119 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} |
|
1120 |
if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$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
|
1121 |
} |
13 | 1122 |
|
1123 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W} -= # reflr_ocean_w is calculated below |
|
1124 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} # NB: this can be set to nan here |
|
1125 |
if numberp($LADCP{ENSEMBLE}[$ens]->{REFLR_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
|
1126 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1127 |
|
13 | 1128 |
#------------------------------------------------------------ |
1129 |
||
1130 |
progress("\tre-binning profile data...\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
|
1131 |
|
13 | 1132 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { # bin data |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1133 |
for (my($i)=0; $i<@{$DNCAST{W}[$bi]}; $i++) { |
13 | 1134 |
$DNCAST{W} [$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W}; |
1135 |
$DNCAST{W12}[$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W}; |
|
1136 |
$DNCAST{W34}[$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_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
|
1137 |
} |
13 | 1138 |
$DNCAST{MEDIAN_W} [$bi] = median(@{$DNCAST{W}[$bi]}); |
1139 |
$DNCAST{MEDIAN_W12}[$bi] = median(@{$DNCAST{W12}[$bi]}); |
|
1140 |
$DNCAST{MEDIAN_W34}[$bi] = median(@{$DNCAST{W34}[$bi]}); |
|
1141 |
$DNCAST{MAD_W} [$bi] = mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{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
|
1142 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1143 |
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
|
1144 |
for (my($i)=0; $i<@{$UPCAST{W}[$bi]}; $i++) { |
13 | 1145 |
$UPCAST{W} [$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W}; |
1146 |
$UPCAST{W12}[$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W}; |
|
1147 |
$UPCAST{W34}[$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_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
|
1148 |
} |
13 | 1149 |
$UPCAST{MEDIAN_W} [$bi] = median(@{$UPCAST{W}[$bi]}); |
1150 |
$UPCAST{MEDIAN_W12}[$bi] = median(@{$UPCAST{W12}[$bi]}); |
|
1151 |
$UPCAST{MEDIAN_W34}[$bi] = median(@{$UPCAST{W34}[$bi]}); |
|
1152 |
$UPCAST{MAD_W} [$bi] = mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{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
|
1153 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1154 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1155 |
} # unless ($opt_q); |
2 | 1156 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1157 |
#------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1158 |
# Output Per-Bin Resiudals |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1159 |
#------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1160 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1161 |
if (defined($out_BR)) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1162 |
my(@dc_nres,@uc_nres,@dc_bres,@uc_bres); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1163 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1164 |
progress("Writing per-bin residual data to $out_BR...\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1165 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1166 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { # downcast |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1167 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1168 |
my(@bindepth) = calc_binDepths($ens); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1169 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1170 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1171 |
push(@{$dc_bres[$bin]}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1172 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] |
13 | 1173 |
- $DNCAST{MEDIAN_W}[$bindepth[$bin]/$opt_o]); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1174 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1175 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1176 |
for ($ens=$LADCP_atbottom; $ens<=$realLastGoodEns; $ens++) { # upcast |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1177 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1178 |
my(@bindepth) = calc_binDepths($ens); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1179 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1180 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1181 |
push(@{$uc_bres[$bin]}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1182 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] |
13 | 1183 |
- $UPCAST{MEDIAN_W}[$bindepth[$bin]/$opt_o]); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1184 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1185 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1186 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1187 |
my($saveParams) = $antsCurParams; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1188 |
@antsNewLayout = ('bin','dc_residual','dc_residual.sig','dc_residual.nsamp', |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1189 |
,'uc_residual','uc_residual.sig','uc_residual.nsamp'); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1190 |
open(STDOUT,"$out_BR") || croak("$out_BR: $!\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1191 |
&antsAddParams('BR_max_bin',max(scalar(@dc_bres),scalar(@uc_bres))); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1192 |
for (my($bin)=0; $bin<max(scalar(@dc_bres),scalar(@uc_bres)); $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1193 |
my($dc_avg) = avg(@{$dc_bres[$bin]}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1194 |
my($uc_avg) = avg(@{$uc_bres[$bin]}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1195 |
&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
|
1196 |
$uc_avg,stddev2($uc_avg,@{$uc_bres[$bin]}),scalar(@{$uc_bres[$bin]})); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1197 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1198 |
&antsOut('EOF'); open(STDOUT,">&2"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1199 |
$antsCurParams = $saveParams; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1200 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1201 |
|
0 | 1202 |
#-------------------------------------------------- |
1203 |
# Calculate BT-referenced vertical-velocity profile |
|
1204 |
#-------------------------------------------------- |
|
1205 |
||
1206 |
if (defined($water_depth)) { |
|
1207 |
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
|
1208 |
calc_BTprof($firstGoodEns,$realLastGoodEns,$water_depth,$sig_water_depth); |
0 | 1209 |
|
1210 |
my($sumSq) = my($n) = 0; |
|
1211 |
for (my($bi)=0; $bi<=$#{$BT{MEDIAN_W}}; $bi++) { |
|
1212 |
next unless defined($BT{MEDIAN_W}[$bi]); |
|
13 | 1213 |
next unless ($BT{N_SAMP}[$bi]>=$opt_k && $DNCAST{N_SAMP}[$bi]>=$opt_k && $UPCAST{N_SAMP}[$bi]>=$opt_k); |
0 | 1214 |
$sumSq += ($BT{MEDIAN_W}[$bi] - $DNCAST{MEDIAN_W}[$bi]/2 - $UPCAST{MEDIAN_W}[$bi]/2)**2; |
1215 |
$n++; |
|
1216 |
} |
|
1217 |
if ($n > 0) { |
|
1218 |
my($rms) = round(sqrt($sumSq/$n),0.001); |
|
1219 |
&antsAddParams('BT_rms_w_discrepancy',$rms); |
|
1220 |
progress("\t$rms m/s rms vertical-velocity discrepancy\n"); |
|
1221 |
} |
|
1222 |
} |
|
1223 |
||
13 | 1224 |
#------------------------ |
1225 |
# output all samples (-w) |
|
1226 |
#------------------------ |
|
2 | 1227 |
|
1228 |
# NB: residual field is calculated with respect to down-/upcast medians in -o-size bins |
|
1229 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1230 |
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
|
1231 |
progress("Writing vertical-velocity data to $out_w...\n"); |
2 | 1232 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1233 |
@antsNewLayout = ('ensemble','bin','elapsed','depth','CTD_depth','downcast', |
13 | 1234 |
'w','w12','w34','residual','CTD_w','CTD_w_tt','LADCP_w','errvel', |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1235 |
'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
|
1236 |
'pitch','roll','tilt','heading','3_beam','svel'); |
2 | 1237 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1238 |
open(STDOUT,"$out_w") || croak("$out_w: $!\n"); |
11 | 1239 |
|
13 | 1240 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { # downcast |
1241 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
1242 |
my(@bindepth) = calc_binDepths($ens); |
|
1243 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1244 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
1245 |
my($bi) = $bindepth[$bin]/$opt_o; |
|
1246 |
&antsOut( |
|
1247 |
$LADCP{ENSEMBLE}[$ens]->{NUMBER},$bin+1, |
|
1248 |
$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1249 |
$bindepth[$bin],$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},1, |
|
1250 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin], |
|
1251 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] : nan, |
|
1252 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] : nan, |
|
1253 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $DNCAST{MEDIAN_W}[$bi], |
|
1254 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1255 |
$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1256 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin], |
|
1257 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin], |
|
1258 |
median(@{$LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin]}), |
|
1259 |
median(@{$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin]}), |
|
1260 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin], |
|
1261 |
$LADCP{ENSEMBLE}[$ens]->{PITCH}, |
|
1262 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
|
1263 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
|
1264 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
|
1265 |
(defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][0]) + # only works for beam coords |
|
1266 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][1]) + |
|
1267 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][2]) + |
|
1268 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][3])) < 4 ? 1 : 0, |
|
1269 |
$CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1270 |
); |
|
1271 |
} # for $bin |
|
1272 |
} # for $ens |
|
1273 |
||
1274 |
for ($ens=$LADCP_atbottom; $ens<=$realLastGoodEns; $ens++) { # upcast |
|
1275 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
1276 |
my(@bindepth) = calc_binDepths($ens); |
|
1277 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1278 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
1279 |
my($bi) = $bindepth[$bin]/$opt_o; |
|
1280 |
&antsOut( |
|
1281 |
$LADCP{ENSEMBLE}[$ens]->{NUMBER},$bin+1, |
|
1282 |
$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1283 |
$bindepth[$bin],$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},0, |
|
1284 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin], |
|
1285 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] : nan, |
|
1286 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] : nan, |
|
1287 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $UPCAST{MEDIAN_W}[$bi], |
|
1288 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1289 |
$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1290 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin], |
|
1291 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin], |
|
1292 |
median(@{$LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin]}), |
|
1293 |
median(@{$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin]}), |
|
1294 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin], |
|
1295 |
$LADCP{ENSEMBLE}[$ens]->{PITCH}, |
|
1296 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
|
1297 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
|
1298 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
|
1299 |
(defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][0]) + # only works for beam coords |
|
1300 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][1]) + |
|
1301 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][2]) + |
|
1302 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][3])) < 4 ? 1 : 0, |
|
1303 |
$CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1304 |
); |
|
1305 |
} # for $bin |
|
1306 |
} # for $ens |
|
2 | 1307 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1308 |
&antsOut('EOF'); open(STDOUT,">&2"); |
2 | 1309 |
} |
1310 |
||
13 | 1311 |
#---------------------------- |
1312 |
# Output depth-binned profile |
|
1313 |
#---------------------------- |
|
0 | 1314 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1315 |
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
|
1316 |
progress("Writing vertical-velocity profiles to <$out_profile>...\n"); |
0 | 1317 |
|
13 | 1318 |
@antsNewLayout = ('depth','dc_depth','dc_elapsed','dc_w','dc_w.mad','dc_w.nsamp','dc_w12','dc_w34', |
1319 |
'uc_depth','uc_elapsed','uc_w','uc_w.mad','uc_w.nsamp','uc_w12','uc_w34', |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1320 |
'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
|
1321 |
'BT_w','BT_w.mad','BT_w.nsamp'); |
0 | 1322 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1323 |
open(STDOUT,"$out_profile") || croak("$out_profile: $!\n"); |
2 | 1324 |
|
1325 |
for (my($bi)=0; $bi<=max($#{$DNCAST{ENSEMBLE}},$#{$UPCAST{ENSEMBLE}},$#{$BT{NSAMP}}); $bi++) { |
|
13 | 1326 |
&antsOut(($bi+0.5)*$opt_o, # nominal depth |
2 | 1327 |
$DNCAST{MEAN_DEPTH}[$bi],$DNCAST{MEAN_ELAPSED}[$bi], |
13 | 1328 |
$DNCAST{N_SAMP}[$bi]>=$opt_k?$DNCAST{MEDIAN_W}[$bi]:nan, |
2 | 1329 |
$DNCAST{MAD_W}[$bi],$DNCAST{N_SAMP}[$bi], |
13 | 1330 |
$DNCAST{MEDIAN_W12}[$bi],$DNCAST{MEDIAN_W34}[$bi], |
2 | 1331 |
$UPCAST{MEAN_DEPTH}[$bi],$UPCAST{MEAN_ELAPSED}[$bi], |
13 | 1332 |
$UPCAST{N_SAMP}[$bi]>=$opt_k?$UPCAST{MEDIAN_W}[$bi]:nan, |
2 | 1333 |
$UPCAST{MAD_W}[$bi],$UPCAST{N_SAMP}[$bi], |
13 | 1334 |
$UPCAST{MEDIAN_W12}[$bi],$UPCAST{MEDIAN_W34}[$bi], |
2 | 1335 |
$DNCAST{MEAN_ELAPSED}[$bi]/2+$UPCAST{MEAN_ELAPSED}[$bi]/2, |
13 | 1336 |
$DNCAST{N_SAMP}[$bi]+$UPCAST{N_SAMP}[$bi]>=$opt_k ? |
2 | 1337 |
($DNCAST{MEDIAN_W}[$bi]*$DNCAST{N_SAMP}[$bi]+$UPCAST{MEDIAN_W}[$bi]*$UPCAST{N_SAMP}[$bi]) / ($DNCAST{N_SAMP}[$bi]+$UPCAST{N_SAMP}[$bi]) : |
1338 |
nan, |
|
13 | 1339 |
$DNCAST{N_SAMP}[$bi]+$UPCAST{N_SAMP}[$bi]>=$opt_k ? |
2 | 1340 |
($DNCAST{MAD_W}[$bi]*$DNCAST{N_SAMP}[$bi]+$UPCAST{MAD_W}[$bi]*$UPCAST{N_SAMP}[$bi]) / ($DNCAST{N_SAMP}[$bi]+$UPCAST{N_SAMP}[$bi]) : |
1341 |
nan, |
|
1342 |
$DNCAST{N_SAMP}[$bi]+$UPCAST{N_SAMP}[$bi], |
|
13 | 1343 |
$BT{N_SAMP}[$bi]>=$opt_k?$BT{MEDIAN_W}[$bi]:nan, |
2 | 1344 |
$BT{MAD_W}[$bi],$BT{N_SAMP}[$bi] |
1345 |
); |
|
0 | 1346 |
} |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1347 |
&antsOut('EOF'); open(STDOUT,">&2"); |
0 | 1348 |
} |
1349 |
||
1350 |
#-------------------------------------- |
|
1351 |
# write time-series output if requested |
|
1352 |
#-------------------------------------- |
|
1353 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1354 |
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
|
1355 |
progress("Writing time-series data to <$out_timeseries>...\n"); |
0 | 1356 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1357 |
@antsNewLayout = ('ens','elapsed','downcast', |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1358 |
'depth','xducer_sound_speed','pitch','gimbal_pitch','roll','tilt','heading', |
13 | 1359 |
'CTD_w','CTD_w_tt','LADCP_reflr_w','LADCP_reflr_w.sig', |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1360 |
'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
|
1361 |
open(STDOUT,"$out_timeseries") || croak("$out_timeseries: $!\n"); |
0 | 1362 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1363 |
for ($ens=$firstGoodEns; $ens<=$realLastGoodEns; $ens++) { |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1364 |
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
|
1365 |
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
|
1366 |
? $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
|
1367 |
: undef; |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1368 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1369 |
$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1370 |
($ens < $LADCP_atbottom) ? 1 : 0, |
0 | 1371 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
1372 |
$CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1373 |
$LADCP{ENSEMBLE}[$ens]->{PITCH}, |
|
1374 |
$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH}, |
|
1375 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
|
1376 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
|
1377 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
|
1378 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
13 | 1379 |
$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
0 | 1380 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W}, |
13 | 1381 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W_STDDEV}, |
1382 |
$reflr_oc_w); |
|
0 | 1383 |
} |
1384 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1385 |
&antsOut('EOF'); open(STDOUT,">&2"); |
0 | 1386 |
} |
1387 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1388 |
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
|
1389 |
if (-x 'PostProcess.sh'); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1390 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1391 |
exit(0); |