author | A.M. Thurnherr <athurnherr@yahoo.com> |
Wed, 25 May 2016 12:14:29 -0400 | |
changeset 46 | cc6c4309828a |
parent 43 | 567b03b9ce8d |
child 47 | 2ccb81b7cea5 |
permissions | -rwxr-xr-x |
18 | 1 |
#!/usr/bin/perl |
2 |
#====================================================================== |
|
29 | 3 |
# L A D C P _ W _ C T D |
18 | 4 |
# doc: Mon Nov 3 17:34:19 2014 |
43 | 5 |
# dlm: Thu Mar 31 05:52:01 2016 |
18 | 6 |
# (c) 2014 A.M. Thurnherr |
43 | 7 |
# uE-Info: 62 42 NIL 0 0 72 2 2 4 NIL ofnI |
18 | 8 |
#====================================================================== |
9 |
||
10 |
$antsSummary = 'pre-process SBE 9plus CTD data for LADCP_w'; |
|
11 |
||
12 |
# HISTORY: |
|
13 |
# Nov 3, 2014: - created |
|
14 |
# Nov 4, 2014: - improved |
|
15 |
# Nov 6, 2014: - BUG: sound speed was not calculated correctly |
|
16 |
# - added -a |
|
17 |
# - added conductivity & temperature editing |
|
18 |
# Nov 7, 2014: - loosened outlier editing |
|
19 |
# - added no-valid-data error message |
|
20 |
# - modified binning criterion to allow any sampling |
|
21 |
# frequency (not just divisors of 24) |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
22 |
# Apr 17, 2015: - added in-situ temperature to output |
29 | 23 |
# Apr 23, 2015: - had to losen unrealistic-soundspeed criterion |
24 |
# because of DUK2#45 |
|
25 |
# May 13, 2015: - BUG: did not work with casts beginning at depth |
|
26 |
# - added errors when editing edits too much |
|
27 |
# May 14, 2015: - BUG: depth was wrong for partial-depth casts |
|
28 |
# - BUG: $badval had not been handled correctly |
|
29 |
# - BUG: editing errors were too tight |
|
30 |
# Jun 16, 2015: - added STDOUT redirection (default output file) on tty stdout |
|
31 |
# - added -p)lot option |
|
32 |
# Jun 17, 2015: - added cond to std output |
|
33 |
# - added conductivity spike filter (different from pressure) |
|
34 |
# Jun 18, 2015: - renamed from SBE_w |
|
35 |
# Jun 19, 2015: - added press & salin to make output suitable for u/v processing |
|
36 |
# - removed a couple of data assertions |
|
37 |
# Jul 20, 2015: - allow for non-numeric -i |
|
31 | 38 |
# Aug 17, 2015: - modified plots |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
39 |
# Sep 21, 2015: - added lat/lon to output if available in input |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
40 |
# Sep 22, 2015: - added error on non-numeric station information |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
41 |
# - changed plot output name |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
42 |
# Sep 23, 2015: - added -o |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
43 |
# - improved pressure editing |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
44 |
# - modified editing algorithm, primarily reducing temperature resolution |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
45 |
# from 0.1deg to 1deg and finding contiguous range up to single gap in histogram |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
46 |
# (requring halving of resolution) |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
47 |
# Oct 12, 2015: - require ANTSlibs V6.2 for release |
33 | 48 |
# Oct 13, 2015: - added code to deal with CNV files with wrong number of scans in header |
49 |
# Oct 13, 2015: - adapted to [version.pl] |
|
34 | 50 |
# Jan 25, 2016: - added software version %PARAM |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
51 |
# Feb 16, 2016: - BUG: %sampling_interval was erroenously called %sampling_frequency |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
52 |
# Feb 19, 2016: - improved on-surface data detection (conductivity <= 10mS/cm) |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
53 |
# - BUG: temperatures < 0 were not allowed |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
54 |
# - temperature histogram resolution increased from 1degC to 0.5degC for no good reason |
39 | 55 |
# Mar 13, 2016: - added simple ASCII file format |
56 |
# - BUG: Layout error when input had no lat/lon |
|
40 | 57 |
# - added lon to simple ASCII format |
41 | 58 |
# Mar 16, 2016: - adapted to gmt5 |
42 | 59 |
# Mar 19, 2016: - added support for $VERB environment var |
60 |
# - added $libSBE_quiet flag |
|
43 | 61 |
# Mar 30, 2016: - added station number of ASCII format |
62 |
# Mar 31, 2016: - changed version %PARAM |
|
18 | 63 |
|
33 | 64 |
($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$}); |
65 |
($WCALC) = ($0 =~ m{^(.*)/[^/]*$}); |
|
66 |
$WCALC = '.' if ($WCALC eq ''); |
|
18 | 67 |
|
33 | 68 |
require "$WCALC/version.pl"; |
18 | 69 |
require "$ANTS/ants.pl"; |
70 |
require "$ANTS/fft.pl"; |
|
29 | 71 |
require "$ANTS/libGMT.pl"; |
18 | 72 |
require "$ANTS/libSBE.pl"; |
73 |
require "$ANTS/libEOS83.pl"; |
|
43 | 74 |
&antsAddParams('LADCP_w_CTD::version',$VERSION); |
18 | 75 |
|
76 |
$antsParseHeader = 0; # usage |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
77 |
&antsUsage('ai:l:orp:s:v:',1, |
18 | 78 |
'[-v)erbosity <level[0]>]', |
79 |
'[use -a)lternate sensor pair]', |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
80 |
'[-r)etain all data (no editing)] [allow infinite -o)utliers]', |
18 | 81 |
'[-s)ampling <rate[6Hz]>]', |
82 |
'[-l)owpass w <cutoff[2s]>]', |
|
29 | 83 |
'[profile -i)d <id>]', |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
84 |
'[-p)lot_basenames <[%03d_w_CTD.ps],[%03d_sspd.ps]>]', |
18 | 85 |
'<SBE CNV file>'); |
86 |
||
87 |
&antsFloatOpt(\$opt_l,2); # defaults |
|
88 |
&antsCardOpt(\$opt_s,6); |
|
42 | 89 |
&antsCardOpt(\$opt_v,$ENV{VERB}); # support VERB env variable |
18 | 90 |
|
91 |
$CNVfile = $ARGV[0]; # open CNV file |
|
92 |
open(F,&antsFileArg()); |
|
28
b07b23485336
after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
26
diff
changeset
|
93 |
&antsActivateOut(); # activate ANTS file |
18 | 94 |
|
95 |
#---------------------------------------------------------------------- |
|
96 |
# Read Data |
|
97 |
#---------------------------------------------------------------------- |
|
98 |
||
99 |
print(STDERR "Reading $CNVfile...") if ($opt_v); |
|
100 |
||
39 | 101 |
chomp($rec = <F>); |
102 |
croak("$CNVfile: no data\n") |
|
103 |
unless defined($rec); |
|
18 | 104 |
|
39 | 105 |
if ($rec =~ /^\*/) { # SBE CNV file |
42 | 106 |
$libSBE_quiet = 1; # suppress diagnostic messages |
39 | 107 |
($nfields,$nscans,$sampint,$badval,$ftype,$lat,$lon) = # decode SBE header |
108 |
SBE_parseHeader(F,0,0); # SBE field names, no time check |
|
109 |
||
110 |
croak("$CNVfile: unexpected sampling interval $sampint\n") |
|
111 |
unless (abs($sampint-1/24) < 1e-5); |
|
112 |
croak("$CNVfile: no latitude in header\n") |
|
113 |
unless numberp($lat); |
|
114 |
||
115 |
$pressF = fnr('prDM'); |
|
116 |
||
117 |
if ($opt_a) { # temp/cond alternate sensor pair |
|
118 |
$tempF = fnr('t190C'); |
|
119 |
$condF = fnrNoErr('c1S/m'); |
|
120 |
if (defined($condF)) { |
|
121 |
$condHistRes = 20; # 0.2 S/m bins |
|
122 |
} else { |
|
123 |
$condF = fnr('c1mS/cm'); |
|
124 |
$condHistRes = 2; # 2.0 mS/cm bins |
|
125 |
} |
|
126 |
} else { # primary sensor pair |
|
127 |
$tempF = fnr('t090C'); |
|
128 |
$condF = fnrNoErr('c0S/m'); |
|
129 |
if (defined($condF)) { |
|
130 |
$condHistRes = 20; |
|
131 |
} else { |
|
132 |
$condF = fnr('c0mS/cm'); |
|
133 |
$condHistRes = 2; |
|
134 |
} |
|
18 | 135 |
} |
39 | 136 |
|
137 |
$latF = &fnrNoErr('lat'); # GPS data if available (to make files useful for u/v processing) |
|
138 |
$lonF = &fnrNoErr('lon'); |
|
139 |
||
140 |
&antsInstallBufFull(0); # read entire CNV file |
|
141 |
&SBEin(F,$ftype,$nfields,$nscans,$badval); |
|
142 |
||
143 |
if (@ants_ != $nscans) { |
|
144 |
if ($opt_v > 1) { |
|
145 |
printf(STDERR "\n\nWARNING: $CNVfile has wrong number of scans in header\n"); |
|
146 |
} else { |
|
147 |
printf(STDERR "WARNING: $CNVfile has wrong number of scans in header\n"); |
|
148 |
} |
|
149 |
$nscans = @ants_; |
|
18 | 150 |
} |
43 | 151 |
} else { # simple CSV ASCII file format: |
152 |
($lat,$lon,$station) = split(',',$rec); |
|
153 |
croak("$CNVfile: ASCII file format error (1st rec must be lat,lon[,id])\n") # header: lat,lon[,station] |
|
40 | 154 |
unless numberp($lat) && numberp($lon) && |
155 |
$lat>=-90 && $lat<=90 && |
|
156 |
$lon>=-360 && $lon<=360; |
|
43 | 157 |
&antsAddParams('station',$station) if defined($station); |
40 | 158 |
&antsAddParams('lat',$lat,'lon',$lon); |
39 | 159 |
$sampint = 1/24; $condHistRes = 2; # assumptions: 24Hz |
160 |
&antsAddParams('ITS',90,'cond.unit','mS/cm'); # ITS-90, mS/cm |
|
161 |
$pressF = 1; $tempF = 2; $condF = 3; # Layout: scan press temp cond |
|
162 |
for ($nscans=0; <F>; $nscans++) { |
|
163 |
chomp; |
|
164 |
@{$ants_[$nscans]} = split(','); # CSV format |
|
165 |
croak("$CNVfile: unexpected scan #$ants_[$nscans][0] (%d expected)\n",$nscans+1) |
|
166 |
unless ($ants_[$nscans][0] == $nscans+1); |
|
167 |
$ants_[$nscans][$pressF] = nan unless defined($ants_[$nscans][$pressF]); # missing values |
|
168 |
$ants_[$nscans][$tempF] = nan unless defined($ants_[$nscans][$tempF]); |
|
169 |
$ants_[$nscans][$condF] = nan unless defined($ants_[$nscans][$condF]); |
|
33 | 170 |
} |
171 |
} |
|
172 |
||
18 | 173 |
printf(STDERR "\n\t%d scans",$nscans) if ($opt_v > 1); |
174 |
printf(STDERR "\n") if ($opt_v); |
|
175 |
||
176 |
#---------------------------------------------------------------------- |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
177 |
# Redirect STDOUT to %.6Hz & create %_w_CTD.ps,%_sspd.ps if STDOUT is a tty |
29 | 178 |
#---------------------------------------------------------------------- |
179 |
||
180 |
$id = defined($opt_i) ? $opt_i : &antsParam('station'); |
|
181 |
croak("$CNVfile: no station information in header => -i required\n") |
|
182 |
unless defined($id); |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
183 |
croak("$CNVfile: non-numeric station information <$id> in header => -i required\n") |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
184 |
unless numberp($id); |
29 | 185 |
|
186 |
if (-t STDOUT) { |
|
187 |
if (numberp($id)) { |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
188 |
$opt_p = '%03d_w_CTD.ps,%03d_sspd.ps' |
29 | 189 |
unless defined($opt_p); |
190 |
$outfile = sprintf('%03d.%dHz',$id,$opt_s); |
|
191 |
} else { |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
192 |
$opt_p = '%s_w_CTD.ps,%s_sspd.ps' |
29 | 193 |
unless defined($opt_p); |
194 |
$outfile = sprintf('%s.%dHz',$id,$opt_s); |
|
195 |
} |
|
196 |
open(STDOUT,">$outfile") || die("$outfile: $!\n"); |
|
197 |
} |
|
198 |
||
199 |
#---------------------------------------------------------------------- |
|
18 | 200 |
# Edit Data |
201 |
# - pressure outliers & spikes |
|
202 |
# - conductivity outliers & spikes |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
203 |
# - max_bin+1 is returned to ensure full range |
18 | 204 |
#---------------------------------------------------------------------- |
205 |
||
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
206 |
sub validRange($) |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
207 |
{ |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
208 |
my($guess_bin) = @_; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
209 |
my($min_bin,$max_bin); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
210 |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
211 |
die("assertion failed") unless ($hist[$guess_bin]); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
212 |
for ($max_bin=$guess_bin; $hist[$max_bin]; $max_bin++) { } |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
213 |
for ($min_bin=$guess_bin; $hist[$min_bin]; $min_bin--) { } |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
214 |
return ($min_bin,$max_bin+1); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
215 |
} |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
216 |
|
18 | 217 |
unless ($opt_r) { |
218 |
print(STDERR "Editing Data...") if ($opt_v); |
|
219 |
||
220 |
#---------------------------------------- |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
221 |
# trim initial records with |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
222 |
# - nan pressure |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
223 |
# - nan conductivity |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
224 |
# - conductivity <= 10 mS/cm |
18 | 225 |
#---------------------------------------- |
226 |
my($trimmed) = 0; # trim leading nan pressures |
|
227 |
shift(@ants_),$trimmed++ |
|
42 | 228 |
# ,printf(STDERR "-> p=$ants_[0][$pressF] c=$ants_[0][$condF]\n") |
39 | 229 |
until !@ants_ || |
230 |
numberp($ants_[0][$pressF]) && |
|
231 |
numberp($ants_[0][$condF]) && |
|
232 |
(($P{'cond.unit'} eq 'mS/cm' && $ants_[0][$condF] > 10) || |
|
233 |
($P{'cond.unit'} eq 'S/m' && $ants_[0][$condF] > 1)); |
|
234 |
croak("\n$CNVfile: no valid records (wrong conductivity units?)\n") |
|
235 |
unless (@ants_); |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
236 |
printf(STDERR "\n\t%d initial at-surface records trimmed",$trimmed) if ($opt_v > 1); |
18 | 237 |
my($lvp) = $ants_[0][$pressF]; |
29 | 238 |
my($lvc) = $ants_[0][$condF]; |
18 | 239 |
|
240 |
#------------------------------------------------ |
|
241 |
# edit pressure outliers outside contiguous range |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
242 |
# - 2dbar resolution |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
243 |
# - histogram shifted by 100dbar to allow for negative values |
18 | 244 |
#------------------------------------------------ |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
245 |
my($outliers) = my($modeSamp) = 0; my($modeBin,$min,$max); local(@hist); |
18 | 246 |
for (my($s)=0; $s<$nscans; $s++) { |
29 | 247 |
next unless ($ants_[$s][$pressF]>=-100 && $ants_[$s][$pressF]<=6500); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
248 |
my($b) = ($ants_[$s][$pressF]+100) / 2; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
249 |
$hist[$b]++; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
250 |
next unless ($hist[$b] > $modeSamp); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
251 |
$modeSamp = $hist[$b]; $modeBin = $b; |
18 | 252 |
} |
33 | 253 |
printf(STDERR "\n\tvalid pressure guess: %d dbar (%d samples)",2*$modeBin-100,$modeSamp) |
254 |
if ($opt_v > 1); |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
255 |
($min,$max) = validRange($modeBin); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
256 |
$min = 2*$min-100; $max = 2*$max-100; |
18 | 257 |
for (my($s)=0; $s<$nscans; $s++) { |
258 |
if ($ants_[$s][$pressF] > $max) { $outliers++; $ants_[$s][$pressF] = nan; } |
|
259 |
if ($ants_[$s][$pressF] < $min) { $outliers++; $ants_[$s][$pressF] = nan; } |
|
260 |
} |
|
261 |
&antsAddParams("pressure_outliers",sprintf("%d",$outliers)); |
|
262 |
printf(STDERR "\n\tcontinuous pressure range: %d..%d dbar (%d outliers removed)",$min,$max,$outliers) if ($opt_v > 1); |
|
29 | 263 |
croak("$CNVfile: pressure editing removed too many 'outliers'\n") |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
264 |
unless ($opt_o || $outliers < 100); |
18 | 265 |
|
266 |
#---------------------------------------------------- |
|
267 |
# edit conductivity outliers outside contiguous range |
|
268 |
#---------------------------------------------------- |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
269 |
$outliers = $modeSamp = 0; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
270 |
undef(@hist); |
18 | 271 |
for (my($s)=0; $s<$nscans; $s++) { |
272 |
next unless ($ants_[$s][$condF] > 0); |
|
273 |
my($b) = $ants_[$s][$condF]*$condHistRes; # 1/10 S/m histogram resolution (1 mS/cm) |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
274 |
$hist[$b]++; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
275 |
next unless ($hist[$b] > $modeSamp); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
276 |
$modeSamp = $hist[$b]; $modeBin = $b; |
18 | 277 |
} |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
278 |
($min,$max) = validRange($modeBin); |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
279 |
$min /= $condHistRes; $max /= $condHistRes; |
18 | 280 |
for (my($s)=0; $s<$nscans; $s++) { |
281 |
if ($ants_[$s][$condF] > $max) { $outliers++; $ants_[$s][$condF] = nan; } |
|
282 |
if ($ants_[$s][$condF] < $min) { $outliers++; $ants_[$s][$condF] = nan; } |
|
283 |
} |
|
284 |
&antsAddParams("conductivity_outliers",sprintf("%d",$outliers)); |
|
285 |
printf(STDERR "\n\tcontinuous conductivity range: %.1f..%.1f S/m (%d outliers removed)",$min,$max,$outliers) if ($opt_v > 1); |
|
29 | 286 |
croak("$CNVfile: conductivity editing removed too many 'outliers'\n") |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
287 |
unless ($opt_o || $outliers/$nscans < 0.4); |
18 | 288 |
|
289 |
#---------------------------------------------------- |
|
290 |
# edit temperature outliers outside contiguous range |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
291 |
# - Stan's NBP0901 profiles require resolution of 1deg |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
292 |
# - otherwise 0.2deg seems to be fine |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
293 |
# - however, on Feb 19, 2016 it was found that the |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
294 |
# resolution had been left at 1degC without any |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
295 |
# apparent adverse effects |
18 | 296 |
#---------------------------------------------------- |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
297 |
$outliers = $modeSamp = 0; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
298 |
undef(@hist); |
18 | 299 |
for (my($s)=0; $s<$nscans; $s++) { |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
300 |
next unless ($ants_[$s][$tempF] >= -10); |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
301 |
my($b) = ($ants_[$s][$tempF] + 10) * 0.5; |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
302 |
$hist[$b]++; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
303 |
next unless ($hist[$b] > $modeSamp); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
304 |
$modeSamp = $hist[$b]; $modeBin = $b; |
18 | 305 |
} |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
306 |
# printf(STDERR "\n\ttemperature mode: %.1f degC (%d samples)",$modeBin/0.5-10,$modeSamp) |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
307 |
# if ($opt_v > 1); |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
308 |
($min,$max) = validRange($modeBin); |
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
309 |
$min = ($min / 0.5) - 10; |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
310 |
$max = ($max / 0.5) - 10; |
18 | 311 |
for (my($s)=0; $s<$nscans; $s++) { |
312 |
if ($ants_[$s][$tempF] > $max) { $outliers++; $ants_[$s][$tempF] = nan; } |
|
313 |
if ($ants_[$s][$tempF] < $min) { $outliers++; $ants_[$s][$tempF] = nan; } |
|
314 |
} |
|
315 |
&antsAddParams("temperature_outliers",sprintf("%d",$outliers)); |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
316 |
printf(STDERR "\n\tcontinuous temperature range: %.1f..%.1f degC (%d outliers removed)",$min,$max,$outliers) |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
317 |
if ($opt_v > 1); |
29 | 318 |
croak("$CNVfile: temperature editing removed too many 'outliers'\n") |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
319 |
unless ($opt_o || $outliers/$nscans < 0.4); |
18 | 320 |
|
321 |
#---------------------------------------- |
|
322 |
# edit pressure spikes based on gradients |
|
323 |
#---------------------------------------- |
|
324 |
||
29 | 325 |
for (my($s)=1; $s<$nscans; $s++) { # calculate pressure gradients (across gaps) |
18 | 326 |
if (numberp($ants_[$s][$pressF])) { |
327 |
$dp[$s-1] = $ants_[$s][$pressF] - $lvp; |
|
328 |
$lvp = $ants_[$s][$pressF]; |
|
329 |
} else { |
|
330 |
$dp[$s-1] = nan; |
|
331 |
} |
|
332 |
} |
|
333 |
||
334 |
my($ns1,$ns2) = (0,0); |
|
335 |
for (my($s)=0; $s<$nscans-2; $s++) { # consecutive large pressure gradients of opposite sign |
|
336 |
if (($dp[$s]*$dp[$s+1] < 0) && # tests return false if either of the dps is not defined |
|
337 |
(abs($dp[$s]) > 10) && |
|
338 |
(abs($dp[$s+1]) > 10)) { |
|
339 |
$ants_[$s+1][$pressF] = nan; |
|
340 |
$dp[$s] = $dp[$s+1] = undef; |
|
341 |
$ns1++; |
|
342 |
} |
|
343 |
} |
|
344 |
for (my($s)=0; $s<$nscans-3; $s++) { # 3 consecutive large pressure gradients of opposite sign |
|
345 |
if (($dp[$s]>2 && $dp[$s+1]<-4 && $dp[$s+2]>2) || |
|
346 |
($dp[$s]<-2 && $dp[$s+1]>4 && $dp[$s+2]<-2)) { |
|
347 |
$ants_[$s+1][$pressF] = $ants_[$s+2][$pressF] = nan; |
|
348 |
$dp[$s] = $dp[$s+1] = $dp[$s+2] = undef; |
|
349 |
$ns2+=2; |
|
350 |
} |
|
351 |
} |
|
352 |
&antsAddParams("pressure_spikes_removed",sprintf("%d+%d",$ns1,$ns2)); |
|
353 |
printf(STDERR "\n\t%d+%d pressure spikes removed",$ns1,$ns2) if ($opt_v > 1); |
|
354 |
||
29 | 355 |
#-------------------------------------------------- |
356 |
# edit conductivity spikes based on large gradients |
|
357 |
# - $lvc = $ants_[0] is guaranteed numeric here |
|
358 |
#-------------------------------------------------- |
|
359 |
||
360 |
my($nv) = my($ns) = my($last_dcond) = my($lvcs) = 0; |
|
361 |
my($run_start) = my($run_dcond) = 0; |
|
362 |
for (my($s)=1; $s<$nscans; $s++) { # calculate conductivity gradients (across gaps) |
|
363 |
next unless numberp($ants_[$s][$condF]); |
|
364 |
||
365 |
my($dcond) = $ants_[$s][$condF] - $lvc; # integrate gradient across runs |
|
366 |
# print(STDERR "ldc/dc/rdc: $last_dcond/$dcond/$run_dcond\n"); |
|
367 |
if ($last_dcond*$dcond >= 0) { # run is continuing (gradient does not change sign) |
|
368 |
$run_dcond += $dcond; |
|
369 |
} else { # run has ended |
|
370 |
# print(STDERR "new run at $lvcs (run_dcond = $last_dcond)\n"); |
|
371 |
$run_start = $lvcs; |
|
372 |
$run_dcond = $dcond; |
|
373 |
} |
|
374 |
||
375 |
if (abs($run_dcond) <= 0.02) { # small integrated gradient => okay |
|
376 |
$lvc = $ants_[$s][$condF]; # update stored previous values |
|
377 |
$lvcs = $s; |
|
378 |
$last_dcond = $dcond; |
|
379 |
next; # process next scan |
|
380 |
} |
|
381 |
||
382 |
# print(STDERR "large gradient ($ants_[$run_start][$condF]-$ants_[$s][$condF], $run_dcond) run $run_start-$s\n"); |
|
383 |
my($i); |
|
384 |
my($max_spike_length) = 24; |
|
385 |
for ($i=$s; $i<=$run_start+$max_spike_length && $i<$nscans-1; $i++) { # large gradient => check whether values return within 10s |
|
386 |
next unless (numberp($ants_[$i][$condF]) && |
|
387 |
numberp($ants_[$i+1][$condF])); |
|
388 |
last if ((abs($ants_[$i][$condF]-$ants_[$run_start][$condF]) <= 0.005) && # 2 vals to avoid large gradients |
|
389 |
(abs($ants_[$i+1][$condF]-$ants_[$run_start][$condF]) <= 0.005)); |
|
390 |
} |
|
391 |
||
392 |
if ($i>$run_start+$max_spike_length || $i==$nscans-1) { # values don't return => leave data alone |
|
393 |
# print(STDERR "values don't return => new run at $s\n"); |
|
394 |
$run_start = $s; $run_dcond = 0; |
|
395 |
$lvc = $ants_[$run_start][$condF]; # start new run |
|
396 |
$lvcs = $run_start; |
|
397 |
$last_dcond = 0; |
|
398 |
next; # process next scan |
|
399 |
} |
|
400 |
||
401 |
$ns++; |
|
402 |
for (my($j)=$run_start+1; $j<$i; $j++) { # values return => remove bad spike |
|
403 |
$ants_[$j][$condF] = nan; |
|
404 |
$nv++; |
|
405 |
} |
|
406 |
# print(STDERR "values return at $i ($ants_[$i][$condF]) => deleted $run_start+1-$i; new run\n"); |
|
407 |
$run_start = $i; $run_dcond = 0; |
|
408 |
$lvc = $ants_[$run_start][$condF]; |
|
409 |
$lvcs = $run_start; |
|
410 |
$last_dcond = 0; |
|
411 |
} |
|
412 |
&antsAddParams("conductivity_spikes_removed",$ns); |
|
413 |
printf(STDERR "\n\t%d conductivity values removed from %d spikes",$nv,$ns) if ($opt_v > 1); |
|
414 |
||
18 | 415 |
printf(STDERR "\n") if ($opt_v); |
416 |
||
417 |
} # if $opt_r |
|
418 |
||
419 |
#---------------------------------------------------------------------- |
|
420 |
# Correcting for pressure bias |
|
421 |
#---------------------------------------------------------------------- |
|
422 |
||
423 |
print(STDERR "Correcting for pressure bias...") if ($opt_v); |
|
424 |
||
425 |
my($minP) = 9e99; |
|
426 |
for (my($s)=0; $s<$nscans; $s++) { |
|
427 |
$minP = $ants_[$s][$pressF] |
|
428 |
if numberp($ants_[$s][$pressF]) && ($ants_[$s][$pressF] < $minP); |
|
429 |
} |
|
430 |
croak("$CNVfile: no valid CTD pressure data below 25dbar\n") |
|
431 |
unless ($minP < 9e99); |
|
29 | 432 |
|
433 |
if ($minP < 25) { |
|
434 |
&antsAddParams('pressure_bias',$minP); |
|
435 |
printf(STDERR "\n\tsubtracting %.1f dbar",$minP) if ($opt_v > 1); |
|
436 |
for (my($s)=0; $s<$nscans; $s++) { |
|
437 |
$ants_[$s][$pressF] -= $minP |
|
438 |
if numberp($ants_[$s][$pressF]); |
|
439 |
} |
|
440 |
} else { |
|
441 |
printf(STDERR "\n\tpartial-depth cast below %.1f dbar (no correction applied)",$minP) if ($opt_v > 1); |
|
18 | 442 |
} |
443 |
printf(STDERR "\n") if ($opt_v); |
|
444 |
||
445 |
#---------------------------------------------------------------------- |
|
446 |
# Binning data |
|
447 |
#---------------------------------------------------------------------- |
|
448 |
||
449 |
my($sps) = round(1 / $sampint / $opt_s); |
|
450 |
print(STDERR "Creating ${opt_s}Hz time series ($sps samples per bin)...") if ($opt_v); |
|
35
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
451 |
&antsAddParams('sampling_interval',1/$opt_s); |
54b8bb450e5f
Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
34
diff
changeset
|
452 |
&antsAddParams('sampling_frequency',$opt_s); |
18 | 453 |
|
454 |
my(@press,@temp,@cond); |
|
455 |
my($sp,$np,$st,$nt,$sc,$nc); |
|
456 |
||
457 |
$sp = $st = $sc = $np = $nt = $nc = 0; |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
458 |
$slat = $slon = $nGPS = 0; |
18 | 459 |
for (my($rec)=1,my($s)=0; $s<$nscans; $s++) { |
460 |
if ($s*$sampint > $rec/$opt_s) { |
|
461 |
$rec++; |
|
462 |
push(@press,$np>0?$sp/$np:nan); |
|
463 |
push(@temp, $nt>0?$st/$nt:nan); |
|
464 |
push(@cond, $nc>0?$sc/$nc:nan); |
|
465 |
$sp = $st = $sc = $np = $nt = $nc = 0; |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
466 |
if (defined($latF)) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
467 |
push(@lat,$nGPS>0?$slat/$nGPS:nan); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
468 |
push(@lon,$nGPS>0?$slon/$nGPS:nan); |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
469 |
$slat = $slon = $nGPS = 0; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
470 |
} |
18 | 471 |
} |
472 |
$sp+=$ants_[$s][$pressF],$np++ if numberp($ants_[$s][$pressF]); |
|
473 |
$st+=$ants_[$s][$tempF],$nt++ if numberp($ants_[$s][$tempF]); |
|
474 |
$sc+=$ants_[$s][$condF],$nc++ if numberp($ants_[$s][$condF]); |
|
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
475 |
if (defined($latF) && numberp($ants_[$s][$latF])) { |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
476 |
$slat += $ants_[$s][$latF]; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
477 |
$slon += $ants_[$s][$lonF]; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
478 |
$nGPS++; |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
479 |
} |
18 | 480 |
} |
481 |
||
482 |
printf(STDERR "\n") if ($opt_v); |
|
483 |
||
484 |
#---------------------------------------------------------------------- |
|
485 |
# Calculating derived quantities |
|
486 |
#---------------------------------------------------------------------- |
|
487 |
||
488 |
print(STDERR "Calculating vertical package velocity & sound speed...") if ($opt_v); |
|
489 |
||
29 | 490 |
my($maxP) = -9e99; my($atBtm); |
491 |
my($min_sspd) = 9e99; my($max_sspd) = -9e99; |
|
18 | 492 |
for (my($r)=0; $r<@press; $r++) { |
29 | 493 |
$maxP=$press[$r],$atBtm=$r if ($press[$r] > $maxP); |
18 | 494 |
$elapsed[$r] = $r/$opt_s; |
495 |
$depth[$r] = &depth($press[$r],$lat); |
|
39 | 496 |
# print(STDERR "depth[$r] = depth($press[$r],$lat) = $depth[$r]\n"); |
29 | 497 |
$salin[$r] = &salin($cond[$r],$temp[$r],$press[$r]); |
498 |
$sspd[$r] = &sVel($salin[$r],$temp[$r],$press[$r]); |
|
499 |
$min_sspd = $sspd[$r] if ($sspd[$r] < $min_sspd); |
|
500 |
$max_sspd = $sspd[$r] if ($sspd[$r] > $max_sspd); |
|
18 | 501 |
} |
502 |
||
503 |
$w[0] = nan; |
|
504 |
for (my($r)=1; $r<@depth-1; $r++) { |
|
505 |
$w[$r] = numbersp($depth[$r-1],$depth[$r+1]) |
|
506 |
? ($depth[$r+1] - $depth[$r-1]) * $opt_s |
|
507 |
: nan; |
|
508 |
} |
|
509 |
push(@w,nan); |
|
510 |
||
511 |
printf(STDERR "\n") if ($opt_v); |
|
512 |
||
513 |
#---------------------------------------------------------------------- |
|
514 |
# Low-pass filter velocity data |
|
515 |
# - interpolate missing vertical velocities first |
|
516 |
#---------------------------------------------------------------------- |
|
517 |
||
518 |
if ($opt_l > 0) { |
|
519 |
print(STDERR "Low-pass filtering vertical package velocity...") if ($opt_v); |
|
520 |
&antsAddParams('w_lowpass_cutoff',$opt_l); |
|
521 |
||
522 |
my($trimmed) = 0; |
|
523 |
shift(@w),shift(@depth),shift(@elapsed),shift(@sspd),$trimmed++ |
|
524 |
until numberp($w[0]); |
|
525 |
my($interpolated) = 0; |
|
526 |
for ($r=1; $r<@w; $r++) { |
|
527 |
next if numberp($w[$r]); |
|
528 |
my($lv) = $r-1; |
|
529 |
for ($nv=$r+1; $nv<@depth && !numberp($w[$nv]); $nv++) {} |
|
530 |
if ($nv < @depth) { |
|
531 |
while ($r < $nv) { |
|
532 |
$w[$r] = $w[$lv] + ($r-$lv)/($nv-$lv) * ($w[$nv]-$w[$lv]); |
|
533 |
$interpolated++; |
|
534 |
$r++; |
|
535 |
} |
|
536 |
||
537 |
} else { |
|
538 |
$trimmed += @w-$r; |
|
539 |
splice(@w,$r); splice(@depth,$r); |
|
540 |
splice(@elapsed,$r); splice(@sspd,$r); |
|
541 |
} |
|
542 |
} |
|
543 |
&antsAddParams('w_interpolated',$interpolated); |
|
544 |
printf(STDERR "\n\t%d/%d vertical velocities trimmed/interpolated",$trimmed,$interpolated) if ($opt_v > 1); |
|
545 |
||
546 |
||
547 |
#-------------------- |
|
548 |
# Zero Pad Data |
|
549 |
#-------------------- |
|
550 |
||
551 |
for ($pot=1; $pot<@w; $pot<<=1) {} # determine power of two |
|
552 |
||
553 |
for ($r=0; $r<@w; $r++) { # copy data |
|
554 |
$fftbuf[2*$r] = $w[$r]; |
|
555 |
$fftbuf[2*$r+1] = 0; |
|
556 |
} |
|
557 |
printf(STDERR "\n\t%d zero records added",$pot-$r) if ($opt_v > 1); |
|
558 |
while ($r < $pot) { # pad with zeroes |
|
559 |
$fftbuf[2*$r] = $fftbuf[2*$r+1] = 0; |
|
560 |
$r++; |
|
561 |
} |
|
562 |
||
563 |
#-------------------- |
|
564 |
# Low-Pass Filter |
|
565 |
#-------------------- |
|
566 |
||
567 |
@fco = &FOUR1(-1,@fftbuf); # forward FFT |
|
568 |
$n = @fco/2; |
|
569 |
for (my($ip)=2; $ip<=$n; $ip+=2) { # +ve freq fco |
|
570 |
my($in) = 2*$n-$ip; # -ve freq fco |
|
571 |
my($f) = $ip/2/$n*$opt_s; # frequency |
|
572 |
$fco[$ip] = $fco[$ip+1] = $fco[$in] = $fco[$in+1] = 0 |
|
573 |
if ($f > 1/$opt_l); # low-pass filter |
|
574 |
} |
|
575 |
@w_lp = &FOUR1(1,@fco); # inverse FFT |
|
576 |
||
577 |
printf(STDERR "\n") if ($opt_v); |
|
578 |
} else { |
|
579 |
@w_lp = @w; |
|
580 |
} |
|
581 |
||
582 |
#---------------------------------------------------------------------- |
|
583 |
||
29 | 584 |
if (defined($opt_p)) { |
585 |
print(STDERR "Plotting data...\n") if ($opt_v); |
|
586 |
my(@pfmt) = split(',',$opt_p); |
|
587 |
croak("$0: cannot decode -p $opt_p\n") |
|
588 |
unless (@pfmt == 2); |
|
589 |
||
590 |
my($xmin) = $elapsed[0]/60; |
|
591 |
my($xmax) = $elapsed[$#elapsed]/60; |
|
592 |
my($ymin) = -3; my($ymax) = 3; |
|
593 |
my($plotsize) = '13c'; |
|
31 | 594 |
GMT_begin(sprintf($pfmt[0],$id),"-JX${plotsize}","-R$xmin/$xmax/$ymin/$ymax",'-X6 -Y4 -P'); |
41 | 595 |
GMT_psxy('-W1,coral'); |
29 | 596 |
for ($r=0; $r<@w; $r++) { |
597 |
printf(GMT "%f %f\n",$elapsed[$r]/60,$w_lp[2*$r]/@w_lp); |
|
41 | 598 |
GMT_psxy('-W1,SeaGreen') if ($r == $atBtm); |
29 | 599 |
} |
600 |
GMT_psbasemap('-Bg60a30f5:"Elapsed Time [min]":/g1a1f0.1:"Vertical Package Velocity [ms@+-1@+]":WeSn'); |
|
601 |
GMT_unitcoords(); |
|
41 | 602 |
GMT_pstext('-F+f14,Helvetica,coral+jTR'); print(GMT "0.98 0.98 dc\n"); |
603 |
GMT_pstext('-F+f14,Helvetica,SeaGreen+jTR'); print(GMT "0.98 0.94 uc\n"); |
|
604 |
GMT_pstext('-F+f14,Helvetica,blue+jTL -N'); |
|
605 |
if (defined($outfile)) { printf(GMT "0.01 1.06 $outfile\n",$id); } |
|
606 |
else { printf(GMT "0.01 1.06 %03d\n",$id); } |
|
29 | 607 |
GMT_end(); |
608 |
||
609 |
my($xmin) = round($min_sspd-3,5); |
|
610 |
my($xmax) = round($max_sspd+3,5); |
|
611 |
my($ymin) = 0; my($ymax) = round($depth[$atBtm]+70,100); |
|
612 |
my($plotsize) = '13c'; |
|
31 | 613 |
GMT_begin(sprintf($pfmt[1],$id),"-JX${plotsize}/-${plotsize}","-R$xmin/$xmax/$ymin/$ymax",'-X6 -Y4 -P'); |
29 | 614 |
GMT_psbasemap('-Bg10a10f1:"Speed of Sound [m/s]":/g1000a500f100:"Depth [m]":WeSn'); |
41 | 615 |
GMT_psxy('-W2,coral'); |
29 | 616 |
for ($r=0; $r<@w; $r++) { |
617 |
printf(GMT "%f %f\n",$sspd[$r],$depth[$r]); |
|
41 | 618 |
GMT_psxy('-W1.5,SeaGreen') if ($r == $atBtm); |
29 | 619 |
} |
620 |
GMT_unitcoords(); |
|
41 | 621 |
GMT_pstext('-F+f14,Helvetica,coral+jTR'); print(GMT "0.98 0.02 dc\n"); |
622 |
GMT_pstext('-F+f14,Helvetica,SeaGreen+jTR'); print(GMT "0.98 0.06 uc\n"); |
|
623 |
GMT_pstext('-F+f14,Helvetica,blue+jTL -N'); |
|
624 |
if (defined($outfile)) { printf(GMT "0.01 -0.06 $outfile\n",$id); } |
|
625 |
else { printf(GMT "0.01 -0.06 %03d\n",$id); } |
|
29 | 626 |
GMT_end(); |
627 |
} |
|
628 |
||
629 |
#---------------------------------------------------------------------- |
|
630 |
||
18 | 631 |
print(STDERR "Writing output...\n") if ($opt_v); |
632 |
||
39 | 633 |
@antsNewLayout = ('elapsed','press','temp','cond','depth','salin','sspd','w.raw','w','lat','lon'); |
18 | 634 |
for ($r=0; $r<@w; $r++) { |
32
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
635 |
&antsOut($elapsed[$r],$press[$r],$temp[$r],$cond[$r],$depth[$r],$salin[$r], |
6041a20feb39
V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
31
diff
changeset
|
636 |
$sspd[$r],$w[$r],$w_lp[2*$r]/@w_lp,$lat[$r],$lon[$r]); |
18 | 637 |
} |
638 |
||
639 |
exit(0); # don't flush @ants_ |