1 #!/usr/bin/perl |
1 #!/usr/bin/perl |
2 #====================================================================== |
2 #====================================================================== |
3 # L A D C P _ W _ C T D |
3 # L A D C P _ W _ C T D |
4 # doc: Mon Nov 3 17:34:19 2014 |
4 # doc: Mon Nov 3 17:34:19 2014 |
5 # dlm: Fri Oct 5 14:52:00 2018 |
5 # dlm: Mon Apr 29 18:00:44 2019 |
6 # (c) 2014 A.M. Thurnherr |
6 # (c) 2014 A.M. Thurnherr |
7 # uE-Info: 85 93 NIL 0 0 72 2 2 4 NIL ofnI |
7 # uE-Info: 111 15 NIL 0 0 72 2 2 4 NIL ofnI |
8 #====================================================================== |
8 #====================================================================== |
9 |
9 |
10 $antsSummary = 'pre-process SBE 9plus CTD data for LADCP_w'; |
10 $antsSummary = 'pre-process SBE 9plus CTD data for LADCP_w'; |
11 |
11 |
12 # HISTORY: |
12 # HISTORY: |
81 # problem with AAIW data is lack of pressure resolution |
81 # problem with AAIW data is lack of pressure resolution |
82 # => returned to 2dbar |
82 # => returned to 2dbar |
83 # - added plotting errors |
83 # - added plotting errors |
84 # - improved log message |
84 # - improved log message |
85 # - BUG: initial in-air scans were not handled correctly (nscans not updated) |
85 # - BUG: initial in-air scans were not handled correctly (nscans not updated) |
86 |
86 # Mar 25, 2019: - changed error message to allow creating 1Hz from 4Hz file (SBE19) |
|
87 # - BUG: ITS was not set. How is this possible????? |
|
88 # Apr 21, 2019: - modified code to allow production of 24Hz files (previous code required |
|
89 # min 2 samples per bin, allowing for max 12Hz sampling rate) |
87 |
90 |
88 # NOTES: |
91 # NOTES: |
89 # w_CTD is positive during the downcast to make the sign of the apparent |
92 # w_CTD is positive during the downcast to make the sign of the apparent |
90 # water velocity consistent with w_ocean |
93 # water velocity consistent with w_ocean |
91 |
94 |
103 require "$ANTS/libEOS83.pl"; |
106 require "$ANTS/libEOS83.pl"; |
104 &antsAddParams('LADCP_w_CTD::version',$VERSION); |
107 &antsAddParams('LADCP_w_CTD::version',$VERSION); |
105 |
108 |
106 $antsParseHeader = 0; # usage |
109 $antsParseHeader = 0; # usage |
107 $antsSuppressCommonOptions = 1; |
110 $antsSuppressCommonOptions = 1; |
108 &antsUsage('ai:l:orp:qs:v:w:',1, |
111 &antsUsage('ac:i:l:orp:qs:v:w:',1, |
109 '[-v)erbosity <level[0]>]', |
112 '[-v)erbosity <level[0]>]', |
110 '[use -a)lternate sensor pair]', |
113 '[use -a)lternate sensor pair]', |
111 '[-r)etain all data (no editing)] [allow infinite -o)utliers]', |
114 '[-r)etain all data (no editing)] [allow infinite -o)utliers]', |
112 '[-s)ampling <rate[6Hz]>]', |
115 '[-s)ampling <rate[6Hz]>]', |
113 '[lowpass w_CTD -c)utoff <limit[2s]>] [-w)inch-speed <granularity[10s]>]', |
116 '[lowpass w_CTD -c)utoff <limit[2s]>] [-w)inch-speed <granularity[10s]>]', |
145 if ($rec =~ /^\*/) { # SBE CNV file |
148 if ($rec =~ /^\*/) { # SBE CNV file |
146 $libSBE_quiet = 1; # suppress diagnostic messages |
149 $libSBE_quiet = 1; # suppress diagnostic messages |
147 ($nfields,$nscans,$sampint,$badval,$ftype,$lat,$lon) = # decode SBE header |
150 ($nfields,$nscans,$sampint,$badval,$ftype,$lat,$lon) = # decode SBE header |
148 SBE_parseHeader(F,0,0); # SBE field names, no time check |
151 SBE_parseHeader(F,0,0); # SBE field names, no time check |
149 |
152 |
150 _croak("$CNVfile: unexpected sampling interval $sampint\n") |
153 # _croak("$CNVfile: unexpected sampling interval $sampint s\n") |
151 unless (abs($sampint-1/24) < 1e-5); |
154 # unless (abs($sampint-1/24) < 1e-5); |
|
155 _croak("$CNVfile: insufficient time resolution ($sampint s) for ${opt_s}Hz time series\n") |
|
156 if (round(1/$sampint/$opt_s) < 1); |
152 |
157 |
153 if (defined($opt_l)) { # set/override station location with -l |
158 if (defined($opt_l)) { # set/override station location with -l |
154 my($slat,$slon) = split('[,/]',$opt_l); |
159 my($slat,$slon) = split('[,/]',$opt_l); |
155 $lat = GMT2deg($slat); |
160 $lat = GMT2deg($slat); |
156 $lon = GMT2deg($slon); |
161 $lon = GMT2deg($slon); |
161 unless numberp($lat); |
166 unless numberp($lat); |
162 |
167 |
163 &antsAddParams('lat',$lat); |
168 &antsAddParams('lat',$lat); |
164 &antsAddParams('lon',$lon); |
169 &antsAddParams('lon',$lon); |
165 |
170 |
166 $pressF = fnr('prDM'); |
171 $pressF = fnrNoErr('prdM'); # pressure; SBE19plus |
|
172 $pressF = fnr('prDM') unless defined($pressF); # SBE 9plus |
167 |
173 |
168 if ($opt_a) { # temp/cond alternate sensor pair |
174 if ($opt_a) { # temp/cond alternate sensor pair |
169 $tempF = fnr('t190C'); |
175 $tempF = fnr('t190C'); |
|
176 &antsAddParams('ITS',90); |
170 $condF = fnrNoErr('c1S/m'); |
177 $condF = fnrNoErr('c1S/m'); |
171 if (defined($condF)) { |
178 if (defined($condF)) { |
172 $condHistRes = 20; # 0.2 S/m bins |
179 $condHistRes = 20; # 0.2 S/m bins |
173 } else { |
180 } else { |
174 $condF = fnr('c1mS/cm'); |
181 $condF = fnr('c1mS/cm'); |
175 $condHistRes = 2; # 2.0 mS/cm bins |
182 $condHistRes = 2; # 2.0 mS/cm bins |
176 } |
183 } |
177 } else { # primary sensor pair |
184 } else { # primary sensor pair |
178 $tempF = fnr('t090C'); |
185 $tempF = fnrNoErr('tv290C'); # SBE 19plus |
|
186 $tempF = fnr('t090C') unless defined($tempF); # SBE 9plus |
|
187 &antsAddParams('ITS',90); |
179 $condF = fnrNoErr('c0S/m'); |
188 $condF = fnrNoErr('c0S/m'); |
180 if (defined($condF)) { |
189 if (defined($condF)) { |
181 $condHistRes = 20; |
190 $condHistRes = 20; |
182 } else { |
191 } else { |
183 $condF = fnr('c0mS/cm'); |
192 $condF = fnr('c0mS/cm'); |