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