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