author | A.M. Thurnherr <athurnherr@yahoo.com> |
Thu, 12 May 2016 10:54:28 -0400 | |
changeset 44 | 515c353a31bd |
parent 43 | 567b03b9ce8d |
child 45 | 6d49c7420a6c |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/perl |
2 |
#====================================================================== |
|
31 | 3 |
# L A D C P _ W _ O C E A N |
0 | 4 |
# doc: Fri Dec 17 18:11:13 2010 |
43 | 5 |
# dlm: Wed Apr 6 10:28:40 2016 |
0 | 6 |
# (c) 2010 A.M. Thurnherr |
43 | 7 |
# uE-Info: 246 73 NIL 0 0 72 2 2 4 NIL ofnI |
0 | 8 |
#====================================================================== |
9 |
||
10 |
# TODO: |
|
42 | 11 |
# ! plots: |
12 |
# - avoid over-plotting axis labels |
|
13 |
# - allow for different nsamp magnitudes |
|
14 |
# - add "dc" "uc" labels |
|
15 |
# - add software version |
|
16 |
# - add seabed to eps.VKE profile |
|
17 |
# - add seabed to LADCP_w_postproc .wprof output |
|
18 |
# ! use instrument tilt in sidelobe editing |
|
19 |
# ! change w_tt output to w_t output; change -a to use w_t or remove -a? |
|
20 |
# - worry about water-depth differences (disabled warning) |
|
21 |
# - make upcast-flag valid for yoyo casts |
|
22 |
# - make diagnostic output 3-beam field work for Earth coordinates |
|
23 |
# ? remove water-depth from BT code, which is not really used and a bit of an outlier |
|
24 |
# because mean and stddev are used instead of median/mad |
|
0 | 25 |
|
26 |
$antsSummary = 'calculate vertical velocities from LADCP & CTD time series'; |
|
27 |
||
28 |
# HISTORY: |
|
42 | 29 |
# Dec 17, 2010: - created from [mergeCTD+LADCP] |
30 |
# Dec 18, 2010: - made to work |
|
31 |
# Dec 19, 2010: - improved considerably |
|
32 |
# Dec 20, 2010: - onward |
|
33 |
# - BUG: depth-binning was off by 1 bin?! |
|
34 |
# - added binning correction for instrument tilt |
|
35 |
# Dec 21, 2010: - added -h (seafloor depth) |
|
36 |
# Dec 22, 2010: - BUG: had not applied soundspeed-correction to w |
|
37 |
# - debugged opt_d |
|
38 |
# Dec 23, 2010: - continued implementation of soundspeed corrections |
|
39 |
# Dec 24, 2010: - added winch_w, wave_w |
|
40 |
# - removed beampair velocities from code |
|
41 |
# Dec 25, 2010: - adapted for surface-wave correction in terms of acceleration (CTD_w_t) |
|
42 |
# - removed elapsed_mismatch |
|
43 |
# - removed winch_w, wave_w |
|
44 |
# Dec 26, 2010: - made -p output layout independent of -x to avoid Makefile problems |
|
45 |
# Dec 30, 2010: - cleaned up some |
|
46 |
# - folded-in backscatter calculation from shear method |
|
47 |
# - folded-in BT calculation from shear method |
|
48 |
# Dec 31, 2010: - added weighted mean w profile to output |
|
49 |
# Jan 2, 2010: - BUG: BT_w.mad could bomb with division by 0 |
|
50 |
# - BUG: division by zero if no valid data |
|
51 |
# Jan 5, 2010: - adapted to allow for gaps in CTD time series |
|
52 |
# Feb 16, 2011: - cosmetics |
|
53 |
# Jun 22, 2011: - cosmetics |
|
54 |
# Jun 23, 2011: - disabled error on large rms reflr w |
|
55 |
# - added -l |
|
56 |
# - removed CTD headers from output |
|
57 |
# Jun 26, 2011: - added -u |
|
58 |
# - changed package correction from acceleration to velocity, because of |
|
59 |
# Stan's Antarctic data set where accelerations are zero but package effects are |
|
60 |
# there |
|
61 |
# Jul 2, 2011: - increased tilt default to 15 degrees |
|
62 |
# Jul 3, 2011: - replaced old package-velocity correction -x code by new beamvel correction |
|
63 |
# - removed -p |
|
64 |
# - replaced -d by residual (diagnostics) output |
|
65 |
# Jul 4, 2011: - saved a snapshot in [Jul_04_2011] |
|
66 |
# - removed output of binned profile (but not calculation code, which is required for residual) |
|
67 |
# - BUG: firstGoodEns or lastGoodEns could end up in a reflr_w gap when valid LADCP data begin |
|
68 |
# or end with CTD in water |
|
69 |
# - moved rarely used option -s to -k |
|
70 |
# - added -s)kip <ens> option |
|
71 |
# - had to very very slightly relax an assertion (by 1e-10 seconds...) |
|
72 |
# Aug 3, 2011: - added -z)ap to truncate range, based on Stan's 2009 data set (017-019 most clearly) |
|
73 |
# obs that final 2 velocities are outliers; could be due to color bar, should check with |
|
74 |
# residuals |
|
75 |
# Sep 22, 2011: - removed (commented out) CTD acceleration |
|
76 |
# - added basename to Parameter File Matching |
|
77 |
# Sep 23, 2011: - cosmetics (lots) |
|
78 |
# - added -d) |
|
79 |
# Oct 6, 2011: - removed old commented-out code (CTD acceleration & old -x) |
|
80 |
# - renamed time-series field names |
|
81 |
# - added uncorrected reflr w to time-series output |
|
82 |
# Oct 10, 2011: - BUG: LADCP_w in .tds output had not been soundspeed corrected |
|
83 |
# - removed -x |
|
84 |
# - added "false-positives" editing filter |
|
85 |
# Oct 11, 2011: - adapted to the new parameter file, removing a few options |
|
86 |
# Oct 12, 2011: - added surface-layer editing |
|
87 |
# - made %min/max_depth/elapsed more accurate |
|
88 |
# Oct 13, 2011: - fiddled |
|
89 |
# Oct 14, 2011: - renamed .prof fields from .N to .nsamp |
|
90 |
# - added %output_basename |
|
91 |
# - removed all ">" from open to allow use in pipelines |
|
92 |
# - made <run-label> argument optional |
|
93 |
# - replaced stdout output by $w_out |
|
94 |
# - renamed _out to out_; output_basename to out_basename |
|
95 |
# Oct 15, 2011: - added editWOutliers() |
|
96 |
# - added step to remove single-ping noise |
|
97 |
# Oct 16, 2011: - BUG: ensemble and bin numbers in output files were off by 1 |
|
98 |
# Oct 17, 2011: - added default run label |
|
99 |
# - added out_BR |
|
100 |
# - BUG: closed STDOUT caused problems with tee in plotting scripts |
|
101 |
# - added %run_label |
|
102 |
# - added PostProcess.sh |
|
103 |
# Oct 18, 2011: - BUG: %{min,max}_ens used ensemble indices, rather than numbers |
|
104 |
# - disabled false-positives editing (removes too much good data on 2011_IWISE) |
|
105 |
# Oct 19, 2011: - BUG: time-series output included ensembles without valid w |
|
106 |
# - increased post-process sleep time to 30s |
|
107 |
# - added corr, Sv and echo_amplitude as new fields to w output |
|
108 |
# Oct 20, 2011: - added editFarBins() |
|
109 |
# - added downcast flag to time-series output |
|
110 |
# - added ensemble number to LADCP-time-series output |
|
111 |
# Oct 21, 2011: - BUG: Sv code was not enabled for uplooker data |
|
112 |
# Oct 24, 2011: - added code to copy %lat/%lon from CTD data |
|
113 |
# - added %ADCP_freuquency, %ADCP_blanking_distance |
|
114 |
# - %LADCP_bin_length => %ADCP_bin_length |
|
115 |
# Oct 26, 2011: - added $first_guess_timelag |
|
116 |
# Oct 27, 2011: - added w12, w34, ww (pitch/roll-weighted average) to full output |
|
117 |
# - removed ww because it apparently does not improve the solutions |
|
118 |
# - moved editTilt() to after time-series calculation to allow |
|
119 |
# time matching to work even with strict tilt limit |
|
120 |
# - added correctAttitude() |
|
121 |
# May 22, 2012: - adapted to ANTS V5 |
|
122 |
# Oct 15, 2012: - added $edit_data_hook |
|
123 |
# - HG COMMIT |
|
124 |
# - separated dc/uc time lagging |
|
125 |
# - removed support for TLhist |
|
126 |
# Oct 16, 2012: - added support for dc/uc only solutions |
|
127 |
# Oct 17, 2012: - renamed $edit_data_hook to $post_merge_hook |
|
128 |
# - HG COMMIT |
|
129 |
# Feb 13, 2013: - BUG: CTD_neg_press_offset did not work for CTD time series with -ve starting depth |
|
130 |
# Mar 23, 2013: - cosmetics |
|
131 |
# - HG COMMIT |
|
132 |
# Apr 22, 2013: - removed opt_? variable aliases |
|
133 |
# May 8, 2013: - replaced default run label (default to profiles) to make more readable directory structure |
|
134 |
# May 14, 2013: - opt_m => w_max_lim |
|
135 |
# - BUG: time-series output had two messed-up fields |
|
136 |
# May 15, 2013: - added w12 and w34 (2-beam solutions) to profile output |
|
137 |
# May 16, 2013: - added CTD_w_tt to time-series & all-sample outputs |
|
138 |
# - -a => -d (CTD depth offset) |
|
139 |
# - implemented pressure-sensor acceleration correction (-a) |
|
140 |
# - added re-gridding of full profile after ping-coherent error removal |
|
141 |
# Jun 5, 2013: - renamed $discard_velocities_from_beam to $bad_beam |
|
142 |
# - BUG: $bad_beam did not discard BT_VELOCITY data |
|
143 |
# Jun 6, 2013: - BUG: error message had -a instead of -d |
|
144 |
# Sep 5, 2013: - BUG: w12/w34 do not work for earth-coordinate data, of course |
|
145 |
# Apr 17, 2014: - BUG: edit_tilt was never called when all recorded bins are valid |
|
146 |
# Apr 21, 2014: - updated comments |
|
147 |
# May 19, 2014: - began adding support for PPI filtering |
|
148 |
# May 20, 2014: - changed volume_scattering_coeff to Sv in output |
|
149 |
# - added editPPI() |
|
150 |
# Jul 6, 2014: - BUG: nan water depth had been interpreted as known |
|
151 |
# - BUG: sVelProf[] was not allowed to have any gaps |
|
152 |
# Jul 9, 2014: - BUG: Jul 6 bug fixes had been applied to older |
|
153 |
# version |
|
154 |
# - BUG: code meant to ensure gap-free svel profiles did not work correctly |
|
155 |
# Jul 12, 2014: - finally made output files executable |
|
156 |
# Apr 5, 2015: - added check for required software |
|
157 |
# - BUG: removed dc/uc mean w fields from .prof again |
|
158 |
# Apr 7, 2015: - made LADCP_w callable from installation directory |
|
159 |
# - BUG: -v default was wrong in usage message |
|
160 |
# - replaced 'ens' in output files by 'ensemble' |
|
161 |
# Apr 16, 2015: - turned output specifies into lists (re-design of |
|
162 |
# plotting sub-system) |
|
163 |
# - removed 30s sleep from PostProcess.sh call |
|
164 |
# - disabled active output when ANTS are not available |
|
165 |
# - removed /bin/ksh requirement |
|
166 |
# - BUG: error messages were not reported in the log file |
|
167 |
# - made seabed detection code more flexible |
|
168 |
# - made reference-layer w_ocean warning more severe |
|
169 |
# - BUG: info() did not write anything into logfile when format string was used |
|
170 |
# - BUG: LADCP_lastBin was set 1 too low |
|
171 |
# Apr 20, 2015: - improved comments |
|
172 |
# - improved diagnostic messages (warning on missing CTD temp) |
|
173 |
# - added support for empirical backscatter correction |
|
174 |
# Apr 21, 2015: - improved screen log output |
|
175 |
# Apr 22, 2015: - BUG: $realLastGoodEns could be undefined, breaking plotting routines |
|
176 |
# Apr 24, 2015: - removed @ARGS |
|
177 |
# - added %profile_id |
|
178 |
# May 13, 2015: - loosened "insufficient valid velocities" test for short casts |
|
179 |
# May 15, 2015: - added $min_valid_vels |
|
180 |
# - BUG: LADCP_atbottom could be less than firstGoodEns |
|
181 |
# May 18, 2015: - added %LADCP_pulse_length, %dnXX |
|
182 |
# May 20, 2015: - added $PROF as newer alternative to $STN |
|
183 |
# - replaced "require ProcessingParams" by "do ProcessingParams" |
|
184 |
# Jun 15, 2015: - clarified warning message |
|
185 |
# Jul 26, 2015: - added %output_grid_dz %output_grid_minsamp for use by [LADCP_w_regrid] |
|
186 |
# - began work on support for [libGMT.pl] |
|
187 |
# - -v usage message had wrong default |
|
188 |
# - added $outGrid_firstBin & $outGrid_lastBin |
|
189 |
# Jul 28, 2015: - added GMT plot support for all @out_ lists |
|
190 |
# Jul 29, 2015: - continue adaptation of code for new plotting system |
|
191 |
# Jul 30, 2015: - cosmetics |
|
192 |
# Sep 3, 2015: - changed out_w to out_wsamp |
|
193 |
# Sep 26, 2015: - replaced numberp($water_depth) by defined($water_depth) for consistency |
|
194 |
# - implemented secondary sidelobe editing |
|
195 |
# - allow for -h <filename> |
|
196 |
# - allow $ID as alias for $PROF and $STN |
|
197 |
# Sep 27, 2015: - BUG: -h filename was broken when water_depth is not known |
|
198 |
# Oct 12, 2015: - upgraded missing water-depth warnings to L2 |
|
199 |
# - added -V)ersion |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
200 |
# - require ANTSlibs V6.2 for release |
33 | 201 |
# Oct 13, 2015: - adapted to [version.pl] |
42 | 202 |
# Nov 25, 2015: - made warning disappear on setting $ANTS_TOOLS_AVAILABLE |
203 |
# Nov 27, 2015: - changed RDI_BB_READ.pl to RDI_PD0_IO.pl |
|
204 |
# Jan 4, 2016: - decreased default vertical resolution to 20m |
|
205 |
# Jan 5, 2016: - adapted to [ADCP_tools_lib.pl] |
|
206 |
# Jan 22, 2016: - updated for improved mean_residuals plot |
|
207 |
# - added per-bin residual quality check |
|
208 |
# Jan 25, 2016: - added antsAddParams() with version number |
|
209 |
# Jan 26, 2016: - added %processing_params, many others |
|
210 |
# - expunged -d |
|
211 |
# - implemented outGrid_firstBin eq '*' (also lastBin) |
|
212 |
# Jan 27, 2016: - BUG: outGrid_lastBin eq '*' did not work |
|
213 |
# - removed large ref-lr w warning |
|
214 |
# Feb 14, 2016: - fiddled with ping-coherent residuals code, fixing |
|
215 |
# 0-2 potential (minor?) bugs related to outGrid_{first,last}Bin; |
|
216 |
# output of new code checked against old code => identical |
|
217 |
# Feb 16, 2016: - BUG: per-bin-residual QC could cause division by zero |
|
218 |
# Feb 19, 2016: - added -l (disable time-lag filtering) |
|
219 |
# Mar 7, 2016: - added error message when -h is neither number nor file |
|
220 |
# - BUG: -ve depth error message referred to obsolete -d |
|
221 |
# - BUG: dn field name did not use zero filling for year number |
|
222 |
# Mar 8, 2016: - removed L0 water-depth-difference warning |
|
223 |
# - added test for 1500m/s sound speed |
|
224 |
# Mar 9, 2016: - added hab field to .wprof output |
|
225 |
# Mar 13, 2016: - cleaned up warnings created before LADCP_file is defined |
|
226 |
# - added sanity checks and warnings |
|
227 |
# Mar 17, 2016: - added {dc,uc}_rms_{tilt,w_pkg} |
|
228 |
# - replaced a couple of **2 by &SQR() |
|
229 |
# - replaced %ADCP_orientation values by DL & UL |
|
230 |
# - {dc,uc}_rms_w_pkg => {dc,uc}_rms_accel_pkg for V1.2beta6 |
|
231 |
# Mar 18, 2016: - added -l to %processing_options |
|
232 |
# Mar 24, 2016: - generalized plotting system (renamed variables) |
|
233 |
# - made plotting system search current dir before LADCP_w dir |
|
234 |
# - BUG: ProcessingParams syntax errors were not flagged |
|
235 |
# - BUG: progress message in rarely used filter |
|
236 |
# Mar 25, 2016: - added -r)esidual rms filter |
|
237 |
# - added -q -r to processing_options |
|
238 |
# Mar 26, 2016: - BUG: water_depth < CTD_maxdepth was allowed |
|
239 |
# - round(CTD_depth) |
|
240 |
# Mar 29, 2016: - split [default_paths.pl] from [defaults.pl] to allow defaults |
|
241 |
# to be read before usage |
|
242 |
# - renamed _subdir to _dir variables |
|
243 |
# - renamed post-process hook script to LADCP_w.PostProcess |
|
244 |
# - added -r default (0.04m/s) |
|
43 | 245 |
# Mar 31, 2016: - changed version %PARAM |
246 |
# Apr 6, 2016: - BUG: GMT test looked for psxy, rather than gmt binary |
|
30 | 247 |
# HISTORY END |
0 | 248 |
|
249 |
# CTD REQUIREMENTS |
|
250 |
# - elapsed elapsed seconds; see note below |
|
251 |
# - depth |
|
19 | 252 |
# - ss sound speed |
0 | 253 |
# - w ddepth/dt |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
254 |
# - temp OPTIONAL; used for backscatter calculation |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
255 |
# - %lat/%lon OPTIONAL |
0 | 256 |
|
13 | 257 |
# 2-BEAM SOLUTIONS |
258 |
# - for beam-coordinate data, two separate two-beam solutions (w12 & w34) are calculated |
|
259 |
# - discrepancies can be indicative of package wake effects (e.g. MIXET data) |
|
260 |
# - for earth-coordinate data, w12 and w34 are simply copies of w |
|
261 |
||
0 | 262 |
# NUMERICAL OPTIONS |
263 |
# - the first option in the list cannot be numerical! |
|
19 | 264 |
# - if need be, use -v 1 as a dummy option |
0 | 265 |
|
266 |
# ELAPSED TIMES |
|
267 |
# - there are 2 different elapsed times used in this program: |
|
268 |
# 1) elapsed based on firstgoodens in the LADCP time series |
|
269 |
# 2) CTD elapsed time |
|
270 |
# - CTD elapsed time does not have to start with zero! |
|
271 |
# - do not use the Seabird elapsed field, which is only reported to |
|
272 |
# 3 significant digits, causing significant jitter in dt; however, |
|
273 |
# at least up to 2010 Seabird simply calculates elapsed time by |
|
274 |
# assuming a 24Hz sampling rate and no record drop; therefore, |
|
275 |
# it is best to calculate elapsed time as %RECNO/24 |
|
276 |
# - the elapsed field of the output is the elapsed time from the CTD |
|
277 |
# file; this is required in order to be able to compare the times |
|
278 |
# from the uplooker and downlooker-derived vertical velocity |
|
279 |
# profiles |
|
11 | 280 |
# - the .TL files use the LADCP elapsed time in output; as a result, |
281 |
# the DL/UL .TL files have different time axes! |
|
0 | 282 |
# - as a result, a profile only starts with elapsed==0 if the CTD |
283 |
# is turned on when the LADCP is already in the water |
|
284 |
||
13 | 285 |
# BINNED-PROFILE OUTPUT NOTES |
286 |
# - residuals are calculated with respect to down-/upcast medians |
|
287 |
# - w12 and w34 2-beam solutions are reported without considering |
|
288 |
# -k (min samples) |
|
2 | 289 |
# - equivalence, assuming -o 10: |
290 |
# 1) 004DL.prof dc_w depth |
|
6 | 291 |
# 2) bindata -Sdowncast:1 -Fw.median,depth -n 20 depth 10 004DL.w |
2 | 292 |
|
0 | 293 |
# VELOCITY AMBIGUITY ERRORS |
294 |
# - quite extensive tests with DIMES US2 station 146, which has a lot of |
|
295 |
# ambiguity velocity errors, reveal that -m 1 catches those errors |
|
296 |
# quite nicely |
|
297 |
# - even when the errors are not filtered with -m 1, they do not |
|
298 |
# affect the w profiles, as long as the median bin values are used |
|
299 |
||
23 | 300 |
($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$}); |
301 |
($ADCP_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$}); |
|
302 |
($WCALC) = ($0 =~ m{^(.*)/[^/]*$}); |
|
303 |
$WCALC = '.' if ($WCALC eq ''); |
|
33 | 304 |
$ANTS_TOOLS_AVAILABLE = (`which list 2>/dev/null` ne ''); |
23 | 305 |
|
19 | 306 |
die("$0: Generic Mapping Tools (GMT) required but not found (bad \$PATH?)\n") |
43 | 307 |
unless (`which gmt` ne ''); |
19 | 308 |
die("$0: ANTSlib required but not found (bad \$PATH?)\n") |
23 | 309 |
unless ($ANTS ne ''); |
19 | 310 |
die("$0: ADCP Tools required but not found (bad \$PATH?)\n") |
23 | 311 |
unless ($ADCP_TOOLS ne ''); |
0 | 312 |
|
33 | 313 |
require "$WCALC/version.pl"; |
0 | 314 |
require "$WCALC/edit_data.pl"; |
315 |
require "$WCALC/time_series.pl"; |
|
316 |
require "$WCALC/time_lag.pl"; |
|
317 |
require "$WCALC/find_seabed.pl"; |
|
318 |
require "$WCALC/svel_corrections.pl"; |
|
319 |
require "$WCALC/acoustic_backscatter.pl"; |
|
320 |
require "$WCALC/bottom_tracking.pl"; |
|
33 | 321 |
require "$ANTS/ants.pl"; |
322 |
require "$ANTS/libstats.pl"; |
|
34 | 323 |
require "$ADCP_TOOLS/ADCP_tools_lib.pl"; |
43 | 324 |
&antsAddParams('LADCP_w_ocean::version',$VERSION); |
0 | 325 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
326 |
use IO::Handle; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
327 |
|
6 | 328 |
my($TINY) = 1e-16; |
329 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
330 |
#------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
331 |
# Usage |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
332 |
#------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
333 |
|
42 | 334 |
require "$WCALC/defaults.pl"; # load default/option parameters |
335 |
||
0 | 336 |
$antsParseHeader = 0; |
42 | 337 |
&antsUsage('3:4a:b:c:e:g:h:i:k:lm:n:o:p:qr:s:t:uv:Vw:x:',0, |
338 |
"[print software -V)ersion] [-v)erbosity <level[$opt_v]>]", |
|
339 |
"[-q)uick (no single-ping denoising)]", |
|
340 |
"[require -4)-beam solutions] [apply beamvel-m)ask <file> if it exists]", |
|
341 |
"[valid LADCP -b)ins <bin,bin[$opt_b]>", |
|
342 |
"[-c)orrelation <min[$opt_c counts]>] [-t)ilt <max[$opt_t deg]> [-e)rr-vel <max[$opt_e m/s]>]", |
|
343 |
"[-r)esidual <rms.max[$opt_r m/s]>]", |
|
344 |
"[-h water <depth|filename>]", |
|
345 |
"[max LADCP time-series -g)ap <length[$opt_g s]>]", |
|
346 |
"[-i)nitial CTD time offset <guestimate> [-u)se as final]]", |
|
347 |
"[calculate -n) <lags,lags[$opt_n]>] [lag -w)indow <sz,sz[$opt_w s]>] [lag-p)iece <CTD_elapsed_min|+[,...]>]", |
|
348 |
"[require top-3) lags to account for <frac[$opt_3]> of all]", |
|
349 |
"[disable time-l)ag filtering]", |
|
350 |
"[pressure-sensor -a)cceleration correction <residual/CTD_w_tt>]", |
|
351 |
"[-o)utput bin <resolution[$opt_o m]>] [-k) require <min[$opt_k]> samples]", |
|
352 |
"[e-x)ecute <perl-expr>]", |
|
353 |
"<profile-id> [run-label]"); |
|
0 | 354 |
|
42 | 355 |
if ($opt_V) { |
356 |
printf(STDERR "+-------------------------+\n"); |
|
357 |
printf(STDERR "| LADCP_w Software V%s |\n",$VERSION); |
|
358 |
printf(STDERR "|(c) 2015- A.M. Thurnherr |\n"); |
|
359 |
printf(STDERR "+-------------------------+\n"); |
|
360 |
exit(0); |
|
361 |
} |
|
2 | 362 |
|
42 | 363 |
&antsUsageError() if ($opt_u && !defined($opt_i)); |
364 |
&antsUsageError() unless (@ARGV==1 || @ARGV==2); |
|
2 | 365 |
|
42 | 366 |
&antsCardOpt(\$opt_s,0); # skip # initial ensembles |
367 |
$opt_p = '+' unless defined($opt_p); # separate uc/dc time lagging |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
368 |
|
42 | 369 |
&antsFloatOpt(\$opt_a,1); # pressure acceleration correction |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
370 |
|
42 | 371 |
$ID = $PROF = $STN = &antsCardArg(); # station id ($STN for compatibility) |
372 |
if (@ARGV) { # run label |
|
373 |
$RUN = $ARGV[0]; |
|
374 |
shift; |
|
375 |
} else { |
|
376 |
$RUN = 'profiles'; |
|
377 |
} |
|
0 | 378 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
379 |
#----------------------------- |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
380 |
# 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
|
381 |
#----------------------------- |
42 | 382 |
|
383 |
require "$WCALC/default_paths.pl"; # load default input/output paths |
|
384 |
croak("$processing_param_file: $@") |
|
385 |
unless ($err = do "$processing_param_file"); # load processing parameters |
|
34 | 386 |
|
387 |
$processing_options = "-k $opt_k -o $opt_o -c $opt_c -t $opt_t -e $opt_e -g $opt_g -3 $opt_3"; |
|
42 | 388 |
$processing_options .= " -i $opt_i" if defined($opt_i); |
389 |
$processing_options .= " -r $opt_r" if defined($opt_r); |
|
390 |
$processing_options .= ' -l' if defined($opt_l); |
|
391 |
$processing_options .= ' -q' if defined($opt_q); |
|
0 | 392 |
|
34 | 393 |
if (defined($opt_x)) { # eval cmd-line expression to override anything |
394 |
$processing_options .= " -x $opt_x"; |
|
395 |
eval($opt_x); |
|
396 |
} |
|
397 |
||
398 |
if ($opt_4) { # disallow 3-beam solutions |
|
399 |
$processing_options .= " -4"; |
|
400 |
$RDI_Coords::minValidVels = 4; |
|
401 |
} |
|
402 |
||
403 |
($LADCP_firstBin,$LADCP_lastBin) = split(',',$opt_b); # select valid bins |
|
13 | 404 |
croak("$0: cannot decode -b $opt_b\n") |
405 |
unless (numberp($LADCP_firstBin) && |
|
406 |
($LADCP_lastBin eq '*' || numberp($LADCP_lastBin))); |
|
34 | 407 |
$processing_options .= " -b $opt_b"; |
408 |
||
409 |
$outGrid_firstBin = $LADCP_firstBin if ($outGrid_firstBin eq '*'); # default bins to use in gridded output |
|
410 |
$outGrid_lastBin = $LADCP_lastBin if ($outGrid_lastBin eq '*'); # NB: can still be '*'!!! |
|
411 |
||
13 | 412 |
@number_of_timelag_windows = split(',',$opt_n); |
413 |
croak("$0: cannot decode -n $opt_n\n") |
|
414 |
unless numberp($number_of_timelag_windows[0]) && numberp($number_of_timelag_windows[1]); |
|
34 | 415 |
$processing_options .= " -n $opt_n"; |
13 | 416 |
@length_of_timelag_windows = split(',',$opt_w); |
417 |
croak("$0: cannot decode -w $opt_w\n") |
|
418 |
unless numberp($length_of_timelag_windows[0]) && numberp($length_of_timelag_windows[1]); |
|
34 | 419 |
$processing_options .= " -w $opt_w"; |
13 | 420 |
|
42 | 421 |
croak("$0: \$out_basename undefined\n") # plotting routines use this to label the plots |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
422 |
unless defined($out_basename); |
34 | 423 |
&antsAddParams('processing_options',$processing_options); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
424 |
&antsAddParams('out_basename',$out_basename); |
29 | 425 |
&antsAddParams('profile_id',$PROF,'run_label',$RUN); |
0 | 426 |
|
427 |
#---------------------------------------------------------------------- |
|
428 |
# Screen Logging |
|
429 |
# - warning levels: |
|
430 |
# 0 probably unimportant, e.g. nonsensical parameters that probably won't affect solution |
|
431 |
# 1 may be somewhat important |
|
432 |
# 2 important |
|
433 |
#---------------------------------------------------------------------- |
|
434 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
435 |
open(LOGF,">$out_log") || croak("$out_log: $!\n") |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
436 |
if defined($out_log); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
437 |
LOGF->autoflush(1); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
438 |
|
0 | 439 |
sub progress(@) |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
440 |
{ |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
441 |
printf(LOGF @_) if defined($out_log); |
13 | 442 |
printf(STDERR @_) if ($opt_v > 1); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
443 |
} |
0 | 444 |
|
445 |
sub info(@) |
|
446 |
{ |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
447 |
print(LOGF "\t"),printf(LOGF @_) if defined($out_log); |
29 | 448 |
printf(STDERR @_) if ($opt_v > 1); |
0 | 449 |
} |
450 |
||
451 |
sub warning(@) |
|
452 |
{ |
|
453 |
my($lvl,@msg) = @_; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
454 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
455 |
if (defined($out_log)) { |
29 | 456 |
print(LOGF "\nWARNING (L$lvl): "); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
457 |
printf(LOGF @msg); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
458 |
print(LOGF "\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
459 |
} |
13 | 460 |
return if ($opt_v == 0); |
29 | 461 |
|
462 |
if ($opt_v == 1) { |
|
39 | 463 |
print(STDERR "$LADCP_file: ") if defined($LADCP_file); |
464 |
print(STDERR "WARNING (L$lvl): "); |
|
29 | 465 |
printf(STDERR @msg); |
466 |
} else { |
|
467 |
print(STDERR "\n-------------\nWARNING (L$lvl): "); |
|
468 |
printf(STDERR @msg); |
|
469 |
print(STDERR "-------------\n\n") |
|
470 |
} |
|
0 | 471 |
} |
472 |
||
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
473 |
sub error($) |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
474 |
{ |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
475 |
print(LOGF "ABORT: @_") if defined($out_log); |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
476 |
croak("ABORT: @_"); |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
477 |
} |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
478 |
|
0 | 479 |
sub debugmsg(@) |
13 | 480 |
{ printf(STDERR @_) if ($opt_v > 2); } |
0 | 481 |
|
40 | 482 |
#--------------------------- |
0 | 483 |
# Read LADCP data |
40 | 484 |
# |
485 |
# sanity checks: |
|
486 |
# - 1500m/s sound speed |
|
487 |
# - single-ping ensembles |
|
488 |
# |
|
489 |
# warnings: |
|
490 |
# - high bandwidth |
|
491 |
# - low transmit power |
|
492 |
#--------------------------- |
|
0 | 493 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
494 |
progress("Reading LADCP data from <$LADCP_file>...\n"); |
0 | 495 |
readData($LADCP_file,\%LADCP); |
19 | 496 |
progress("\t%d ensembles\n",scalar(@{$LADCP{ENSEMBLE}})); |
0 | 497 |
|
40 | 498 |
error("$LADCP_file: cannot process multi-ping ensembles\n") |
499 |
unless ($LADCP{PINGS_PER_ENSEMBLE} == 1); |
|
500 |
error(sprintf("$LADCP_file: unsupported soundspeed setting (%d m/s != 1500 m/s)\n",$LADCP{ENSEMBLE}[0]->{SPEED_OF_SOUND})) |
|
501 |
unless ($LADCP{ENSEMBLE}[0]->{SPEED_OF_SOUND} == 1500); |
|
502 |
warning(2,"$LADCP_file: wide-bandwidth setting\n") |
|
503 |
if ($LADCP{WIDE_BANDWIDTH}); |
|
504 |
warning(2,"$LADCP_file: low transmit-power setting\n") |
|
505 |
unless ($LADCP{TRANSMIT_POWER_HIGH}); |
|
506 |
||
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
507 |
error("$LADCP_file: not enough LADCP bins ($LADCP{N_BINS}) for choice of -r\n") |
0 | 508 |
unless ($LADCP{N_BINS} >= $refLr_lastBin); |
509 |
||
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
510 |
error("$0: first reference-layer bin outside valid range\n") |
0 | 511 |
unless ($refLr_firstBin>=1 && $refLr_firstBin<=$LADCP{N_BINS}); |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
512 |
error("$0: last reference-layer bin outside valid range\n") |
0 | 513 |
unless ($refLr_lastBin>=1 && $refLr_lastBin<=$LADCP{N_BINS}); |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
514 |
error("$0: first reference-layer bin > last reference-layer bin\n") |
0 | 515 |
unless ($refLr_firstBin <= $refLr_lastBin); |
34 | 516 |
&antsAddParams('refLr_firstBin',$refLr_firstBin,'refLr_lastBin',$refLr_lastBin); |
0 | 517 |
|
34 | 518 |
$LADCP_lastBin = $LADCP{N_BINS} if ($LADCP_lastBin eq '*'); |
519 |
$outGrid_lastBin = $LADCP{N_BINS} if ($outGrid_lastBin eq '*'); |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
520 |
error("$0: first valid LADCP bin outside valid range\n") |
0 | 521 |
unless ($LADCP_firstBin>=1 && $LADCP_firstBin<=$LADCP{N_BINS}); |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
522 |
error("$0: last valid LADCP bin outside valid range\n") |
0 | 523 |
unless ($LADCP_lastBin>=1 && $LADCP_lastBin<=$LADCP{N_BINS}); |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
524 |
error("$0: first valid LADCP bin > last valid LADCP bin\n") |
0 | 525 |
unless ($LADCP_firstBin <= $LADCP_lastBin); |
34 | 526 |
&antsAddParams('LADCP_firstBin',$LADCP_firstBin,'LADCP_lastBin',$LADCP_lastBin); |
0 | 527 |
|
528 |
warning(0,"first reference-layer bin < first valid LADCP bin\n") |
|
529 |
unless ($refLr_firstBin >= $LADCP_firstBin); |
|
530 |
warning(0,"last reference-layer bin > last valid LADCP bin\n") |
|
531 |
unless ($refLr_lastBin <= $LADCP_lastBin); |
|
532 |
||
533 |
warning(1,"if at all, bin 1 should not be used for short blank-after-transmit values\n") |
|
534 |
if ($LADCP{BLANKING_DISTANCE}<$LADCP{BIN_LENGTH} && $refLr_firstBin==1); |
|
535 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
536 |
&antsAddParams('ADCP_bin_length',$LADCP{BIN_LENGTH}, |
29 | 537 |
'ADCP_pulse_length',$LADCP{TRANSMITTED_PULSE_LENGTH}, |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
538 |
'ADCP_frequency',$LADCP{BEAM_FREQUENCY}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
539 |
'ADCP_blanking_distance',$LADCP{BLANKING_DISTANCE}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
540 |
|
0 | 541 |
#------------------------------------------------------------ |
542 |
# Edit beam-velocity data |
|
13 | 543 |
# 0) beam-vel mask on -m |
0 | 544 |
# 1) correlation threshold |
545 |
#------------------------------------------------------------ |
|
546 |
||
547 |
if ($LADCP{BEAM_COORDINATES}) { |
|
548 |
progress("Editing beam-velocity data...\n"); |
|
13 | 549 |
|
550 |
if (defined($opt_m) && -r $opt_m) { |
|
551 |
progress("\tmasking beam velocities according to $opt_m:"); |
|
552 |
||
553 |
my($nee) = 0; |
|
554 |
open(BVM,$opt_m) || die("$opt_m: $!\n"); |
|
555 |
while (<BVM>) { |
|
556 |
s/#.*//; |
|
557 |
s/^\s*$//; |
|
558 |
next if ($_ eq ''); |
|
559 |
my($fe,$te,$db) = split; |
|
560 |
die("$opt_m: cannot decode $_\n") |
|
561 |
unless (numberp($fe) && numberp($te) && $te>=$fe && $db>=1 && $db<=4); |
|
562 |
die("$0: assertion failed") |
|
563 |
unless ($LADCP{ENSEMBLE}[$fe-1]->{NUMBER} == $fe && |
|
564 |
$LADCP{ENSEMBLE}[$te-1]->{NUMBER} == $te); |
|
565 |
for (my($ens)=$fe-1; $ens<=$te-1; $ens++) { |
|
566 |
$nee++; |
|
567 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
568 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$db-1]); |
|
569 |
} |
|
570 |
} |
|
571 |
} |
|
42 | 572 |
progress(" $nee ensembles edited\n"); |
13 | 573 |
close(BVM); |
574 |
} |
|
575 |
||
0 | 576 |
$nvv = $cte = 0; |
34 | 577 |
|
578 |
if ($pitch_bias || $roll_bias || $heading_bias) { |
|
579 |
&antsAddParams('pitch_bias',$pitch_bias, |
|
580 |
'roll_bias',$roll_bias, |
|
581 |
'heading_bias',$heading_bias); |
|
582 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
583 |
correctAttitude($ens,$pitch_bias,$roll_bias,$heading_bias); |
|
584 |
} |
|
585 |
} |
|
0 | 586 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
587 |
$nvv += countValidBeamVels($ens); |
|
13 | 588 |
$cte += editCorr($ens,$opt_c); |
0 | 589 |
} |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
590 |
error("$LADCP_file: no valid data\n") unless ($nvv > 0); |
13 | 591 |
progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$opt_c,$cte,round(100*$cte/$nvv)); |
592 |
# progress("\tattitude threshold (-t %d deg): %d velocites removed (%d%% of total)\n",$opt_t,$pte,round(100*$pte/$nvv)); |
|
0 | 593 |
} else { |
594 |
progress("Editing velocity data...\n"); |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
595 |
error("$LADCP_file: cannot apply beamvel-mask $opt_m to earth-coordinate data\n") |
13 | 596 |
if defined($opt_m); |
0 | 597 |
$nvv = $cte = 0; |
598 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
599 |
$nvv += countValidBeamVels($ens); |
|
13 | 600 |
$cte += editCorr_Earthcoords($ens,$opt_c); |
0 | 601 |
} |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
602 |
error("$LADCP_file: no valid data\n") unless ($nvv > 0); |
13 | 603 |
progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$opt_c,$cte,round(100*$cte/$nvv)); |
604 |
# progress("\tattitude threshold (-t %d deg): %d velocites removed (%d%% of total)\n",$opt_t,$pte,round(100*$pte/$nvv)); |
|
0 | 605 |
} |
606 |
||
607 |
#------------------------------------------------------------------- |
|
608 |
# Calculate earth velocities |
|
609 |
# - this is done for all bins (not just valid ones), to allow |
|
610 |
# useless possibility that invalid bins are used for reflr calcs |
|
611 |
# - also calculate separate beam-pair velocities |
|
612 |
# - the UNEDITED velocities are saved for the BT calculations |
|
613 |
# (W is required, U & V are only used for stats that have not |
|
614 |
# been very useful so far) |
|
615 |
#------------------------------------------------------------------- |
|
616 |
||
617 |
if ($LADCP{BEAM_COORDINATES}) { |
|
6 | 618 |
my($dummy); |
0 | 619 |
progress("Calculating earth-coordinate velocities...\n"); |
34 | 620 |
if ($bad_beam) { |
621 |
progress("\tdiscarding velocities from beam $bad_beam\n"); |
|
622 |
&antsAddParams('bad_beam_discarded',$bad_beam); |
|
623 |
} |
|
0 | 624 |
$nvw = 0; |
625 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
626 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
13 | 627 |
if ($bad_beam) { |
628 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$bad_beam-1]); |
|
629 |
undef($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$bin][$bad_beam-1]); |
|
630 |
} |
|
0 | 631 |
($LADCP{ENSEMBLE}[$ens]->{U}[$bin], |
632 |
$LADCP{ENSEMBLE}[$ens]->{V}[$bin], |
|
633 |
$LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
|
634 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin]) = |
|
635 |
velInstrumentToEarth(\%LADCP,$ens, |
|
636 |
velBeamToInstrument(\%LADCP, |
|
637 |
@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]})); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
638 |
if (defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin])) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
639 |
$per_bin_nsamp[$bin]++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
640 |
$nvw++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
641 |
} |
0 | 642 |
$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH} = |
643 |
gimbal_pitch($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
|
644 |
$LADCP{ENSEMBLE}[$ens]->{U_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{U}[$bin]; |
|
645 |
$LADCP{ENSEMBLE}[$ens]->{V_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{V}[$bin]; |
|
646 |
$LADCP{ENSEMBLE}[$ens]->{W_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin]; |
|
6 | 647 |
|
648 |
($dummy,$LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
|
649 |
$dummy,$LADCP{ENSEMBLE}[$ens]->{W34}[$bin]) = |
|
650 |
velBeamToBPEarth(\%LADCP,$ens,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}); |
|
0 | 651 |
} |
652 |
} |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
653 |
progress("\t$nvw valid velocities in bins $LADCP_firstBin-$LADCP_lastBin\n"); |
0 | 654 |
progress("\t3-beam solutions : $RDI_Coords::threeBeam_1 " . |
655 |
"$RDI_Coords::threeBeam_2 " . |
|
656 |
"$RDI_Coords::threeBeam_3 " . |
|
657 |
"$RDI_Coords::threeBeam_4\n") |
|
658 |
unless ($opt_4); |
|
6 | 659 |
} else { # Earth Coordinates |
0 | 660 |
progress("Counting valid vertical velocities...\n"); |
661 |
$nvw = 0; |
|
662 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
663 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
664 |
($LADCP{ENSEMBLE}[$ens]->{U}[$bin], |
|
665 |
$LADCP{ENSEMBLE}[$ens]->{V}[$bin], |
|
666 |
$LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
|
667 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin]) = @{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
668 |
if (defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin])) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
669 |
$per_bin_nsamp[$bin]++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
670 |
$nvw++; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
671 |
} |
0 | 672 |
$LADCP{ENSEMBLE}[$ens]->{U_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{U}[$bin]; |
673 |
$LADCP{ENSEMBLE}[$ens]->{V_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{V}[$bin]; |
|
674 |
$LADCP{ENSEMBLE}[$ens]->{W_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin]; |
|
13 | 675 |
|
676 |
$LADCP{ENSEMBLE}[$ens]->{W12}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W34}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin]; |
|
0 | 677 |
} |
678 |
} |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
679 |
progress("\t$nvw valid velocities in bins $LADCP_firstBin-$LADCP_lastBin\n"); |
0 | 680 |
} |
681 |
||
29 | 682 |
error("$LADCP_file: insufficient valid velocities\n") unless ($nvw >= $min_valid_vels); |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
683 |
|
0 | 684 |
#---------------------------------------------- |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
685 |
# STEP: Edit earth-coordinate -velocity data |
0 | 686 |
# 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
|
687 |
# 2) vertical-velocity outliers |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
688 |
# 3) truncate range by deleting farthest valid velocities (disbled by default) |
0 | 689 |
#---------------------------------------------- |
690 |
||
691 |
progress("Editing earth-coordinate velocity data...\n"); |
|
692 |
||
34 | 693 |
&antsAddParams('per_ens_outliers_mad_limit',$per_ens_outliers_mad_limit) |
694 |
&antsAddParams('farthest_valid_bins_truncated',$truncate_farthest_valid_bins) |
|
695 |
if ($truncate_farthest_valid_bins); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
696 |
$evrm = $trrm = $worm = 0; |
0 | 697 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
13 | 698 |
$evrm += editErrVel($ens,$opt_e); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
699 |
$worm += editWOutliers($ens,$per_ens_outliers_mad_limit); |
34 | 700 |
$trrm += editTruncRange($ens,$truncate_farthest_valid_bins) if ($truncate_farthest_valid_bins); |
0 | 701 |
} |
13 | 702 |
progress("\terror-velocity threshold (-e %.2f m/s): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n", |
703 |
$opt_e,$evrm,round(100*$evrm/$nvw)); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
704 |
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
|
705 |
$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
|
706 |
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
|
707 |
$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
|
708 |
if ($truncate_farthest_valid_bins > 0); |
0 | 709 |
|
710 |
#---------------------------- |
|
711 |
# Calculate LADCP time series |
|
712 |
#---------------------------- |
|
713 |
||
714 |
progress("Calculating LADCP time-series...\n"); |
|
715 |
||
716 |
($firstGoodEns,$lastGoodEns,$LADCP_atbottom,$LADCP_w_gap_time) = |
|
13 | 717 |
calcLADCPts(\%LADCP,$opt_s,$refLr_firstBin,$refLr_lastBin,$opt_g); |
29 | 718 |
error("$LADCP_file: insufficient valid data\n") |
719 |
unless defined($firstGoodEns) && ($lastGoodEns>$firstGoodEns) && ($LADCP_atbottom>=$firstGoodEns); |
|
0 | 720 |
|
721 |
my($cast_duration) = $LADCP{ENSEMBLE}[$lastGoodEns]->{ELAPSED} - |
|
722 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{ELAPSED}; |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
723 |
error("$0: implausibly short cast ($cast_duration seconds)\n") |
0 | 724 |
unless ($cast_duration > 600); |
725 |
||
29 | 726 |
my($year) = $LADCP{ENSEMBLE}[$firstGoodEns]->{YEAR} % 100; |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
727 |
&antsAddParams(sprintf('dn%02d',$year),$LADCP{ENSEMBLE}[$firstGoodEns]->{DAYNO}); |
29 | 728 |
|
0 | 729 |
$LADCP{MEAN_DT} = $cast_duration / ($lastGoodEns-$firstGoodEns-1); |
730 |
||
731 |
progress("\tStart of cast : %s (#%5d)\n", |
|
732 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{TIME}, |
|
733 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER}); |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
734 |
progress("\tBottom of cast : %s (#%5d) @ dz=%6dm\n", |
0 | 735 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{TIME}, |
736 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{NUMBER}, |
|
737 |
$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
|
738 |
progress("\tEnd of cast : %s (#%5d) @ dz=%6dm\n", |
0 | 739 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{TIME}, |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
740 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{NUMBER}, |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
741 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{DEPTH}); |
0 | 742 |
progress("\tCast duration : %.1f hours (pinging for %.1f hours)\n", |
743 |
$cast_duration / 3600, |
|
744 |
($LADCP{ENSEMBLE}[$#{$LADCP{ENSEMBLE}}]->{UNIX_TIME} - |
|
745 |
$LADCP{ENSEMBLE}[0]->{UNIX_TIME}) / 3600); |
|
746 |
progress("\tMean ping interval: %.1f seconds\n",$LADCP{MEAN_DT}); |
|
747 |
||
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
748 |
if (@out_LADCPtis) { |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
749 |
progress("Writing LADCP-timeseries to "); |
23 | 750 |
@antsNewLayout = ('ensemble','elapsed','reflr_w','reflr_w.stddev','reflr_w.nsamp','depth'); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
751 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
752 |
foreach my $of (@out_LADCP) { |
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
753 |
progress("<$of> "); |
42 | 754 |
my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/); # sub(arg), e.g. plot_wprof(DL/003_wprof.ps) |
755 |
if (defined($arg)) { # NB: exactly one arg |
|
756 |
if (-f "./${sub}.pl") { # # NB: don't quote arg |
|
757 |
require "./${sub}.pl"; |
|
758 |
} else { |
|
759 |
require "$WCALC/${sub}.pl"; |
|
760 |
} |
|
761 |
&{$sub}($arg); |
|
30 | 762 |
next; |
763 |
} |
|
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
764 |
$of = ">$of" unless ($of =~ /^$|^\s*\|/); |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
765 |
open(STDOUT,$of) || error("$of: $!\n"); |
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
766 |
undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
767 |
for (my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
768 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
769 |
$LADCP{ENSEMBLE}[$ens]->{ELAPSED}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
770 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
771 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W_STDDEV}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
772 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W_NSAMP}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
773 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH}); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
774 |
} |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
775 |
&antsOut('EOF'); open(STDOUT,'>&2'); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
776 |
} |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
777 |
progress("\n"); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
778 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
779 |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
780 |
error("deepest depth is at end of cast (no upcast data)\n") |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
781 |
if ($lastGoodEns-$LADCP_atbottom < 100); |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
782 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
783 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
784 |
# More editing |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
785 |
# - this requires ${first,last}GoodEns to be known |
6 | 786 |
# - TILT field is set as a side-effect |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
787 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
788 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
789 |
progress("Editing additional earth-coordinate velocity data...\n"); |
34 | 790 |
&antsAddParams('per_bin_valid_frac_lim',$per_bin_valid_frac_lim); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
791 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
792 |
my($first_bad_bin); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
793 |
for (my($bin)=$LADCP_firstBin-1; $bin<$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
794 |
next unless ($per_bin_nsamp[$bin]/($lastGoodEns-$firstGoodEns) < $per_bin_valid_frac_lim); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
795 |
$first_bad_bin = $bin; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
796 |
last; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
797 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
798 |
|
41 | 799 |
my($dc_sumsq,$dc_n,$uc_sumsq,$uc_n) = (0,0,0,0); |
15 | 800 |
$fprm = $pte = 0; |
801 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
41 | 802 |
my($ne) = editTilt($ens,$opt_t); |
803 |
if ($ne == 0) { |
|
804 |
if ($ens <= $LADCP_atbottom) { |
|
805 |
$dc_sumsq += &SQR($LADCP{ENSEMBLE}[$ens]->{TILT}); |
|
806 |
$dc_n++; |
|
807 |
} else { |
|
808 |
$uc_sumsq += &SQR($LADCP{ENSEMBLE}[$ens]->{TILT}); |
|
809 |
$uc_n++; |
|
810 |
} |
|
811 |
} else { |
|
812 |
$pte += $ne; |
|
813 |
} |
|
15 | 814 |
$fprm += editFarBins($ens,$first_bad_bin) if defined($first_bad_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
|
815 |
} |
41 | 816 |
my($dc_rms_tilt) = ($dc_n > 0) ? sqrt($dc_sumsq/$dc_n) : nan; |
817 |
my($uc_rms_tilt) = ($uc_n > 0) ? sqrt($uc_sumsq/$uc_n) : nan; |
|
818 |
&antsAddParams('dc_rms_tilt',$dc_rms_tilt,'uc_rms_tilt',$uc_rms_tilt); |
|
819 |
||
15 | 820 |
progress("\tattitude threshold (max_tilt = %d deg): %d velocites removed (%d%% of total)\n", |
821 |
$opt_t,$pte,round(100*$pte/$nvv)); |
|
822 |
progress("\tvelocities beyond bin $first_bad_bin (<%d%% valid values): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n", |
|
823 |
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
|
824 |
|
0 | 825 |
#-------------- |
826 |
# Read CTD data |
|
827 |
#-------------- |
|
828 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
829 |
progress("Reading CTD data from <$CTD_file>...\n"); |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
830 |
open(STDIN,$CTD_file) || error("$CTD_file: $!\n"); |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
831 |
error("$CTD_file: no data\n") unless (&antsIn()); |
2 | 832 |
undef($antsOldHeaders); |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
833 |
|
19 | 834 |
&antsAddParams('lat',$P{lat}) if defined($P{lat}); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
835 |
&antsAddParams('lon',$P{lon}) if defined($P{lon}); |
0 | 836 |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
837 |
($CTD_elapsed,$CTD_depth,$CTD_svel,$CTD_w) = &fnr('elapsed','depth','ss','w'); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
838 |
$CTD_temp = &fnrNoErr('temp'); |
29 | 839 |
warning(0,"no CTD temperature --- using ADCP temperature instead => Sv degraded!\n",$s) |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
840 |
unless defined($CTD_temp); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
841 |
|
0 | 842 |
$CTD_maxdepth = -1; |
13 | 843 |
do { # read data |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
844 |
error("$0: cannot deal with non-numeric CTD elapsed time\n") |
0 | 845 |
unless &antsNumbers($CTD_elapsed); |
846 |
push(@{$CTD{ELAPSED}},$ants_[0][$CTD_elapsed]); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
847 |
push(@{$CTD{DEPTH}}, $ants_[0][$CTD_depth]); |
0 | 848 |
push(@{$CTD{SVEL}}, $ants_[0][$CTD_svel]); |
849 |
push(@{$CTD{W}}, $ants_[0][$CTD_w]); |
|
850 |
push(@{$CTD{TEMP}}, $ants_[0][$CTD_temp]) if defined($CTD_temp); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
851 |
if ($ants_[0][$CTD_depth] > $CTD_maxdepth) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
852 |
$CTD_maxdepth = $ants_[0][$CTD_depth]; |
0 | 853 |
$CTD_atbottom = $#{$CTD{DEPTH}}; |
854 |
} |
|
855 |
} while (&antsIn()); |
|
856 |
||
857 |
$CTD{DT} = ($CTD{ELAPSED}[$#{$CTD{ELAPSED}}] - $CTD{ELAPSED}[0]) / $#{$CTD{ELAPSED}}; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
858 |
progress("\t%d scans at %.1fHz\n",scalar(@{$CTD{DEPTH}}),1/$CTD{DT}); |
0 | 859 |
|
13 | 860 |
$CTD{W_t}[0] = $CTD{W_t} [@{$CTD{ELAPSED}}] = nan; # calculate w-derivatives |
861 |
$CTD{W_tt}[0] = $CTD{W_tt}[@{$CTD{ELAPSED}}] = nan; |
|
862 |
for (my($s)=1; $s<@{$CTD{ELAPSED}}-1; $s++) { # centered differences for both |
|
863 |
$CTD{W_t} [$s] = ($CTD{W}[$s+1] - $CTD{W}[$s-1]) / (2*$CTD{DT}); |
|
41 | 864 |
$CTD{W_tt}[$s] = ($CTD{W}[$s+1] + $CTD{W}[$s-1] - 2*$CTD{W}[$s]) / &SQR($CTD{DT}); |
13 | 865 |
} |
42 | 866 |
$CTD_maxdepth = round($CTD_maxdepth); |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
867 |
error("$0: CTD start depth must be numeric\n") |
0 | 868 |
unless numberp($CTD{DEPTH}[0]); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
869 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
870 |
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
|
871 |
progress("\tmax depth = %dm (# $CTD_atbottom)\n",$CTD_maxdepth); |
0 | 872 |
|
873 |
#-------------------------------------------------------------------- |
|
874 |
# Construct sound-speed correction profile from CTD 1Hz downcast data |
|
875 |
# very simple algorithm that stores the last value found |
|
876 |
# in each 1m bin |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
877 |
# For PPI filtering, a sound speed profile without gaps is required. |
0 | 878 |
#-------------------------------------------------------------------- |
879 |
||
880 |
progress("Constructing sound-speed correction profile\n"); |
|
881 |
||
882 |
my($scans_per_sec) = int(1/$CTD{DT}+0.5); |
|
15 | 883 |
my($min_depth) = 9e99; |
0 | 884 |
for (my($s)=0; $s<=$CTD_atbottom; $s+=$scans_per_sec) { |
885 |
next unless ($CTD{DEPTH}[$s] >= 0 && numberp($CTD{SVEL}[$s])); |
|
19 | 886 |
my($d) = int($CTD{DEPTH}[$s]); |
887 |
$min_depth = $d if ($d < $min_depth); |
|
888 |
$sVelProf[$d] = $CTD{SVEL}[$s]; |
|
0 | 889 |
} |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
890 |
while ($min_depth > 0) { # fill surface gap |
15 | 891 |
$sVelProf[$min_depth-1] = $sVelProf[$min_depth]; |
892 |
$min_depth--; |
|
893 |
} |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
894 |
for (my($d)=$min_depth+1; $d<=$#sVelProf; $d++) { # fill interior gaps |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
895 |
$sVelProf[$d] = $sVelProf[$d-1] |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
896 |
unless defined($sVelProf[$d]); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
897 |
} |
19 | 898 |
|
18 | 899 |
|
0 | 900 |
#------------------- |
901 |
# Determine time lag |
|
902 |
#------------------- |
|
903 |
||
13 | 904 |
if (defined($opt_i)) { |
0 | 905 |
progress("Setting initial time lag...\n"); |
13 | 906 |
$CTD{TIME_LAG} = $opt_i; |
0 | 907 |
progress("\t-i => elapsed(CTD) ~ elapsed(LADCP) + %.1fs\n",$CTD{TIME_LAG}); |
908 |
} else { |
|
909 |
progress("Guestimating time lag...\n"); |
|
910 |
||
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
911 |
my($CTD_10pct_down) = 0; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
912 |
my($LADCP_10pct_down) = $firstGoodEns; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
913 |
|
0 | 914 |
$CTD_10pct_down++ |
915 |
until ($CTD{DEPTH}[$CTD_10pct_down]-$CTD{DEPTH}[0] >= 0.1*($CTD_maxdepth-$CTD{DEPTH}[0])); |
|
916 |
$LADCP_10pct_down++ |
|
917 |
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
|
918 |
|
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
919 |
$CTD{TIME_LAG} = |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
920 |
$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
|
921 |
|
0 | 922 |
progress("\telapsed(dz(CTD)=%.1fm) ~ elapsed(dz(LADCP)=%.1fm) + %.1fs\n", |
923 |
$CTD{DEPTH}[$CTD_10pct_down]-$CTD{DEPTH}[0],$LADCP{ENSEMBLE}[$LADCP_10pct_down]->{DEPTH},$CTD{TIME_LAG}); |
|
924 |
} |
|
925 |
||
2 | 926 |
if ($opt_u) { |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
927 |
progress("\tskipping time lagging (-u)\n"); |
2 | 928 |
} else { |
13 | 929 |
|
930 |
#------------------------ |
|
931 |
# stage 1: 1Hz; full cast |
|
932 |
#------------------------ |
|
933 |
||
934 |
$CTD{TIME_LAG} = |
|
935 |
calc_lag($number_of_timelag_windows[0],$length_of_timelag_windows[0], |
|
936 |
int(1/$CTD{DT}+0.5),$firstGoodEns,$lastGoodEns); |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
937 |
error("$0: Cannot proceed without valid lag!\n") unless defined($CTD{TIME_LAG}); |
2 | 938 |
progress("\telapsed(CTD) ~ elapsed(LADCP) + %.2fs\n",$CTD{TIME_LAG}); |
13 | 939 |
|
940 |
#--------------------------------- |
|
941 |
# stage 2: piece-wise time lagging |
|
942 |
#--------------------------------- |
|
943 |
||
944 |
my(@splits); |
|
945 |
push(@splits,$firstGoodEns); |
|
946 |
foreach my $s (split(/,/,$opt_p)) { |
|
947 |
if ($s eq '+') { |
|
948 |
push(@splits,$LADCP_atbottom); |
|
949 |
} elsif (numberp($s)) { # find ens for given LADCP elapsed time in min |
|
950 |
my($ela) = $s*60; |
|
951 |
my($ens) = $firstGoodEns + round($ela / $LADCP{MEAN_DT}); # first, guess |
|
952 |
while ($LADCP{ENSEMBLE}[$ens]->{ELAPSED} > $ela) { $ens--; } # then, correct |
|
953 |
while ($LADCP{ENSEMBLE}[$ens]->{ELAPSED} < $ela) { $ens++; } |
|
954 |
push(@splits,$ens); |
|
955 |
} else { |
|
956 |
warning(2,"ignoring non-numeric -p argument %s",$s); |
|
957 |
} |
|
958 |
} |
|
959 |
push(@splits,$lastGoodEns); |
|
11 | 960 |
|
13 | 961 |
my($valid_lag); # determine piece-wise lags |
962 |
while (@splits > 1) { |
|
963 |
push(@CTD_tl_fromEns,$splits[0]); |
|
964 |
push(@CTD_tl_toEns,$splits[1]); |
|
29 | 965 |
debugmsg("lag($splits[0],$splits[1]) = "); |
13 | 966 |
my($lag) = calc_lag($number_of_timelag_windows[1],$length_of_timelag_windows[1], |
967 |
1,$splits[0],$splits[1]); |
|
29 | 968 |
debugmsg("$lag\n"); |
13 | 969 |
if (defined($lag)) { |
970 |
progress("\tcast-piece: elapsed(CTD) = elapsed(LADCP) + %.2fs\n",$lag); |
|
971 |
push(@CTD_time_lag,$lag); |
|
972 |
$valid_lag = $#CTD_time_lag; |
|
973 |
} else { |
|
974 |
progress("\tcast-piece: time-lagging failed\n"); |
|
975 |
push(@CTD_time_lag,nan); |
|
976 |
} |
|
977 |
shift(@splits); |
|
978 |
} |
|
979 |
||
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
980 |
error("$0: Cannot proceed without at least one lag!\n") # fill failed lag with surrounding data |
13 | 981 |
unless defined($valid_lag); |
982 |
while ($valid_lag < $#CTD_time_lag) { # forward |
|
983 |
$CTD_time_lag[$valid_lag+1] = $CTD_time_lag[$valid_lag]; |
|
984 |
$valid_lag++; |
|
985 |
} |
|
986 |
while ($valid_lag > 0) { # backward |
|
987 |
$CTD_time_lag[$valid_lag-1] = $CTD_time_lag[$valid_lag] |
|
988 |
unless (numberp($CTD_time_lag[$valid_lag-1])); |
|
989 |
$valid_lag--; |
|
990 |
} |
|
2 | 991 |
} |
0 | 992 |
|
13 | 993 |
&antsAddParams('CTD_time_lags',"@CTD_time_lag"); |
994 |
undef($CTD{TIME_LAG}); # to avoid confusion, clear old 1Hz-based lag |
|
0 | 995 |
|
996 |
#------------------------------------------------ |
|
997 |
# Merge CTD with LADCP data |
|
998 |
# - after this step, reflr w is sound-speed corrected!!! |
|
999 |
#------------------------------------------------ |
|
1000 |
||
1001 |
progress("Merging CTD with LADCP data...\n"); |
|
1002 |
||
34 | 1003 |
&antsAddParams('w_max_lim',$w_max_lim); |
1004 |
||
13 | 1005 |
my($cli) = 0; # current-lag index |
1006 |
my($lag) = $CTD_time_lag[$cli]; # current lag |
|
1007 |
||
42 | 1008 |
my($dc_sumsq,$dc_n,$uc_sumsq,$uc_n) = (0,0,0,0); # for a_pkg calcs |
0 | 1009 |
for (my($skipped)=0,my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
13 | 1010 |
|
1011 |
if ($ens > $CTD_tl_toEns[$cli]) { # use correct lag piece |
|
1012 |
$cli++; |
|
1013 |
die("assertion failed!\n\ttest: \$cli(=$cli) <= \$#CTD_time_lag\n") |
|
1014 |
unless ($cli <= $#CTD_time_lag); |
|
1015 |
$lag = $CTD_time_lag[$cli]; |
|
1016 |
} |
|
1017 |
||
1018 |
my($scan) = |
|
1019 |
int(($LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $lag - $CTD{ELAPSED}[0]) / $CTD{DT} + 0.5); |
|
0 | 1020 |
if ($scan <= 0) { # NB: must be <=, rather than <, or assertion below sometimes fails |
1021 |
$skipped++; |
|
1022 |
$firstGoodEns = $ens+1; |
|
1023 |
next; |
|
1024 |
} |
|
1025 |
if ($skipped > 0) { |
|
13 | 1026 |
$firstGoodEns++,$skipped++,next # in gap |
2 | 1027 |
unless defined($LADCP{ENSEMBLE}[$firstGoodEns]->{REFLR_W}); |
0 | 1028 |
info("$skipped initial LADCP ensembles skipped because CTD data begin with LADCP in water\n"); |
1029 |
$skipped = 0; |
|
1030 |
} |
|
1031 |
if ($scan > $#{$CTD{ELAPSED}}) { |
|
13 | 1032 |
while (!defined($LADCP{ENSEMBLE}[$ens-1]->{REFLR_W})) { $ens--; } # in gap |
0 | 1033 |
info(sprintf("%d final LADCP ensembles skipped because CTD data end with LADCP in water\n", |
1034 |
$lastGoodEns-$ens+1)); |
|
1035 |
$lastGoodEns = $ens-1; |
|
1036 |
last; |
|
1037 |
} |
|
1038 |
||
1039 |
$LADCP{ENSEMBLE}[$ens]->{CTD_ELAPSED} = $CTD{ELAPSED}[$scan]; # elapsed field for output |
|
1040 |
||
1041 |
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
|
1042 |
&& numberp($CTD{DEPTH}[$scan])) { |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1043 |
$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
|
1044 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W} *= $CTD{SVEL}[$scan]/1500; # correct for sound-speed variations at source |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1045 |
error(sprintf("\n$0: negative depth (%.1fm) in CTD file at elapsed(CTD) = %.1fs\n", |
0 | 1046 |
$CTD{DEPTH}[$scan],$CTD{ELAPSED}[$scan])) |
1047 |
unless ($CTD{DEPTH}[$scan] >= 0); |
|
1048 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} = $CTD{DEPTH}[$scan]; |
|
42 | 1049 |
$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN} = $scan; # calc rms package acceleration |
1050 |
if (numberp($CTD{W_t}[$scan])) { |
|
1051 |
if ($ens <= $LADCP_atbottom) { |
|
1052 |
$dc_sumsq += &SQR($CTD{W_t}[$scan]); $dc_n++; |
|
1053 |
} else { |
|
1054 |
$uc_sumsq += &SQR($CTD{W_t}[$scan]); $uc_n++; |
|
1055 |
} |
|
41 | 1056 |
} |
0 | 1057 |
my($reflr_ocean_w) = $LADCP{ENSEMBLE}[$ens]->{REFLR_W} - $CTD{W}[$scan]; |
13 | 1058 |
if (abs($reflr_ocean_w) <= $w_max_lim) { |
0 | 1059 |
$sumWsq += &SQR($reflr_ocean_w); |
1060 |
$nWsq++; |
|
1061 |
if ($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} > 100 && |
|
1062 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} < $LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH}-100) { |
|
1063 |
$sumWsqI += &SQR($reflr_ocean_w); |
|
1064 |
$nWsqI++; |
|
1065 |
} |
|
1066 |
} else { |
|
1067 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); # DON'T USE THIS ENSEMBLE LATER |
|
1068 |
} |
|
1069 |
} else{ |
|
1070 |
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
|
1071 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); # old DEPTH from calcLADCPts() must be removed |
0 | 1072 |
} |
1073 |
} |
|
41 | 1074 |
|
42 | 1075 |
my($dc_rms_apkg) = ($dc_n > 0) ? sqrt($dc_sumsq / $dc_n) : nan; # rms package acceleration |
1076 |
my($uc_rms_apkg) = ($uc_n > 0) ? sqrt($uc_sumsq / $uc_n) : nan; |
|
1077 |
&antsAddParams('dc_rms_accel_pkg',$dc_rms_apkg,'uc_rms_accel_pkg',$uc_rms_apkg); |
|
0 | 1078 |
|
1079 |
if ($nWsq > 0 && $nWsqI > 0) { |
|
1080 |
&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',sqrt($sumWsqI/$nWsqI)); |
|
1081 |
progress("\t%.2f cm/s rms reference-layer w_ocean, %.2f cm/s away from boundaries\n", |
|
1082 |
100*sqrt($sumWsq/$nWsq),100*sqrt($sumWsqI/$nWsqI)); |
|
34 | 1083 |
# if (sqrt($sumWsqI/$nWsqI) > 0.05) { |
1084 |
# warning(0,"%.2f cm/s (large) reference-layer w_ocean away from boundaries\n",100*sqrt($sumWsqI/$nWsqI)); |
|
1085 |
# } els |
|
1086 |
if (sqrt($sumWsqI/$nWsqI) > 0.15) { |
|
1087 |
warning(2,"%.2f cm/s (implausibly large) reference-layer w_ocean away from boundaries\n",100*sqrt($sumWsqI/$nWsqI)); |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
1088 |
} |
0 | 1089 |
} elsif ($nWsq > 0) { |
1090 |
&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',nan); |
|
1091 |
progress("\t%.2f cm/s rms reference-layer w_ocean\n",100*sqrt($sumWsq/$nWsq)); |
|
1092 |
} else { |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
1093 |
error("$0: no valid vertical velocities\n"); |
0 | 1094 |
} |
1095 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1096 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1097 |
# Calculate Volume Scattering Coefficients |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1098 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1099 |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
1100 |
progress("Calculating volume-scattering coefficients (Sv)...\n"); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1101 |
calc_backscatter_profs($firstGoodEns,$lastGoodEns); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1102 |
|
34 | 1103 |
if (@nSv) { |
1104 |
progress("\tapplying empirical Sv correction\n"); |
|
1105 |
correct_backscatter($firstGoodEns,$lastGoodEns); |
|
1106 |
} |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
1107 |
|
0 | 1108 |
#---------------------------------------------------------------------------- |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
1109 |
# Find Seabed & Edit data |
15 | 1110 |
# 1) contaminated by sidelobe reflection from seabed and sea surface |
1111 |
# 2) PPI |
|
0 | 1112 |
#---------------------------------------------------------------------------- |
1113 |
||
42 | 1114 |
error("$0: conflicting water-depth information provided by user\n") # this can only happen if |
1115 |
if defined($opt_h) && defined($water_depth); # the user is setting $water_depth |
|
1116 |
# explicitly?! |
|
1117 |
if (defined($opt_h)) { # deal with user-provided water-depth info |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1118 |
if (numberp($opt_h)) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1119 |
$water_depth = $opt_h; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1120 |
} elsif (-f $opt_h) { |
40 | 1121 |
open(WDF,$opt_h) || error("$opt_h: $_\n"); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1122 |
$water_depth = &antsFileScanParam(WDF,'water_depth'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1123 |
close(WDF); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1124 |
undef($water_depth) unless numberp($water_depth); |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1125 |
} else { |
40 | 1126 |
error("$0: -h $opt_h defines neither number nor existing file\n"); |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1127 |
} |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1128 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1129 |
|
42 | 1130 |
#die("assertion failed (water_depth = $water_depth)") |
1131 |
# unless (!defined($water_depth) || numberp($water_depth)); |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1132 |
|
42 | 1133 |
if (!defined($water_depth) && # find seabed in data |
1134 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{XDUCER_FACING_DOWN}) { |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1135 |
progress("Finding seabed...\n"); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1136 |
($water_depth,$sig_water_depth) = |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1137 |
find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH}); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1138 |
($water_depth_BT,$sig_water_depth_BT) = |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1139 |
find_seabed(\%LADCP,$LADCP_atbottom,$LADCP{BEAM_COORDINATES}); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1140 |
if (defined($water_depth) && defined($water_depth_BT)) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1141 |
my($dd) = abs($water_depth_BT - $water_depth); |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1142 |
# warning(0,sprintf("Large instrument vs. backscatter-derived water-depth difference (%.1fm)\n",$dd)) |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1143 |
# if ($dd > 10); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1144 |
} |
42 | 1145 |
if (!$SS_use_BT && !defined($water_depth) && defined($water_depth_BT)) { # warn if use of BT was not |
1146 |
warning(1,"using water_depth from ADCP BT data\n"); # explicitly requested |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1147 |
$SS_use_BT = 1; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1148 |
} |
42 | 1149 |
if ($SS_use_BT) { # water depth from BT data |
34 | 1150 |
&antsAddParams('water_depth_from','BT_data'); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1151 |
$water_depth = $water_depth_BT; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1152 |
$sig_water_depth = $sig_water_depth_BT; |
42 | 1153 |
} else { # water depth from WT data |
34 | 1154 |
&antsAddParams('water_depth_from','echo_amplitudes'); |
1155 |
} |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1156 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1157 |
|
42 | 1158 |
if (defined($water_depth)) { # 1 or 2 water depths available |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1159 |
if (defined($water_depth_BT)) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1160 |
progress("\t%.1f(%.1f) m water depth (%.1f(%.1f)m from ADCP BT data)\n", |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1161 |
$water_depth,$sig_water_depth,$water_depth_BT,$sig_water_depth_BT); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1162 |
} else { |
42 | 1163 |
progress("\t%.1f(%.1f) m water depth (no seabed found in BT data)\n", |
1164 |
$water_depth,$sig_water_depth); |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1165 |
} |
42 | 1166 |
warning(1,sprintf("large uncertainty in water-depth estimation (%.1fm)\n", |
1167 |
$sig_water_depth)) |
|
1168 |
if ($sig_water_depth > $LADCP{BIN_LENGTH}); |
|
1169 |
if ($water_depth < $CTD_maxdepth) { |
|
1170 |
warning(2,"water depth ($water_depth m) < max CTD depth ($CTD_maxdepth m) ignored\n"); |
|
1171 |
undef($water_depth); |
|
1172 |
} |
|
1173 |
} |
|
1174 |
||
1175 |
if (defined($water_depth)) { # set %PARAMs |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1176 |
&antsAddParams('water_depth',$water_depth,'water_depth.sig',$sig_water_depth); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1177 |
} else { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1178 |
warning(2,"unknown water depth --- cannot edit sidelobes or PPI near the seabed\n"); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1179 |
&antsAddParams('water_depth','unknown','water_depth.sig','nan'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1180 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1181 |
|
42 | 1182 |
if ($LADCP{ENSEMBLE}[$LADCP_atbottom]->{XDUCER_FACING_DOWN}) { # DOWNLOOKER |
41 | 1183 |
&antsAddParams('ADCP_orientation','DL'); |
0 | 1184 |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1185 |
if (defined($water_depth)) { |
0 | 1186 |
progress("Editing data to remove sidelobe interference from seabed...\n"); |
1187 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,$water_depth); |
|
1188 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
|
1189 |
||
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1190 |
if ($sidelobe_editing_DL_surface) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1191 |
progress("Editing data to remove sidelobe interference from sea surface...\n"); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1192 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,undef); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1193 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
34 | 1194 |
&antsAddParams('sidelobe_editing','surface+seabed','vessel_draft',$vessel_draft); |
1195 |
} else { |
|
1196 |
&antsAddParams('sidelobe_editing','seabed'); |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1197 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1198 |
|
19 | 1199 |
if ($PPI_editing) { |
34 | 1200 |
&antsAddParams('PPI_editing','seabed'); |
1201 |
&antsAddParams('PPI_extend_upper_limit',$PPI_extend_upper_limit) |
|
1202 |
if numberp($PPI_extend_upper_limit); |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1203 |
progress("Editing data to remove PPI from seabed...\n"); |
19 | 1204 |
progress("\tConstructing depth-average soundspeed profile...\n"); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1205 |
die("assertion failed") unless defined($water_depth); |
19 | 1206 |
my($dz) = $water_depth - $#sVelProf; # $#sVelProf = max_depth(profile) in meters |
1207 |
my($sum) = $dz * $sVelProf[$#sVelProf]; |
|
1208 |
$DASSprof[$#sVelProf] = $sum/$dz; |
|
1209 |
for (my($d)=$#sVelProf-1; $d>=0; $d--) { |
|
1210 |
die("assertion failed (d=$d, #sVelProf=$#sVelProf)") unless numberp($sVelProf[$d]); |
|
1211 |
$sum += $sVelProf[$d]; |
|
1212 |
$dz++; |
|
1213 |
$DASSprof[$d] = $sum/$dz; |
|
1214 |
} |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1215 |
($nvrm,$nerm) = editPPI($firstGoodEns,$lastGoodEns,$water_depth); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1216 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1217 |
} |
0 | 1218 |
} |
1219 |
||
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1220 |
} else { # UPLOOKER |
41 | 1221 |
&antsAddParams('ADCP_orientation','UL'); |
15 | 1222 |
|
0 | 1223 |
progress("Editing data to remove sidelobe interference from sea surface...\n"); |
1224 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,undef); |
|
1225 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
|
15 | 1226 |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1227 |
if ($sidelobe_editing_UL_seabed) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1228 |
if (defined($water_depth)) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1229 |
progress("Editing data to remove sidelobe interference from seabed...\n"); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1230 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,$water_depth); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1231 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1232 |
} else { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1233 |
warning(2,"unknown water depth --- cannot edit UL data for sidelobe interference from seabed\n"); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1234 |
} |
34 | 1235 |
&antsAddParams('sidelobe_editing','surface+seabed','vessel_draft',$vessel_draft); |
1236 |
} else { |
|
1237 |
&antsAddParams('sidelobe_editing','surface','vessel_draft',$vessel_draft); |
|
1238 |
} |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1239 |
if ($PPI_editing) { |
34 | 1240 |
&antsAddParams('PPI_editing','surface'); |
1241 |
&antsAddParams('PPI_extend_upper_limit',$PPI_extend_upper_limit) |
|
1242 |
if numberp($PPI_extend_upper_limit); |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1243 |
progress("Editing data to remove PPI from sea surface...\n"); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1244 |
progress("\tConstructing depth-average soundspeed profile...\n"); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1245 |
$DASSprof[0] = my($sum) = 0; |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1246 |
for (my($d)=1; $d<=$#sVelProf; $d++) { |
19 | 1247 |
die("assertion failed") unless numberp($sVelProf[$d]); |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1248 |
$sum += $sVelProf[$d]; |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1249 |
$DASSprof[$d] = $sum/$d; |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1250 |
} |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1251 |
($nvrm,$nerm) = editPPI($firstGoodEns,$lastGoodEns,undef); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1252 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1253 |
} |
0 | 1254 |
} |
1255 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1256 |
#---------------------------------------------------------------------- |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1257 |
# 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
|
1258 |
# 1) surface layer editing |
19 | 1259 |
# 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
|
1260 |
#---------------------------------------------------------------------- |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1261 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1262 |
progress("Removing data from instrument at surface...\n"); |
34 | 1263 |
&antsAddParams('surface_layer_depth',$surface_layer_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
|
1264 |
$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
|
1265 |
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
|
1266 |
|
11 | 1267 |
if (defined($post_merge_hook)) { |
1268 |
progress("Executing user-supplied \$post_merge_hook...\n"); |
|
1269 |
&{$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
|
1270 |
} |
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
1271 |
|
13 | 1272 |
#---------------------------------------------------------------------- |
1273 |
# apply pressure-sensor acceleration correction (-a) |
|
1274 |
# - valid, but useless except for troubleshooting data sets (e.g. DIMES UK2) |
|
1275 |
# - useless, because ping-coherent error removal below does same job but better |
|
1276 |
# - it does not make sense to to use this with ping-coherent error removal enabled |
|
1277 |
#---------------------------------------------------------------------- |
|
1278 |
||
1279 |
if ($opt_a != 1) { |
|
1280 |
progress("Applying pressure-sensor acceleration correction...\n"); |
|
1281 |
for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
|
1282 |
next unless numberp($CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1283 |
my($acorr) = $opt_a * $CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
|
1284 |
if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH})) { |
|
1285 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1286 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
1287 |
$LADCP{ENSEMBLE}[$ens]->{W}[$bin] -= $acorr; |
|
1288 |
} |
|
1289 |
} |
|
1290 |
if (numberp($LADCP{ENSEMBLE}[$ens]->{REFLR_W})) { |
|
1291 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W} -= $acorr; |
|
1292 |
} |
|
1293 |
} |
|
1294 |
} |
|
1295 |
||
0 | 1296 |
#--------------------------------------------------------------------------- |
1297 |
# Depth-bin LADCP velocity data |
|
1298 |
# |
|
1299 |
# NOTES: |
|
1300 |
# 1) ensemble and bin numbers are saved for maximum flexibility |
|
1301 |
# 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
|
1302 |
# 3) applying the full soundspeed correction to w is pointless in |
0 | 1303 |
# practice, but hey!, CPU cycles are cheap; [in a cast in the Gulf of Mexico |
1304 |
# which has fairly pronounce soundspeed gradients, the max value of Kn |
|
1305 |
# is 1.00004160558372, which gives rise to a correction of less than 0.2mm/s |
|
1306 |
# at a winch+wave speed of 3m/s....] |
|
1307 |
# 4) as far as I can tell, the soundspeed correction for bin length also |
|
1308 |
# has only a minute effect |
|
1309 |
#--------------------------------------------------------------------------- |
|
1310 |
||
13 | 1311 |
progress("Creating binned profiles at ${opt_o}m resolution...\n"); |
30 | 1312 |
|
1313 |
&antsAddParams('outgrid_dz',$opt_o,'outgrid_minsamp',$opt_k); # used by LADCP_w_regrid |
|
1314 |
&antsAddParams('outgrid_firstbin',$outGrid_firstBin,'outgrid_lastbin',$outGrid_lastBin); |
|
0 | 1315 |
|
2 | 1316 |
my($min_depth) = 9e99; |
1317 |
my($max_depth) = 0; |
|
30 | 1318 |
local($realLastGoodEns); |
2 | 1319 |
|
0 | 1320 |
progress("\tdowncast...\n"); |
1321 |
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
|
1322 |
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
|
1323 |
$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
|
1324 |
next; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1325 |
} |
29 | 1326 |
$realLastGoodEns = $ens; |
0 | 1327 |
my(@bindepth) = calc_binDepths($ens); |
1328 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1329 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
30 | 1330 |
next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1); |
2 | 1331 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
1332 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
1333 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] = |
|
0 | 1334 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
1335 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1336 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
1337 |
$bindepth[$bin]); |
|
6 | 1338 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] = |
1339 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
|
1340 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1341 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
1342 |
$bindepth[$bin]) |
|
1343 |
if numberp($LADCP{ENSEMBLE}[$ens]->{W12}[$bin]); |
|
1344 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] = |
|
1345 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W34}[$bin], |
|
1346 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1347 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
1348 |
$bindepth[$bin]) |
|
1349 |
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
|
1350 |
$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
|
1351 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] + $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
13 | 1352 |
my($bi) = $bindepth[$bin]/$opt_o; |
0 | 1353 |
push(@{$DNCAST{ENSEMBLE}[$bi]},$ens); |
1354 |
push(@{$DNCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
42 | 1355 |
# push(@{$DNCAST{CTD_W}[$bi]},$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
1356 |
# push(@{$DNCAST{CTD_W_tt}[$bi]},$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1357 |
# push(@{$DNCAST{BIN}[$bi]},$bin); |
|
0 | 1358 |
push(@{$DNCAST{DEPTH}[$bi]},$bindepth[$bin]); |
2 | 1359 |
push(@{$DNCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
13 | 1360 |
push(@{$DNCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
1361 |
push(@{$DNCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
0 | 1362 |
} |
1363 |
} |
|
1364 |
||
6 | 1365 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { # bin data into profile |
0 | 1366 |
$DNCAST{MEAN_DEPTH}[$bi] = avg(@{$DNCAST{DEPTH}[$bi]}); |
1367 |
$DNCAST{MEAN_ELAPSED}[$bi] = avg(@{$DNCAST{ELAPSED}[$bi]}); |
|
1368 |
$DNCAST{MEDIAN_W}[$bi] = median(@{$DNCAST{W}[$bi]}); |
|
13 | 1369 |
$DNCAST{MEDIAN_W12}[$bi] = median(@{$DNCAST{W12}[$bi]}); |
1370 |
$DNCAST{MEDIAN_W34}[$bi] = median(@{$DNCAST{W34}[$bi]}); |
|
0 | 1371 |
$DNCAST{MAD_W}[$bi] = mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]}); |
1372 |
$DNCAST{N_SAMP}[$bi] = @{$DNCAST{W}[$bi]}; |
|
1373 |
} |
|
1374 |
||
2 | 1375 |
progress("\tupcast...\n"); # upcast |
0 | 1376 |
|
1377 |
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) { |
|
1378 |
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
|
1379 |
$realLastGoodEns = $ens; |
0 | 1380 |
my(@bindepth) = calc_binDepths($ens); |
1381 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1382 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
30 | 1383 |
next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1); |
2 | 1384 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
1385 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
1386 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] = |
|
0 | 1387 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
1388 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1389 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
1390 |
$bindepth[$bin]); |
|
6 | 1391 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] = |
1392 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
|
1393 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1394 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
1395 |
$bindepth[$bin]) |
|
1396 |
if numberp($LADCP{ENSEMBLE}[$ens]->{W12}[$bin]); |
|
1397 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] = |
|
1398 |
sscorr_w($LADCP{ENSEMBLE}[$ens]->{W34}[$bin], |
|
1399 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
|
1400 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
|
1401 |
$bindepth[$bin]) |
|
1402 |
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
|
1403 |
$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
|
1404 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] + $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
13 | 1405 |
my($bi) = $bindepth[$bin]/$opt_o; |
0 | 1406 |
push(@{$UPCAST{ENSEMBLE}[$bi]},$ens); |
1407 |
push(@{$UPCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
42 | 1408 |
# push(@{$UPCAST{CTD_W}[$bi]},$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
1409 |
# push(@{$UPCAST{CTD_W_tt}[$bi]},$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1410 |
# push(@{$UPCAST{BIN}[$bi]},$bin); |
|
0 | 1411 |
push(@{$UPCAST{DEPTH}[$bi]},$bindepth[$bin]); |
2 | 1412 |
push(@{$UPCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
13 | 1413 |
push(@{$UPCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
1414 |
push(@{$UPCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
0 | 1415 |
} |
1416 |
} |
|
1417 |
||
1418 |
for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) { |
|
1419 |
$UPCAST{MEAN_DEPTH}[$bi] = avg(@{$UPCAST{DEPTH}[$bi]}); |
|
1420 |
$UPCAST{MEAN_ELAPSED}[$bi] = avg(@{$UPCAST{ELAPSED}[$bi]}); |
|
1421 |
$UPCAST{MEDIAN_W}[$bi] = median(@{$UPCAST{W}[$bi]}); |
|
13 | 1422 |
$UPCAST{MEDIAN_W12}[$bi] = median(@{$UPCAST{W12}[$bi]}); |
1423 |
$UPCAST{MEDIAN_W34}[$bi] = median(@{$UPCAST{W34}[$bi]}); |
|
0 | 1424 |
$UPCAST{MAD_W}[$bi] = mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]}); |
1425 |
$UPCAST{N_SAMP}[$bi] = @{$UPCAST{W}[$bi]}; |
|
1426 |
} |
|
1427 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1428 |
#------------------------------------------------------------------------------------------------------ |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1429 |
# remove ping-coherent residuals |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1430 |
# - potential error sources: |
13 | 1431 |
# 1) acceleration-dependence of Paroscientific pressure measurements; O(10cm/s) [IWISE 28] |
1432 |
# 2) residual CTD/LADCP mismatch errors; O(1cm/s) [Thurnherr, CWTMC 2011] |
|
1433 |
# 3) ADCP short-term variability; O(1cm/s) for vertical? |
|
1434 |
# - two steps: |
|
1435 |
# - remove ensemble-median residual from all ocean vertical velocities |
|
1436 |
# - re-bin profiles |
|
1437 |
# - 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
|
1438 |
# - 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
|
1439 |
# 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
|
1440 |
#------------------------------------------------------------------------------------------------------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1441 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1442 |
unless ($opt_q) { |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1443 |
progress("Removing ping-coherent residuals...\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
|
1444 |
|
13 | 1445 |
for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
1446 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
11 | 1447 |
|
13 | 1448 |
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
|
1449 |
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
|
1450 |
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
|
1451 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
30 | 1452 |
next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1); |
13 | 1453 |
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
|
1454 |
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
|
1455 |
$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
|
1456 |
(($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
|
1457 |
: $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
|
1458 |
} |
13 | 1459 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} = median(@residuals); # NB: can be nan! |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1460 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W}); |
13 | 1461 |
|
1462 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { # remove from ocean velocities |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1463 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$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
|
1464 |
$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
|
1465 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W}; |
13 | 1466 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] -= |
1467 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} |
|
1468 |
if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
1469 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] -= |
|
1470 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} |
|
1471 |
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
|
1472 |
} |
13 | 1473 |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1474 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W} -= # NB: this can be nan here |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1475 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1476 |
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
|
1477 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1478 |
|
13 | 1479 |
#------------------------------------------------------------ |
1480 |
||
1481 |
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
|
1482 |
|
13 | 1483 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { # bin data |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1484 |
for (my($i)=0; $i<@{$DNCAST{W}[$bi]}; $i++) { # code works if MEDIAN_RESIDUAL_W is nan (possible?) |
13 | 1485 |
$DNCAST{W} [$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W}; |
1486 |
$DNCAST{W12}[$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W}; |
|
1487 |
$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
|
1488 |
} |
13 | 1489 |
$DNCAST{MEDIAN_W} [$bi] = median(@{$DNCAST{W}[$bi]}); |
1490 |
$DNCAST{MEDIAN_W12}[$bi] = median(@{$DNCAST{W12}[$bi]}); |
|
1491 |
$DNCAST{MEDIAN_W34}[$bi] = median(@{$DNCAST{W34}[$bi]}); |
|
1492 |
$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
|
1493 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1494 |
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
|
1495 |
for (my($i)=0; $i<@{$UPCAST{W}[$bi]}; $i++) { |
13 | 1496 |
$UPCAST{W} [$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W}; |
1497 |
$UPCAST{W12}[$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W}; |
|
1498 |
$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
|
1499 |
} |
13 | 1500 |
$UPCAST{MEDIAN_W} [$bi] = median(@{$UPCAST{W}[$bi]}); |
1501 |
$UPCAST{MEDIAN_W12}[$bi] = median(@{$UPCAST{W12}[$bi]}); |
|
1502 |
$UPCAST{MEDIAN_W34}[$bi] = median(@{$UPCAST{W34}[$bi]}); |
|
1503 |
$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
|
1504 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1505 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1506 |
} # unless ($opt_q); |
2 | 1507 |
|
42 | 1508 |
#---------------------------------------------------------------------- |
1509 |
# remove ensembles with large rms residuals |
|
1510 |
#---------------------------------------------------------------------- |
|
1511 |
||
1512 |
if (defined($opt_r)) { |
|
1513 |
progress("Removing ensembles with large residuals...\n"); |
|
1514 |
||
1515 |
$nerm = 0; |
|
1516 |
for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
|
1517 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
1518 |
||
1519 |
my($sum) = my($n) = 0; # calculate rms residual |
|
1520 |
my(@bindepth) = calc_binDepths($ens); |
|
1521 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1522 |
next unless ($bin+1>=$outGrid_firstBin && $bin+1<=$outGrid_lastBin); |
|
1523 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
1524 |
my($bi) = $bindepth[$bin]/$opt_o; |
|
1525 |
my($res) = ($ens < $LADCP_atbottom) ? |
|
1526 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $DNCAST{MEDIAN_W}[$bi] : |
|
1527 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $UPCAST{MEDIAN_W}[$bi]; |
|
1528 |
$sum += &SQR($res); $n++; |
|
1529 |
} |
|
1530 |
||
1531 |
if ($n == 0 || sqrt($sum/$n) > $opt_r) { # ensemble is bad |
|
1532 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
1533 |
$nerm++; |
|
1534 |
} |
|
1535 |
} |
|
1536 |
progress("\t$nerm ensembles removed (%d%% of total)\n",round(100*$nerm/($lastGoodEns-$firstGoodEns+1))); |
|
1537 |
||
1538 |
progress("\tre-binning profile data...\n"); |
|
1539 |
undef(%DNCAST); undef(%UPCAST); |
|
1540 |
$min_depth = 9e99; my($max_depth) = 0; |
|
1541 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { # downcast |
|
1542 |
unless (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH})) { |
|
1543 |
$firstGoodEns++ if ($ens == $firstGoodEns); # start has been edited away |
|
1544 |
next; |
|
1545 |
} |
|
1546 |
$realLastGoodEns = $ens; |
|
1547 |
my(@bindepth) = calc_binDepths($ens); |
|
1548 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1549 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
1550 |
next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1); |
|
1551 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
|
1552 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
1553 |
my($bi) = $bindepth[$bin]/$opt_o; |
|
1554 |
push(@{$DNCAST{ENSEMBLE}[$bi]},$ens); |
|
1555 |
push(@{$DNCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1556 |
push(@{$DNCAST{DEPTH}[$bi]},$bindepth[$bin]); |
|
1557 |
push(@{$DNCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
|
1558 |
push(@{$DNCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
1559 |
push(@{$DNCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
1560 |
} |
|
1561 |
} |
|
1562 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { # bin data into profile |
|
1563 |
$DNCAST{MEAN_DEPTH}[$bi] = avg(@{$DNCAST{DEPTH}[$bi]}); |
|
1564 |
$DNCAST{MEAN_ELAPSED}[$bi] = avg(@{$DNCAST{ELAPSED}[$bi]}); |
|
1565 |
$DNCAST{MEDIAN_W}[$bi] = median(@{$DNCAST{W}[$bi]}); |
|
1566 |
$DNCAST{MEDIAN_W12}[$bi] = median(@{$DNCAST{W12}[$bi]}); |
|
1567 |
$DNCAST{MEDIAN_W34}[$bi] = median(@{$DNCAST{W34}[$bi]}); |
|
1568 |
$DNCAST{MAD_W}[$bi] = mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]}); |
|
1569 |
$DNCAST{N_SAMP}[$bi] = @{$DNCAST{W}[$bi]}; |
|
1570 |
} |
|
1571 |
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) { |
|
1572 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
1573 |
$realLastGoodEns = $ens; |
|
1574 |
my(@bindepth) = calc_binDepths($ens); |
|
1575 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1576 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
1577 |
next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1); |
|
1578 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
|
1579 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
1580 |
my($bi) = $bindepth[$bin]/$opt_o; |
|
1581 |
push(@{$UPCAST{ENSEMBLE}[$bi]},$ens); |
|
1582 |
push(@{$UPCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1583 |
push(@{$UPCAST{DEPTH}[$bi]},$bindepth[$bin]); |
|
1584 |
push(@{$UPCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
|
1585 |
push(@{$UPCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
1586 |
push(@{$UPCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
1587 |
} |
|
1588 |
} |
|
1589 |
for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) { |
|
1590 |
$UPCAST{MEAN_DEPTH}[$bi] = avg(@{$UPCAST{DEPTH}[$bi]}); |
|
1591 |
$UPCAST{MEAN_ELAPSED}[$bi] = avg(@{$UPCAST{ELAPSED}[$bi]}); |
|
1592 |
$UPCAST{MEDIAN_W}[$bi] = median(@{$UPCAST{W}[$bi]}); |
|
1593 |
$UPCAST{MEDIAN_W12}[$bi] = median(@{$UPCAST{W12}[$bi]}); |
|
1594 |
$UPCAST{MEDIAN_W34}[$bi] = median(@{$UPCAST{W34}[$bi]}); |
|
1595 |
$UPCAST{MAD_W}[$bi] = mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]}); |
|
1596 |
$UPCAST{N_SAMP}[$bi] = @{$UPCAST{W}[$bi]}; |
|
1597 |
} |
|
1598 |
} # if defined($opt_r) |
|
1599 |
||
34 | 1600 |
#-------------------------------------------- |
1601 |
# Calculate and Output Bin-Averaged Resiudals |
|
1602 |
#-------------------------------------------- |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1603 |
|
42 | 1604 |
&antsAddParams('min_depth',$min_depth,'max_depth',$max_depth, # plot range limits |
1605 |
'min_ens',$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER}, |
|
1606 |
'max_ens',$LADCP{ENSEMBLE}[$realLastGoodEns]->{NUMBER}, |
|
1607 |
'min_elapsed',$LADCP{ENSEMBLE}[$firstGoodEns]->{CTD_ELAPSED}, |
|
1608 |
'max_elapsed',$LADCP{ENSEMBLE}[$realLastGoodEns]->{CTD_ELAPSED}); |
|
1609 |
||
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1610 |
if (@out_BR) { |
31 | 1611 |
progress("Binning residuals..."); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1612 |
|
30 | 1613 |
local(@dc_bres,@uc_bres); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1614 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { # downcast |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1615 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1616 |
my(@bindepth) = calc_binDepths($ens); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1617 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1618 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1619 |
push(@{$dc_bres[$bin]}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1620 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] |
13 | 1621 |
- $DNCAST{MEDIAN_W}[$bindepth[$bin]/$opt_o]); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1622 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1623 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1624 |
for ($ens=$LADCP_atbottom; $ens<=$realLastGoodEns; $ens++) { # upcast |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1625 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1626 |
my(@bindepth) = calc_binDepths($ens); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1627 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1628 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1629 |
push(@{$uc_bres[$bin]}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1630 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] |
13 | 1631 |
- $UPCAST{MEDIAN_W}[$bindepth[$bin]/$opt_o]); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1632 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1633 |
} |
34 | 1634 |
local(@dc_avg_bres,@uc_avg_bres,@dc_avg_bres_nsamp,@uc_avg_bres_nsamp); # calc means/stddevs |
1635 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1636 |
$dc_bres_nsamp[$bin] = @{$dc_bres[$bin]}; |
|
1637 |
if ($dc_bres_nsamp[$bin] > 0) { |
|
1638 |
$dc_avg_bres[$bin] = avg(@{$dc_bres[$bin]}); |
|
1639 |
$dc_sig_bres[$bin] = stddev2($dc_avg_bres[$bin],@{$dc_bres[$bin]}); |
|
1640 |
} else { |
|
1641 |
$dc_avg_bres[$bin] = nan; |
|
1642 |
$dc_sig_bres[$bin] = nan; |
|
1643 |
} |
|
1644 |
$uc_bres_nsamp[$bin] = @{$uc_bres[$bin]}; |
|
1645 |
if ($uc_bres_nsamp[$bin] > 0) { |
|
1646 |
$uc_avg_bres[$bin] = avg(@{$uc_bres[$bin]}); |
|
1647 |
$uc_sig_bres[$bin] = stddev2($uc_avg_bres[$bin],@{$uc_bres[$bin]}); |
|
1648 |
} else { |
|
1649 |
$uc_avg_bres[$bin] = nan; |
|
1650 |
$uc_sig_bres[$bin] = nan; |
|
1651 |
} |
|
30 | 1652 |
} |
1653 |
||
34 | 1654 |
local($uc_bres_max_nsamp,$dc_bres_max_nsamp) = (0,0); # calc rms in block of well-determined bins |
1655 |
for (my($bin)=$LADCP_firstBin; $bin<=$LADCP_lastBin-1; $bin++) { # SKIP 1ST BIN!!! |
|
1656 |
next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin); # skip bins not included in gridded output |
|
1657 |
$dc_bres_max_nsamp = $dc_bres_nsamp[$bin] # nsamp in best sampled bin |
|
1658 |
if ($dc_bres_nsamp[$bin] > $dc_bres_max_nsamp); |
|
1659 |
$uc_bres_max_nsamp = $uc_bres_nsamp[$bin] |
|
1660 |
if ($uc_bres_nsamp[$bin] > $uc_bres_max_nsamp); |
|
1661 |
} |
|
1662 |
my($dc_sumsq,$uc_sumsq,$dc_n,$uc_n) = (0,0,0,0); # calc rms residual |
|
1663 |
for (my($bin)=$LADCP_firstBin; $bin<=$LADCP_lastBin-1; $bin++) { # SKIP 1ST BIN |
|
1664 |
next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin); # skip bins not included in gridded output |
|
1665 |
if ($dc_bres_nsamp[$bin] >= $dc_bres_max_nsamp/3) { # skip bins with < 1/3 max(nsamp) |
|
1666 |
$dc_sumsq += $dc_avg_bres[$bin]**2; |
|
1667 |
$dc_n++; |
|
1668 |
} |
|
1669 |
if ($uc_bres_nsamp[$bin] >= $uc_bres_max_nsamp/3) { |
|
1670 |
$uc_sumsq += $uc_avg_bres[$bin]**2; |
|
1671 |
$uc_n++; |
|
1672 |
} |
|
1673 |
} |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1674 |
local($dc_bres_rms) = ($dc_n > 0) ? sqrt($dc_sumsq/$dc_n) : nan; |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1675 |
local($uc_bres_rms) = ($uc_n > 0) ? sqrt($uc_sumsq/$uc_n) : nan; |
34 | 1676 |
|
30 | 1677 |
progress("\nWriting binned residuals to "); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1678 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1679 |
my($saveParams) = $antsCurParams; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1680 |
@antsNewLayout = ('bin','dc_residual','dc_residual.sig','dc_residual.nsamp', |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1681 |
,'uc_residual','uc_residual.sig','uc_residual.nsamp'); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1682 |
&antsAddParams('BR_max_bin',max(scalar(@dc_bres),scalar(@uc_bres))); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1683 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1684 |
foreach my $of (@out_BR) { |
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1685 |
progress("<$of> "); |
42 | 1686 |
my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/); # plot_sub(out_file) |
1687 |
if (defined($arg)) { |
|
1688 |
require "$WCALC/${sub}.pl"; |
|
1689 |
&{$sub}($arg); |
|
30 | 1690 |
next; |
1691 |
} |
|
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1692 |
$of = ">$of" unless ($of =~ /^$|^\s*\|/); |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
1693 |
open(STDOUT,$of) || error("$of: $!\n"); |
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1694 |
undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1695 |
for (my($bin)=0; $bin<max(scalar(@dc_bres),scalar(@uc_bres)); $bin++) { |
34 | 1696 |
&antsOut($bin+1,$dc_avg_bres[$bin],$dc_sig_bres[$bin],$dc_bres_nsamp[$bin], |
1697 |
$uc_avg_bres[$bin],$uc_sig_bres[$bin],$uc_bres_nsamp[$bin]); |
|
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1698 |
} |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1699 |
&antsOut('EOF'); open(STDOUT,">&2"); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1700 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1701 |
$antsCurParams = $saveParams; |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1702 |
progress("\n"); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1703 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1704 |
|
0 | 1705 |
#-------------------------------------------------- |
1706 |
# Calculate BT-referenced vertical-velocity profile |
|
1707 |
#-------------------------------------------------- |
|
1708 |
||
1709 |
if (defined($water_depth)) { |
|
1710 |
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
|
1711 |
calc_BTprof($firstGoodEns,$realLastGoodEns,$water_depth,$sig_water_depth); |
0 | 1712 |
|
1713 |
my($sumSq) = my($n) = 0; |
|
1714 |
for (my($bi)=0; $bi<=$#{$BT{MEDIAN_W}}; $bi++) { |
|
1715 |
next unless defined($BT{MEDIAN_W}[$bi]); |
|
13 | 1716 |
next unless ($BT{N_SAMP}[$bi]>=$opt_k && $DNCAST{N_SAMP}[$bi]>=$opt_k && $UPCAST{N_SAMP}[$bi]>=$opt_k); |
0 | 1717 |
$sumSq += ($BT{MEDIAN_W}[$bi] - $DNCAST{MEDIAN_W}[$bi]/2 - $UPCAST{MEDIAN_W}[$bi]/2)**2; |
1718 |
$n++; |
|
1719 |
} |
|
1720 |
if ($n > 0) { |
|
1721 |
my($rms) = round(sqrt($sumSq/$n),0.001); |
|
1722 |
&antsAddParams('BT_rms_w_discrepancy',$rms); |
|
1723 |
progress("\t$rms m/s rms vertical-velocity discrepancy\n"); |
|
1724 |
} |
|
1725 |
} |
|
1726 |
||
13 | 1727 |
#------------------------ |
1728 |
# output all samples (-w) |
|
1729 |
#------------------------ |
|
2 | 1730 |
|
1731 |
# NB: residual field is calculated with respect to down-/upcast medians in -o-size bins |
|
1732 |
||
31 | 1733 |
if (@out_wsamp) { |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1734 |
progress("Writing vertical-velocity data to "); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1735 |
@antsNewLayout = ('ensemble','bin','elapsed','depth','CTD_depth','downcast', |
13 | 1736 |
'w','w12','w34','residual','CTD_w','CTD_w_tt','LADCP_w','errvel', |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1737 |
'correlation','echo_amplitude','Sv', |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1738 |
'pitch','roll','tilt','heading','3_beam','svel'); |
2 | 1739 |
|
31 | 1740 |
foreach my $of (@out_wsamp) { |
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1741 |
progress("<$of> "); |
30 | 1742 |
|
42 | 1743 |
my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/); # plot_sub(out_file) |
1744 |
if (defined($arg)) { |
|
1745 |
require "$WCALC/${sub}.pl"; |
|
1746 |
&{$sub}($arg); |
|
30 | 1747 |
next; |
1748 |
} |
|
1749 |
||
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1750 |
$of = ">$of" unless ($of =~ /^$|^\s*\|/); |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
1751 |
open(STDOUT,$of) || error("$of: $!\n"); |
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1752 |
undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1753 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1754 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { # downcast |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1755 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1756 |
my(@bindepth) = calc_binDepths($ens); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1757 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1758 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1759 |
my($bi) = $bindepth[$bin]/$opt_o; |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1760 |
&antsOut( |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1761 |
$LADCP{ENSEMBLE}[$ens]->{NUMBER},$bin+1, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1762 |
$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1763 |
$bindepth[$bin],$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},1, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1764 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1765 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] : nan, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1766 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] : nan, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1767 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $DNCAST{MEDIAN_W}[$bi], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1768 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1769 |
$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1770 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1771 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1772 |
median(@{$LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin]}), |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1773 |
median(@{$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin]}), |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1774 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1775 |
$LADCP{ENSEMBLE}[$ens]->{PITCH}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1776 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1777 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1778 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1779 |
(defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][0]) + # only works for beam coords |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1780 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][1]) + |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1781 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][2]) + |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1782 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][3])) < 4 ? 1 : 0, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1783 |
$CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1784 |
); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1785 |
} # for $bin |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1786 |
} # for $ens |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1787 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1788 |
for ($ens=$LADCP_atbottom; $ens<=$realLastGoodEns; $ens++) { # upcast |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1789 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1790 |
my(@bindepth) = calc_binDepths($ens); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1791 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1792 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1793 |
my($bi) = $bindepth[$bin]/$opt_o; |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1794 |
&antsOut( |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1795 |
$LADCP{ENSEMBLE}[$ens]->{NUMBER},$bin+1, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1796 |
$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1797 |
$bindepth[$bin],$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},0, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1798 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1799 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] : nan, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1800 |
$LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] : nan, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1801 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $UPCAST{MEDIAN_W}[$bi], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1802 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1803 |
$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1804 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1805 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1806 |
median(@{$LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin]}), |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1807 |
median(@{$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin]}), |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1808 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1809 |
$LADCP{ENSEMBLE}[$ens]->{PITCH}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1810 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1811 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1812 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1813 |
(defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][0]) + # only works for beam coords |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1814 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][1]) + |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1815 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][2]) + |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1816 |
defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][3])) < 4 ? 1 : 0, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1817 |
$CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1818 |
); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1819 |
} # for $bin |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1820 |
} # for $ens |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1821 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1822 |
&antsOut('EOF'); open(STDOUT,">&2"); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1823 |
} |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1824 |
progress("\n"); |
2 | 1825 |
} |
1826 |
||
13 | 1827 |
#---------------------------- |
1828 |
# Output depth-binned profile |
|
1829 |
#---------------------------- |
|
0 | 1830 |
|
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1831 |
if (@out_profile) { |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1832 |
progress("Writing vertical-velocity profiles to "); |
37 | 1833 |
@antsNewLayout = ('depth','hab','dc_depth','dc_elapsed','dc_w','dc_w.mad','dc_w.nsamp','dc_w12','dc_w34', |
1834 |
'uc_depth','uc_elapsed','uc_w','uc_w.mad','uc_w.nsamp','uc_w12','uc_w34', |
|
1835 |
'BT_w','BT_w.mad','BT_w.nsamp'); |
|
0 | 1836 |
|
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1837 |
foreach my $of (@out_profile) { |
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1838 |
progress("<$of> "); |
29 | 1839 |
|
42 | 1840 |
my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/); # plot_sub(out_file) |
1841 |
if (defined($arg)) { |
|
1842 |
require "$WCALC/${sub}.pl"; |
|
1843 |
&{$sub}($arg); |
|
29 | 1844 |
next; |
1845 |
} |
|
1846 |
||
1847 |
$of = ">$of" unless ($of =~ /^$|^\s*\|/); # pipe or file output |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
1848 |
open(STDOUT,$of) || error("$of: $!\n"); |
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1849 |
undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1850 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1851 |
for (my($bi)=0; $bi<=max($#{$DNCAST{ENSEMBLE}},$#{$UPCAST{ENSEMBLE}},$#{$BT{NSAMP}}); $bi++) { |
37 | 1852 |
&antsOut(($bi+0.5)*$opt_o, # nominal depth |
1853 |
defined($water_depth)?$water_depth-($bi+0.5)*$opt_o:nan, # nominal hab |
|
1854 |
$DNCAST{MEAN_DEPTH}[$bi],$DNCAST{MEAN_ELAPSED}[$bi], # dc data |
|
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1855 |
$DNCAST{N_SAMP}[$bi]>=$opt_k?$DNCAST{MEDIAN_W}[$bi]:nan, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1856 |
$DNCAST{MAD_W}[$bi],$DNCAST{N_SAMP}[$bi], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1857 |
$DNCAST{MEDIAN_W12}[$bi],$DNCAST{MEDIAN_W34}[$bi], |
37 | 1858 |
$UPCAST{MEAN_DEPTH}[$bi],$UPCAST{MEAN_ELAPSED}[$bi], # uc data |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1859 |
$UPCAST{N_SAMP}[$bi]>=$opt_k?$UPCAST{MEDIAN_W}[$bi]:nan, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1860 |
$UPCAST{MAD_W}[$bi],$UPCAST{N_SAMP}[$bi], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1861 |
$UPCAST{MEDIAN_W12}[$bi],$UPCAST{MEDIAN_W34}[$bi], |
37 | 1862 |
$BT{N_SAMP}[$bi]>=$opt_k?$BT{MEDIAN_W}[$bi]:nan, # BT data |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1863 |
$BT{MAD_W}[$bi],$BT{N_SAMP}[$bi] |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1864 |
); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1865 |
} |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1866 |
&antsOut('EOF'); open(STDOUT,">&2"); |
0 | 1867 |
} |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1868 |
progress("\n"); |
0 | 1869 |
} |
1870 |
||
1871 |
#-------------------------------------- |
|
1872 |
# write time-series output if requested |
|
1873 |
#-------------------------------------- |
|
1874 |
||
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1875 |
if (@out_timeseries) { |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1876 |
progress("Writing time-series data to "); |
23 | 1877 |
@antsNewLayout = ('ensemble','elapsed','downcast', |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1878 |
'depth','xducer_sound_speed','pitch','gimbal_pitch','roll','tilt','heading', |
13 | 1879 |
'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
|
1880 |
'reflr_ocean_w'); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1881 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1882 |
foreach my $of (@out_timeseries) { |
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1883 |
progress("<$of> "); |
42 | 1884 |
my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/); # plot_sub(out_file) |
1885 |
if (defined($arg)) { |
|
1886 |
require "$WCALC/${sub}.pl"; |
|
1887 |
&{$sub}($arg); |
|
30 | 1888 |
next; |
1889 |
} |
|
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1890 |
$of = ">$of" unless ($of =~ /^$|^\s*\|/); |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
1891 |
open(STDOUT,$of) || error("$of: $!\n"); |
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
1892 |
undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1893 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1894 |
for ($ens=$firstGoodEns; $ens<=$realLastGoodEns; $ens++) { |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1895 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1896 |
my($reflr_oc_w) = defined($LADCP{ENSEMBLE}[$ens]->{REFLR_W}) |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1897 |
? $LADCP{ENSEMBLE}[$ens]->{REFLR_W} - $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}] |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1898 |
: undef; |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1899 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1900 |
$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1901 |
($ens < $LADCP_atbottom) ? 1 : 0, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1902 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1903 |
$CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1904 |
$LADCP{ENSEMBLE}[$ens]->{PITCH}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1905 |
$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1906 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1907 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1908 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1909 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1910 |
$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1911 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1912 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W_STDDEV}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1913 |
$reflr_oc_w); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1914 |
} |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1915 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1916 |
&antsOut('EOF'); open(STDOUT,">&2"); |
0 | 1917 |
} |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
1918 |
progress("\n"); |
0 | 1919 |
} |
1920 |
||
42 | 1921 |
system("{ ./LADCP_w.PostProcess $out_basename $RUN $data_dir $plot_dir $log_dir; }&") |
1922 |
if (-x 'LADCP_w.PostProcess'); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1923 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1924 |
exit(0); |