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