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