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