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