author | A.M. Thurnherr <athurnherr@yahoo.com> |
Fri, 09 Sep 2022 12:36:19 -0400 | |
changeset 61 | 20d9316fdeb8 |
parent 57 | 69e39fcb7f41 |
child 63 | 4832af086e8c |
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 |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
5 |
# dlm: Mon Oct 18 21:27:57 2021 |
0 | 6 |
# (c) 2010 A.M. Thurnherr |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
7 |
# uE-Info: 2040 92 NIL 0 0 72 0 2 4 NIL ofnI |
0 | 8 |
#====================================================================== |
9 |
||
10 |
# TODO: |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
11 |
# ! use instrument tilt in sidelobe editing |
48 | 12 |
# - use instrument tilt in e.g. calculation of Sv |
13 |
# - use instrument tilt in PPI editing |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
14 |
# |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
15 |
# - plots: |
42 | 16 |
# - avoid over-plotting axis labels |
17 |
# - allow for different nsamp magnitudes |
|
18 |
# - add "dc" "uc" labels |
|
19 |
# - add seabed to eps.VKE profile |
|
20 |
# - add seabed to LADCP_w_postproc .wprof output |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
21 |
# |
42 | 22 |
# - worry about water-depth differences (disabled warning) |
23 |
# - make upcast-flag valid for yoyo casts |
|
24 |
# - make diagnostic output 3-beam field work for Earth coordinates |
|
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 |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
247 |
# May 12, 2106: - added v12, v34 to wsamp output |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
248 |
# May 17, 2016: - added residual12, residual34 to wsamp output |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
249 |
# - changed pitch field in wsamp output to gimbal pitch |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
250 |
# - added w_t to .wsamp output for completeness |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
251 |
# May 18, 2016: - replaced rms_tilt by mean_tilt |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
252 |
# - add (gimbal-)pitch, roll and residual{12,34} to wprof output |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
253 |
# - expunged super-confusing $realLastGoodEns |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
254 |
# - removed assumption of default 1500m/s sspd setting during acquisition |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
255 |
# - added w12, w34 for earth-coordinates |
46 | 256 |
# May 19, 2016: - updated to ADCP_tools V1.6 |
257 |
# May 24, 2016: - calc_binDepths() -> binDepths() |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
258 |
# May 26, 2016: - added -d)isable bin interpolation |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
259 |
# - adapted to w_CTD, w_winch |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
260 |
# - re-enabled disabled L0 warning |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
261 |
# - suppressing L0 warnings on screen |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
262 |
# May 27, 2016: - cosmetics |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
263 |
# - added reflr_w to .wsamp output |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
264 |
# May 29, 2016: - BUG: do ProcessingParams did not handle all errors correctly |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
265 |
# Jun 1, 2016: - made empirical accoustic backscatter correction optional |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
266 |
# - split [default_paths.pl] to same plus [default_output.pl] |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
267 |
# Jun 2, 2016: - added applyTiltCorrection() |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
268 |
# - BUG: PPI-editing was no longer enabled automatically |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
269 |
# for 150kHz instruments |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
270 |
# Jun 3, 2016: - BUG: earth-coordinate data did not have gimbal-pitch |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
271 |
# calculated |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
272 |
# Jun 6, 2016: - removed applyTiltCorrection() |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
273 |
# Jun 11, 2016: - BUG: w12, w34 were wrong for Earth-coord data |
48 | 274 |
# Jul 7, 2016: - BUG: finally fixed with velEarthToBPw() from [RDI_Coords.pl] |
275 |
# Jul 31, 2016: - BUG: -d did not work because it was handled in [defaults.pl] |
|
276 |
# Oct 16, 2016: - cosmetics |
|
277 |
# Dec 22, 2016: - moved $opt_p to [defaults.pl] |
|
278 |
# Dec 23, 2016: - BUG: -u did not set required variables to proceed |
|
279 |
# Mar 6, 2017: - BUG: division by zero when water-depth ~ max(CTD_depth) |
|
49 | 280 |
# Oct 12, 2017: - BUG: beampair w did not work for earth-coord vels; major re-write |
281 |
# of earthcoord code to unify processing |
|
282 |
# Nov 26, 2017: - BUG: $bad_beam did not work correctly with bin interpolation |
|
283 |
# - BUG: ping-coherent residual removal did not respect missing values |
|
284 |
# Nov 28, 2017: - added $initial_time_lag |
|
285 |
# - expanded semantics of -q to disable time-lagging and residual filters |
|
286 |
# Dec 9, 2017: - added $antsSuppressCommonOptions = 1; |
|
287 |
# Dec 17, 2017: - added dependencies |
|
288 |
# Apr 24, 2018: - added support for $water_depth_db_cmd |
|
289 |
# May 1, 2018: - added threshold for reference-layer horizontal speed |
|
290 |
# - added ambiguity velocity check |
|
291 |
# May 2, 2018: - BUG: ref-lr threshold did not work |
|
292 |
# - BUG: BT code was called for UL when -h was used |
|
293 |
# - replaced $PPI_seabed_editing_required by &PPI_seabed_editing_required |
|
294 |
# - BUG: surface PPI editing code could not be enabled; added &PPI_surface_editing_required |
|
295 |
# Nov 2, 2018: - BUG: for 3-beam solutions, residual{12,34} with affected beam was wrong |
|
51
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
296 |
# Apr 12, 2019: - added logfile error message for non-existing file |
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
297 |
# Apr 18, 2019: - added addtional RDI coordinate transformation %PARAMs |
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
298 |
# Apr 21, 2019: - BUG: removed duplicate warning about lacking water-depth info |
54 | 299 |
# Sep 10, 2019: - BUG: -i was erroneously listed as the initial CTD time offset |
300 |
# Sep 12, 2019: - modified .prof output layout to be consistent with [LADCP_w_postproc] |
|
301 |
# May 15, 2020: - BUG: re-binning on -r did not work for v12 and v34 |
|
302 |
# - BUG: before re-binning, upcast v12 and v34 were actuall from DC data |
|
303 |
# - BUG: all beam-pair velocity stats were contaminated by missing values |
|
304 |
# - made bin residuals per beam pair |
|
305 |
# May 16, 2020: - BUG: write_residual_profs() clobbered layout |
|
306 |
# Jun 22, 2020: - sscorr_w renamed to remove conflict with [RDI_Coords.pl] |
|
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
307 |
# Mar 17, 2021: - turned multi-ping error into warning (for Nortek files) |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
308 |
# Mar 23, 3021: - adapted to ADCP_tools V2.4 (Nortek PD0 files) |
56 | 309 |
# Jun 30, 2021: - BUG: rms instead of mean tilt was reported in fig |
310 |
# - added pitch/roll/tilt to output profile |
|
311 |
# Jul 1, 2021: - made %PARAMs more standard |
|
312 |
# - added %dc_w.mu, %uc_w.mu |
|
313 |
# Jul 6, 2021: - BUG: %uc_w.mu was off by factor 2 |
|
314 |
# Jul 9, 2021: - added LR_RMS_BP_RESIDUAL, dc_lr_bp_res.rms, uc_lr_bp_res.rms |
|
315 |
# - added residuals profile filter |
|
316 |
# Jul 11, 2021: - added %dc_w.var, %uc_w.var |
|
317 |
# - reduced warning associated with residuals profile filter |
|
318 |
# - disable time-lag filtering for transmission-error corrected CTD files |
|
319 |
# Jul 13, 2021: - set dc_w.mu, dc_w.var to nan on insufficient data |
|
320 |
# - BUG: residuals profile filter bombed when no data were removed |
|
321 |
# - BUG: rms BT discrepancy was broken (residuals profile filter) |
|
322 |
# - BUG: *_w.var did not respect -k |
|
323 |
# Jul 23, 2021: - added %ADCP_type |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
324 |
# Aug 8, 2021: - cosmetics |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
325 |
# - added -p to $processing_options |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
326 |
# Sep 1, 2021: - added Sv to .wprof output (dc_Sv, uc_Sv, Sv.diff) |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
327 |
# - made .wprof Layout more logical |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
328 |
# - added {dc,uc}_exposure_time to .wprof output |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
329 |
# Oct 18, 2021: - BUG: Sv profiles included bins without valid w |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
330 |
# - moved Sv profile code after additional filters; |
30 | 331 |
# HISTORY END |
0 | 332 |
|
333 |
# CTD REQUIREMENTS |
|
334 |
# - elapsed elapsed seconds; see note below |
|
335 |
# - depth |
|
19 | 336 |
# - ss sound speed |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
337 |
# - w[_CTD] ddepth/dt |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
338 |
# - w_winch OPTIONAL; winch-speed estimate |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
339 |
# - temp OPTIONAL; used for backscatter calculation |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
340 |
# - %lat/%lon OPTIONAL |
56 | 341 |
# - %CTD_transmission_errors OPTIONAL; if defined, -l is implicitly enabled |
342 |
||
343 |
# OUTPUT PITCH |
|
344 |
# - gimbal pitch is used |
|
345 |
||
346 |
# OUTPUT EQUIVALENCES: |
|
347 |
# 1) list -Q %uc_w.var UL/042.wprof |
|
348 |
# list dc_w='$dc_w-%dc_w.mu' UL/042.wprof | avg -Qm dc_w |
|
0 | 349 |
|
13 | 350 |
# 2-BEAM SOLUTIONS |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
351 |
# - both for beam- and Earth-coordinate data, two separate two-beam |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
352 |
# solutions (w12 & w34) are calculated: |
46 | 353 |
# - w12 corresponds to ROLL axis (plotted with dashed lines) |
354 |
# - w34 corresponds to PITCH axis (plotted with dotted lines) |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
355 |
# - the 2-beam solutions are largely independent of each other |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
356 |
# => key for detecting data problems, such as package wakes |
13 | 357 |
|
0 | 358 |
# NUMERICAL OPTIONS |
359 |
# - the first option in the list cannot be numerical! |
|
19 | 360 |
# - if need be, use -v 1 as a dummy option |
0 | 361 |
|
362 |
# ELAPSED TIMES |
|
363 |
# - there are 2 different elapsed times used in this program: |
|
364 |
# 1) elapsed based on firstgoodens in the LADCP time series |
|
365 |
# 2) CTD elapsed time |
|
366 |
# - CTD elapsed time does not have to start with zero! |
|
367 |
# - do not use the Seabird elapsed field, which is only reported to |
|
368 |
# 3 significant digits, causing significant jitter in dt; however, |
|
369 |
# at least up to 2010 Seabird simply calculates elapsed time by |
|
370 |
# assuming a 24Hz sampling rate and no record drop; therefore, |
|
371 |
# it is best to calculate elapsed time as %RECNO/24 |
|
372 |
# - the elapsed field of the output is the elapsed time from the CTD |
|
373 |
# file; this is required in order to be able to compare the times |
|
374 |
# from the uplooker and downlooker-derived vertical velocity |
|
375 |
# profiles |
|
11 | 376 |
# - the .TL files use the LADCP elapsed time in output; as a result, |
377 |
# the DL/UL .TL files have different time axes! |
|
0 | 378 |
# - as a result, a profile only starts with elapsed==0 if the CTD |
379 |
# is turned on when the LADCP is already in the water |
|
380 |
||
13 | 381 |
# BINNED-PROFILE OUTPUT NOTES |
382 |
# - residuals are calculated with respect to down-/upcast medians |
|
383 |
# - w12 and w34 2-beam solutions are reported without considering |
|
384 |
# -k (min samples) |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
385 |
# - elapsed times: |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
386 |
# - {dc,uc}_elapsed are averages estimated BEFORE |
2 | 387 |
# - equivalence, assuming -o 10: |
388 |
# 1) 004DL.prof dc_w depth |
|
6 | 389 |
# 2) bindata -Sdowncast:1 -Fw.median,depth -n 20 depth 10 004DL.w |
2 | 390 |
|
0 | 391 |
# VELOCITY AMBIGUITY ERRORS |
392 |
# - quite extensive tests with DIMES US2 station 146, which has a lot of |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
393 |
# ambiguity velocity errors, reveal that $w_max_lim catches those errors |
0 | 394 |
# quite nicely |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
395 |
# - even when the errors are not filtered with $w_max_lim, they do not |
0 | 396 |
# affect the w profiles, as long as the median bin values are used |
397 |
||
23 | 398 |
($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$}); |
399 |
($ADCP_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$}); |
|
400 |
($WCALC) = ($0 =~ m{^(.*)/[^/]*$}); |
|
401 |
$WCALC = '.' if ($WCALC eq ''); |
|
33 | 402 |
$ANTS_TOOLS_AVAILABLE = (`which list 2>/dev/null` ne ''); |
23 | 403 |
|
19 | 404 |
die("$0: Generic Mapping Tools (GMT) required but not found (bad \$PATH?)\n") |
43 | 405 |
unless (`which gmt` ne ''); |
19 | 406 |
die("$0: ANTSlib required but not found (bad \$PATH?)\n") |
23 | 407 |
unless ($ANTS ne ''); |
19 | 408 |
die("$0: ADCP Tools required but not found (bad \$PATH?)\n") |
23 | 409 |
unless ($ADCP_TOOLS ne ''); |
0 | 410 |
|
33 | 411 |
require "$WCALC/version.pl"; |
0 | 412 |
require "$WCALC/edit_data.pl"; |
413 |
require "$WCALC/time_series.pl"; |
|
414 |
require "$WCALC/time_lag.pl"; |
|
415 |
require "$WCALC/find_seabed.pl"; |
|
416 |
require "$WCALC/svel_corrections.pl"; |
|
417 |
require "$WCALC/acoustic_backscatter.pl"; |
|
418 |
require "$WCALC/bottom_tracking.pl"; |
|
33 | 419 |
require "$ANTS/ants.pl"; |
420 |
require "$ANTS/libstats.pl"; |
|
34 | 421 |
require "$ADCP_TOOLS/ADCP_tools_lib.pl"; |
43 | 422 |
&antsAddParams('LADCP_w_ocean::version',$VERSION); |
0 | 423 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
424 |
use IO::Handle; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
425 |
|
6 | 426 |
my($TINY) = 1e-16; |
427 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
428 |
#------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
429 |
# Usage |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
430 |
#------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
431 |
|
42 | 432 |
require "$WCALC/defaults.pl"; # load default/option parameters |
433 |
||
0 | 434 |
$antsParseHeader = 0; |
49 | 435 |
$antsSuppressCommonOptions = 1; |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
436 |
&antsUsage('3:4a:b:c:de:g:h:i:k:lm:n:o:p:qr:s:t:uv:Vw:x:',0, |
42 | 437 |
"[print software -V)ersion] [-v)erbosity <level[$opt_v]>]", |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
438 |
"[require -4)-beam solutions] [-d)isable bin interpolation] [apply beamvel-m)ask <file> if it exists]", |
42 | 439 |
"[valid LADCP -b)ins <bin,bin[$opt_b]>", |
440 |
"[-c)orrelation <min[$opt_c counts]>] [-t)ilt <max[$opt_t deg]> [-e)rr-vel <max[$opt_e m/s]>]", |
|
49 | 441 |
"[max -r)esidual <rms.max[,delta.max][$opt_r m/s]>]", |
42 | 442 |
"[-h water <depth|filename>]", |
443 |
"[max LADCP time-series -g)ap <length[$opt_g s]>]", |
|
54 | 444 |
"[-i)nitial LADCP time offset <guestimate> [-u)se as final]]", |
42 | 445 |
"[calculate -n) <lags,lags[$opt_n]>] [lag -w)indow <sz,sz[$opt_w s]>] [lag-p)iece <CTD_elapsed_min|+[,...]>]", |
446 |
"[require top-3) lags to account for <frac[$opt_3]> of all]", |
|
447 |
"[disable time-l)ag filtering]", |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
448 |
"[pressure-sensor -a)cceleration-derivative correction <residual/CTD_w_tt>]", |
42 | 449 |
"[-o)utput bin <resolution[$opt_o m]>] [-k) require <min[$opt_k]> samples]", |
450 |
"[e-x)ecute <perl-expr>]", |
|
49 | 451 |
"[-q)uick-and-dirty (no single-ping denoising, residual and time-lagging filters)]", |
42 | 452 |
"<profile-id> [run-label]"); |
0 | 453 |
|
42 | 454 |
if ($opt_V) { |
49 | 455 |
printf(STDERR "+------------------------------+\n"); |
456 |
printf(STDERR "| LADCP_w Software V%s |\n",$VERSION); |
|
56 | 457 |
printf(STDERR "| (c) 2015-2021 A.M. Thurnherr |\n"); |
49 | 458 |
printf(STDERR "+------------------------------+\n"); |
42 | 459 |
exit(0); |
460 |
} |
|
2 | 461 |
|
42 | 462 |
&antsUsageError() if ($opt_u && !defined($opt_i)); |
463 |
&antsUsageError() unless (@ARGV==1 || @ARGV==2); |
|
2 | 464 |
|
42 | 465 |
&antsCardOpt(\$opt_s,0); # skip # initial ensembles |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
466 |
|
42 | 467 |
&antsFloatOpt(\$opt_a,1); # pressure acceleration correction |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
468 |
|
42 | 469 |
$ID = $PROF = $STN = &antsCardArg(); # station id ($STN for compatibility) |
470 |
if (@ARGV) { # run label |
|
471 |
$RUN = $ARGV[0]; |
|
472 |
shift; |
|
473 |
} else { |
|
474 |
$RUN = 'profiles'; |
|
475 |
} |
|
0 | 476 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
477 |
#---------------------------------------------------------------- |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
478 |
# Handle Processing Parameters |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
479 |
# - paths need to be read first to define ProcessingParams file |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
480 |
# and output directories |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
481 |
# - processing params file is read next to allow setting |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
482 |
# plotting_level |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
483 |
# - default_output.pl is read finally to set any missing output |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
484 |
# variables to default values |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
485 |
#---------------------------------------------------------------- |
42 | 486 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
487 |
require "$WCALC/default_paths.pl"; # define default input/output paths |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
488 |
my($retval) = do $processing_param_file; # load processing parameters |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
489 |
if (!defined($retval) && $@ ne '') { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
490 |
croak("$processing_param_file: $@\n"); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
491 |
} elsif (!defined($retval) && $! != 0) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
492 |
croak("$processing_param_file: $!\n"); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
493 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
494 |
require "$WCALC/default_output.pl"; # set default output plots and files |
34 | 495 |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
496 |
$processing_options = "-c $opt_c -e $opt_e -g $opt_g -k $opt_k -o $opt_o -p $opt_p -t $opt_t -3 $opt_3"; |
42 | 497 |
$processing_options .= ' -l' if defined($opt_l); |
49 | 498 |
|
499 |
if (defined($opt_q)) { # quick-and-dirty |
|
500 |
$processing_options .= ' -q'; |
|
501 |
$opt_l = 1; # disable time-lagging filter |
|
502 |
} |
|
503 |
||
504 |
if (defined($opt_i)) { # set initial time lag |
|
505 |
$processing_options .= " -i $opt_i"; |
|
506 |
$initial_time_lag = &antsFloatOpt($opt_i); |
|
507 |
} |
|
0 | 508 |
|
34 | 509 |
if (defined($opt_x)) { # eval cmd-line expression to override anything |
510 |
$processing_options .= " -x $opt_x"; |
|
511 |
eval($opt_x); |
|
512 |
} |
|
513 |
||
514 |
if ($opt_4) { # disallow 3-beam solutions |
|
515 |
$processing_options .= " -4"; |
|
516 |
$RDI_Coords::minValidVels = 4; |
|
517 |
} |
|
48 | 518 |
|
49 | 519 |
if ($opt_d) { # disable bin mapping |
48 | 520 |
$processing_options .= ' -d'; |
521 |
$RDI_Coords::binMapping = 'none'; |
|
522 |
} |
|
34 | 523 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
524 |
if (defined($opt_r)) { # residuals filters |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
525 |
$processing_options .= " -r $opt_r"; |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
526 |
($residuals_rms_max,$residuals_delta_max) = split(',',$opt_r); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
527 |
croak("$0: cannot decode -r $opt_r\n") unless ($residuals_rms_max > 0); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
528 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
529 |
|
34 | 530 |
($LADCP_firstBin,$LADCP_lastBin) = split(',',$opt_b); # select valid bins |
13 | 531 |
croak("$0: cannot decode -b $opt_b\n") |
532 |
unless (numberp($LADCP_firstBin) && |
|
533 |
($LADCP_lastBin eq '*' || numberp($LADCP_lastBin))); |
|
34 | 534 |
$processing_options .= " -b $opt_b"; |
535 |
||
536 |
$outGrid_firstBin = $LADCP_firstBin if ($outGrid_firstBin eq '*'); # default bins to use in gridded output |
|
537 |
$outGrid_lastBin = $LADCP_lastBin if ($outGrid_lastBin eq '*'); # NB: can still be '*'!!! |
|
538 |
||
13 | 539 |
@number_of_timelag_windows = split(',',$opt_n); |
540 |
croak("$0: cannot decode -n $opt_n\n") |
|
541 |
unless numberp($number_of_timelag_windows[0]) && numberp($number_of_timelag_windows[1]); |
|
34 | 542 |
$processing_options .= " -n $opt_n"; |
13 | 543 |
@length_of_timelag_windows = split(',',$opt_w); |
544 |
croak("$0: cannot decode -w $opt_w\n") |
|
545 |
unless numberp($length_of_timelag_windows[0]) && numberp($length_of_timelag_windows[1]); |
|
34 | 546 |
$processing_options .= " -w $opt_w"; |
13 | 547 |
|
42 | 548 |
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
|
549 |
unless defined($out_basename); |
49 | 550 |
#&antsAddParams('RDI_Coords::binMapping',$RDI_Coords::binMapping); # must be set below since binmapping depends on coords |
34 | 551 |
&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
|
552 |
&antsAddParams('out_basename',$out_basename); |
29 | 553 |
&antsAddParams('profile_id',$PROF,'run_label',$RUN); |
0 | 554 |
|
555 |
#---------------------------------------------------------------------- |
|
556 |
# Screen Logging |
|
557 |
# - warning levels: |
|
558 |
# 0 probably unimportant, e.g. nonsensical parameters that probably won't affect solution |
|
559 |
# 1 may be somewhat important |
|
560 |
# 2 important |
|
561 |
#---------------------------------------------------------------------- |
|
562 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
563 |
open(LOGF,">$out_log") || croak("$out_log: $!\n") |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
564 |
if defined($out_log); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
565 |
LOGF->autoflush(1); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
566 |
|
0 | 567 |
sub progress(@) |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
568 |
{ |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
569 |
printf(LOGF @_) if defined($out_log); |
13 | 570 |
printf(STDERR @_) if ($opt_v > 1); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
571 |
} |
0 | 572 |
|
573 |
sub info(@) |
|
574 |
{ |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
575 |
print(LOGF "\t"),printf(LOGF @_) if defined($out_log); |
29 | 576 |
printf(STDERR @_) if ($opt_v > 1); |
0 | 577 |
} |
578 |
||
579 |
sub warning(@) |
|
580 |
{ |
|
581 |
my($lvl,@msg) = @_; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
582 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
583 |
if (defined($out_log)) { |
29 | 584 |
print(LOGF "\nWARNING (L$lvl): "); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
585 |
printf(LOGF @msg); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
586 |
print(LOGF "\n"); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
587 |
} |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
588 |
return if ($opt_v == 0) || ($lvl == 0); |
29 | 589 |
|
590 |
if ($opt_v == 1) { |
|
39 | 591 |
print(STDERR "$LADCP_file: ") if defined($LADCP_file); |
592 |
print(STDERR "WARNING (L$lvl): "); |
|
29 | 593 |
printf(STDERR @msg); |
594 |
} else { |
|
595 |
print(STDERR "\n-------------\nWARNING (L$lvl): "); |
|
596 |
printf(STDERR @msg); |
|
597 |
print(STDERR "-------------\n\n") |
|
598 |
} |
|
0 | 599 |
} |
600 |
||
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
601 |
sub error($) |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
602 |
{ |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
603 |
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
|
604 |
croak("ABORT: @_"); |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
605 |
} |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
606 |
|
0 | 607 |
sub debugmsg(@) |
13 | 608 |
{ printf(STDERR @_) if ($opt_v > 2); } |
0 | 609 |
|
40 | 610 |
#--------------------------- |
0 | 611 |
# Read LADCP data |
40 | 612 |
# |
613 |
# sanity checks: |
|
614 |
# - single-ping ensembles |
|
615 |
# |
|
616 |
# warnings: |
|
617 |
# - high bandwidth |
|
618 |
# - low transmit power |
|
619 |
#--------------------------- |
|
0 | 620 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
621 |
progress("Reading LADCP data from <$LADCP_file>...\n"); |
51
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
622 |
error("cannot open <$LADCP_file> for reading\n") |
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
623 |
unless (-r $LADCP_file); |
0 | 624 |
readData($LADCP_file,\%LADCP); |
49 | 625 |
&antsAddDeps($LADCP_file); |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
626 |
if ($LADCP{BEAM_COORDINATES}) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
627 |
progress("\t%d ensembles (beam coordinates)\n",scalar(@{$LADCP{ENSEMBLE}})); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
628 |
} else { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
629 |
progress("\t%d ensembles (Earth coordinates)\n",scalar(@{$LADCP{ENSEMBLE}})); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
630 |
} |
0 | 631 |
|
49 | 632 |
if ($valid_ensemble_range[0] > 0) { # remove leading invalid records |
633 |
my($ens) = 0; |
|
634 |
while ($ens < @{$LADCP{ENSEMBLE}} && $LADCP{ENSEMBLE}[$ens]->{NUMBER}<$valid_ensemble_range[0]) { $ens++ } |
|
635 |
splice(@{$LADCP{ENSEMBLE}},0,$ens); |
|
636 |
progress("\t%d invalid leading ensembles removed\n",$ens) |
|
637 |
} |
|
638 |
if ($valid_ensemble_range[1] > 0) { # remove trailing invalid records |
|
639 |
my($ens) = 0; |
|
640 |
while ($ens < @{$LADCP{ENSEMBLE}} && $LADCP{ENSEMBLE}[$ens]->{NUMBER}<$valid_ensemble_range[1]) { $ens++ } |
|
641 |
splice(@{$LADCP{ENSEMBLE}},$ens); |
|
642 |
progress("\t%d invalid trailing ensembles removed\n",@{$LADCP{ENSEMBLE}}-$ens) |
|
643 |
} |
|
644 |
||
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
645 |
warning(2,"$LADCP_file: multi-ping ensembles\n") |
40 | 646 |
unless ($LADCP{PINGS_PER_ENSEMBLE} == 1); |
647 |
warning(2,"$LADCP_file: wide-bandwidth setting\n") |
|
648 |
if ($LADCP{WIDE_BANDWIDTH}); |
|
649 |
warning(2,"$LADCP_file: low transmit-power setting\n") |
|
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
650 |
unless ($LADCP{TRANSMIT_POWER_MAX}); |
40 | 651 |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
652 |
error("$LADCP_file: not enough LADCP bins ($LADCP{N_BINS}) for choice of -r\n") |
0 | 653 |
unless ($LADCP{N_BINS} >= $refLr_lastBin); |
654 |
||
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
655 |
error("$0: first reference-layer bin outside valid range\n") |
0 | 656 |
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
|
657 |
error("$0: last reference-layer bin outside valid range\n") |
0 | 658 |
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
|
659 |
error("$0: first reference-layer bin > last reference-layer bin\n") |
0 | 660 |
unless ($refLr_firstBin <= $refLr_lastBin); |
34 | 661 |
&antsAddParams('refLr_firstBin',$refLr_firstBin,'refLr_lastBin',$refLr_lastBin); |
0 | 662 |
|
34 | 663 |
$LADCP_lastBin = $LADCP{N_BINS} if ($LADCP_lastBin eq '*'); |
664 |
$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
|
665 |
error("$0: first valid LADCP bin outside valid range\n") |
0 | 666 |
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
|
667 |
error("$0: last valid LADCP bin outside valid range\n") |
0 | 668 |
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
|
669 |
error("$0: first valid LADCP bin > last valid LADCP bin\n") |
0 | 670 |
unless ($LADCP_firstBin <= $LADCP_lastBin); |
34 | 671 |
&antsAddParams('LADCP_firstBin',$LADCP_firstBin,'LADCP_lastBin',$LADCP_lastBin); |
0 | 672 |
|
673 |
warning(0,"first reference-layer bin < first valid LADCP bin\n") |
|
674 |
unless ($refLr_firstBin >= $LADCP_firstBin); |
|
675 |
warning(0,"last reference-layer bin > last valid LADCP bin\n") |
|
676 |
unless ($refLr_lastBin <= $LADCP_lastBin); |
|
677 |
||
678 |
warning(1,"if at all, bin 1 should not be used for short blank-after-transmit values\n") |
|
679 |
if ($LADCP{BLANKING_DISTANCE}<$LADCP{BIN_LENGTH} && $refLr_firstBin==1); |
|
680 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
681 |
&antsAddParams('ADCP_bin_length',$LADCP{BIN_LENGTH}, |
29 | 682 |
'ADCP_pulse_length',$LADCP{TRANSMITTED_PULSE_LENGTH}, |
56 | 683 |
'ADCP_type',$LADCP{INSTRUMENT_TYPE}, |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
684 |
'ADCP_frequency',$LADCP{BEAM_FREQUENCY}, |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
685 |
'ADCP_blanking_distance',$LADCP{BLANKING_DISTANCE}); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
686 |
|
49 | 687 |
|
0 | 688 |
#------------------------------------------------------------ |
49 | 689 |
# Edit velocity data |
690 |
# beam coords: |
|
691 |
# 1) beam-vel mask on -m |
|
692 |
# mask file has three columns: from_ens to_ens ignore_beam |
|
693 |
# 2) correlation threshold |
|
694 |
# Earth coords: |
|
695 |
# 1) correlation threshold |
|
0 | 696 |
#------------------------------------------------------------ |
697 |
||
698 |
if ($LADCP{BEAM_COORDINATES}) { |
|
699 |
progress("Editing beam-velocity data...\n"); |
|
13 | 700 |
|
701 |
if (defined($opt_m) && -r $opt_m) { |
|
702 |
progress("\tmasking beam velocities according to $opt_m:"); |
|
703 |
||
704 |
my($nee) = 0; |
|
705 |
open(BVM,$opt_m) || die("$opt_m: $!\n"); |
|
706 |
while (<BVM>) { |
|
707 |
s/#.*//; |
|
708 |
s/^\s*$//; |
|
709 |
next if ($_ eq ''); |
|
710 |
my($fe,$te,$db) = split; |
|
711 |
die("$opt_m: cannot decode $_\n") |
|
712 |
unless (numberp($fe) && numberp($te) && $te>=$fe && $db>=1 && $db<=4); |
|
713 |
die("$0: assertion failed") |
|
714 |
unless ($LADCP{ENSEMBLE}[$fe-1]->{NUMBER} == $fe && |
|
715 |
$LADCP{ENSEMBLE}[$te-1]->{NUMBER} == $te); |
|
716 |
for (my($ens)=$fe-1; $ens<=$te-1; $ens++) { |
|
717 |
$nee++; |
|
718 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
719 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$db-1]); |
|
720 |
} |
|
721 |
} |
|
722 |
} |
|
42 | 723 |
progress(" $nee ensembles edited\n"); |
13 | 724 |
close(BVM); |
725 |
} |
|
726 |
||
0 | 727 |
$nvv = $cte = 0; |
34 | 728 |
|
729 |
if ($pitch_bias || $roll_bias || $heading_bias) { |
|
730 |
&antsAddParams('pitch_bias',$pitch_bias, |
|
731 |
'roll_bias',$roll_bias, |
|
732 |
'heading_bias',$heading_bias); |
|
733 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
734 |
correctAttitude($ens,$pitch_bias,$roll_bias,$heading_bias); |
|
735 |
} |
|
736 |
} |
|
0 | 737 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
738 |
$nvv += countValidBeamVels($ens); |
|
13 | 739 |
$cte += editCorr($ens,$opt_c); |
0 | 740 |
} |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
741 |
error("$LADCP_file: no valid data\n") unless ($nvv > 0); |
13 | 742 |
progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$opt_c,$cte,round(100*$cte/$nvv)); |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
743 |
} else { # if BEAM_COORDINATES |
0 | 744 |
progress("Editing velocity data...\n"); |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
745 |
error("$LADCP_file: cannot apply beamvel-mask $opt_m to Earth-coordinate data\n") |
13 | 746 |
if defined($opt_m); |
0 | 747 |
$nvv = $cte = 0; |
748 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
749 |
$nvv += countValidBeamVels($ens); |
|
13 | 750 |
$cte += editCorr_Earthcoords($ens,$opt_c); |
0 | 751 |
} |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
752 |
error("$LADCP_file: no valid data\n") unless ($nvv > 0); |
13 | 753 |
progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$opt_c,$cte,round(100*$cte/$nvv)); |
0 | 754 |
} |
755 |
||
49 | 756 |
#------------------------------------------------------------ |
757 |
# Create beam coordinate velocities for Earth-velocity data |
|
758 |
# - velocities are replaced "in place" |
|
759 |
# - BT velocities are treated separately in [find_seabed.pl] |
|
760 |
# - this transformation will remove all 3-beam solutions |
|
761 |
# - disable bin mapping because Earth coords are typically bin-remapped |
|
762 |
#------------------------------------------------------------ |
|
763 |
||
764 |
unless ($LADCP{BEAM_COORDINATES}) { |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
765 |
progress("Replacing Earth- with beam-velocities...\n"); |
49 | 766 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
767 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
768 |
@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} = |
|
769 |
&velEarthToBeam(\%LADCP,$ens,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}); |
|
770 |
} |
|
771 |
} |
|
772 |
$RDI_Coords::binMapping = 'none'; |
|
773 |
} |
|
774 |
||
51
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
775 |
&antsAddParams('RDI_Coords::binMapping', $RDI_Coords::binMapping, # finally, bin mapping is known |
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
776 |
'RDI_Coords::minValidVels', $RDI_Coords::minValidVels, |
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
777 |
'RDI_Coords::beamTransformation',$RDI_Coords::beamTransformation); |
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
778 |
|
49 | 779 |
|
0 | 780 |
#------------------------------------------------------------------- |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
781 |
# Calculate Earth velocities |
0 | 782 |
# - this is done for all bins (not just valid ones), to allow |
783 |
# useless possibility that invalid bins are used for reflr calcs |
|
784 |
# - also calculate separate beam-pair velocities |
|
785 |
# - the UNEDITED velocities are saved for the BT calculations |
|
786 |
# (W is required, U & V are only used for stats that have not |
|
787 |
# been very useful so far) |
|
788 |
#------------------------------------------------------------------- |
|
789 |
||
49 | 790 |
my($dummy); |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
791 |
progress("Calculating Earth-coordinate velocities...\n"); |
49 | 792 |
if ($bad_beam) { |
793 |
progress("\tdiscarding velocities from beam $bad_beam\n"); |
|
794 |
&antsAddParams('bad_beam_discarded',$bad_beam); |
|
795 |
} |
|
796 |
$nvw = 0; |
|
797 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
798 |
$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH} = |
|
799 |
gimbal_pitch($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
800 |
|
49 | 801 |
if ($bad_beam) { |
802 |
for (my($bin)=0; $bin<=$LADCP{N_BINS}-1; $bin++) { |
|
803 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$bad_beam-1]); |
|
804 |
undef($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$bin][$bad_beam-1]); |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
805 |
} |
49 | 806 |
} |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
807 |
|
49 | 808 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
809 |
($LADCP{ENSEMBLE}[$ens]->{INTERP_U}[$bin], |
|
810 |
$LADCP{ENSEMBLE}[$ens]->{INTERP_V}[$bin], |
|
811 |
$LADCP{ENSEMBLE}[$ens]->{INTERP_W}[$bin], |
|
812 |
$LADCP{ENSEMBLE}[$ens]->{INTERP_ERRVEL}[$bin]) = earthVels(\%LADCP,$ens,$bin); |
|
813 |
($LADCP{ENSEMBLE}[$ens]->{V12}[$bin],$LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
|
814 |
$LADCP{ENSEMBLE}[$ens]->{V34}[$bin],$LADCP{ENSEMBLE}[$ens]->{W34}[$bin]) = BPEarthVels(\%LADCP,$ens,$bin); |
|
815 |
} |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
816 |
|
49 | 817 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
818 |
$LADCP{ENSEMBLE}[$ens]->{U}[$bin] = $LADCP{ENSEMBLE}[$ens]->{INTERP_U}[$bin]; |
|
819 |
$LADCP{ENSEMBLE}[$ens]->{V}[$bin] = $LADCP{ENSEMBLE}[$ens]->{INTERP_V}[$bin]; |
|
820 |
$LADCP{ENSEMBLE}[$ens]->{W}[$bin] = $LADCP{ENSEMBLE}[$ens]->{INTERP_W}[$bin]; |
|
821 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin] = $LADCP{ENSEMBLE}[$ens]->{INTERP_ERRVEL}[$bin]; |
|
822 |
undef($LADCP{ENSEMBLE}[$ens]->{INTERP_U}[$bin]); |
|
823 |
undef($LADCP{ENSEMBLE}[$ens]->{INTERP_V}[$bin]); |
|
824 |
undef($LADCP{ENSEMBLE}[$ens]->{INTERP_W}[$bin]); |
|
825 |
undef($LADCP{ENSEMBLE}[$ens]->{INTERP_ERRVEL}[$bin]); |
|
826 |
||
827 |
if (defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin])) { |
|
828 |
$per_bin_nsamp[$bin]++; |
|
829 |
$nvw++; |
|
0 | 830 |
} |
49 | 831 |
|
832 |
$LADCP{ENSEMBLE}[$ens]->{U_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{U}[$bin]; |
|
833 |
$LADCP{ENSEMBLE}[$ens]->{V_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{V}[$bin]; |
|
834 |
$LADCP{ENSEMBLE}[$ens]->{W_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin]; |
|
0 | 835 |
} |
836 |
} |
|
49 | 837 |
progress("\t$nvw valid velocities in bins $LADCP_firstBin-$LADCP_lastBin\n"); |
838 |
progress("\t3-beam solutions : $RDI_Coords::threeBeam_1 " . |
|
839 |
"$RDI_Coords::threeBeam_2 " . |
|
840 |
"$RDI_Coords::threeBeam_3 " . |
|
841 |
"$RDI_Coords::threeBeam_4\n") |
|
842 |
unless ($opt_4); |
|
0 | 843 |
|
29 | 844 |
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
|
845 |
|
0 | 846 |
#---------------------------------------------- |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
847 |
# STEP: Edit Earth-coordinate -velocity data |
0 | 848 |
# 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
|
849 |
# 2) vertical-velocity outliers |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
850 |
# 3) truncate range by deleting farthest valid velocities (disbled by default) |
0 | 851 |
#---------------------------------------------- |
852 |
||
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
853 |
progress("Editing Earth-coordinate velocity data...\n"); |
0 | 854 |
|
34 | 855 |
&antsAddParams('per_ens_outliers_mad_limit',$per_ens_outliers_mad_limit) |
856 |
&antsAddParams('farthest_valid_bins_truncated',$truncate_farthest_valid_bins) |
|
857 |
if ($truncate_farthest_valid_bins); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
858 |
$evrm = $trrm = $worm = 0; |
0 | 859 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
13 | 860 |
$evrm += editErrVel($ens,$opt_e); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
861 |
$worm += editWOutliers($ens,$per_ens_outliers_mad_limit); |
34 | 862 |
$trrm += editTruncRange($ens,$truncate_farthest_valid_bins) if ($truncate_farthest_valid_bins); |
0 | 863 |
} |
13 | 864 |
progress("\terror-velocity threshold (-e %.2f m/s): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n", |
865 |
$opt_e,$evrm,round(100*$evrm/$nvw)); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
866 |
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
|
867 |
$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
|
868 |
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
|
869 |
$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
|
870 |
if ($truncate_farthest_valid_bins > 0); |
0 | 871 |
|
872 |
#---------------------------- |
|
873 |
# Calculate LADCP time series |
|
874 |
#---------------------------- |
|
875 |
||
876 |
progress("Calculating LADCP time-series...\n"); |
|
877 |
||
878 |
($firstGoodEns,$lastGoodEns,$LADCP_atbottom,$LADCP_w_gap_time) = |
|
13 | 879 |
calcLADCPts(\%LADCP,$opt_s,$refLr_firstBin,$refLr_lastBin,$opt_g); |
29 | 880 |
error("$LADCP_file: insufficient valid data\n") |
881 |
unless defined($firstGoodEns) && ($lastGoodEns>$firstGoodEns) && ($LADCP_atbottom>=$firstGoodEns); |
|
0 | 882 |
|
883 |
my($cast_duration) = $LADCP{ENSEMBLE}[$lastGoodEns]->{ELAPSED} - |
|
884 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{ELAPSED}; |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
885 |
error("$0: implausibly short cast ($cast_duration seconds)\n") |
0 | 886 |
unless ($cast_duration > 600); |
887 |
||
29 | 888 |
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
|
889 |
&antsAddParams(sprintf('dn%02d',$year),$LADCP{ENSEMBLE}[$firstGoodEns]->{DAYNO}); |
29 | 890 |
|
0 | 891 |
$LADCP{MEAN_DT} = $cast_duration / ($lastGoodEns-$firstGoodEns-1); |
892 |
||
893 |
progress("\tStart of cast : %s (#%5d)\n", |
|
894 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{TIME}, |
|
895 |
$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER}); |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
896 |
progress("\tBottom of cast : %s (#%5d) @ dz=%6dm\n", |
0 | 897 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{TIME}, |
898 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{NUMBER}, |
|
899 |
$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
|
900 |
progress("\tEnd of cast : %s (#%5d) @ dz=%6dm\n", |
0 | 901 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{TIME}, |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
902 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{NUMBER}, |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
903 |
$LADCP{ENSEMBLE}[$lastGoodEns]->{DEPTH}); |
0 | 904 |
progress("\tCast duration : %.1f hours (pinging for %.1f hours)\n", |
905 |
$cast_duration / 3600, |
|
906 |
($LADCP{ENSEMBLE}[$#{$LADCP{ENSEMBLE}}]->{UNIX_TIME} - |
|
907 |
$LADCP{ENSEMBLE}[0]->{UNIX_TIME}) / 3600); |
|
908 |
progress("\tMean ping interval: %.1f seconds\n",$LADCP{MEAN_DT}); |
|
909 |
||
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
910 |
if (@out_LADCPtis) { |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
911 |
progress("Writing LADCP-timeseries to "); |
23 | 912 |
@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
|
913 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
914 |
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
|
915 |
progress("<$of> "); |
42 | 916 |
my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/); # sub(arg), e.g. plot_wprof(DL/003_wprof.ps) |
917 |
if (defined($arg)) { # NB: exactly one arg |
|
918 |
if (-f "./${sub}.pl") { # # NB: don't quote arg |
|
919 |
require "./${sub}.pl"; |
|
920 |
} else { |
|
921 |
require "$WCALC/${sub}.pl"; |
|
922 |
} |
|
923 |
&{$sub}($arg); |
|
30 | 924 |
next; |
925 |
} |
|
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
926 |
$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
|
927 |
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
|
928 |
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
|
929 |
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
|
930 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
931 |
$LADCP{ENSEMBLE}[$ens]->{ELAPSED}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
932 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
933 |
$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
|
934 |
$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
|
935 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH}); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
936 |
} |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
937 |
&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
|
938 |
} |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
939 |
progress("\n"); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
940 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
941 |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
942 |
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
|
943 |
if ($lastGoodEns-$LADCP_atbottom < 100); |
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
944 |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
945 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
946 |
# More editing |
49 | 947 |
# - attitude threshold |
948 |
# - data in far bins (beyond reliable range) |
|
949 |
# - at this stage ${first,last}GoodEns are known |
|
6 | 950 |
# - TILT field is set as a side-effect |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
951 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
952 |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
953 |
progress("Editing additional Earth-coordinate velocity data...\n"); |
34 | 954 |
&antsAddParams('per_bin_valid_frac_lim',$per_bin_valid_frac_lim); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
955 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
956 |
my($first_bad_bin); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
957 |
for (my($bin)=$LADCP_firstBin-1; $bin<$LADCP_lastBin-1; $bin++) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
958 |
next unless ($per_bin_nsamp[$bin]/($lastGoodEns-$firstGoodEns) < $per_bin_valid_frac_lim); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
959 |
$first_bad_bin = $bin; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
960 |
last; |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
961 |
} |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
962 |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
963 |
my($dc_sumTilts,$dc_n,$uc_sumTilts,$uc_n) = (0,0,0,0); |
15 | 964 |
$fprm = $pte = 0; |
965 |
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
|
56 | 966 |
my($ne) = editTilt($ens,$opt_t); # this sets the TILT field |
41 | 967 |
if ($ne == 0) { |
968 |
if ($ens <= $LADCP_atbottom) { |
|
56 | 969 |
$dc_sumTilts += $LADCP{ENSEMBLE}[$ens]->{TILT}; |
41 | 970 |
$dc_n++; |
971 |
} else { |
|
56 | 972 |
$uc_sumTilts += $LADCP{ENSEMBLE}[$ens]->{TILT}; |
41 | 973 |
$uc_n++; |
974 |
} |
|
975 |
} else { |
|
976 |
$pte += $ne; |
|
977 |
} |
|
15 | 978 |
$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
|
979 |
} |
56 | 980 |
my($dc_mean_tilt) = ($dc_n > 0) ? $dc_sumTilts/$dc_n : nan; |
981 |
my($uc_mean_tilt) = ($uc_n > 0) ? $uc_sumTilts/$uc_n : nan; |
|
982 |
&antsAddParams('dc_tilt.mu',$dc_mean_tilt,'uc_tilt.mu',$uc_mean_tilt); |
|
41 | 983 |
|
15 | 984 |
progress("\tattitude threshold (max_tilt = %d deg): %d velocites removed (%d%% of total)\n", |
985 |
$opt_t,$pte,round(100*$pte/$nvv)); |
|
986 |
progress("\tvelocities beyond bin $first_bad_bin (<%d%% valid values): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n", |
|
987 |
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
|
988 |
|
49 | 989 |
#---------------------------------------------------------------------- |
0 | 990 |
# Read CTD data |
49 | 991 |
#---------------------------------------------------------------------- |
0 | 992 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
993 |
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
|
994 |
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
|
995 |
error("$CTD_file: no data\n") unless (&antsIn()); |
2 | 996 |
undef($antsOldHeaders); |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
997 |
|
56 | 998 |
$opt_l = 1 # disable time-lag filtering |
999 |
if defined($P{CTD_transmission_errors}); # for transmission-corrected CTD files |
|
1000 |
||
49 | 1001 |
&antsAddDeps($CTD_file); |
19 | 1002 |
&antsAddParams('lat',$P{lat}) if defined($P{lat}); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1003 |
&antsAddParams('lon',$P{lon}) if defined($P{lon}); |
0 | 1004 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1005 |
($CTD_elapsed,$CTD_depth,$CTD_svel) = &fnr('elapsed','depth','ss'); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1006 |
$CTD_w = &fnrNoErr('w_CTD'); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1007 |
$CTD_w = &fnr('w') unless defined($CTD_w); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1008 |
$CTD_winchvel = &fnrNoErr('w_winch'); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1009 |
$CTD_temp = &fnrNoErr('temp'); |
29 | 1010 |
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
|
1011 |
unless defined($CTD_temp); |
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
1012 |
|
0 | 1013 |
$CTD_maxdepth = -1; |
13 | 1014 |
do { # read data |
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
1015 |
error("$0: cannot deal with non-numeric CTD elapsed time\n") |
0 | 1016 |
unless &antsNumbers($CTD_elapsed); |
1017 |
push(@{$CTD{ELAPSED}},$ants_[0][$CTD_elapsed]); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1018 |
push(@{$CTD{DEPTH}}, $ants_[0][$CTD_depth]); |
0 | 1019 |
push(@{$CTD{SVEL}}, $ants_[0][$CTD_svel]); |
1020 |
push(@{$CTD{W}}, $ants_[0][$CTD_w]); |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1021 |
push(@{$CTD{TEMP}}, $ants_[0][$CTD_temp]) if defined($CTD_temp); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1022 |
push(@{$CTD{W_WINCH}},$ants_[0][$CTD_winchvel]) if defined($CTD_winchvel); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1023 |
if ($ants_[0][$CTD_depth] > $CTD_maxdepth) { |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1024 |
$CTD_maxdepth = $ants_[0][$CTD_depth]; |
0 | 1025 |
$CTD_atbottom = $#{$CTD{DEPTH}}; |
1026 |
} |
|
1027 |
} while (&antsIn()); |
|
1028 |
||
1029 |
$CTD{DT} = ($CTD{ELAPSED}[$#{$CTD{ELAPSED}}] - $CTD{ELAPSED}[0]) / $#{$CTD{ELAPSED}}; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1030 |
progress("\t%d scans at %.1fHz\n",scalar(@{$CTD{DEPTH}}),1/$CTD{DT}); |
0 | 1031 |
|
13 | 1032 |
$CTD{W_t}[0] = $CTD{W_t} [@{$CTD{ELAPSED}}] = nan; # calculate w-derivatives |
1033 |
$CTD{W_tt}[0] = $CTD{W_tt}[@{$CTD{ELAPSED}}] = nan; |
|
1034 |
for (my($s)=1; $s<@{$CTD{ELAPSED}}-1; $s++) { # centered differences for both |
|
1035 |
$CTD{W_t} [$s] = ($CTD{W}[$s+1] - $CTD{W}[$s-1]) / (2*$CTD{DT}); |
|
41 | 1036 |
$CTD{W_tt}[$s] = ($CTD{W}[$s+1] + $CTD{W}[$s-1] - 2*$CTD{W}[$s]) / &SQR($CTD{DT}); |
13 | 1037 |
} |
42 | 1038 |
$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
|
1039 |
error("$0: CTD start depth must be numeric\n") |
0 | 1040 |
unless numberp($CTD{DEPTH}[0]); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1041 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1042 |
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
|
1043 |
progress("\tmax depth = %dm (# $CTD_atbottom)\n",$CTD_maxdepth); |
0 | 1044 |
|
1045 |
#-------------------------------------------------------------------- |
|
1046 |
# Construct sound-speed correction profile from CTD 1Hz downcast data |
|
1047 |
# very simple algorithm that stores the last value found |
|
1048 |
# in each 1m bin |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1049 |
# For PPI filtering, a sound speed profile without gaps is required. |
0 | 1050 |
#-------------------------------------------------------------------- |
1051 |
||
1052 |
progress("Constructing sound-speed correction profile\n"); |
|
1053 |
||
1054 |
my($scans_per_sec) = int(1/$CTD{DT}+0.5); |
|
15 | 1055 |
my($min_depth) = 9e99; |
0 | 1056 |
for (my($s)=0; $s<=$CTD_atbottom; $s+=$scans_per_sec) { |
1057 |
next unless ($CTD{DEPTH}[$s] >= 0 && numberp($CTD{SVEL}[$s])); |
|
19 | 1058 |
my($d) = int($CTD{DEPTH}[$s]); |
1059 |
$min_depth = $d if ($d < $min_depth); |
|
1060 |
$sVelProf[$d] = $CTD{SVEL}[$s]; |
|
0 | 1061 |
} |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1062 |
while ($min_depth > 0) { # fill surface gap |
15 | 1063 |
$sVelProf[$min_depth-1] = $sVelProf[$min_depth]; |
1064 |
$min_depth--; |
|
1065 |
} |
|
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1066 |
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
|
1067 |
$sVelProf[$d] = $sVelProf[$d-1] |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1068 |
unless defined($sVelProf[$d]); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1069 |
} |
18 | 1070 |
|
0 | 1071 |
#------------------- |
1072 |
# Determine time lag |
|
1073 |
#------------------- |
|
1074 |
||
49 | 1075 |
if (defined($initial_time_lag)) { |
0 | 1076 |
progress("Setting initial time lag...\n"); |
49 | 1077 |
$CTD{TIME_LAG} = $initial_time_lag; |
0 | 1078 |
progress("\t-i => elapsed(CTD) ~ elapsed(LADCP) + %.1fs\n",$CTD{TIME_LAG}); |
1079 |
} else { |
|
1080 |
progress("Guestimating time lag...\n"); |
|
1081 |
||
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1082 |
my($CTD_10pct_down) = 0; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1083 |
my($LADCP_10pct_down) = $firstGoodEns; |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1084 |
|
0 | 1085 |
$CTD_10pct_down++ |
1086 |
until ($CTD{DEPTH}[$CTD_10pct_down]-$CTD{DEPTH}[0] >= 0.1*($CTD_maxdepth-$CTD{DEPTH}[0])); |
|
1087 |
$LADCP_10pct_down++ |
|
1088 |
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
|
1089 |
|
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1090 |
$CTD{TIME_LAG} = |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1091 |
$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
|
1092 |
|
0 | 1093 |
progress("\telapsed(dz(CTD)=%.1fm) ~ elapsed(dz(LADCP)=%.1fm) + %.1fs\n", |
1094 |
$CTD{DEPTH}[$CTD_10pct_down]-$CTD{DEPTH}[0],$LADCP{ENSEMBLE}[$LADCP_10pct_down]->{DEPTH},$CTD{TIME_LAG}); |
|
1095 |
} |
|
1096 |
||
2 | 1097 |
if ($opt_u) { |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1098 |
progress("\tskipping time lagging (-u)\n"); |
48 | 1099 |
$CTD_time_lag[0] = $CTD{TIME_LAG}; |
1100 |
$CTD_tl_toEns[0] = $lastGoodEns; |
|
2 | 1101 |
} else { |
13 | 1102 |
|
1103 |
#------------------------ |
|
1104 |
# stage 1: 1Hz; full cast |
|
1105 |
#------------------------ |
|
1106 |
||
1107 |
$CTD{TIME_LAG} = |
|
1108 |
calc_lag($number_of_timelag_windows[0],$length_of_timelag_windows[0], |
|
1109 |
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
|
1110 |
error("$0: Cannot proceed without valid lag!\n") unless defined($CTD{TIME_LAG}); |
2 | 1111 |
progress("\telapsed(CTD) ~ elapsed(LADCP) + %.2fs\n",$CTD{TIME_LAG}); |
13 | 1112 |
|
1113 |
#--------------------------------- |
|
1114 |
# stage 2: piece-wise time lagging |
|
1115 |
#--------------------------------- |
|
1116 |
||
1117 |
my(@splits); |
|
1118 |
push(@splits,$firstGoodEns); |
|
1119 |
foreach my $s (split(/,/,$opt_p)) { |
|
1120 |
if ($s eq '+') { |
|
1121 |
push(@splits,$LADCP_atbottom); |
|
1122 |
} elsif (numberp($s)) { # find ens for given LADCP elapsed time in min |
|
1123 |
my($ela) = $s*60; |
|
1124 |
my($ens) = $firstGoodEns + round($ela / $LADCP{MEAN_DT}); # first, guess |
|
1125 |
while ($LADCP{ENSEMBLE}[$ens]->{ELAPSED} > $ela) { $ens--; } # then, correct |
|
1126 |
while ($LADCP{ENSEMBLE}[$ens]->{ELAPSED} < $ela) { $ens++; } |
|
1127 |
push(@splits,$ens); |
|
1128 |
} else { |
|
1129 |
warning(2,"ignoring non-numeric -p argument %s",$s); |
|
1130 |
} |
|
1131 |
} |
|
1132 |
push(@splits,$lastGoodEns); |
|
11 | 1133 |
|
13 | 1134 |
my($valid_lag); # determine piece-wise lags |
1135 |
while (@splits > 1) { |
|
1136 |
push(@CTD_tl_fromEns,$splits[0]); |
|
1137 |
push(@CTD_tl_toEns,$splits[1]); |
|
29 | 1138 |
debugmsg("lag($splits[0],$splits[1]) = "); |
13 | 1139 |
my($lag) = calc_lag($number_of_timelag_windows[1],$length_of_timelag_windows[1], |
1140 |
1,$splits[0],$splits[1]); |
|
29 | 1141 |
debugmsg("$lag\n"); |
13 | 1142 |
if (defined($lag)) { |
1143 |
progress("\tcast-piece: elapsed(CTD) = elapsed(LADCP) + %.2fs\n",$lag); |
|
1144 |
push(@CTD_time_lag,$lag); |
|
1145 |
$valid_lag = $#CTD_time_lag; |
|
1146 |
} else { |
|
1147 |
progress("\tcast-piece: time-lagging failed\n"); |
|
1148 |
push(@CTD_time_lag,nan); |
|
1149 |
} |
|
1150 |
shift(@splits); |
|
1151 |
} |
|
1152 |
||
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
1153 |
error("$0: Cannot proceed without at least one lag!\n") # fill failed lag with surrounding data |
13 | 1154 |
unless defined($valid_lag); |
1155 |
while ($valid_lag < $#CTD_time_lag) { # forward |
|
1156 |
$CTD_time_lag[$valid_lag+1] = $CTD_time_lag[$valid_lag]; |
|
1157 |
$valid_lag++; |
|
1158 |
} |
|
1159 |
while ($valid_lag > 0) { # backward |
|
1160 |
$CTD_time_lag[$valid_lag-1] = $CTD_time_lag[$valid_lag] |
|
1161 |
unless (numberp($CTD_time_lag[$valid_lag-1])); |
|
1162 |
$valid_lag--; |
|
1163 |
} |
|
2 | 1164 |
} |
0 | 1165 |
|
13 | 1166 |
&antsAddParams('CTD_time_lags',"@CTD_time_lag"); |
1167 |
undef($CTD{TIME_LAG}); # to avoid confusion, clear old 1Hz-based lag |
|
0 | 1168 |
|
1169 |
#------------------------------------------------ |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1170 |
# Merge (associate) CTD with LADCP data |
0 | 1171 |
# - after this step, reflr w is sound-speed corrected!!! |
1172 |
#------------------------------------------------ |
|
1173 |
||
1174 |
progress("Merging CTD with LADCP data...\n"); |
|
1175 |
||
56 | 1176 |
&antsAddParams('w_lim.max',$w_max_lim); |
34 | 1177 |
|
13 | 1178 |
my($cli) = 0; # current-lag index |
1179 |
my($lag) = $CTD_time_lag[$cli]; # current lag |
|
1180 |
||
42 | 1181 |
my($dc_sumsq,$dc_n,$uc_sumsq,$uc_n) = (0,0,0,0); # for a_pkg calcs |
0 | 1182 |
for (my($skipped)=0,my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
13 | 1183 |
|
1184 |
if ($ens > $CTD_tl_toEns[$cli]) { # use correct lag piece |
|
1185 |
$cli++; |
|
48 | 1186 |
die("assertion failed!\n\ttest: \$cli(=$cli) <= \$#CTD_time_lag(=$#CTD_time_lag) at ens=$ens\n") |
13 | 1187 |
unless ($cli <= $#CTD_time_lag); |
1188 |
$lag = $CTD_time_lag[$cli]; |
|
1189 |
} |
|
1190 |
||
1191 |
my($scan) = |
|
1192 |
int(($LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $lag - $CTD{ELAPSED}[0]) / $CTD{DT} + 0.5); |
|
0 | 1193 |
if ($scan <= 0) { # NB: must be <=, rather than <, or assertion below sometimes fails |
1194 |
$skipped++; |
|
1195 |
$firstGoodEns = $ens+1; |
|
1196 |
next; |
|
1197 |
} |
|
1198 |
if ($skipped > 0) { |
|
13 | 1199 |
$firstGoodEns++,$skipped++,next # in gap |
2 | 1200 |
unless defined($LADCP{ENSEMBLE}[$firstGoodEns]->{REFLR_W}); |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1201 |
info("\t$skipped initial LADCP ensembles skipped because CTD data begin with LADCP in water\n"); |
0 | 1202 |
$skipped = 0; |
1203 |
} |
|
1204 |
if ($scan > $#{$CTD{ELAPSED}}) { |
|
13 | 1205 |
while (!defined($LADCP{ENSEMBLE}[$ens-1]->{REFLR_W})) { $ens--; } # in gap |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1206 |
info(sprintf("\t%d final LADCP ensembles skipped because CTD data end with LADCP in water\n", |
0 | 1207 |
$lastGoodEns-$ens+1)); |
1208 |
$lastGoodEns = $ens-1; |
|
1209 |
last; |
|
1210 |
} |
|
1211 |
||
1212 |
$LADCP{ENSEMBLE}[$ens]->{CTD_ELAPSED} = $CTD{ELAPSED}[$scan]; # elapsed field for output |
|
1213 |
||
1214 |
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
|
1215 |
&& numberp($CTD{DEPTH}[$scan])) { |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
1216 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W_NOSSCORR} = $LADCP{ENSEMBLE}[$ens]->{REFLR_W}; |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1217 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W} *= # correct for sound-speed variations at source |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1218 |
$CTD{SVEL}[$scan] / $LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}; |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1219 |
error(sprintf("\n$0: negative depth (%.1fm) in CTD file at elapsed(CTD) = %.1fs\n", |
0 | 1220 |
$CTD{DEPTH}[$scan],$CTD{ELAPSED}[$scan])) |
1221 |
unless ($CTD{DEPTH}[$scan] >= 0); |
|
1222 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} = $CTD{DEPTH}[$scan]; |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1223 |
$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN} = $scan; # used for other CTD fields |
42 | 1224 |
if (numberp($CTD{W_t}[$scan])) { |
1225 |
if ($ens <= $LADCP_atbottom) { |
|
1226 |
$dc_sumsq += &SQR($CTD{W_t}[$scan]); $dc_n++; |
|
1227 |
} else { |
|
1228 |
$uc_sumsq += &SQR($CTD{W_t}[$scan]); $uc_n++; |
|
1229 |
} |
|
41 | 1230 |
} |
0 | 1231 |
my($reflr_ocean_w) = $LADCP{ENSEMBLE}[$ens]->{REFLR_W} - $CTD{W}[$scan]; |
13 | 1232 |
if (abs($reflr_ocean_w) <= $w_max_lim) { |
0 | 1233 |
$sumWsq += &SQR($reflr_ocean_w); |
1234 |
$nWsq++; |
|
1235 |
if ($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} > 100 && |
|
1236 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} < $LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH}-100) { |
|
1237 |
$sumWsqI += &SQR($reflr_ocean_w); |
|
1238 |
$nWsqI++; |
|
1239 |
} |
|
1240 |
} else { |
|
1241 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); # DON'T USE THIS ENSEMBLE LATER |
|
1242 |
} |
|
1243 |
} else{ |
|
1244 |
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
|
1245 |
undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); # old DEPTH from calcLADCPts() must be removed |
0 | 1246 |
} |
1247 |
} |
|
41 | 1248 |
|
42 | 1249 |
my($dc_rms_apkg) = ($dc_n > 0) ? sqrt($dc_sumsq / $dc_n) : nan; # rms package acceleration |
1250 |
my($uc_rms_apkg) = ($uc_n > 0) ? sqrt($uc_sumsq / $uc_n) : nan; |
|
56 | 1251 |
&antsAddParams('dc_accel_pkg.rms',$dc_rms_apkg,'uc_accel_pkg.rms',$uc_rms_apkg); |
0 | 1252 |
|
1253 |
if ($nWsq > 0 && $nWsqI > 0) { |
|
1254 |
&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',sqrt($sumWsqI/$nWsqI)); |
|
1255 |
progress("\t%.2f cm/s rms reference-layer w_ocean, %.2f cm/s away from boundaries\n", |
|
1256 |
100*sqrt($sumWsq/$nWsq),100*sqrt($sumWsqI/$nWsqI)); |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1257 |
if (sqrt($sumWsqI/$nWsqI) > 0.05) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1258 |
warning(0,"%.2f cm/s (large) reference-layer w_ocean away from boundaries\n",100*sqrt($sumWsqI/$nWsqI)); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1259 |
} elsif (sqrt($sumWsqI/$nWsqI) > 0.15) { |
34 | 1260 |
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
|
1261 |
} |
0 | 1262 |
} elsif ($nWsq > 0) { |
1263 |
&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',nan); |
|
1264 |
progress("\t%.2f cm/s rms reference-layer w_ocean\n",100*sqrt($sumWsq/$nWsq)); |
|
1265 |
} else { |
|
27
2053d8de8d6b
updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
1266 |
error("$0: no valid vertical velocities\n"); |
0 | 1267 |
} |
1268 |
||
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1269 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1270 |
# Calculate Volume Scattering Coefficients |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1271 |
#---------------------------------------------------------------------- |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1272 |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
1273 |
progress("Calculating volume-scattering coefficients (Sv)...\n"); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1274 |
calc_backscatter_profs($firstGoodEns,$lastGoodEns); |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1275 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1276 |
if (defined($Sv_ref_bin) && @nSv) { |
34 | 1277 |
progress("\tapplying empirical Sv correction\n"); |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1278 |
&antsAddParams('Sv_correction','empirical'); |
34 | 1279 |
correct_backscatter($firstGoodEns,$lastGoodEns); |
1280 |
} |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
1281 |
|
0 | 1282 |
#---------------------------------------------------------------------------- |
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
27
diff
changeset
|
1283 |
# Find Seabed & Edit data |
15 | 1284 |
# 1) contaminated by sidelobe reflection from seabed and sea surface |
1285 |
# 2) PPI |
|
0 | 1286 |
#---------------------------------------------------------------------------- |
1287 |
||
49 | 1288 |
error("$0: conflicting water-depth information provided by user\n") # only happens when $water_depth is set explicitly |
1289 |
if defined($opt_h) && defined($water_depth); |
|
1290 |
||
1291 |
if (defined($opt_h)) { # handle user-provided water-depth info |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1292 |
if (numberp($opt_h)) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1293 |
$water_depth = $opt_h; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1294 |
} elsif (-f $opt_h) { |
40 | 1295 |
open(WDF,$opt_h) || error("$opt_h: $_\n"); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1296 |
$water_depth = &antsFileScanParam(WDF,'water_depth'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1297 |
close(WDF); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1298 |
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
|
1299 |
} else { |
40 | 1300 |
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
|
1301 |
} |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1302 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1303 |
|
42 | 1304 |
if (!defined($water_depth) && # find seabed in data |
1305 |
$LADCP{ENSEMBLE}[$LADCP_atbottom]->{XDUCER_FACING_DOWN}) { |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1306 |
progress("Finding seabed...\n"); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1307 |
($water_depth,$sig_water_depth) = |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1308 |
find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH}); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1309 |
($water_depth_BT,$sig_water_depth_BT) = |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1310 |
find_seabed(\%LADCP,$LADCP_atbottom,$LADCP{BEAM_COORDINATES}); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1311 |
if (defined($water_depth) && defined($water_depth_BT)) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1312 |
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
|
1313 |
# 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
|
1314 |
# if ($dd > 10); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1315 |
} |
42 | 1316 |
if (!$SS_use_BT && !defined($water_depth) && defined($water_depth_BT)) { # warn if use of BT was not |
1317 |
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
|
1318 |
$SS_use_BT = 1; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1319 |
} |
49 | 1320 |
if ($SS_use_BT && numberp($water_depth_BT)) { # water depth from BT data |
34 | 1321 |
&antsAddParams('water_depth_from','BT_data'); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1322 |
$water_depth = $water_depth_BT; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1323 |
$sig_water_depth = $sig_water_depth_BT; |
49 | 1324 |
} elsif (defined($water_depth)) { # water depth from WT data |
34 | 1325 |
&antsAddParams('water_depth_from','echo_amplitudes'); |
1326 |
} |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1327 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1328 |
|
42 | 1329 |
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
|
1330 |
if (defined($water_depth_BT)) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1331 |
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
|
1332 |
$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
|
1333 |
} else { |
42 | 1334 |
progress("\t%.1f(%.1f) m water depth (no seabed found in BT data)\n", |
1335 |
$water_depth,$sig_water_depth); |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1336 |
} |
42 | 1337 |
warning(1,sprintf("large uncertainty in water-depth estimation (%.1fm)\n", |
1338 |
$sig_water_depth)) |
|
1339 |
if ($sig_water_depth > $LADCP{BIN_LENGTH}); |
|
1340 |
if ($water_depth < $CTD_maxdepth) { |
|
1341 |
warning(2,"water depth ($water_depth m) < max CTD depth ($CTD_maxdepth m) ignored\n"); |
|
1342 |
undef($water_depth); |
|
1343 |
} |
|
1344 |
} |
|
1345 |
||
49 | 1346 |
if (!defined($water_depth) && defined($water_depth_db_cmd)) { # set water depth from data base |
1347 |
error("$0: lat/lon required for running $water_depth_db_cmd\n") |
|
1348 |
unless numbersp($P{lat},$P{lon}); |
|
1349 |
chomp($water_depth = `$water_depth_db_cmd $P{lon} $P{lat}`); |
|
1350 |
error("$0: command '$water_depth_db_cmd $P{lon} $P{lat}' did not return valid water depth\n") |
|
1351 |
unless numberp($water_depth); |
|
1352 |
&antsAddParams('water_depth_from',"$water_depth_db_cmd $P{lon} $P{lat}"); |
|
1353 |
} |
|
1354 |
||
42 | 1355 |
if (defined($water_depth)) { # set %PARAMs |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1356 |
&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
|
1357 |
} else { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1358 |
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
|
1359 |
&antsAddParams('water_depth','unknown','water_depth.sig','nan'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1360 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1361 |
|
42 | 1362 |
if ($LADCP{ENSEMBLE}[$LADCP_atbottom]->{XDUCER_FACING_DOWN}) { # DOWNLOOKER |
41 | 1363 |
&antsAddParams('ADCP_orientation','DL'); |
0 | 1364 |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1365 |
if (defined($water_depth)) { |
0 | 1366 |
progress("Editing data to remove sidelobe interference from seabed...\n"); |
1367 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,$water_depth); |
|
1368 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
|
1369 |
||
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1370 |
if ($sidelobe_editing_DL_surface) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1371 |
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
|
1372 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,undef); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1373 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
34 | 1374 |
&antsAddParams('sidelobe_editing','surface+seabed','vessel_draft',$vessel_draft); |
1375 |
} else { |
|
1376 |
&antsAddParams('sidelobe_editing','seabed'); |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1377 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1378 |
|
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1379 |
# Setting $DEBUG_DL_SURFACE_PPI_EDITING to 1 enables sea-surface PPI editing for |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1380 |
# downlookers (but disabled seabed editing). This was used on 2021 A20 for testing. |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1381 |
|
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1382 |
if ($DEBUG_DL_SURFACE_PPI_EDITING) { |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1383 |
&antsAddParams('PPI_editing','surface'); |
34 | 1384 |
&antsAddParams('PPI_extend_upper_limit',$PPI_extend_upper_limit) |
1385 |
if numberp($PPI_extend_upper_limit); |
|
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1386 |
progress("Editing data to remove PPI from sea surface...\n"); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1387 |
progress("\tConstructing depth-average soundspeed profile...\n"); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1388 |
$DASSprof[0] = my($sum) = 0; |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1389 |
for (my($d)=1; $d<=$#sVelProf; $d++) { |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1390 |
die("assertion failed") unless numberp($sVelProf[$d]); |
48 | 1391 |
$sum += $sVelProf[$d]; |
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1392 |
$DASSprof[$d] = $sum/$d; |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1393 |
} |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1394 |
($nvrm,$nerm) = editPPI($firstGoodEns,$lastGoodEns,undef); |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1395 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
55
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1396 |
} else { |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1397 |
if (&PPI_seabed_editing_required()) { |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1398 |
&antsAddParams('PPI_editing','seabed'); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1399 |
&antsAddParams('PPI_extend_upper_limit',$PPI_extend_upper_limit) |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1400 |
if numberp($PPI_extend_upper_limit); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1401 |
progress("Editing data to remove PPI from seabed...\n"); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1402 |
progress("\tConstructing depth-average soundspeed profile...\n"); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1403 |
die("assertion failed") unless defined($water_depth); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1404 |
my($dz) = $water_depth - $#sVelProf; # $#sVelProf = max_depth(profile) in meters |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1405 |
my($sum) = $dz * $sVelProf[$#sVelProf]; |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1406 |
if ($dz == 0) { # water-depth <= max CTD depth |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1407 |
warning(1,"inferred water depth very close to max(CTD depth)\n"); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1408 |
$DASSprof[$#sVelProf] = $sVelProf[$#sVelProf]; |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1409 |
} else { |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1410 |
die("assertion failed") unless defined($dz > 0); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1411 |
$DASSprof[$#sVelProf] = $sum/$dz; |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1412 |
} |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1413 |
for (my($d)=$#sVelProf-1; $d>=0; $d--) { |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1414 |
die("assertion failed (d=$d, #sVelProf=$#sVelProf)") unless numberp($sVelProf[$d]); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1415 |
$sum += $sVelProf[$d]; |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1416 |
$dz++; |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1417 |
$DASSprof[$d] = $sum/$dz; |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1418 |
} |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1419 |
($nvrm,$nerm) = editPPI($firstGoodEns,$lastGoodEns,$water_depth); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1420 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
2d8e1139acd5
adapted to Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
54
diff
changeset
|
1421 |
} |
16
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1422 |
} |
0 | 1423 |
} |
1424 |
||
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1425 |
} else { # UPLOOKER |
41 | 1426 |
&antsAddParams('ADCP_orientation','UL'); |
15 | 1427 |
|
0 | 1428 |
progress("Editing data to remove sidelobe interference from sea surface...\n"); |
1429 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,undef); |
|
1430 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
|
15 | 1431 |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1432 |
if ($sidelobe_editing_UL_seabed) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1433 |
if (defined($water_depth)) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1434 |
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
|
1435 |
($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,$water_depth); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1436 |
progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1437 |
} else { |
51
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
1438 |
# WARNING ALREADY PRODUCED ABOVE |
0f6d9e64cc4f
before adding dropped-scan correction to LADCP_w_CTD
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
49
diff
changeset
|
1439 |
# warning(2,"unknown water depth --- cannot edit UL data for sidelobe interference from seabed\n"); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
1440 |
} |
34 | 1441 |
&antsAddParams('sidelobe_editing','surface+seabed','vessel_draft',$vessel_draft); |
1442 |
} else { |
|
1443 |
&antsAddParams('sidelobe_editing','surface','vessel_draft',$vessel_draft); |
|
1444 |
} |
|
49 | 1445 |
if (&PPI_surface_editing_required()) { |
34 | 1446 |
&antsAddParams('PPI_editing','surface'); |
1447 |
&antsAddParams('PPI_extend_upper_limit',$PPI_extend_upper_limit) |
|
1448 |
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
|
1449 |
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
|
1450 |
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
|
1451 |
$DASSprof[0] = my($sum) = 0; |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1452 |
for (my($d)=1; $d<=$#sVelProf; $d++) { |
19 | 1453 |
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
|
1454 |
$sum += $sVelProf[$d]; |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1455 |
$DASSprof[$d] = $sum/$d; |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1456 |
} |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1457 |
($nvrm,$nerm) = editPPI($firstGoodEns,$lastGoodEns,undef); |
29e867b3e070
whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
15
diff
changeset
|
1458 |
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
|
1459 |
} |
0 | 1460 |
} |
1461 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1462 |
#---------------------------------------------------------------------- |
49 | 1463 |
# Check For Ambiguity Velocity Problems |
1464 |
#---------------------------------------------------------------------- |
|
1465 |
||
1466 |
progress("Checking for ambiguity velocity violations...\n"); |
|
1467 |
||
1468 |
my($ambiguity_velocity) = ambiguity_velocity($LADCP{BEAM_FREQUENCY}, |
|
1469 |
$LADCP{BEAM_ANGLE}, |
|
1470 |
$LADCP{SPEED_OF_SOUND}, |
|
1471 |
$LADCP{TRANSMIT_LAG_DISTANCE}); |
|
1472 |
&antsAddParams('ambiguity_velocity',$ambiguity_velocity); |
|
1473 |
my($nbad) = 0; |
|
1474 |
for (my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
|
1475 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
1476 |
next unless ($CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}] > $ambiguity_velocity); |
|
1477 |
$nbad++; |
|
1478 |
} |
|
1479 |
||
1480 |
my($badf) = $nbad / ($lastGoodEns - $firstGoodEns + 1); # fraction of bad values |
|
1481 |
if ($bad > 0.01) { # allow 1% violations before warning is triggered |
|
1482 |
warning(2,"%d ensembles (%d%% of total) have CTD_w > ambiguity velocity of %.1 m/s\n", |
|
1483 |
$nbad,round(100*$badf),$ambiguity_velocity); |
|
1484 |
} elsif ($nbad > 0) { |
|
1485 |
info("\t%d ensembles (%d%% of total) have CTD_w > ambiguity velocity of %.1 m/s", |
|
1486 |
$nbad,round(100*$badf),$ambiguity_velocity); |
|
1487 |
} else { |
|
1488 |
info("\tnone found\n"); |
|
1489 |
} |
|
1490 |
||
1491 |
#---------------------------------------------------------------------- |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1492 |
# 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
|
1493 |
# 1) surface layer editing |
49 | 1494 |
# 2) reference-layer horizontal velocity threshold |
1495 |
# 3) Execute 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
|
1496 |
#---------------------------------------------------------------------- |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1497 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1498 |
progress("Removing data from instrument at surface...\n"); |
34 | 1499 |
&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
|
1500 |
$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
|
1501 |
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
|
1502 |
|
49 | 1503 |
progress("Removing data collected at large horizontal package speeds...\n"); |
1504 |
$max_hspeed = &max_hspeed(); # defined in [defaults.h] |
|
1505 |
&antsAddParams('max_hspeed',$max_hspeed); |
|
1506 |
$nerm = editLargeHSpeeds($firstGoodEns,$lastGoodEns,$max_hspeed); |
|
1507 |
my($nermf) = $nerm / ($lastGoodEns - $firstGoodEns + 1); |
|
1508 |
info("\treference-layer horizontal speed threshold (max_hspeed = %g m/s): %d ensembles removed (%d%% of total)\n", |
|
1509 |
$max_hspeed,$nerm,round(100*$nermf)); |
|
1510 |
warning(2,"large fraction (%d%%) of samples exceed reference-layer horizontal speed threshold\n",round(100*$nermf)) |
|
1511 |
if ($nermf > 0.05); |
|
1512 |
||
11 | 1513 |
if (defined($post_merge_hook)) { |
1514 |
progress("Executing user-supplied \$post_merge_hook...\n"); |
|
1515 |
&{$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
|
1516 |
} |
7e76fdef8953
version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
6
diff
changeset
|
1517 |
|
13 | 1518 |
#---------------------------------------------------------------------- |
1519 |
# apply pressure-sensor acceleration correction (-a) |
|
1520 |
# - valid, but useless except for troubleshooting data sets (e.g. DIMES UK2) |
|
1521 |
# - useless, because ping-coherent error removal below does same job but better |
|
1522 |
# - it does not make sense to to use this with ping-coherent error removal enabled |
|
1523 |
#---------------------------------------------------------------------- |
|
1524 |
||
1525 |
if ($opt_a != 1) { |
|
1526 |
progress("Applying pressure-sensor acceleration correction...\n"); |
|
1527 |
for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
|
1528 |
next unless numberp($CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1529 |
my($acorr) = $opt_a * $CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
|
1530 |
if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH})) { |
|
1531 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
1532 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
1533 |
$LADCP{ENSEMBLE}[$ens]->{W}[$bin] -= $acorr; |
|
1534 |
} |
|
1535 |
} |
|
1536 |
if (numberp($LADCP{ENSEMBLE}[$ens]->{REFLR_W})) { |
|
1537 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W} -= $acorr; |
|
1538 |
} |
|
1539 |
} |
|
1540 |
} |
|
1541 |
||
0 | 1542 |
#--------------------------------------------------------------------------- |
1543 |
# Depth-bin LADCP velocity data |
|
1544 |
# |
|
1545 |
# NOTES: |
|
1546 |
# 1) ensemble and bin numbers are saved for maximum flexibility |
|
1547 |
# 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
|
1548 |
# 3) applying the full soundspeed correction to w is pointless in |
0 | 1549 |
# practice, but hey!, CPU cycles are cheap; [in a cast in the Gulf of Mexico |
1550 |
# which has fairly pronounce soundspeed gradients, the max value of Kn |
|
1551 |
# is 1.00004160558372, which gives rise to a correction of less than 0.2mm/s |
|
1552 |
# at a winch+wave speed of 3m/s....] |
|
1553 |
# 4) as far as I can tell, the soundspeed correction for bin length also |
|
1554 |
# has only a minute effect |
|
1555 |
#--------------------------------------------------------------------------- |
|
1556 |
||
13 | 1557 |
progress("Creating binned profiles at ${opt_o}m resolution...\n"); |
30 | 1558 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1559 |
&antsAddParams('outgrid_dz',$opt_o,'outgrid_minsamp',$opt_k); # used by LADCP_w_postproc |
30 | 1560 |
&antsAddParams('outgrid_firstbin',$outGrid_firstBin,'outgrid_lastbin',$outGrid_lastBin); |
0 | 1561 |
|
2 | 1562 |
my($min_depth) = 9e99; |
1563 |
my($max_depth) = 0; |
|
30 | 1564 |
local($realLastGoodEns); |
2 | 1565 |
|
0 | 1566 |
progress("\tdowncast...\n"); |
1567 |
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
|
1568 |
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
|
1569 |
$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
|
1570 |
next; |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1571 |
} |
29 | 1572 |
$realLastGoodEns = $ens; |
46 | 1573 |
my(@bindepth) = binDepths($ens); |
0 | 1574 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
1575 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
30 | 1576 |
next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1); |
2 | 1577 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
1578 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
1579 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] = |
|
54 | 1580 |
sscorr_LADCP_w($LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
0 | 1581 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1582 |
$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}, |
0 | 1583 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
1584 |
$bindepth[$bin]); |
|
6 | 1585 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] = |
54 | 1586 |
sscorr_LADCP_w($LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
6 | 1587 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1588 |
$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}, |
6 | 1589 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
1590 |
$bindepth[$bin]) |
|
1591 |
if numberp($LADCP{ENSEMBLE}[$ens]->{W12}[$bin]); |
|
1592 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] = |
|
54 | 1593 |
sscorr_LADCP_w($LADCP{ENSEMBLE}[$ens]->{W34}[$bin], |
6 | 1594 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1595 |
$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}, |
6 | 1596 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
1597 |
$bindepth[$bin]) |
|
1598 |
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
|
1599 |
$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
|
1600 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] + $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
54 | 1601 |
$LADCP{ENSEMBLE}[$ens]->{V12}[$bin] *= $CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]/$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND} |
1602 |
if defined($LADCP{ENSEMBLE}[$ens]->{V12}[$bin]); |
|
1603 |
$LADCP{ENSEMBLE}[$ens]->{V34}[$bin] *= $CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]/$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND} |
|
1604 |
if defined($LADCP{ENSEMBLE}[$ens]->{V34}[$bin]); |
|
13 | 1605 |
my($bi) = $bindepth[$bin]/$opt_o; |
0 | 1606 |
push(@{$DNCAST{ENSEMBLE}[$bi]},$ens); |
1607 |
push(@{$DNCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1608 |
push(@{$DNCAST{DEPTH}[$bi]},$bindepth[$bin]); |
|
2 | 1609 |
push(@{$DNCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
54 | 1610 |
push(@{$DNCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]) |
1611 |
if defined($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
1612 |
push(@{$DNCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]) |
|
1613 |
if defined($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
1614 |
push(@{$DNCAST{V12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{V12}[$bin]) |
|
1615 |
if defined($LADCP{ENSEMBLE}[$ens]->{V12}[$bin]); |
|
1616 |
push(@{$DNCAST{V34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{V34}[$bin]) |
|
1617 |
if defined($LADCP{ENSEMBLE}[$ens]->{V34}[$bin]); |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1618 |
push(@{$DNCAST{PITCH}[$bi]},$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH}); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1619 |
push(@{$DNCAST{ROLL}[$bi]},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
56 | 1620 |
push(@{$DNCAST{TILT}[$bi]},$LADCP{ENSEMBLE}[$ens]->{TILT}); |
0 | 1621 |
} |
1622 |
} |
|
1623 |
||
6 | 1624 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { # bin data into profile |
0 | 1625 |
$DNCAST{MEAN_DEPTH}[$bi] = avg(@{$DNCAST{DEPTH}[$bi]}); |
1626 |
$DNCAST{MEAN_ELAPSED}[$bi] = avg(@{$DNCAST{ELAPSED}[$bi]}); |
|
1627 |
$DNCAST{MEDIAN_W}[$bi] = median(@{$DNCAST{W}[$bi]}); |
|
13 | 1628 |
$DNCAST{MEDIAN_W12}[$bi] = median(@{$DNCAST{W12}[$bi]}); |
1629 |
$DNCAST{MEDIAN_W34}[$bi] = median(@{$DNCAST{W34}[$bi]}); |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1630 |
$DNCAST{MEDIAN_V12}[$bi] = median(@{$DNCAST{V12}[$bi]}); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1631 |
$DNCAST{MEDIAN_V34}[$bi] = median(@{$DNCAST{V34}[$bi]}); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1632 |
$DNCAST{MEAN_PITCH}[$bi] = avg(@{$DNCAST{PITCH}[$bi]}); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1633 |
$DNCAST{MEAN_ROLL}[$bi] = avg(@{$DNCAST{ROLL}[$bi]}); |
56 | 1634 |
$DNCAST{MEAN_TILT}[$bi] = avg(@{$DNCAST{TILT}[$bi]}); |
0 | 1635 |
$DNCAST{MAD_W}[$bi] = mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]}); |
1636 |
$DNCAST{N_SAMP}[$bi] = @{$DNCAST{W}[$bi]}; |
|
1637 |
} |
|
1638 |
||
2 | 1639 |
progress("\tupcast...\n"); # upcast |
0 | 1640 |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1641 |
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) { |
0 | 1642 |
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
|
1643 |
$realLastGoodEns = $ens; |
46 | 1644 |
my(@bindepth) = binDepths($ens); |
0 | 1645 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
1646 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
30 | 1647 |
next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1); |
2 | 1648 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
1649 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
1650 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] = |
|
54 | 1651 |
sscorr_LADCP_w($LADCP{ENSEMBLE}[$ens]->{W}[$bin], |
0 | 1652 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1653 |
$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}, |
0 | 1654 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
1655 |
$bindepth[$bin]); |
|
6 | 1656 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] = |
54 | 1657 |
sscorr_LADCP_w($LADCP{ENSEMBLE}[$ens]->{W12}[$bin], |
6 | 1658 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1659 |
$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}, |
6 | 1660 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
1661 |
$bindepth[$bin]) |
|
1662 |
if numberp($LADCP{ENSEMBLE}[$ens]->{W12}[$bin]); |
|
1663 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] = |
|
54 | 1664 |
sscorr_LADCP_w($LADCP{ENSEMBLE}[$ens]->{W34}[$bin], |
6 | 1665 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1666 |
$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}, |
6 | 1667 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
1668 |
$bindepth[$bin]) |
|
1669 |
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
|
1670 |
$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
|
1671 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] + $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]; |
54 | 1672 |
$LADCP{ENSEMBLE}[$ens]->{V12}[$bin] *= $CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]/$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND} |
1673 |
if defined($LADCP{ENSEMBLE}[$ens]->{V12}[$bin]); |
|
1674 |
$LADCP{ENSEMBLE}[$ens]->{V34}[$bin] *= $CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]/$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND} |
|
1675 |
if defined($LADCP{ENSEMBLE}[$ens]->{V34}[$bin]); |
|
13 | 1676 |
my($bi) = $bindepth[$bin]/$opt_o; |
0 | 1677 |
push(@{$UPCAST{ENSEMBLE}[$bi]},$ens); |
1678 |
push(@{$UPCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1679 |
push(@{$UPCAST{DEPTH}[$bi]},$bindepth[$bin]); |
|
2 | 1680 |
push(@{$UPCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
54 | 1681 |
push(@{$UPCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]) |
1682 |
if defined($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
1683 |
push(@{$UPCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]) |
|
1684 |
if defined($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
1685 |
push(@{$UPCAST{V12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{V12}[$bin]) |
|
1686 |
if defined($LADCP{ENSEMBLE}[$ens]->{V12}[$bin]); |
|
1687 |
push(@{$UPCAST{V34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{V34}[$bin]) |
|
1688 |
if defined($LADCP{ENSEMBLE}[$ens]->{V34}[$bin]); |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1689 |
push(@{$UPCAST{PITCH}[$bi]},$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH}); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1690 |
push(@{$UPCAST{ROLL}[$bi]},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
56 | 1691 |
push(@{$UPCAST{TILT}[$bi]},$LADCP{ENSEMBLE}[$ens]->{TILT}); |
0 | 1692 |
} |
1693 |
} |
|
1694 |
||
1695 |
for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) { |
|
1696 |
$UPCAST{MEAN_DEPTH}[$bi] = avg(@{$UPCAST{DEPTH}[$bi]}); |
|
1697 |
$UPCAST{MEAN_ELAPSED}[$bi] = avg(@{$UPCAST{ELAPSED}[$bi]}); |
|
1698 |
$UPCAST{MEDIAN_W}[$bi] = median(@{$UPCAST{W}[$bi]}); |
|
13 | 1699 |
$UPCAST{MEDIAN_W12}[$bi] = median(@{$UPCAST{W12}[$bi]}); |
1700 |
$UPCAST{MEDIAN_W34}[$bi] = median(@{$UPCAST{W34}[$bi]}); |
|
54 | 1701 |
$UPCAST{MEDIAN_V12}[$bi] = median(@{$UPCAST{V12}[$bi]}); |
1702 |
$UPCAST{MEDIAN_V34}[$bi] = median(@{$UPCAST{V34}[$bi]}); |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1703 |
$UPCAST{MEAN_PITCH}[$bi] = avg(@{$UPCAST{PITCH}[$bi]}); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1704 |
$UPCAST{MEAN_ROLL}[$bi] = avg(@{$UPCAST{ROLL}[$bi]}); |
56 | 1705 |
$UPCAST{MEAN_TILT}[$bi] = avg(@{$UPCAST{TILT}[$bi]}); |
0 | 1706 |
$UPCAST{MAD_W}[$bi] = mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]}); |
1707 |
$UPCAST{N_SAMP}[$bi] = @{$UPCAST{W}[$bi]}; |
|
1708 |
} |
|
1709 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1710 |
#------------------------------------------------------------------------------------------------------ |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1711 |
# 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
|
1712 |
# - potential error sources: |
13 | 1713 |
# 1) acceleration-dependence of Paroscientific pressure measurements; O(10cm/s) [IWISE 28] |
1714 |
# 2) residual CTD/LADCP mismatch errors; O(1cm/s) [Thurnherr, CWTMC 2011] |
|
1715 |
# 3) ADCP short-term variability; O(1cm/s) for vertical? |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1716 |
# - multiple sub-steps: |
13 | 1717 |
# - remove ensemble-median residual from all ocean vertical velocities |
1718 |
# - re-bin profiles |
|
1719 |
# - 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
|
1720 |
# - 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
|
1721 |
# 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
|
1722 |
#------------------------------------------------------------------------------------------------------ |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1723 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1724 |
unless ($opt_q) { |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1725 |
progress("Subtracting 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
|
1726 |
|
13 | 1727 |
for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
1728 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
11 | 1729 |
|
13 | 1730 |
my(@residuals) = (); # calc median of residuals |
46 | 1731 |
my(@bindepth) = binDepths($ens); |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1732 |
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
|
1733 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
30 | 1734 |
next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1); |
13 | 1735 |
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
|
1736 |
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
|
1737 |
$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
|
1738 |
(($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
|
1739 |
: $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
|
1740 |
} |
13 | 1741 |
$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
|
1742 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W}); |
13 | 1743 |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1744 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { # subtract 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
|
1745 |
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
|
1746 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] -= |
49 | 1747 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} |
1748 |
if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
|
13 | 1749 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] -= |
49 | 1750 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} |
1751 |
if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
13 | 1752 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] -= |
49 | 1753 |
$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} |
1754 |
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
|
1755 |
} |
13 | 1756 |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
1757 |
$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
|
1758 |
$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
|
1759 |
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
|
1760 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1761 |
|
13 | 1762 |
#------------------------------------------------------------ |
1763 |
||
1764 |
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
|
1765 |
|
13 | 1766 |
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
|
1767 |
for (my($i)=0; $i<@{$DNCAST{W}[$bi]}; $i++) { # code works if MEDIAN_RESIDUAL_W is nan (possible?) |
49 | 1768 |
$DNCAST{W} [$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W} |
1769 |
if numberp($DNCAST{W}[$bi][$i]); |
|
1770 |
$DNCAST{W12}[$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W} |
|
1771 |
if numberp($DNCAST{W12}[$bi][$i]); |
|
1772 |
$DNCAST{W34}[$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W} |
|
1773 |
if numberp($DNCAST{W34}[$bi][$i]); |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1774 |
} |
49 | 1775 |
$DNCAST{MEDIAN_W} [$bi] = median(@{$DNCAST{W}[$bi]}) if numberp($DNCAST{MEDIAN_W} [$bi]); |
1776 |
$DNCAST{MEDIAN_W12}[$bi] = median(@{$DNCAST{W12}[$bi]}) if numberp($DNCAST{MEDIAN_W12}[$bi]); |
|
1777 |
$DNCAST{MEDIAN_W34}[$bi] = median(@{$DNCAST{W34}[$bi]}) if numberp($DNCAST{MEDIAN_W34}[$bi]); |
|
13 | 1778 |
$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
|
1779 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1780 |
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
|
1781 |
for (my($i)=0; $i<@{$UPCAST{W}[$bi]}; $i++) { |
49 | 1782 |
$UPCAST{W} [$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W} |
1783 |
if numberp($UPCAST{W}[$bi][$i]); |
|
1784 |
$UPCAST{W12}[$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W} |
|
1785 |
if numberp($UPCAST{W12}[$bi][$i]); |
|
1786 |
$UPCAST{W34}[$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W} |
|
1787 |
if numberp($UPCAST{W34}[$bi][$i]); |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1788 |
} |
49 | 1789 |
$UPCAST{MEDIAN_W} [$bi] = median(@{$UPCAST{W}[$bi]}) if numberp($UPCAST{MEDIAN_W} [$bi]); |
1790 |
$UPCAST{MEDIAN_W12}[$bi] = median(@{$UPCAST{W12}[$bi]}) if numberp($UPCAST{MEDIAN_W12}[$bi]); |
|
1791 |
$UPCAST{MEDIAN_W34}[$bi] = median(@{$UPCAST{W34}[$bi]}) if numberp($UPCAST{MEDIAN_W34}[$bi]); |
|
13 | 1792 |
$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
|
1793 |
} |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1794 |
|
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
1795 |
} # unless ($opt_q); |
2 | 1796 |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1797 |
#-------------------------------- |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1798 |
# Add Sv to depth-binned profiles |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1799 |
#-------------------------------- |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1800 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1801 |
progress("Binning Sv into depth profiles..."); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1802 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1803 |
my(@dc_nSv); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1804 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1805 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1806 |
my(@bindepth) = binDepths($ens); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1807 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1808 |
next unless ($bin+1>=$outGrid_firstBin && $bin+1<=$outGrid_lastBin); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1809 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1810 |
my($bi) = $bindepth[$bin]/$opt_o; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1811 |
next unless ($DNCAST{N_SAMP}[$bi]>=$opt_k) && numberp($DNCAST{MEDIAN_W}[$bi]); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1812 |
$DNCAST{SV}[$bi] += $LADCP{ENSEMBLE}[$ens]->{SV}[$bin]; $dc_nSv[$bi]++; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1813 |
} |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1814 |
} |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1815 |
my(@uc_nSv); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1816 |
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) { |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1817 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1818 |
my(@bindepth) = binDepths($ens); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1819 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1820 |
next unless ($bin+1>=$outGrid_firstBin && $bin+1<=$outGrid_lastBin); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1821 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1822 |
my($bi) = $bindepth[$bin]/$opt_o; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1823 |
next unless ($UPCAST{N_SAMP}[$bi]>=$opt_k) && numberp($UPCAST{MEDIAN_W}[$bi]); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1824 |
$UPCAST{SV}[$bi] += $LADCP{ENSEMBLE}[$ens]->{SV}[$bin]; $uc_nSv[$bi]++; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1825 |
} |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1826 |
} |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1827 |
for (my($bi)=0; $bi<=max($#{$DNCAST{ENSEMBLE}},$#{$UPCAST{ENSEMBLE}}); $bi++) { |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1828 |
$DNCAST{SV}[$bi] = $dc_nSv[$bi] ? ($DNCAST{SV}[$bi]/$dc_nSv[$bi]) : nan; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1829 |
$UPCAST{SV}[$bi] = $uc_nSv[$bi] ? ($UPCAST{SV}[$bi]/$uc_nSv[$bi]) : nan; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1830 |
} |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1831 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1832 |
progress("\n"); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1833 |
|
42 | 1834 |
#---------------------------------------------------------------------- |
1835 |
# remove ensembles with large rms residuals |
|
1836 |
#---------------------------------------------------------------------- |
|
1837 |
||
49 | 1838 |
if (defined($opt_r) && !$opt_q) { |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1839 |
progress("Applying residuals filters...\n"); |
42 | 1840 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1841 |
progress("\trms residuals > $residuals_rms_max: "); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1842 |
my($nerm) = editResiduals_rmsMax($firstGoodEns,$lastGoodEns,$residuals_rms_max); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1843 |
progress("$nerm ensembles removed (%d%% of total)\n",round(100*$nerm/($lastGoodEns-$firstGoodEns+1))); |
42 | 1844 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1845 |
if (defined($residuals_delta_max)) { # filter based on difference between |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1846 |
progress("\tbeampair residuals difference > $residuals_delta_max [m/s]: "); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1847 |
my($nvrm) = editResiduals_deltaMax($firstGoodEns,$lastGoodEns,$residuals_delta_max); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
1848 |
progress("$nvrm velocities removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n",round(100*$nvrm/$nvw)); |
42 | 1849 |
} |
1850 |
||
1851 |
progress("\tre-binning profile data...\n"); |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1852 |
foreach my $k (keys(%DNCAST)) { # keep Sv profiles |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1853 |
next if ($k eq 'SV'); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1854 |
undef($DNCAST{$k}); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1855 |
undef($UPCAST{$k}); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1856 |
} |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1857 |
|
42 | 1858 |
$min_depth = 9e99; my($max_depth) = 0; |
1859 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { # downcast |
|
1860 |
unless (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH})) { |
|
1861 |
$firstGoodEns++ if ($ens == $firstGoodEns); # start has been edited away |
|
1862 |
next; |
|
1863 |
} |
|
1864 |
$realLastGoodEns = $ens; |
|
46 | 1865 |
my(@bindepth) = binDepths($ens); |
42 | 1866 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
1867 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
1868 |
next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1); |
|
1869 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
|
1870 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
1871 |
my($bi) = $bindepth[$bin]/$opt_o; |
|
1872 |
push(@{$DNCAST{ENSEMBLE}[$bi]},$ens); |
|
1873 |
push(@{$DNCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1874 |
push(@{$DNCAST{DEPTH}[$bi]},$bindepth[$bin]); |
|
1875 |
push(@{$DNCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
|
54 | 1876 |
push(@{$DNCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]) |
1877 |
if defined($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
1878 |
push(@{$DNCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]) |
|
1879 |
if defined($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
1880 |
push(@{$DNCAST{V12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{V12}[$bin]) |
|
1881 |
if defined($LADCP{ENSEMBLE}[$ens]->{V12}[$bin]); |
|
1882 |
push(@{$DNCAST{V34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{V34}[$bin]) |
|
1883 |
if defined($LADCP{ENSEMBLE}[$ens]->{V34}[$bin]); |
|
1884 |
push(@{$DNCAST{PITCH}[$bi]},$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH}); |
|
1885 |
push(@{$DNCAST{ROLL}[$bi]},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
|
56 | 1886 |
push(@{$DNCAST{TILT}[$bi]},$LADCP{ENSEMBLE}[$ens]->{TILT}); |
42 | 1887 |
} |
1888 |
} |
|
1889 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { # bin data into profile |
|
1890 |
$DNCAST{MEAN_DEPTH}[$bi] = avg(@{$DNCAST{DEPTH}[$bi]}); |
|
1891 |
$DNCAST{MEAN_ELAPSED}[$bi] = avg(@{$DNCAST{ELAPSED}[$bi]}); |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1892 |
$DNCAST{MIN_ELAPSED}[$bi] = min(@{$DNCAST{ELAPSED}[$bi]}); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1893 |
$DNCAST{MAX_ELAPSED}[$bi] = max(@{$DNCAST{ELAPSED}[$bi]}); |
42 | 1894 |
$DNCAST{MEDIAN_W}[$bi] = median(@{$DNCAST{W}[$bi]}); |
1895 |
$DNCAST{MEDIAN_W12}[$bi] = median(@{$DNCAST{W12}[$bi]}); |
|
1896 |
$DNCAST{MEDIAN_W34}[$bi] = median(@{$DNCAST{W34}[$bi]}); |
|
54 | 1897 |
$DNCAST{MEDIAN_V12}[$bi] = median(@{$DNCAST{V12}[$bi]}); |
1898 |
$DNCAST{MEDIAN_V34}[$bi] = median(@{$DNCAST{V34}[$bi]}); |
|
1899 |
$DNCAST{MEAN_PITCH}[$bi] = avg(@{$DNCAST{PITCH}[$bi]}); |
|
1900 |
$DNCAST{MEAN_ROLL}[$bi] = avg(@{$DNCAST{ROLL}[$bi]}); |
|
56 | 1901 |
$DNCAST{MEAN_TILT}[$bi] = avg(@{$DNCAST{TILT}[$bi]}); |
42 | 1902 |
$DNCAST{MAD_W}[$bi] = mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]}); |
1903 |
$DNCAST{N_SAMP}[$bi] = @{$DNCAST{W}[$bi]}; |
|
1904 |
} |
|
1905 |
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) { |
|
1906 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
1907 |
$realLastGoodEns = $ens; |
|
46 | 1908 |
my(@bindepth) = binDepths($ens); |
42 | 1909 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
1910 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
1911 |
next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1); |
|
1912 |
$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth); |
|
1913 |
$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth); |
|
1914 |
my($bi) = $bindepth[$bin]/$opt_o; |
|
1915 |
push(@{$UPCAST{ENSEMBLE}[$bi]},$ens); |
|
1916 |
push(@{$UPCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]); |
|
1917 |
push(@{$UPCAST{DEPTH}[$bi]},$bindepth[$bin]); |
|
1918 |
push(@{$UPCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]); |
|
54 | 1919 |
push(@{$UPCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]) |
1920 |
if defined($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
1921 |
push(@{$UPCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]) |
|
1922 |
if defined($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
1923 |
push(@{$UPCAST{V12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{V12}[$bin]) |
|
1924 |
if defined($LADCP{ENSEMBLE}[$ens]->{V12}[$bin]); |
|
1925 |
push(@{$UPCAST{V34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{V34}[$bin]) |
|
1926 |
if defined($LADCP{ENSEMBLE}[$ens]->{V34}[$bin]); |
|
1927 |
push(@{$UPCAST{PITCH}[$bi]},$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH}); |
|
56 | 1928 |
push(@{$UPCAST{ROLL}<[$bi]},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
1929 |
push(@{$UPCAST{TILT}[$bi]},$LADCP{ENSEMBLE}[$ens]->{TILT}); |
|
42 | 1930 |
} |
1931 |
} |
|
1932 |
for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) { |
|
1933 |
$UPCAST{MEAN_DEPTH}[$bi] = avg(@{$UPCAST{DEPTH}[$bi]}); |
|
1934 |
$UPCAST{MEAN_ELAPSED}[$bi] = avg(@{$UPCAST{ELAPSED}[$bi]}); |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1935 |
$UPCAST{MIN_ELAPSED}[$bi] = min(@{$UPCAST{ELAPSED}[$bi]}); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1936 |
$UPCAST{MAX_ELAPSED}[$bi] = max(@{$UPCAST{ELAPSED}[$bi]}); |
42 | 1937 |
$UPCAST{MEDIAN_W}[$bi] = median(@{$UPCAST{W}[$bi]}); |
1938 |
$UPCAST{MEDIAN_W12}[$bi] = median(@{$UPCAST{W12}[$bi]}); |
|
1939 |
$UPCAST{MEDIAN_W34}[$bi] = median(@{$UPCAST{W34}[$bi]}); |
|
54 | 1940 |
$UPCAST{MEDIAN_V12}[$bi] = median(@{$UPCAST{V12}[$bi]}); |
1941 |
$UPCAST{MEDIAN_V34}[$bi] = median(@{$UPCAST{V34}[$bi]}); |
|
1942 |
$UPCAST{MEAN_PITCH}[$bi] = avg(@{$UPCAST{PITCH}[$bi]}); |
|
1943 |
$UPCAST{MEAN_ROLL}[$bi] = avg(@{$UPCAST{ROLL}[$bi]}); |
|
56 | 1944 |
$UPCAST{MEAN_TILT}[$bi] = avg(@{$UPCAST{TILT}[$bi]}); |
42 | 1945 |
$UPCAST{MAD_W}[$bi] = mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]}); |
1946 |
$UPCAST{N_SAMP}[$bi] = @{$UPCAST{W}[$bi]}; |
|
1947 |
} |
|
1948 |
} # if defined($opt_r) |
|
1949 |
||
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1950 |
$lastGoodEns = $realLastGoodEns; # now the ensemble range is final |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1951 |
|
56 | 1952 |
&antsAddParams('depth.min',$min_depth,'depth.max',$max_depth, # plot range limits |
1953 |
'ens.min',$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER}, |
|
1954 |
'ens.max',$LADCP{ENSEMBLE}[$lastGoodEns]->{NUMBER}, |
|
1955 |
'elapsed.min',$LADCP{ENSEMBLE}[$firstGoodEns]->{CTD_ELAPSED}, |
|
1956 |
'elapsed.max',$LADCP{ENSEMBLE}[$lastGoodEns]->{CTD_ELAPSED}); |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1957 |
|
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1958 |
#----------------------------------------------- |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1959 |
# Add residuals to depth-binned profiles (wprof) |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1960 |
#----------------------------------------------- |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1961 |
|
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1962 |
progress("Binning vertical-velocity residuals into depth profiles..."); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
1963 |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1964 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1965 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
46 | 1966 |
my(@bindepth) = binDepths($ens); |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1967 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1968 |
next unless ($bin+1>=$outGrid_firstBin && $bin+1<=$outGrid_lastBin); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1969 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1970 |
my($bi) = $bindepth[$bin]/$opt_o; |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1971 |
next unless numberp($DNCAST{MEDIAN_W}[$bi]); |
49 | 1972 |
push(@{$DNCAST{RESIDUAL12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]-$DNCAST{MEDIAN_W}[$bi]) |
1973 |
if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
1974 |
push(@{$DNCAST{RESIDUAL34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]-$DNCAST{MEDIAN_W}[$bi]) |
|
1975 |
if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1976 |
} |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1977 |
} |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1978 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1979 |
$DNCAST{MEAN_RESIDUAL12}[$bi] = avg(@{$DNCAST{RESIDUAL12}[$bi]}); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1980 |
$DNCAST{MEAN_RESIDUAL34}[$bi] = avg(@{$DNCAST{RESIDUAL34}[$bi]}); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1981 |
} |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1982 |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
1983 |
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) { # rms beampair residual in 5-bin-thick layers |
56 | 1984 |
$DNCAST{LR_RMS_BP_RESIDUAL}[$bi] = |
1985 |
rms(@{$DNCAST{MEAN_RESIDUAL12}}[max(0,$bi-2)..min($#{$DNCAST{ENSEMBLE}},$bi+2)], |
|
1986 |
@{$DNCAST{MEAN_RESIDUAL34}}[max(0,$bi-2)..min($#{$DNCAST{ENSEMBLE}},$bi+2)]); |
|
1987 |
} |
|
1988 |
||
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1989 |
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) { |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1990 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
46 | 1991 |
my(@bindepth) = binDepths($ens); |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1992 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1993 |
next unless ($bin+1>=$outGrid_firstBin && $bin+1<=$outGrid_lastBin); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1994 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1995 |
my($bi) = $bindepth[$bin]/$opt_o; |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
1996 |
next unless numberp($UPCAST{MEDIAN_W}[$bi]); |
49 | 1997 |
push(@{$UPCAST{RESIDUAL12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]-$UPCAST{MEDIAN_W}[$bi]) |
1998 |
if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]); |
|
1999 |
push(@{$UPCAST{RESIDUAL34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]-$UPCAST{MEDIAN_W}[$bi]) |
|
2000 |
if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]); |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2001 |
} |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2002 |
} |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2003 |
for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) { |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2004 |
$UPCAST{MEAN_RESIDUAL12}[$bi] = avg(@{$UPCAST{RESIDUAL12}[$bi]}); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2005 |
$UPCAST{MEAN_RESIDUAL34}[$bi] = avg(@{$UPCAST{RESIDUAL34}[$bi]}); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2006 |
} |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2007 |
|
56 | 2008 |
for (my($bi)=0; $bi<$#{$UPCAST{ENSEMBLE}}; $bi++) { # rms beampair residual in 5-bin-thick layers |
2009 |
$UPCAST{LR_RMS_BP_RESIDUAL}[$bi] = |
|
2010 |
rms(@{$UPCAST{MEAN_RESIDUAL12}}[max(0,$bi-2)..min($#{$UPCAST{ENSEMBLE}},$bi+2)], |
|
2011 |
@{$UPCAST{MEAN_RESIDUAL34}}[max(0,$bi-2)..min($#{$UPCAST{ENSEMBLE}},$bi+2)]); |
|
2012 |
} |
|
2013 |
||
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2014 |
progress("\n"); |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2015 |
|
56 | 2016 |
#----------------------------------------------- |
2017 |
# Apply high-layer-residuals filter |
|
2018 |
#----------------------------------------------- |
|
2019 |
||
2020 |
progress("Applying residuals profile filter...\n"); |
|
2021 |
&antsAddParams('layer_residuals_rms.max',$layer_residuals_rms_max); |
|
2022 |
progress("\t5-bin rms residuals > $layer_residuals_rms_max: "); |
|
2023 |
my($nbrm) = editHighResidualLayers($layer_residuals_rms_max); |
|
2024 |
my($nbrmf) = 0; |
|
2025 |
$nbrmf = $nbrm / (@{$DNCAST{LR_RMS_BP_RESIDUAL}}+@{$UPCAST{LR_RMS_BP_RESIDUAL}}) |
|
2026 |
if ($nbrm > 0); |
|
2027 |
progress("$nbrm bins removed (%d%% of profile)\n",round(100*$nbrmf)); |
|
2028 |
warning(2,"large fraction (%d%%) of profile exceeds residuals-profile threshold\n",round(100*$nbrmf)) |
|
2029 |
if ($nbrmf >= 0.1); |
|
2030 |
||
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2031 |
#----------------------------------------------- |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2032 |
# Apply Sv Seabed Contamination Filter |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2033 |
#----------------------------------------------- |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2034 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2035 |
progress("Applying seabed echo return filter...\n"); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2036 |
&antsAddParams('seabed_contamination_filter_limit',$seabed_contamination_Sv_grad_limit); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2037 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2038 |
my($nbrm) = editSeabedContamination($seabed_contamination_Sv_grad_limit); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2039 |
progress("\t$nbrm depth bins removed\n"); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2040 |
warning(2,"seabed contamination threshold exceeded in a large number of profile bins ($nbrm)\n") |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2041 |
if ($nbrm > 4); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2042 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2043 |
#---------------------------------- |
56 | 2044 |
# Profile is now final |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2045 |
# - calculate <w>, w.var metadata |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2046 |
#---------------------------------- |
56 | 2047 |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2048 |
my($dcw,$ucw,$nw) = (0,0,0); # <w> (vertically averaged) |
56 | 2049 |
for (my($bi)=0; $bi<@{$DNCAST{ENSEMBLE}}; $bi++) { |
2050 |
next unless ($DNCAST{N_SAMP}[$bi]>=$opt_k) && numberp($DNCAST{MEDIAN_W}[$bi]); |
|
2051 |
$dcw += $DNCAST{MEDIAN_W}[$bi]; |
|
2052 |
$nw++; |
|
2053 |
} |
|
2054 |
$dcw = $nw ? ($dcw/$nw) : nan; |
|
2055 |
$nw = 0; |
|
2056 |
for (my($bi)=0; $bi<@{$UPCAST{ENSEMBLE}}; $bi++) { |
|
2057 |
next unless ($UPCAST{N_SAMP}[$bi]>=$opt_k) && numberp($UPCAST{MEDIAN_W}[$bi]); |
|
2058 |
$ucw += $UPCAST{MEDIAN_W}[$bi]; |
|
2059 |
$nw++; |
|
2060 |
} |
|
2061 |
$ucw = $nw ? ($ucw/$nw) : nan; |
|
2062 |
||
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2063 |
my($dcss,$ucss,$nw) = (0,0,0); # variance(w) |
56 | 2064 |
for (my($bi)=0; $bi<@{$DNCAST{ENSEMBLE}}; $bi++) { |
2065 |
next unless ($DNCAST{N_SAMP}[$bi]>=$opt_k) && numberp($DNCAST{MEDIAN_W}[$bi]); |
|
2066 |
$dcss += ($DNCAST{MEDIAN_W}[$bi] - $dcw)**2; |
|
2067 |
$nw++; |
|
2068 |
} |
|
2069 |
$dcss = ($nw > 1) ? ($dcss/$nw) : nan; |
|
2070 |
$nw = 0; |
|
2071 |
for (my($bi)=0; $bi<@{$UPCAST{ENSEMBLE}}; $bi++) { |
|
2072 |
next unless ($UPCAST{N_SAMP}[$bi]>=$opt_k) && numberp($UPCAST{MEDIAN_W}[$bi]); |
|
2073 |
$ucss += ($UPCAST{MEDIAN_W}[$bi] - $ucw)**2; |
|
2074 |
$nw++; |
|
2075 |
} |
|
2076 |
$ucss = ($nw > 1) ? ($ucss/$nw) : nan; |
|
2077 |
||
2078 |
&antsAddParams('dc_w.mu',$dcw,'dc_w.var',$dcss,'uc_w.mu',$ucw,'uc_w.var',$ucss); |
|
2079 |
||
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2080 |
#------------------------------------------------- |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2081 |
# Calculate and Output ADCP-Bin-Averaged Residuals |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2082 |
#------------------------------------------------- |
42 | 2083 |
|
56 | 2084 |
progress("Binning vertical-velocity residuals wrt. ADCP bin number..."); |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
2085 |
|
56 | 2086 |
local(@dc_bres12,@uc_bres12,@dc_bres34,@uc_bres34); |
2087 |
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) { # DOWNCAST |
|
2088 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
2089 |
my(@bindepth) = binDepths($ens); |
|
2090 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
2091 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
2092 |
next unless numberp($DNCAST{MEDIAN_W}[$bindepth[$bin]/$opt_o]); |
|
2093 |
push(@{$dc_bres12[$bin]}, |
|
2094 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] |
|
2095 |
- $DNCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o]) |
|
2096 |
if numberp($DNCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o]); |
|
2097 |
push(@{$dc_bres34[$bin]}, |
|
2098 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] |
|
2099 |
- $DNCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o]) |
|
2100 |
if numberp($DNCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o]); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
2101 |
} |
56 | 2102 |
} |
2103 |
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) { # UPCAST |
|
2104 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
|
2105 |
my(@bindepth) = binDepths($ens); |
|
2106 |
for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
2107 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]); |
|
2108 |
next unless numberp($UPCAST{MEDIAN_W}[$bindepth[$bin]/$opt_o]); |
|
2109 |
push(@{$uc_bres12[$bin]}, |
|
2110 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] |
|
2111 |
- $UPCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o]) |
|
2112 |
if numberp($UPCAST{MEDIAN_W12}[$bindepth[$bin]/$opt_o]); |
|
2113 |
push(@{$uc_bres34[$bin]}, |
|
2114 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] |
|
2115 |
- $UPCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o]) |
|
2116 |
if numberp($UPCAST{MEDIAN_W34}[$bindepth[$bin]/$opt_o]); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
2117 |
} |
56 | 2118 |
} |
2119 |
local(@dc_avg_bres12,@uc_avg_bres12,@dc_avg_bres12_nsamp,@uc_avg_bres12_nsamp); # means/stddevs |
|
2120 |
local(@dc_avg_bres34,@uc_avg_bres34,@dc_avg_bres34_nsamp,@uc_avg_bres34_nsamp); |
|
2121 |
for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
2122 |
$dc_bres12_nsamp[$bin] = @{$dc_bres12[$bin]}; |
|
2123 |
if ($dc_bres12_nsamp[$bin] > 0) { |
|
2124 |
$dc_avg_bres12[$bin] = avg(@{$dc_bres12[$bin]}); |
|
2125 |
$dc_sig_bres12[$bin] = stddev2($dc_avg_bres12[$bin],@{$dc_bres12[$bin]}); |
|
2126 |
} else { |
|
2127 |
$dc_avg_bres12[$bin] = nan; |
|
2128 |
$dc_sig_bres12[$bin] = nan; |
|
30 | 2129 |
} |
56 | 2130 |
$uc_bres12_nsamp[$bin] = @{$uc_bres12[$bin]}; |
2131 |
if ($uc_bres12_nsamp[$bin] > 0) { |
|
2132 |
$uc_avg_bres12[$bin] = avg(@{$uc_bres12[$bin]}); |
|
2133 |
$uc_sig_bres12[$bin] = stddev2($uc_avg_bres12[$bin],@{$uc_bres12[$bin]}); |
|
2134 |
} else { |
|
2135 |
$uc_avg_bres12[$bin] = nan; |
|
2136 |
$uc_sig_bres12[$bin] = nan; |
|
2137 |
} |
|
2138 |
$dc_bres34_nsamp[$bin] = @{$dc_bres34[$bin]}; |
|
2139 |
if ($dc_bres34_nsamp[$bin] > 0) { |
|
2140 |
$dc_avg_bres34[$bin] = avg(@{$dc_bres34[$bin]}); |
|
2141 |
$dc_sig_bres34[$bin] = stddev2($dc_avg_bres34[$bin],@{$dc_bres34[$bin]}); |
|
2142 |
} else { |
|
2143 |
$dc_avg_bres34[$bin] = nan; |
|
2144 |
$dc_sig_bres34[$bin] = nan; |
|
2145 |
} |
|
2146 |
$uc_bres34_nsamp[$bin] = @{$uc_bres34[$bin]}; |
|
2147 |
if ($uc_bres34_nsamp[$bin] > 0) { |
|
2148 |
$uc_avg_bres34[$bin] = avg(@{$uc_bres34[$bin]}); |
|
2149 |
$uc_sig_bres34[$bin] = stddev2($uc_avg_bres34[$bin],@{$uc_bres34[$bin]}); |
|
2150 |
} else { |
|
2151 |
$uc_avg_bres34[$bin] = nan; |
|
2152 |
$uc_sig_bres34[$bin] = nan; |
|
2153 |
} |
|
2154 |
} |
|
30 | 2155 |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2156 |
local($uc_bres12_max_nsamp,$dc_bres12_max_nsamp) = (0,0); # calc rms in block of well sampled bins |
56 | 2157 |
local($uc_bres34_max_nsamp,$dc_bres34_max_nsamp) = (0,0); |
2158 |
for (my($bin)=$LADCP_firstBin; $bin<=$LADCP_lastBin-1; $bin++) { # SKIP 1ST BIN!!! |
|
2159 |
next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin); # skip bins not included in gridded output |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2160 |
$dc_bres12_max_nsamp = $dc_bres12_nsamp[$bin] # nsamp in best sampled bin |
56 | 2161 |
if ($dc_bres12_nsamp[$bin] > $dc_bres12_max_nsamp); |
2162 |
$uc_bres12_max_nsamp = $uc_bres12_nsamp[$bin] |
|
2163 |
if ($uc_bres12_nsamp[$bin] > $uc_bres12_max_nsamp); |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2164 |
$dc_bres34_max_nsamp = $dc_bres34_nsamp[$bin] # nsamp in best sampled bin |
56 | 2165 |
if ($dc_bres34_nsamp[$bin] > $dc_bres34_max_nsamp); |
2166 |
$uc_bres34_max_nsamp = $uc_bres34_nsamp[$bin] |
|
2167 |
if ($uc_bres34_nsamp[$bin] > $uc_bres34_max_nsamp); |
|
2168 |
} |
|
2169 |
my($dc_sumsq12,$uc_sumsq12,$dc_n12,$uc_n12) = (0,0,0,0); # calc rms residuals |
|
2170 |
my($dc_sumsq34,$uc_sumsq34,$dc_n34,$uc_n34) = (0,0,0,0); |
|
2171 |
for (my($bin)=$LADCP_firstBin; $bin<=$LADCP_lastBin-1; $bin++) { # SKIP 1ST BIN |
|
2172 |
next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin); # skip bins not included in gridded output |
|
2173 |
if ($dc_bres12_nsamp[$bin] >= $dc_bres12_max_nsamp/3) { # skip bins with < 1/3 max(nsamp) |
|
2174 |
$dc_sumsq12 += $dc_avg_bres12[$bin]**2; |
|
2175 |
$dc_n12++; |
|
34 | 2176 |
} |
56 | 2177 |
if ($uc_bres12_nsamp[$bin] >= $uc_bres12_max_nsamp/3) { |
2178 |
$uc_sumsq12 += $uc_avg_bres12[$bin]**2; |
|
2179 |
$uc_n12++; |
|
2180 |
} |
|
2181 |
if ($dc_bres34_nsamp[$bin] >= $dc_bres34_max_nsamp/3) { # skip bins with < 1/3 max(nsamp) |
|
2182 |
$dc_sumsq34 += $dc_avg_bres34[$bin]**2; |
|
2183 |
$dc_n34++; |
|
2184 |
} |
|
2185 |
if ($uc_bres34_nsamp[$bin] >= $uc_bres34_max_nsamp/3) { |
|
2186 |
$uc_sumsq34 += $uc_avg_bres34[$bin]**2; |
|
2187 |
$uc_n34++; |
|
34 | 2188 |
} |
56 | 2189 |
} |
2190 |
$dc_bres12_rms = ($dc_n12 > 0) ? sqrt($dc_sumsq12/$dc_n12) : nan; |
|
2191 |
$uc_bres12_rms = ($uc_n12 > 0) ? sqrt($uc_sumsq12/$uc_n12) : nan; |
|
2192 |
$dc_bres34_rms = ($dc_n34 > 0) ? sqrt($dc_sumsq34/$dc_n34) : nan; |
|
2193 |
$uc_bres34_rms = ($uc_n34 > 0) ? sqrt($uc_sumsq34/$uc_n34) : nan; |
|
54 | 2194 |
|
56 | 2195 |
&antsAddParams('dc_bin_residuals12.rms',$dc_bres12_rms, |
2196 |
'dc_bin_residuals34.rms',$dc_bres34_rms, |
|
2197 |
'uc_bin_residuals12.rms',$uc_bres12_rms, |
|
2198 |
'uc_bin_residuals34.rms',$uc_bres34_rms); |
|
2199 |
||
2200 |
progress("\n\twriting binned residuals to "); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
2201 |
|
56 | 2202 |
my($saveParams) = $antsCurParams; |
2203 |
@antsNewLayout = ('bin','dc_residual12','dc_residual12.sig','dc_residual12.nsamp', |
|
2204 |
'uc_residual12','uc_residual12.sig','uc_residual12.nsamp', |
|
2205 |
'dc_residual34','dc_residual34.sig','dc_residual34.nsamp', |
|
2206 |
'uc_residual34','uc_residual34.sig','uc_residual34.nsamp'); |
|
2207 |
&antsAddParams('BR_bin.max',max(scalar(@dc_bres12),scalar(@uc_bres12), |
|
2208 |
scalar(@dc_bres34),scalar(@uc_bres34))); |
|
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2209 |
|
56 | 2210 |
foreach my $of (@out_BR) { |
2211 |
progress("<$of> "); |
|
2212 |
my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/); # plot_sub(out_file) |
|
2213 |
if (defined($arg)) { |
|
2214 |
require "$WCALC/${sub}.pl"; |
|
2215 |
&{$sub}($arg); |
|
2216 |
next; |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
2217 |
} |
56 | 2218 |
$of = ">$of" unless ($of =~ /^$|^\s*\|/); |
2219 |
open(STDOUT,$of) || error("$of: $!\n"); |
|
2220 |
undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE); |
|
2221 |
for (my($bin)=0; $bin<max(scalar(@dc_bres12),scalar(@uc_bres12)); $bin++) { |
|
2222 |
&antsOut($bin+1,$dc_avg_bres12[$bin],$dc_sig_bres12[$bin],$dc_bres12_nsamp[$bin], |
|
2223 |
$uc_avg_bres12[$bin],$uc_sig_bres12[$bin],$uc_bres12_nsamp[$bin], |
|
2224 |
$dc_avg_bres34[$bin],$dc_sig_bres34[$bin],$dc_bres34_nsamp[$bin], |
|
2225 |
$uc_avg_bres34[$bin],$uc_sig_bres34[$bin],$uc_bres34_nsamp[$bin]); |
|
2226 |
} |
|
2227 |
&antsOut('EOF'); open(STDOUT,">&2"); |
|
2228 |
} |
|
2229 |
$antsCurParams = $saveParams; |
|
2230 |
progress("\n"); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
2231 |
|
0 | 2232 |
#-------------------------------------------------- |
2233 |
# Calculate BT-referenced vertical-velocity profile |
|
2234 |
#-------------------------------------------------- |
|
2235 |
||
49 | 2236 |
if ($LADCP{ENSEMBLE}[$LADCP_atbottom]->{XDUCER_FACING_DOWN} && defined($water_depth)) { |
2237 |
||
0 | 2238 |
progress("Calculating BT-referenced vertical velocities\n"); |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2239 |
calc_BTprof($firstGoodEns,$lastGoodEns,$water_depth,$sig_water_depth); |
0 | 2240 |
|
2241 |
my($sumSq) = my($n) = 0; |
|
2242 |
for (my($bi)=0; $bi<=$#{$BT{MEDIAN_W}}; $bi++) { |
|
56 | 2243 |
next unless numbersp($BT{MEDIAN_W}[$bi],$DNCAST{MEDIAN_W}[$bi],$UPCAST{MEDIAN_W}[$bi]); |
13 | 2244 |
next unless ($BT{N_SAMP}[$bi]>=$opt_k && $DNCAST{N_SAMP}[$bi]>=$opt_k && $UPCAST{N_SAMP}[$bi]>=$opt_k); |
0 | 2245 |
$sumSq += ($BT{MEDIAN_W}[$bi] - $DNCAST{MEDIAN_W}[$bi]/2 - $UPCAST{MEDIAN_W}[$bi]/2)**2; |
2246 |
$n++; |
|
2247 |
} |
|
2248 |
if ($n > 0) { |
|
2249 |
my($rms) = round(sqrt($sumSq/$n),0.001); |
|
56 | 2250 |
&antsAddParams('BT_w_discrepancy.rms',$rms); |
0 | 2251 |
progress("\t$rms m/s rms vertical-velocity discrepancy\n"); |
2252 |
} |
|
2253 |
} |
|
2254 |
||
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2255 |
#---------------------------- |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2256 |
# output all samples (.wsamp) |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2257 |
#---------------------------- |
2 | 2258 |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2259 |
# NB: residual fields are calculated with respect to down-/upcast medians in -o-size bins |
2 | 2260 |
|
31 | 2261 |
if (@out_wsamp) { |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2262 |
progress("Writing vertical-velocity data to "); |
2 | 2263 |
|
31 | 2264 |
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
|
2265 |
progress("<$of> "); |
30 | 2266 |
|
42 | 2267 |
my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/); # plot_sub(out_file) |
2268 |
if (defined($arg)) { |
|
2269 |
require "$WCALC/${sub}.pl"; |
|
2270 |
&{$sub}($arg); |
|
30 | 2271 |
next; |
2272 |
} |
|
2273 |
||
54 | 2274 |
@antsNewLayout = ('ensemble','bin','elapsed','depth','CTD_depth','downcast', |
2275 |
'w','w12','w34','v12','v34','residual','residual12','residual34', |
|
2276 |
'CTD_w','CTD_w_t','CTD_w_tt','LADCP_w','LADCP_reflr_w','winch_w', |
|
2277 |
'errvel','correlation','echo_amplitude','Sv', |
|
2278 |
'pitch','roll','tilt','heading','3_beam','svel'); |
|
2279 |
||
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
2280 |
$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
|
2281 |
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
|
2282 |
undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE); |
49 | 2283 |
|
2284 |
sub res($$) |
|
2285 |
{ |
|
2286 |
my($meas,$mean) = @_; |
|
2287 |
return numberp($meas) ? ($meas - $mean) : undef; |
|
2288 |
} |
|
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2289 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2290 |
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
|
2291 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
46 | 2292 |
my(@bindepth) = binDepths($ens); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2293 |
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
|
2294 |
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
|
2295 |
my($bi) = $bindepth[$bin]/$opt_o; |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2296 |
next unless numberp($DNCAST{MEDIAN_W}[$bi]); # don't output samples contributing to bad depth bins |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2297 |
&antsOut( |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2298 |
$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
|
2299 |
$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
|
2300 |
$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
|
2301 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2302 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin], |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2303 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin], |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2304 |
$LADCP{ENSEMBLE}[$ens]->{V12}[$bin],$LADCP{ENSEMBLE}[$ens]->{V34}[$bin], |
49 | 2305 |
res($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin],$DNCAST{MEDIAN_W}[$bi]), |
2306 |
res($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin],$DNCAST{MEDIAN_W}[$bi]), |
|
2307 |
res($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin],$DNCAST{MEDIAN_W}[$bi]), |
|
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2308 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2309 |
$CTD{W_t}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2310 |
$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
|
2311 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin], |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
2312 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W}, |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
2313 |
$CTD{W_WINCH}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2314 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2315 |
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
|
2316 |
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
|
2317 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2318 |
$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH}, |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2319 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2320 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2321 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2322 |
(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
|
2323 |
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
|
2324 |
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
|
2325 |
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
|
2326 |
$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
|
2327 |
); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2328 |
} # for $bin |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2329 |
} # for $ens |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2330 |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2331 |
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) { # upcast |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2332 |
next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}); |
46 | 2333 |
my(@bindepth) = binDepths($ens); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2334 |
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
|
2335 |
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
|
2336 |
my($bi) = $bindepth[$bin]/$opt_o; |
56 | 2337 |
next unless numberp($UPCAST{MEDIAN_W}[$bi]); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2338 |
&antsOut( |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2339 |
$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
|
2340 |
$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
|
2341 |
$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
|
2342 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2343 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin], |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2344 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin], |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2345 |
$LADCP{ENSEMBLE}[$ens]->{V12}[$bin],$LADCP{ENSEMBLE}[$ens]->{V34}[$bin], |
49 | 2346 |
res($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin],$UPCAST{MEDIAN_W}[$bi]), |
2347 |
res($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin],$UPCAST{MEDIAN_W}[$bi]), |
|
2348 |
res($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin],$UPCAST{MEDIAN_W}[$bi]), |
|
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2349 |
$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2350 |
$CTD{W_t}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2351 |
$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
|
2352 |
$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin], |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
2353 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W}, |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
2354 |
$CTD{W_WINCH}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}], |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2355 |
$LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin], |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2356 |
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
|
2357 |
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
|
2358 |
$LADCP{ENSEMBLE}[$ens]->{SV}[$bin], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2359 |
$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH}, |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2360 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2361 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2362 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2363 |
(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
|
2364 |
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
|
2365 |
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
|
2366 |
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
|
2367 |
$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
|
2368 |
); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2369 |
} # for $bin |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2370 |
} # for $ens |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2371 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2372 |
&antsOut('EOF'); open(STDOUT,">&2"); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2373 |
} |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2374 |
progress("\n"); |
2 | 2375 |
} |
2376 |
||
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2377 |
#------------------------------------- |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2378 |
# Output depth-binned profile (.wprof) |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2379 |
#------------------------------------- |
0 | 2380 |
|
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2381 |
if (@out_profile) { |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2382 |
progress("Writing vertical-velocity profiles to "); |
54 | 2383 |
undef(@antsNewLayout); |
2384 |
push(@antsNewLayout,'depth','hab', # consistent with [LADCP_w_postproc] |
|
2385 |
'dc_elapsed','dc_w','dc_w.mad','dc_w.nsamp', |
|
2386 |
'uc_elapsed','uc_w','uc_w.mad','uc_w.nsamp'); |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2387 |
push(@antsNewLayout,'dc_lr_bp_res.rms','dc_Sv', # additional fields (inconsistent w postproc) |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2388 |
'dc_exposure_time', |
56 | 2389 |
'dc_depth','dc_w12','dc_w34','dc_v12','dc_v34', |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2390 |
'dc_pitch.mu','dc_roll.mu','dc_tilt.mu', |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2391 |
'uc_lr_bp_res.rms','uc_Sv', |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2392 |
'uc_exposure_time', |
54 | 2393 |
'uc_depth','uc_w12','uc_w34','uc_v12','uc_v34', |
56 | 2394 |
'uc_pitch.mu','uc_roll.mu','uc_tilt.mu', |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2395 |
'BT_w','BT_w.mad','BT_w.nsamp','Sv.diff'); |
0 | 2396 |
|
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2397 |
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
|
2398 |
progress("<$of> "); |
29 | 2399 |
|
42 | 2400 |
my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/); # plot_sub(out_file) |
2401 |
if (defined($arg)) { |
|
2402 |
require "$WCALC/${sub}.pl"; |
|
2403 |
&{$sub}($arg); |
|
29 | 2404 |
next; |
2405 |
} |
|
2406 |
||
2407 |
$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
|
2408 |
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
|
2409 |
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
|
2410 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2411 |
for (my($bi)=0; $bi<=max($#{$DNCAST{ENSEMBLE}},$#{$UPCAST{ENSEMBLE}},$#{$BT{NSAMP}}); $bi++) { |
37 | 2412 |
&antsOut(($bi+0.5)*$opt_o, # nominal depth |
2413 |
defined($water_depth)?$water_depth-($bi+0.5)*$opt_o:nan, # nominal hab |
|
54 | 2414 |
$DNCAST{MEAN_ELAPSED}[$bi], # dc data consistent w postproc |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2415 |
$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
|
2416 |
$DNCAST{MAD_W}[$bi],$DNCAST{N_SAMP}[$bi], |
54 | 2417 |
$UPCAST{MEAN_ELAPSED}[$bi], # uc data consistent w postproc |
2418 |
$UPCAST{N_SAMP}[$bi]>=$opt_k?$UPCAST{MEDIAN_W}[$bi]:nan, |
|
2419 |
$UPCAST{MAD_W}[$bi],$UPCAST{N_SAMP}[$bi], |
|
56 | 2420 |
$DNCAST{LR_RMS_BP_RESIDUAL}[$bi], # remaining dc data |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2421 |
$DNCAST{SV}[$bi], |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2422 |
$DNCAST{MAX_ELAPSED}[$bi]-$DNCAST{MIN_ELAPSED}[$bi], |
56 | 2423 |
$DNCAST{MEAN_DEPTH}[$bi], |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2424 |
$DNCAST{MEDIAN_W12}[$bi],$DNCAST{MEDIAN_W34}[$bi], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2425 |
$DNCAST{MEDIAN_V12}[$bi],$DNCAST{MEDIAN_V34}[$bi], |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2426 |
$DNCAST{MEAN_PITCH}[$bi],$DNCAST{MEAN_ROLL}[$bi],$DNCAST{MEAN_TILT}[$bi], |
56 | 2427 |
$UPCAST{LR_RMS_BP_RESIDUAL}[$bi], # remaining uc data |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2428 |
$UPCAST{SV}[$bi], |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2429 |
$UPCAST{MAX_ELAPSED}[$bi]-$UPCAST{MIN_ELAPSED}[$bi], |
56 | 2430 |
$UPCAST{MEAN_DEPTH}[$bi], |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2431 |
$UPCAST{MEDIAN_W12}[$bi],$UPCAST{MEDIAN_W34}[$bi], |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2432 |
$UPCAST{MEDIAN_V12}[$bi],$UPCAST{MEDIAN_V34}[$bi], |
56 | 2433 |
$UPCAST{MEAN_PITCH}[$bi],$UPCAST{MEAN_ROLL}[$bi],$UPCAST{MEAN_TILT}[$bi], |
37 | 2434 |
$BT{N_SAMP}[$bi]>=$opt_k?$BT{MEDIAN_W}[$bi]:nan, # BT data |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2435 |
$BT{MAD_W}[$bi],$BT{N_SAMP}[$bi], |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
2436 |
$DNCAST{SV}[$bi]-$UPCAST{SV}[$bi], |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2437 |
); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2438 |
} |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2439 |
&antsOut('EOF'); open(STDOUT,">&2"); |
0 | 2440 |
} |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2441 |
progress("\n"); |
0 | 2442 |
} |
2443 |
||
2444 |
#-------------------------------------- |
|
2445 |
# write time-series output if requested |
|
2446 |
#-------------------------------------- |
|
2447 |
||
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2448 |
if (@out_timeseries) { |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2449 |
progress("Writing time-series data to "); |
23 | 2450 |
@antsNewLayout = ('ensemble','elapsed','downcast', |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
2451 |
'depth','xducer_sound_speed','pitch','gimbal_pitch','roll','tilt','heading', |
13 | 2452 |
'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
|
2453 |
'reflr_ocean_w'); |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2454 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2455 |
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
|
2456 |
progress("<$of> "); |
42 | 2457 |
my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/); # plot_sub(out_file) |
2458 |
if (defined($arg)) { |
|
2459 |
require "$WCALC/${sub}.pl"; |
|
2460 |
&{$sub}($arg); |
|
30 | 2461 |
next; |
2462 |
} |
|
26
b89d4b01fcc5
after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
25
diff
changeset
|
2463 |
$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
|
2464 |
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
|
2465 |
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
|
2466 |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
43
diff
changeset
|
2467 |
for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) { |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2468 |
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
|
2469 |
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
|
2470 |
? $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
|
2471 |
: undef; |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2472 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2473 |
$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
|
2474 |
($ens < $LADCP_atbottom) ? 1 : 0, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2475 |
$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2476 |
$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
|
2477 |
$LADCP{ENSEMBLE}[$ens]->{PITCH}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2478 |
$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2479 |
$LADCP{ENSEMBLE}[$ens]->{ROLL}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2480 |
$LADCP{ENSEMBLE}[$ens]->{TILT}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2481 |
$LADCP{ENSEMBLE}[$ens]->{HEADING}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2482 |
$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
|
2483 |
$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
|
2484 |
$LADCP{ENSEMBLE}[$ens]->{REFLR_W}, |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2485 |
$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
|
2486 |
$reflr_oc_w); |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2487 |
} |
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2488 |
|
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2489 |
&antsOut('EOF'); open(STDOUT,">&2"); |
0 | 2490 |
} |
25
bd38f8bfb8e6
first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
23
diff
changeset
|
2491 |
progress("\n"); |
0 | 2492 |
} |
2493 |
||
42 | 2494 |
system("{ ./LADCP_w.PostProcess $out_basename $RUN $data_dir $plot_dir $log_dir; }&") |
2495 |
if (-x 'LADCP_w.PostProcess'); |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
2496 |
|
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
2497 |
exit(0); |