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