author | A.M. Thurnherr <athurnherr@yahoo.com> |
Tue, 06 Dec 2022 12:47:21 -0500 | |
changeset 64 | 58ef697c01ae |
parent 63 | 4832af086e8c |
permissions | -rwxr-xr-x |
29 | 1 |
#!/usr/bin/perl |
2 |
#====================================================================== |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
3 |
# L A D C P _ W _ P O S T P R O C |
29 | 4 |
# doc: Fri Apr 24 17:15:59 2015 |
63 | 5 |
# dlm: Mon Sep 19 18:33:30 2022 |
29 | 6 |
# (c) 2015 A.M. Thurnherr |
63 | 7 |
# uE-Info: 92 33 NIL 0 0 72 2 2 4 NIL ofnI |
29 | 8 |
#====================================================================== |
9 |
||
10 |
$antsSummary = 'edit and re-grid LADCP vertical-velocity samples'; |
|
11 |
||
12 |
# HISTORY: |
|
13 |
# Apr 24, 2015: - created |
|
14 |
# Apr 25, 2015: - maded gridding work |
|
15 |
# Apr 26, 2015: - made editing work |
|
16 |
# Apr 27, 2015: - added -p |
|
17 |
# May 5, 2015: - modified Editfile syntax to use parens() |
|
18 |
# May 7, 2015: - allow leading whitespace before Editfile labels |
|
19 |
# May 17, 2015: - removed warning about missing ./Editfile |
|
20 |
# May 18, 2015: - added important %PARAMs for dual-head data |
|
21 |
# - updated to libV6.1 |
|
22 |
# May 19, 2015: - added hab to output |
|
23 |
# - allow setting %PARAMS in Editfile |
|
24 |
# May 20, 2015: - Editfile => EditParams |
|
25 |
# Jun 18, 2015: - added -i |
|
26 |
# - implemented default output on -t stdout |
|
27 |
# - changed to libGMT.pl |
|
28 |
# - removed dead -d option |
|
30 | 29 |
# Jul 26, 2015: - adapted for %outgrid_* |
30 |
# Jul 27, 2015: - B-t)rack <wprof> |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
31 |
# Sep 21, 2015: - added valid_bins() |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
32 |
# - replaced -t by -b |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
33 |
# - BUG: -k default was wrong |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
34 |
# - added error message output to EditParams |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
35 |
# Sep 22, 2015: - added output_resolution() |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
36 |
# Sep 24, 2015: - BUG: -k did not work any more |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
37 |
# - BUG: some plot commands were exectuted even without -p |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
38 |
# - BUG: wprof plot did not respect -k |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
39 |
# - BUG: typo in mad output |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
40 |
# Sep 26, 2015: - allow $ID as alias for $STN and $PROF |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
41 |
# Sep 27, 2015: - adapted to 'unknown' %water_depth |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
42 |
# Oct 12, 2015: - improved EditParams handling |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
43 |
# - BUG: single-profile plot did not work any more |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
44 |
# - BUG: wrong single-profile bin size warning produced |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
45 |
# - BUG: -o /-k code was wrong |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
46 |
# - BUG: plot was in landscape mode |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
47 |
# - added run-label(s) to plot |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
48 |
# - require ANTSlibs V6.2 for release |
33 | 49 |
# Oct 13, 2015: - adapted to [version.pl] |
34 | 50 |
# Jan 20, 2016: - added dc_w.diff, uc_w.diff for dual-head profiles |
51 |
# Jan 21, 2016: - added %_wcorr.ps plot output |
|
52 |
# - added correlation-based QC to wprof plot |
|
53 |
# Jan 22, 2016: - added output -d)ir option |
|
54 |
# Jan 24, 2016: - BUG: uc_/dc_corr returned single nan on failure |
|
55 |
# Jan 25, 2016: - added software version %PARAM |
|
56 |
# Jan 26, 2016: - added -v |
|
57 |
# Jan 30, 2016: - added -w |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
58 |
# Feb 14, 2016: - BUG: all bins were off by 1! (-v, inherited limits) |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
59 |
# Mar 1, 2016: - added required ADCP sampling %PARAMs to dual-head |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
60 |
# output |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
61 |
# Mar 7, 2016: - BUG: correlation stats were defined/used for single-head data |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
62 |
# - removed good_bins() from library as -v allows more control |
41 | 63 |
# Mar 16, 2016: - adapted to gmt5 |
43 | 64 |
# Mar 31, 2016: - changed version %PARAM |
44 | 65 |
# Apr 14, 2016: - added profile id to warning messages |
46 | 66 |
# May 24, 2016: - improved plot |
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
67 |
# May 26, 2016: - added automatic directory creation on -d |
49 | 68 |
# Nov 28, 2017: - removed wcorr plot |
69 |
# Dec 9, 2017: - added $antsSuppressCommonOptions = 1; |
|
70 |
# Oct 31, 2018: - improved label (no longer explained/residual stddev) |
|
71 |
# Nov 1, 2018: - made layout consistent for dual- and single-head profiles |
|
56 | 72 |
# Jul 1, 2021: - made %PARAMs more standard |
73 |
# - added -z to remove biases |
|
74 |
# - added %?c_w_diff.rms to output |
|
75 |
# - BUG: dc_corr returned strange rms |
|
76 |
# Jul 7, 2021: - reversed logic of -z (enables bias correction by default) |
|
77 |
# - BUG: plot had label in wrong location for single-head profiles |
|
78 |
# Jul 9, 2021: - added window correlation stats |
|
79 |
# - updated %PARAM names |
|
80 |
# Jul 13, 2021: - BUG: dc_sig, dc_rms confusion |
|
81 |
# Jul 23, 2021: - added summary info to plot |
|
82 |
# - added seabed to plot |
|
83 |
# - added annotations to plot |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
84 |
# Aug 7, 2021: - BUG: some wsamp params were wrong |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
85 |
# Oct 12, 2021: - reduced window thickness for correlations from 500m to 320m |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
86 |
# Oct 13, 2021: - add filter to include correlation results only if there are |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
87 |
# less than 20% gaps |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
88 |
# May 10, 2022: - added -f |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
89 |
# May 17, 2022: - changed semantics to take output file name from input file names |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
90 |
# May 18, 2022: - BUG: new semantics did not work (oops) |
63 | 91 |
# Sep 19, 2022: - BUG: plot did not work any more (unclear since when) for dual-head |
92 |
# profiles |
|
56 | 93 |
# HISTORY END |
49 | 94 |
|
29 | 95 |
|
33 | 96 |
($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$}); |
97 |
($WCALC) = ($0 =~ m{^(.*)/[^/]*$}); |
|
98 |
$WCALC = '.' if ($WCALC eq ''); |
|
29 | 99 |
|
100 |
die("$0: ANTSlib required but not found (bad \$PATH?)\n") |
|
101 |
unless ($ANTS ne ''); |
|
102 |
||
33 | 103 |
require "$WCALC/version.pl"; |
29 | 104 |
require "$ANTS/ants.pl"; |
105 |
require "$ANTS/libstats.pl"; |
|
106 |
require "$ANTS/libGMT.pl"; |
|
43 | 107 |
&antsAddParams('LADCP_w_postproc::version',$VERSION); |
29 | 108 |
|
49 | 109 |
$antsSuppressCommonOptions = 1; |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
110 |
&antsUsage('b:c:d:f:i:k:l:o:p:v:w:z',1, |
29 | 111 |
'[profile -i)d <id>]', |
56 | 112 |
'[disable -z)eroing of <w> (disable bias correction)]', |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
113 |
'[-o)utput bin <resolution>] [-k) require <min> samples]', |
34 | 114 |
'[-v)alid bins <DL first>,<DL last>[,<UL first>,<UL_last>]', |
115 |
'[-w) <DL_dc_field>,<DL_uc_field>[,<UL_dc_field>,<UL_uc_field>]', |
|
116 |
'[-s)urface-layer <limit[300m]>]', |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
117 |
'[-c)orrelation <window size[320m]>]', |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
118 |
'[ouptput -d)ir <name> -f)ile <fmt[%03d.wprof]>]', |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
119 |
'[-p)lot <[%03d_wprof.eps]> [-b)t <wprof>]]', |
34 | 120 |
'<DL.wsamp file> [UL.wsamp file] (or only <UL.wsamp file>)'); |
121 |
||
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
122 |
($basename) = ($ARGV =~ m{([^/]*)\.[^\.]*$}); # determine output file name |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
123 |
|
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
124 |
$opt_f = '%03d.wprof' # output file name |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
125 |
unless defined($opt_f); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
126 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
127 |
$dual_head = (@ARGV==1); # single or dual head |
34 | 128 |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
129 |
if ($dual_head) { |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
130 |
my($basename2) = ($ARGV[0] =~ m{([^/]*)\.[^\.]*$}); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
131 |
undef($basename) unless ($basename2 eq $basename); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
132 |
} |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
133 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
134 |
$id = defined($opt_i) ? $opt_i : &antsParam('profile_id'); # ensure profile id exists |
34 | 135 |
croak("$0: no profile_id in first file => -i required\n") |
136 |
unless defined($id); |
|
137 |
||
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
138 |
if (defined($opt_d)) { # select output directory |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
139 |
unless (-d $opt_d) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
140 |
unless ($opt_d =~ m{/}) { |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
141 |
print(STDERR "Warning: Creating output sub-directory ./$opt_d\n"); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
142 |
mkdir($opt_d); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
143 |
} |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
144 |
croak("$opt_d: no such directory\n") unless (-d $opt_d); |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
145 |
} |
34 | 146 |
} |
147 |
||
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
148 |
&antsCardOpt(\$opt_s,300); # surface layer depth limit |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
149 |
&antsCardOpt(\$opc_c,320); # window thickness for correlation estimates |
29 | 150 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
151 |
if (defined($opt_v)) { # bin ranges with valid data to use |
34 | 152 |
($fvBin,$lvBin,$UL_fvBin,$UL_lvBin) = split(/,/,$opt_v); |
153 |
croak("$0: cannot decode -v $opt_v\n") |
|
154 |
unless (defined($lvBin) && (!$dual_head || defined($UL_lvBin))); |
|
155 |
$fvBin = &antsRequireParam('LADCP_firstBin') if ($fvBin eq '*'); # corresponding UL values set below |
|
156 |
$lvBin = &antsRequireParam('LADCP_lastBin') if ($lvBin eq '*'); |
|
157 |
&antsAddParams('DL_first_valid_bin',$fvBin, |
|
158 |
'DL_last_valid_bin', $lvBin); |
|
159 |
} else { |
|
160 |
&antsAddParams('DL_first_valid_bin',&antsRequireParam('outgrid_firstbin'), |
|
161 |
'DL_last_valid_bin',&antsRequireParam('outgrid_lastbin')); |
|
162 |
} |
|
29 | 163 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
164 |
if (defined($opt_w)) { # vertical-velocity fields to use |
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
165 |
($Ddwf,$Duwf,$Udwf,$Uuwf) = split(/,/,$opt_w); # DL dc, DL uc, ... |
34 | 166 |
croak("$0: cannot decode -w $opt_w\n") |
167 |
unless (defined($Duwf) && (!$dual_head || defined($Uuwf))); |
|
168 |
&antsAddParams('DL_dc_w_field',$Ddwf,'DL_uc_w_field',$Duwf, |
|
169 |
'UL_dc_w_field',$Udwf,'UL_uc_w_field',$Uuwf); |
|
170 |
} else { |
|
171 |
($Ddwf,$Duwf,$Udwf,$Uuwf) = ('w','w','w','w'); |
|
172 |
} |
|
173 |
||
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
174 |
if (defined($opt_o)) { # output grid resolution |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
175 |
$opt_o_override = 1; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
176 |
&antsCardOpt($opt_o); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
177 |
} else { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
178 |
$opt_o = &antsRequireParam('outgrid_dz'); |
30 | 179 |
} |
29 | 180 |
|
47
2ccb81b7cea5
version found on whoosher after repair
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
46
diff
changeset
|
181 |
if (defined($opt_k)) { # minimum number of required samples |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
182 |
$opt_k_override = 1; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
183 |
&antsCardOpt($opt_k); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
184 |
} else { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
185 |
$opt_k = &antsRequireParam('outgrid_minsamp'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
186 |
$opt_k *= 2 if ($dual_head); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
187 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
188 |
|
29 | 189 |
#---------------------------------------------------------------------- |
34 | 190 |
# Redirect STDOUT to %.wprof & create plots if STDOUT is a tty |
29 | 191 |
#---------------------------------------------------------------------- |
192 |
||
193 |
if (-t STDOUT) { |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
194 |
if (defined($basename)) { |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
195 |
$outfile = defined($opt_d) ? "$opt_d/$basename.wprof" : "$basename.wprof"; |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
196 |
$opt_p = defined($opt_d) ? "$opt_d/${basename}_wprof.ps" : "${basename}_wprof.ps" |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
197 |
unless defined($opt_p); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
198 |
} else { |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
199 |
$opt_p = defined($opt_d) ? "$opt_d/%03d_wprof.ps" : '%03d_wprof.ps' |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
200 |
unless defined($opt_p); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
201 |
$outfile = defined($opt_d) ? sprintf("%s/$opt_f",$opt_d,$id) |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
202 |
: sprintf($opt_f,$id); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
203 |
} |
29 | 204 |
open(STDOUT,">$outfile") || die("$outfile: $!\n"); |
205 |
} |
|
206 |
||
34 | 207 |
croak("$0: -b only makes sense when plots are produced\n") |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
208 |
if $opt_b && !defined($opt_p); |
30 | 209 |
|
29 | 210 |
#---------------------------------------------------------------------- |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
211 |
# EditParams Library |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
212 |
# |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
213 |
# output_resolution(dz) output_resolution(40) |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
214 |
# bad_range[_dc|_uc](field,min_val,max_val) bad_range_uc('depth',3500,3600) |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
215 |
# |
29 | 216 |
#---------------------------------------------------------------------- |
217 |
||
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
218 |
my(@brFnr,@brMin,@brMax,@brDUc); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
219 |
my(@gbFirst,@gbLast); |
29 | 220 |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
221 |
sub output_resolution($) |
29 | 222 |
{ |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
223 |
my($dz) = @_; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
224 |
$opt_o = $dz; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
225 |
$opt_o_override = 1; |
29 | 226 |
} |
227 |
||
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
228 |
sub bad_range($$$) |
29 | 229 |
{ |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
230 |
push(@brFnr,&fnr(shift)); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
231 |
push(@brMin,shift); push(@brMax,shift); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
232 |
$brMin[$#brMin] = -9e99 if ($brMin[$#brMin] eq '*'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
233 |
$brMax[$#brMax] = 9e99 if ($brMax[$#brMax] eq '*'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
234 |
push(@brDUc,2); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
235 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
236 |
|
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
237 |
sub bad_range_dc($$$) |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
238 |
{ |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
239 |
push(@brFnr,&fnr(shift)); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
240 |
push(@brMin,shift); push(@brMax,shift); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
241 |
$brMin[$#brMin] = -9e99 if ($brMin[$#brMin] eq '*'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
242 |
$brMax[$#brMax] = 9e99 if ($brMax[$#brMax] eq '*'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
243 |
push(@brDUc,1); |
29 | 244 |
} |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
245 |
|
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
246 |
sub bad_range_uc($$$) |
29 | 247 |
{ |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
248 |
push(@brFnr,&fnr(shift)); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
249 |
push(@brMin,shift); push(@brMax,shift); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
250 |
$brMin[$#brMin] = -9e99 if ($brMin[$#brMin] eq '*'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
251 |
$brMax[$#brMax] = 9e99 if ($brMax[$#brMax] eq '*'); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
252 |
push(@brDUc,0); |
29 | 253 |
} |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
254 |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
255 |
#---------------------------------------------------------------------- |
29 | 256 |
|
257 |
sub isBad() |
|
258 |
{ |
|
259 |
for (my($f)=0; $f<$antsBufNFields; $f++) { |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
260 |
for (my($i)=0; $i<@gbFirst; $i++) { # good bin range |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
261 |
return 1 if ($ants_[0][$bF] < $gbFirst[$i] || |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
262 |
$ants_[0][$bF] > $gbLast[$i]); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
263 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
264 |
|
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
265 |
for (my($i)=0; $i<@brFnr; $i++) { # bad ranges |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
266 |
next unless ($brFnr[$i] == $f); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
267 |
next unless ($brDUc[$i]==2 || $brDUc[$i]==$ants_[0][$dcF]); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
268 |
return 1 if ($ants_[0][$f] >= $brMin[$i] && |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
269 |
$ants_[0][$f] <= $brMax[$i]); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
270 |
} |
29 | 271 |
} |
272 |
return 0; |
|
273 |
} |
|
274 |
||
275 |
#---------------------------------------------------------------------- |
|
56 | 276 |
# Correlation Statistics |
277 |
# |
|
278 |
# return values: |
|
279 |
# R correlation coefficient w_DL,w_UL |
|
280 |
# var variance of avg(w_DL,w_UL) |
|
281 |
# DL_var variance of w_DL |
|
282 |
# UL_var variance of w_DL |
|
283 |
# rms_diff rms of w_DL-w_UL |
|
29 | 284 |
#---------------------------------------------------------------------- |
285 |
||
56 | 286 |
sub dc_corr($$) |
34 | 287 |
{ |
56 | 288 |
my($fi,$li) = @_; |
34 | 289 |
my($n) = 0; |
290 |
my($ax,$ay) = (0,0); |
|
56 | 291 |
my($ssq_diff) = 0; |
34 | 292 |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
293 |
return (nan,nan,nan,nan,nan) unless ($li > $fi); # for shallow profiles this fails |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
294 |
|
56 | 295 |
for (my($bi)=$fi; $bi<=$li; $bi++) { |
34 | 296 |
next unless numberp($DL_dc_median[$bi]) && numberp($UL_dc_median[$bi]); |
297 |
$n++; |
|
298 |
$ax += $DL_dc_median[$bi]; |
|
299 |
$ay += $UL_dc_median[$bi]; |
|
56 | 300 |
$ssq_diff += ($DL_dc_median[$bi] - $UL_dc_median[$bi])**2; |
34 | 301 |
} |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
302 |
return (nan,nan,nan,nan,nan) unless ($n > 0.8*($li-$fi+1)); |
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
303 |
die("$n,$li,$fi [$n > 0.8*($li-$fi+1)]\n") unless ($n > 0); |
34 | 304 |
$ax /= $n; |
305 |
$ay /= $n; |
|
306 |
||
307 |
my($syy,$sxy,$sxx) = (0,0,0); |
|
56 | 308 |
for (my($bi)=$fi; $bi<=$li; $bi++) { |
34 | 309 |
next unless numberp($DL_dc_median[$bi]) && numberp($UL_dc_median[$bi]); |
310 |
my($xt) = $DL_dc_median[$bi] - $ax; |
|
311 |
my($yt) = $UL_dc_median[$bi] - $ay; |
|
312 |
$sxx += $xt * $xt; |
|
313 |
$syy += $yt * $yt; |
|
314 |
$sxy += $xt * $yt; |
|
315 |
} |
|
316 |
my($R) = $sxy/(sqrt($sxx * $syy) + 1e-16); |
|
56 | 317 |
my($var) = ($sxx + $syy) / (2*$n); # variance of avg(w_DL,w_UL) |
318 |
my($var_DL) = $sxx/$n; |
|
319 |
my($var_UL) = $syy/$n; |
|
320 |
my($rms_diff) = sqrt($ssq_diff/$n); |
|
321 |
return ($R,$var,$var_DL,$var_UL,$rms_diff); |
|
34 | 322 |
} |
323 |
||
56 | 324 |
sub uc_corr($$) |
34 | 325 |
{ |
56 | 326 |
my($fi,$li) = @_; |
34 | 327 |
my($n) = 0; |
328 |
my($ax,$ay) = (0,0); |
|
56 | 329 |
my($ssq_diff) = 0; |
34 | 330 |
|
56 | 331 |
for (my($bi)=$fi; $bi<=$li; $bi++) { |
34 | 332 |
next unless numberp($DL_uc_median[$bi]) && numberp($UL_uc_median[$bi]); |
333 |
$n++; |
|
334 |
$ax += $DL_uc_median[$bi]; |
|
335 |
$ay += $UL_uc_median[$bi]; |
|
56 | 336 |
$ssq_diff += ($DL_uc_median[$bi] - $UL_uc_median[$bi])**2; |
34 | 337 |
} |
56 | 338 |
return (nan,nan,nan,nan,nan) unless ($n > 2); |
34 | 339 |
$ax /= $n; |
340 |
$ay /= $n; |
|
341 |
||
342 |
my($syy,$sxy,$sxx) = (0,0,0); |
|
56 | 343 |
for (my($bi)=$fi; $bi<=$li; $bi++) { |
34 | 344 |
next unless numberp($DL_uc_median[$bi]) && numberp($UL_uc_median[$bi]); |
345 |
my($xt) = $DL_uc_median[$bi] - $ax; |
|
346 |
my($yt) = $UL_uc_median[$bi] - $ay; |
|
347 |
$sxx += $xt * $xt; |
|
348 |
$syy += $yt * $yt; |
|
349 |
$sxy += $xt * $yt; |
|
350 |
} |
|
351 |
my($R) = $sxy/(sqrt($sxx * $syy) + 1e-16); |
|
56 | 352 |
my($var) = ($sxx + $syy) / (2*$n); # variance of avg(w_DL,w_UL) |
353 |
my($var_DL) = $sxx/$n; |
|
354 |
my($var_UL) = $syy/$n; |
|
355 |
my($rms_diff) = sqrt($ssq_diff/$n); |
|
356 |
return ($R,$var,$var_DL,$var_UL,$rms_diff); |
|
34 | 357 |
} |
358 |
||
359 |
#---------------------------------------------------------------------- |
|
56 | 360 |
# Main Program |
361 |
#---------------------------------------------------------------------- |
|
34 | 362 |
|
363 |
$dcwF = &fnr($Ddwf); $ucwF = &fnr($Duwf); |
|
29 | 364 |
$eF = &fnr('elapsed'); |
365 |
$dF = &fnr('depth'); |
|
30 | 366 |
$bF = &fnr('bin'); |
29 | 367 |
$dcF = &fnr('downcast'); |
368 |
||
56 | 369 |
$first_label = &antsRequireParam('run_label'); |
370 |
||
371 |
$bin_length = &antsRequireParam('ADCP_bin_length'); |
|
372 |
$pulse_length = &antsRequireParam('ADCP_pulse_length'); |
|
373 |
$blanking_dist = &antsRequireParam('ADCP_blanking_distance'); |
|
374 |
$instrument_type = &antsRequireParam('ADCP_type'); |
|
375 |
$xducer_frequency = &antsRequireParam('ADCP_frequency'); |
|
376 |
$orientation = &antsRequireParam('ADCP_orientation'); |
|
377 |
||
378 |
$dc_var = &antsRequireParam('dc_w.var'); # for dual-head LADCPs, variables will be |
|
379 |
$uc_var = &antsRequireParam('uc_w.var'); # overwritten by [du]c_corr() |
|
380 |
||
29 | 381 |
($dayNoP,$dn) = &antsFindParam('dn\d\d'); |
382 |
croak("$0: cannot determine day number\n") |
|
383 |
unless defined($dayNoP); |
|
384 |
||
34 | 385 |
if (defined($opt_p)) { |
386 |
($sumPF,$corrPF) = split(/,/,$opt_p); |
|
387 |
croak("$0: cannot decode -p $opt_p\n") |
|
49 | 388 |
unless (length($sumPF)>0); |
34 | 389 |
} |
390 |
||
29 | 391 |
my($R,$R2); |
34 | 392 |
if (defined($opt_p)) { # begin summary plot |
41 | 393 |
$xmin = -0.1; $x2min = -700; |
394 |
$xmax = 0.35; $x2max = 500; |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
395 |
$ymin = antsParam('depth.min'); |
46 | 396 |
$ymin = round($ymin-25,50); |
29 | 397 |
$ymax = antsParam('water_depth'); |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
398 |
$ymax = antsRequireParam('depth.max') unless numberp($ymax); |
46 | 399 |
$ymax = round($ymax+25,50); |
29 | 400 |
$plotsize = 13; |
401 |
$R = "-R$xmin/$xmax/$ymin/$ymax"; |
|
402 |
$R2 = "-R$x2min/$x2max/$ymin/$ymax"; |
|
34 | 403 |
GMT_begin(sprintf($sumPF,$id),"-JX$plotsize/-$plotsize",$R,'-P -X6 -Y4'); |
41 | 404 |
GMT_psxy('-W0.5'); |
29 | 405 |
print(GMT "0 $ymin\n0 $ymax"); |
406 |
GMT_psxy('-L -G200'); |
|
407 |
print(GMT "0.07 $ymin\n0.07 $ymax\n0.18 $ymax\n0.18 $ymin\n"); |
|
408 |
GMT_setR($R2); |
|
41 | 409 |
GMT_psxy('-W0.5'); |
29 | 410 |
print(GMT ">\n50 $ymin\n50 $ymax\n"); |
41 | 411 |
print(GMT ">\n250 $ymin\n250 $ymax\n"); |
412 |
print(GMT ">\n450 $ymin\n450 $ymax\n"); |
|
29 | 413 |
GMT_setR($R); |
30 | 414 |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
415 |
if (defined($opt_b)) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
416 |
open(BT,$opt_b) || croak("$opt_b: $!\n"); |
30 | 417 |
@BTL = &antsFileLayout(BT); |
418 |
my($BTwf,$BTdf,$BTmf,$BTnf); |
|
419 |
for (my($f)=0; $f<=$#BTL; $f++) { |
|
420 |
$BTdf = $f if ($BTL[$f] eq 'depth'); |
|
421 |
$BTwf = $f if ($BTL[$f] eq 'BT_w'); |
|
422 |
$BTmf = $f if ($BTL[$f] eq 'BT_w.mad'); |
|
423 |
$BTnf = $f if ($BTL[$f] eq 'BT_w.nsamp'); |
|
424 |
} |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
425 |
croak("$opt_b: file-layout error\n") |
30 | 426 |
unless defined($BTdf) && defined($BTwf) && |
427 |
defined($BTmf) && defined($BTnf); |
|
41 | 428 |
GMT_psxy('-W1.5'); |
30 | 429 |
while (@BT = &antsFileIn(BT)) { |
430 |
next unless numberp($BT[$BTwf]); |
|
431 |
printf(GMT "%f %f\n",$BT[$BTwf],$BT[$BTdf]); |
|
432 |
} |
|
433 |
} |
|
29 | 434 |
} |
435 |
||
436 |
$min_depth = 9e99; # sentinels |
|
437 |
$max_depth = -9e99; |
|
34 | 438 |
$curF = $P{PATHNAME}; # current input file (sentinel) |
29 | 439 |
$filt = 0; |
34 | 440 |
for ($r=0; &antsIn(); $r++) { |
441 |
if ($P{PATHNAME} ne $curF) { # 2nd file (UL data) |
|
29 | 442 |
$curF = $P{PATHNAME}; |
443 |
||
34 | 444 |
$dcwF = &fnr($Udwf); $ucwF = &fnr($Uuwf); |
445 |
||
44 | 446 |
&antsInfo("WARNING: #$id: inconsistent %%outgrid_dz in profile #$id") # consistency checks |
30 | 447 |
if (defined($P{outgrid_dz}) && $P{outgrid_dz}!=$opt_o &&!$opt_o_override); |
44 | 448 |
&antsInfo("WARNING: inconsistent %%outgrid_minsamp in profile #$id") |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
449 |
if defined($P{outgrid_minsamp}) && !$opt_k_override && |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
450 |
(( $dual_head && $P{outgrid_minsamp}*2!=$opt_k) || |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
451 |
(!$dual_head && $P{outgrid_minsamp}!=$opt_k)); |
29 | 452 |
|
34 | 453 |
if (defined($opt_v)) { |
454 |
$fvBin = &antsRequireParam('LADCP_firstBin') if ($UL_fvBin eq '*'); # valid bin ranges |
|
455 |
$lvBin = &antsRequireParam('LADCP_lastBin') if ($UL_lvBin eq '*'); |
|
456 |
&antsAddParams('UL_first_valid_bin',$fvBin, |
|
457 |
'UL_last_valid_bin', $lvBin); |
|
458 |
} else { |
|
459 |
&antsAddParams('UL_first_valid_bin',&antsRequireParam('outgrid_firstbin'), |
|
460 |
'UL_last_valid_bin',&antsRequireParam('outgrid_lastbin')); |
|
461 |
} |
|
462 |
||
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
463 |
for (my($bi)=0; $bi<=$#dcw1; $bi++) { # calc DL median profile (before reading UL data) |
34 | 464 |
$DL_dc_median[$bi] = median(@{$dcw1[$bi]}); |
465 |
$DL_uc_median[$bi] = median(@{$ucw1[$bi]}); |
|
466 |
} |
|
467 |
||
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
468 |
# |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
469 |
# ADCP bin length, pulse length, and blanking distance for dual head casts |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
470 |
# with inconsistent values: |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
471 |
# bin length: use smaller value, which will lead to smaller spectral correction |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
472 |
# pulse length: same |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
473 |
# blanking distance: use smaller value, which is conservative e.g. for filters for ringing |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
474 |
# |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
475 |
my($warned); |
56 | 476 |
unless (round($bin_length) == round(&antsRequireParam('ADCP_bin_length'))) { |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
477 |
unless ($warned) { |
44 | 478 |
&antsInfo("WARNING: inconsistent ADCP sampling parameters in profile #$id --- using conservative values"); |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
479 |
$warned = 1; |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
480 |
} |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
481 |
$bin_length = min($bin_length,$P{ADCP_bin_length}); |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
482 |
} |
56 | 483 |
unless (round($pulse_length) == round(&antsRequireParam('ADCP_pulse_length'))) { |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
484 |
unless ($warned) { |
44 | 485 |
&antsInfo("WARNING: inconsistent ADCP sampling parameters in profile #$id --- using conservative values"); |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
486 |
$warned = 1; |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
487 |
} |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
488 |
$pulse_length = min($pulse_length,$P{ADCP_pulse_length}); |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
489 |
} |
56 | 490 |
unless (round($blanking_dist) == round(&antsRequireParam('ADCP_blanking_distance'))) { |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
491 |
unless ($warned) { |
44 | 492 |
&antsInfo("WARNING: inconsistent ADCP sampling parameters in profile #$id --- using conservative values"); |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
493 |
$warned = 1; |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
494 |
} |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
495 |
$blanking_dist = min($blanking_dist,$P{ADCP_blanking_distance}); |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
496 |
} |
29 | 497 |
|
56 | 498 |
$instrument_type2 = &antsRequireParam('ADCP_type'); # for summary info |
499 |
$xducer_frequency2 = &antsRequireParam('ADCP_frequency'); |
|
500 |
$orientation2 = &antsRequireParam('ADCP_orientation'); |
|
501 |
||
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
502 |
$PROF = $STN = $ID = $id; $RUN = antsRequireParam('run_label'); # set variables for editing |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
503 |
undef(@rngMin); undef(@rngMax); undef(@bins); |
34 | 504 |
unless ($return = do "./EditParams") { # man perlfunc |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
505 |
croak("./EditParams: $@\n") if ($@); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
506 |
} |
29 | 507 |
|
34 | 508 |
if (defined($opt_p)) { # 2nd file in dual-head profile => plot 1st |
41 | 509 |
GMT_psxy('-W1,coral,-'); |
29 | 510 |
for (my($bi)=0; $bi<=$#dcw1; $bi++) { |
34 | 511 |
printf(GMT "%f %f\n",$DL_dc_median[$bi],($bi+0.5)*$opt_o); |
29 | 512 |
} |
41 | 513 |
GMT_psxy('-W1,SeaGreen,-'); |
29 | 514 |
for (my($bi)=0; $bi<=$#ucw1; $bi++) { |
34 | 515 |
printf(GMT "%f %f\n",$DL_uc_median[$bi],($bi+0.5)*$opt_o); |
29 | 516 |
} |
517 |
undef(@dcw1); undef(@ucw1); |
|
518 |
} |
|
34 | 519 |
} # of 2nd file started |
520 |
||
521 |
if (defined($opt_v)) { # explicit ranges of validity given |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
522 |
next if ($ants_[0][$bF]<$fvBin || # => apply them |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
523 |
$ants_[0][$bF]>$lvBin); |
34 | 524 |
} else { # no range of valid bins given |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
525 |
next if ($ants_[0][$bF]<$P{outgrid_firstbin} || # => use values from [LADCP_w_ocean] |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
526 |
$ants_[0][$bF]>$P{outgrid_lastbin}); |
29 | 527 |
} |
34 | 528 |
|
529 |
$filt++,next if &isBad(); # additional editing |
|
530 |
||
531 |
$min_depth = $ants_[0][$dF] if ($ants_[0][$dF] < $min_depth); # update depth limits |
|
29 | 532 |
$max_depth = $ants_[0][$dF] if ($ants_[0][$dF] > $max_depth); |
34 | 533 |
|
29 | 534 |
my($bi) = $ants_[0][$dF]/$opt_o; |
34 | 535 |
if ($ants_[0][$dcF]) { # downcast |
56 | 536 |
push(@{$dcw[$bi]}, $ants_[0][$dcwF] - (!$opt_z ? $P{'dc_w.mu'} : 0)); # vertical velocity |
537 |
push(@{$dcw1[$bi]},$ants_[0][$dcwF] - (!$opt_z ? $P{'dc_w.mu'} : 0)) # single-instrument w |
|
538 |
if ($dual_head); |
|
539 |
push(@{$dce[$bi]}, $ants_[0][$eF]); # elapsed time |
|
34 | 540 |
} else { # upcast |
56 | 541 |
push(@{$ucw[$bi]}, $ants_[0][$ucwF] - (!$opt_z ? $P{'uc_w.mu'} : 0)); |
542 |
push(@{$ucw1[$bi]},$ants_[0][$ucwF] - (!$opt_z ? $P{'uc_w.mu'} : 0)) |
|
543 |
if ($dual_head); |
|
544 |
push(@{$uce[$bi]}, $ants_[0][$eF]); |
|
29 | 545 |
} |
34 | 546 |
} # file-read loop |
547 |
||
548 |
if ($dual_head) { |
|
549 |
for (my($bi)=0; $bi<=$#dcw1; $bi++) { # calc UL median & difference profiles |
|
550 |
$UL_dc_median[$bi] = median(@{$dcw1[$bi]}); |
|
551 |
$UL_uc_median[$bi] = median(@{$ucw1[$bi]}); |
|
552 |
$dc_diff[$bi] = numberp($DL_dc_median[$bi]) && numberp($UL_dc_median[$bi]) |
|
553 |
? $DL_dc_median[$bi] - $UL_dc_median[$bi] : nan; |
|
554 |
$uc_diff[$bi] = numberp($DL_uc_median[$bi]) && numberp($UL_uc_median[$bi]) |
|
555 |
? $DL_uc_median[$bi] - $UL_uc_median[$bi] : nan; |
|
556 |
} |
|
29 | 557 |
|
56 | 558 |
($dc_R,$dc_var,$dc_var_DL,$dc_var_UL,$dc_rms_wdiff) = &dc_corr(int($opt_s/$opt_o),$#dcw1); # correlation statistics |
559 |
($uc_R,$uc_var,$uc_var_DL,$uc_var_UL,$uc_rms_wdiff) = &uc_corr(int($opt_s/$opt_o),$#ucw1); |
|
560 |
&antsAddParams('dc_w.R',$dc_R,'uc_w.R',$uc_R, |
|
561 |
'DL_dc_w.var',$dc_var_DL,'UL_dc_w.var',$dc_var_UL, |
|
562 |
'DL_uc_w.var',$uc_var_DL,'UL_uc_w.var',$uc_var_UL, |
|
563 |
'dc_w.var',$dc_var,'uc_w.var',$uc_var, |
|
564 |
'dc_wdiff.rms',$dc_rms_wdiff,'uc_wdiff.rms',$uc_rms_wdiff); |
|
565 |
||
566 |
my($last_depth,$last_bi,$dc_sumsq_res,$dc_n,$uc_sumsq_res,$uc_n); # window correlation |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
567 |
my($window_size) = 320; |
56 | 568 |
for (my($bi)=0; $bi<=$#dcw1; $bi++) { |
569 |
($dc_R[$bi],$dc_var[$bi],$dummy,$dummy,$dc_rms_wdiff[$bi]) = |
|
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
570 |
&dc_corr(max(0,$bi-int($window_size/2/$opt_o)),min($#dcw1,$bi+int($window_size/2/$opt_o))); |
56 | 571 |
($uc_R[$bi],$uc_var[$bi],$dummy,$dummy,$uc_rms_wdiff[$bi]) = |
57
69e39fcb7f41
whoosher version pre P2
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
56
diff
changeset
|
572 |
&uc_corr(max(0,$bi-int($window_size/2/$opt_o)),min($#dcw1,$bi+int($window_size/2/$opt_o))); |
56 | 573 |
} |
574 |
||
34 | 575 |
if (defined($opt_p)) { # plot 2nd-instrument profiles |
41 | 576 |
GMT_psxy('-W1,coral,.'); |
34 | 577 |
for (my($bi)=0; $bi<=$#dcw1; $bi++) { |
578 |
printf(GMT "%f %f\n",$UL_dc_median[$bi],($bi+0.5)*$opt_o); |
|
579 |
} |
|
41 | 580 |
GMT_psxy('-W1,SeaGreen,.'); |
34 | 581 |
for (my($bi)=0; $bi<=$#ucw1; $bi++) { |
582 |
printf(GMT "%f %f\n",$UL_uc_median[$bi],($bi+0.5)*$opt_o); |
|
583 |
} |
|
29 | 584 |
} |
585 |
} |
|
586 |
||
587 |
&antsInfo("%d measurements edited (%d%% of total)",$filt,round(100*$filt/$r)) |
|
588 |
if ($filt > 0); |
|
589 |
||
590 |
#---------------------------------------------------------------------- |
|
34 | 591 |
# Average and Output Profiles, Add to Summary Plot |
56 | 592 |
# - same output file layout for single- and dual-head systems |
29 | 593 |
#---------------------------------------------------------------------- |
594 |
||
49 | 595 |
@antsNewLayout = ('depth','hab', |
596 |
'dc_elapsed','dc_w','dc_w.mad','dc_w.nsamp', |
|
597 |
'uc_elapsed','uc_w','uc_w.mad','uc_w.nsamp', |
|
56 | 598 |
'dc_w.diff','uc_w.diff', # DL-UL differences |
599 |
'dc_w.R','dc_w.var','dc_wdiff.rms', |
|
600 |
'uc_w.R','uc_w.var','uc_wdiff.rms'); |
|
49 | 601 |
|
37 | 602 |
if ($dual_head) { # dual-head output |
603 |
&antsAddParams('profile_id',$id,'lat',$P{lat},'lon',$P{lon}); # selected %PARAMs |
|
29 | 604 |
&antsAddParams($dayNoP,$dn,'run_label',"$first_label & $P{run_label}"); |
30 | 605 |
&antsAddParams('outgrid_dz',$opt_o,'outgrid_minsamp',$opt_k); |
56 | 606 |
&antsAddParams('depth.min',round($min_depth),'depth.max',round($max_depth)); |
29 | 607 |
&antsAddParams('water_depth',$P{water_depth},'water_depth.sig',$P{water_depth.sig}); |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
608 |
&antsAddParams('ADCP_bin_length',$bin_length,'ADCP_pulse_length',$pulse_length); |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
609 |
&antsAddParams('ADCP_blanking_distance',$blanking_dist); |
29 | 610 |
undef($antsOldHeaders); |
611 |
} |
|
612 |
||
37 | 613 |
#&antsInfo("WARNING: unknown water depth (no height-above-bottom)") |
63 | 614 |
|
37 | 615 |
# unless numberp($P{water_depth}); |
29 | 616 |
|
617 |
my(@dcwm,@ucwm,@dcns,@ucns,@dcwmad,@ucwmad); |
|
618 |
for (my($bi)=0; $bi<=max($#dcw,$#ucw); $bi++) { |
|
619 |
$dcwm[$bi] = median(@{$dcw[$bi]}); |
|
620 |
$ucwm[$bi] = median(@{$ucw[$bi]}); |
|
63 | 621 |
$dcns[$bi] = @{$dcw[$bi]}; |
29 | 622 |
$ucns[$bi] = @{$ucw[$bi]}; |
623 |
$dcwmad[$bi] = mad2($dcwm[$bi],@{$dcw[$bi]}); |
|
624 |
$ucwmad[$bi] = mad2($ucwm[$bi],@{$ucw[$bi]}); |
|
625 |
push(@{$out[$bi]}, |
|
63 | 626 |
($bi+0.5)*$opt_o, # depth |
627 |
(numberp($P{water_depth}) ? $P{water_depth}-($bi+0.5)*$opt_o : nan), # hab |
|
628 |
avg(@{$dce[$bi]}), # dc_elapsed |
|
629 |
(($dcns[$bi]>=$opt_k)?$dcwm[$bi]:nan),(($dcns[$bi]>=$opt_k)?$dcwmad[$bi]:nan), # dc_w, dc_w.mad |
|
630 |
scalar(@{$dcw[$bi]}), # dc_w.nsamp |
|
631 |
avg(@{$uce[$bi]}), # uc_elapsed |
|
632 |
(($ucns[$bi]>=$opt_k)?$ucwm[$bi]:nan),(($ucns[$bi]>=$opt_k)?$ucwmad[$bi]:nan), # uc_w, uc_w.mad |
|
633 |
scalar(@{$ucw[$bi]})); # uc_w.nsamp |
|
49 | 634 |
if ($dual_head) { |
56 | 635 |
push(@{$out[$bi]},$dc_diff[$bi],$uc_diff[$bi], |
636 |
$dc_R[$bi],$dc_var[$bi],$dc_rms_wdiff[$bi], |
|
637 |
$uc_R[$bi],$uc_var[$bi],$uc_rms_wdiff[$bi]); |
|
49 | 638 |
} else { |
56 | 639 |
push(@{$out[$bi]},nan,nan,nan,nan,nan,nan); |
49 | 640 |
} |
29 | 641 |
&antsOut(@{$out[$bi]}); |
642 |
} |
|
643 |
||
34 | 644 |
if (defined($opt_p)) { # complete summary plot |
29 | 645 |
GMT_setR($R); |
646 |
||
63 | 647 |
if ($P{water_depth} > 0) { # SEABED |
56 | 648 |
GMT_psxy('-G204/153/102'); |
649 |
print(GMT "$xmin $ymax\n0.07 $ymax\n0.07 $P{water_depth}\n $xmin $P{water_depth}\n"); |
|
650 |
} |
|
651 |
||
41 | 652 |
GMT_psxy('-W1.5,coral'); # median profiles |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
653 |
for (my($bi)=0; $bi<=$#dcw; $bi++) { |
63 | 654 |
if ($dual_head) { |
655 |
printf(GMT "%f %f\n",(numberp($DL_dc_median[$bi]) && |
|
656 |
numberp($UL_dc_median[$bi]) && |
|
657 |
($dcns[$bi]>=$opt_k)?$dcwm[$bi]:nan) |
|
658 |
,($bi+0.5)*$opt_o); |
|
659 |
} else { |
|
660 |
printf(GMT "%f %f\n",(($dcns[$bi]>=$opt_k)?$dcwm[$bi]:nan) |
|
661 |
,($bi+0.5)*$opt_o); |
|
662 |
} |
|
29 | 663 |
} |
41 | 664 |
GMT_psxy('-W1.5,SeaGreen'); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
665 |
for (my($bi)=0; $bi<=$#ucw; $bi++) { |
63 | 666 |
if ($dual_head) { |
667 |
printf(GMT "%f %f\n",(numberp($DL_uc_median[$bi]) && |
|
668 |
numberp($UL_uc_median[$bi]) && |
|
669 |
($ucns[$bi]>=$opt_k)?$ucwm[$bi]:nan) |
|
670 |
,($bi+0.5)*$opt_o); |
|
671 |
} else { |
|
672 |
printf(GMT "%f %f\n",(($ucns[$bi]>=$opt_k)?$ucwm[$bi]:nan) |
|
673 |
,($bi+0.5)*$opt_o); |
|
674 |
} |
|
29 | 675 |
} |
676 |
||
46 | 677 |
GMT_psxy('-Sc0.1 -Gcoral'); # m.a.d. profiles |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
678 |
for (my($bi)=0; $bi<=$#dcw; $bi++) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
679 |
printf(GMT "%f %f\n",(($dcns[$bi]>=$opt_k)?$dcwmad[$bi]:nan),($bi+0.5)*$opt_o); |
29 | 680 |
} |
41 | 681 |
GMT_psxy('-Sc0.1 -GSeaGreen'); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
682 |
for (my($bi)=0; $bi<=$#ucw; $bi++) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
683 |
printf(GMT "%f %f\n",(($ucns[$bi]>=$opt_k)?$ucwmad[$bi]:nan),($bi+0.5)*$opt_o); |
29 | 684 |
} |
685 |
||
686 |
GMT_setR($R2); |
|
41 | 687 |
GMT_psxy('-W0.7,coral'); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
688 |
for (my($bi)=0; $bi<=$#dcw; $bi++) { # number of samples |
46 | 689 |
if ($dcns[$bi]) { printf(GMT "%f %f\n",$dcns[$bi],($bi+0.5)*$opt_o); } |
690 |
else { print(GMT "nan nan\n"); } |
|
29 | 691 |
} |
41 | 692 |
GMT_psxy('-W0.7,SeaGreen'); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
693 |
for (my($bi)=0; $bi<=$#dcw; $bi++) { |
46 | 694 |
if ($ucns[$bi]) { printf(GMT "%f %f\n",$ucns[$bi],($bi+0.5)*$opt_o); } |
695 |
else { print(GMT "nan nan\n"); } |
|
29 | 696 |
} |
697 |
||
41 | 698 |
GMT_psbasemap('-Bf10a1000-950:" # of Samples":N'); |
699 |
GMT_psbasemap('-Ba2000-1550N'); GMT_psbasemap('-Ba1000-750N'); |
|
29 | 700 |
|
701 |
$depth_tics = ($ymax-$ymin< 1000) ? 'f10a100' : 'f100a500'; |
|
702 |
GMT_setR($R); |
|
703 |
GMT_psbasemap('-Bf0.01a10-10.05:"Vertical Velocity [m/s] ":/' . |
|
704 |
$depth_tics . ':"Depth [m]":WeS'); |
|
705 |
GMT_psbasemap('-Ba10-9.95S'); GMT_psbasemap('-Ba10-9.85S'); |
|
706 |
||
46 | 707 |
if ($dual_head) { |
708 |
GMT_psxy('-W1,100/100/255'); # surface layer limit |
|
709 |
print(GMT "-0.1 $opt_s\n0.07 $opt_s\n"); |
|
56 | 710 |
} |
711 |
||
712 |
GMT_unitcoords(); |
|
713 |
my(@y) = (1.018,1.052,1.076,1.109); |
|
714 |
||
715 |
GMT_pstext('-F+f9,Helvetica,CornFlowerBlue+jTL -N'); # summary information |
|
716 |
if ($dual_head) { |
|
717 |
printf(GMT "0.64 $y[0] Dual-Head (%d / %d kHz)\n", |
|
718 |
round($xducer_frequency,50),round($xducer_frequency2,50)); |
|
719 |
} else { |
|
720 |
printf(GMT "0.64 $y[0] %d kHz $instrument_type $orientation\n", |
|
721 |
round($xducer_frequency,50)); |
|
722 |
} |
|
723 |
print( GMT "0.64 $y[1] rms <w>\n 0.77 $y[1] :\n"); |
|
724 |
if ($dual_head) { |
|
725 |
printf(GMT "0.64 $y[2] rms @~D@~w\n 0.77 %f :\n",$y[2]+0.007); |
|
726 |
printf(GMT "0.64 %f correl. (r)\n 0.77 $y[3] :\n",$y[3]-0.005); |
|
46 | 727 |
} |
728 |
||
56 | 729 |
if ($dual_head) { |
730 |
if ($dc_rms_wdiff > sqrt($dc_var)) { |
|
731 |
GMT_pstext('-F+f9,Helvetica,coral+jTR -N -Gyellow'); |
|
732 |
} else { |
|
733 |
GMT_pstext('-F+f9,Helvetica,coral+jTR -N'); |
|
734 |
} |
|
735 |
if (numberp($dc_R)) { |
|
736 |
&antsInfo("WARNING: low dc correlation (r = %.1f) between UL and DL data in profile #$id",$dc_R) |
|
737 |
if ($dc_R < 0.3); |
|
738 |
printf(GMT "0.88 %f %.1fmm/s\n",$y[1]-0.005,round(sqrt($dc_var)*1000,.1)); |
|
739 |
printf(GMT "0.88 %f %.1fmm/s\n",$y[2]+0.001,round($dc_rms_wdiff*1000,.1)); |
|
740 |
printf(GMT "0.88 %f %.1f",$y[3]-0.005,$dc_R); |
|
741 |
} else { |
|
742 |
&antsInfo("WARNING: no overlap between UL and DL dc data below the surface layer in profile #$id"); |
|
743 |
} |
|
744 |
} else { |
|
745 |
GMT_pstext('-F+f9,Helvetica,coral+jTR -N'); |
|
746 |
printf(GMT "0.88 %f %.1fmm/s\n",$y[1]-0.005,round(sqrt($dc_var)*1000,.1)); |
|
747 |
} |
|
748 |
||
749 |
if ($dual_head) { |
|
750 |
if ($uc_rms_wdiff > sqrt($uc_var)) { |
|
751 |
GMT_pstext('-F+f9,Helvetica,SeaGreen+jTR -N -Gyellow'); |
|
752 |
} else { |
|
753 |
GMT_pstext('-F+f9,Helvetica,SeaGreen+jTR -N'); |
|
754 |
} |
|
755 |
if (numberp($uc_R)) { |
|
756 |
&antsInfo("WARNING: low uc correlation (r = %.1f) between UL and DL data in profile #$id",$uc_R) |
|
757 |
if ($uc_R < 0.3); |
|
758 |
printf(GMT "0.99 %f %.1fmm/s\n",$y[1]-0.005,round(sqrt($uc_var)*1000,.1)); |
|
759 |
printf(GMT "0.99 %f %.1fmm/s\n",$y[2]+0.001,round($uc_rms_wdiff*1000,.1)); |
|
760 |
printf(GMT "0.99 %f %.1f",$y[3]-0.005,$uc_R); |
|
761 |
} else { |
|
762 |
&antsInfo("WARNING: no overlap between UL and DL uc data below the surface layer in profile #$id"); |
|
763 |
} |
|
764 |
} else { |
|
765 |
GMT_pstext('-F+f9,Helvetica,SeaGreen+jTR -N'); |
|
766 |
printf(GMT "0.99 %f %.1fmm/s\n",$y[1]-0.005,round(sqrt($uc_var)*1000,.1)); |
|
767 |
} |
|
768 |
||
769 |
GMT_pstext('-F+f14,Helvetica,blue+jTL -N'); # annotations |
|
41 | 770 |
if (defined($outfile)) { print(GMT "0.01 -0.06 $outfile [$P{run_label}]\n"); } |
771 |
else { printf(GMT "0.01 -0.06 %03d\n [$P{run_label}]",$id); } |
|
772 |
GMT_pstext('-F+f12,Helvetica+jMR'); |
|
56 | 773 |
print(GMT '0.62 0.98 m.abs.dev.'); |
46 | 774 |
GMT_pstext('-F+f9,Helvetica,orange+jBR -N -Gwhite'); |
775 |
print(GMT "0.99 0.99 V$VERSION\n"); |
|
56 | 776 |
GMT_pstext('-F+f12,Helvetica,coral+jTL -Gwhite'); |
777 |
print(GMT "0.02 0.02 downcast\n"); |
|
778 |
GMT_pstext('-F+f12,Helvetica,SeaGreen+jTL -Gwhite'); |
|
779 |
print(GMT "0.24 0.02 upcast\n"); |
|
780 |
GMT_pstext('-F+f12,Helvetica+jBL -Gwhite'); |
|
781 |
print(GMT "0.02 0.98 b.track\n"); |
|
41 | 782 |
|
29 | 783 |
GMT_end(); |
34 | 784 |
|
49 | 785 |
if ($dual_head && length($corrPF)>0) { # correlation plot |
34 | 786 |
my($mwm) = 0.05; # max(|w|) for axes |
787 |
for (my($bi)=0; $bi<@DL_dc_median; $bi++) { |
|
788 |
next unless numberp($DL_dc_median[$bi]) && numberp($UL_dc_median[$bi]); |
|
789 |
$mwm = abs($DL_dc_median[$bi]) if abs($DL_dc_median[$bi]) > $mwm; |
|
790 |
$mwm = abs($UL_dc_median[$bi]) if abs($UL_dc_median[$bi]) > $mwm; |
|
791 |
} |
|
792 |
for (my($bi)=0; $bi<@DL_uc_median; $bi++) { |
|
793 |
next unless numberp($DL_uc_median[$bi]) && numberp($UL_uc_median[$bi]); |
|
794 |
$mwm = abs($DL_uc_median[$bi]) if abs($DL_uc_median[$bi]) > $mwm; |
|
795 |
$mwm = abs($UL_uc_median[$bi]) if abs($UL_uc_median[$bi]) > $mwm; |
|
796 |
} |
|
797 |
$mwm = int(100*$mwm+0.9999) / 100; |
|
798 |
$R = "-R-$mwm/$mwm/-$mwm/$mwm"; |
|
799 |
||
800 |
GMT_begin(sprintf($corrPF,$id),"-JX$plotsize/$plotsize",$R,'-P -X6 -Y4'); |
|
801 |
GMT_psxy('-Ggrey80 -L'); |
|
802 |
printf(GMT "%g %g\n%g %g\n%g %g\n%g %g\n%g %g\n%g %g\n", |
|
803 |
-$mwm, -$mwm+0.01, |
|
804 |
-$mwm, -$mwm, |
|
805 |
-$mwm+0.01, -$mwm, |
|
806 |
$mwm, $mwm-0.01, |
|
807 |
$mwm, $mwm, |
|
808 |
$mwm-0.01, $mwm); |
|
809 |
||
41 | 810 |
GMT_psxy('-W2,grey50'); |
34 | 811 |
print(GMT "-$mwm -$mwm\n$mwm $mwm\n"); |
41 | 812 |
GMT_psxy('-Sc0.12c -Gcoral -W0.3,blue'); |
34 | 813 |
for (my($bi)=0; $bi<@DL_dc_median; $bi++) { |
814 |
next unless numberp($DL_dc_median[$bi]) && numberp($UL_dc_median[$bi]); |
|
815 |
my($depth) = ($bi+0.5)*$opt_o; |
|
816 |
last if ($depth > $opt_s); |
|
817 |
print(GMT "$DL_dc_median[$bi] $UL_dc_median[$bi]\n"); |
|
818 |
} |
|
41 | 819 |
GMT_psxy('-Sc0.12c -Gcoral'); |
34 | 820 |
for (my($bi)=0; $bi<@DL_dc_median; $bi++) { |
821 |
next unless numberp($DL_dc_median[$bi]) && numberp($UL_dc_median[$bi]); |
|
822 |
my($depth) = ($bi+0.5)*$opt_o; |
|
823 |
next unless ($depth > $opt_s); |
|
824 |
print(GMT "$DL_dc_median[$bi] $UL_dc_median[$bi]\n"); |
|
825 |
} |
|
41 | 826 |
GMT_psxy('-Sc0.12c -GSeaGreen -W0.3,blue'); |
34 | 827 |
for (my($bi)=0; $bi<@DL_uc_median; $bi++) { |
828 |
next unless numberp($DL_uc_median[$bi]) && numberp($UL_uc_median[$bi]); |
|
829 |
my($depth) = ($bi+0.5)*$opt_o; |
|
830 |
last if ($depth > $opt_s); |
|
831 |
print(GMT "$DL_uc_median[$bi] $UL_uc_median[$bi]\n"); |
|
832 |
} |
|
41 | 833 |
GMT_psxy('-Sc0.12c -GSeaGreen'); |
34 | 834 |
for (my($bi)=0; $bi<@DL_uc_median; $bi++) { |
835 |
next unless numberp($DL_uc_median[$bi]) && numberp($UL_uc_median[$bi]); |
|
836 |
my($depth) = ($bi+0.5)*$opt_o; |
|
837 |
next unless ($depth > $opt_s); |
|
838 |
print(GMT "$DL_uc_median[$bi] $UL_uc_median[$bi]\n"); |
|
839 |
} |
|
41 | 840 |
GMT_pstext('-F+f14,Helvetica,blue+jTL -N'); |
841 |
if (defined($outfile)) { printf(GMT "%f %f $outfile [$P{run_label}]\n",-$mwm,1.1*$mwm); } |
|
842 |
else { printf(GMT "%f %f %03d\n [$P{run_label}]",$id,-$mwm,1.1*$wmw); } |
|
34 | 843 |
GMT_psbasemap('-Bf0.01a0.05:"DL Vertical Velocity [m/s]":/f0.01a0.05:"UL Vertical Velocity [m/s]":WeSn'); |
844 |
GMT_end(); |
|
845 |
||
49 | 846 |
} # if dual_head && length(corrPF) > 0 |
34 | 847 |
|
29 | 848 |
} |
849 |
||
850 |
&antsExit(0); |