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