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: Tue Jul 13 11:33:11 2021 |
5 # dlm: Tue May 17 15:39:24 2022 |
6 # (c) 2014 A.M. Thurnherr |
6 # (c) 2014 A.M. Thurnherr |
7 # uE-Info: 226 118 NIL 0 0 72 2 2 4 NIL ofnI |
7 # uE-Info: 158 0 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: |
96 # Apr 29, 2021: - improved warning message |
96 # Apr 29, 2021: - improved warning message |
97 # Jun 29, 2021: - improved plot labelling |
97 # Jun 29, 2021: - improved plot labelling |
98 # Jun 30, 2021: - ditto |
98 # Jun 30, 2021: - ditto |
99 # Jul 13, 2021: - improved gaps PARAMs |
99 # Jul 13, 2021: - improved gaps PARAMs |
100 # - added clock/transmission warnings |
100 # - added clock/transmission warnings |
|
101 # Apr 6, 2022: - added %profile_id (not tested) |
|
102 # May 10, 2022: - BUG: non-numeric ids no longer worked |
|
103 # - added -d to allow for station and cast numbering |
|
104 # May 17, 2022: - made station cast numbering work based on input file name |
101 # HISTORY END |
105 # HISTORY END |
102 |
106 |
103 # NOTES: |
107 # NOTES: |
104 # w_CTD is positive during the downcast to make the sign of the apparent |
108 # w_CTD is positive during the downcast to make the sign of the apparent |
105 # water velocity consistent with w_ocean |
109 # water velocity consistent with w_ocean |
122 &antsAddParams('LADCP_w_CTD::version',$VERSION); |
126 &antsAddParams('LADCP_w_CTD::version',$VERSION); |
123 |
127 |
124 $antsParseHeader = 0; # usage |
128 $antsParseHeader = 0; # usage |
125 $antsSuppressCommonOptions = 1; |
129 $antsSuppressCommonOptions = 1; |
126 $IS = &antsLoadModel('`','.nminterp','linear'); |
130 $IS = &antsLoadModel('`','.nminterp','linear'); |
127 &antsUsage("ab:c:fgi:l:morp:qs:v:w:$IS_opts",1, |
131 &antsUsage("ab:c:d:fgi:l:morp:qs:v:w:$IS_opts",1, |
128 '[-v)erbosity <level[0]>]', |
132 '[-v)erbosity <level[0]>]', |
129 '[use -a)lternate sensor pair]', |
133 '[use -a)lternate sensor pair]', |
130 '[correct -S)alinity <bias>]', |
134 '[correct -S)alinity <bias>]', |
131 '[-r)etain all data (no editing)] [allow infinite -o)utliers]', |
135 '[-r)etain all data (no editing)] [allow infinite -o)utliers]', |
132 '[suppress CTD -m)odulo error correction]', |
136 '[suppress CTD -m)odulo error correction]', |
133 '[-s)ampling <rate[6Hz]>]', |
137 '[-s)ampling <rate[6Hz]>]', |
134 '[lowpass w_CTD -c)utoff <limit[2s]>] [-w)inch-speed <granularity[10s]>]', |
138 '[lowpass w_CTD -c)utoff <limit[2s]>] [-w)inch-speed <granularity[10s]>]', |
135 '[profile -i)d <id>] [station -l)ocation <lat/lon>]', |
139 '[profile -i)d <id>] [id -d)igits <#[3]>] [station -l)ocation <lat/lon>]', |
136 '[-p)lot_basenames <[%03d_w_CTD.ps],[%03d_sspd.ps]>]', |
140 '[-p)lot_basenames <[%03d_w_CTD.ps],[%03d_sspd.ps]>]', |
137 '[-q)uiet (no plots)]', |
141 '[-q)uiet (no plots)]', |
138 '[-f)ill gaps with linear interpolation]', |
142 '[-f)ill gaps with linear interpolation]', |
139 '<SBE CNV file>'); |
143 '<SBE CNV file>'); |
140 &antsUsageError() unless defined($IS); |
144 &antsUsageError() unless defined($IS); |
143 &antsCardOpt(\$opt_s,6); # default output sampling rate (Hz) |
147 &antsCardOpt(\$opt_s,6); # default output sampling rate (Hz) |
144 &antsFloatOpt(\$opt_w,10); # winch velocity granularity |
148 &antsFloatOpt(\$opt_w,10); # winch velocity granularity |
145 &antsFloatOpt(\$opt_b,0); # salinity bias |
149 &antsFloatOpt(\$opt_b,0); # salinity bias |
146 &antsCardOpt(\$opt_v,$ENV{VERB}); # support VERB env variable |
150 &antsCardOpt(\$opt_v,$ENV{VERB}); # support VERB env variable |
147 |
151 |
148 $CNVfile = $ARGV[0]; # open CNV file |
152 $CNVfile = $ARGV[0]; # input file |
149 open(F,&antsFileArg()); |
153 |
|
154 ($basename) = ($CNVfile =~ m{([^/]*)\.[^\.]*$}); # determine number of digits to use in profile id |
|
155 $opt_d = length($basename) # - default is 3 |
|
156 if length($basename)>3 && !defined($opt_d); # - use length of input basename if it is longer than 3 |
|
157 &antsCardOpt(\$opt_d,3); # - explicit -d overrides |
|
158 |
|
159 open(F,&antsFileArg()); # open CNV file |
150 &antsAddDeps($CNVfile); |
160 &antsAddDeps($CNVfile); |
151 &antsActivateOut(); # activate ANTS file |
161 &antsActivateOut(); # activate ANTS file |
152 |
162 |
153 &antsAddParams('salinity_bias_corrected',$opt_b) |
163 &antsAddParams('salinity_bias_corrected',$opt_b) |
154 if ($opt_b != 0); |
164 if ($opt_b != 0); |
404 #---------------------------------------------------------------------- |
414 #---------------------------------------------------------------------- |
405 |
415 |
406 $id = defined($opt_i) ? $opt_i : &antsParam('station'); |
416 $id = defined($opt_i) ? $opt_i : &antsParam('station'); |
407 _croak("$CNVfile: no station information in header => -i required\n") |
417 _croak("$CNVfile: no station information in header => -i required\n") |
408 unless defined($id); |
418 unless defined($id); |
409 _croak("$CNVfile: non-numeric station information <$id> in header => -i required\n") |
419 #_croak("$CNVfile: non-numeric station information <$id> in header => -i required\n") |
410 unless numberp($id); |
420 # unless numberp($id); |
|
421 &antsAddParams('profile_id',$id); |
411 |
422 |
412 if (-t STDOUT) { |
423 if (-t STDOUT) { |
413 if (numberp($id)) { |
424 if (numberp($id)) { |
414 $opt_p = '%03d_w_CTD.ps,%03d_sspd.ps' |
425 my($numfmt) = "%0${opt_d}d"; |
|
426 $opt_p = "${numfmt}_w_CTD.ps,${numfmt}_sspd.ps" |
415 unless defined($opt_p); |
427 unless defined($opt_p); |
416 $outfile = sprintf('%03d.%dHz',$id,$opt_s); |
428 $outfile = sprintf("$numfmt.%dHz",$id,$opt_s); |
417 } else { |
429 } else { |
418 $opt_p = '%s_w_CTD.ps,%s_sspd.ps' |
430 $opt_p = '%s_w_CTD.ps,%s_sspd.ps' |
419 unless defined($opt_p); |
431 unless defined($opt_p); |
420 $outfile = sprintf('%s.%dHz',$id,$opt_s); |
432 $outfile = sprintf('%s.%dHz',$id,$opt_s); |
421 } |
433 } |