1 %====================================================================== |
1 %====================================================================== |
2 % L O A D C T D . M |
2 % L O A D C T D . M |
3 % doc: Sat Jun 26 15:56:43 2004 |
3 % doc: Sat Jun 26 15:56:43 2004 |
4 % dlm: Fri Mar 21 11:01:39 2014 |
4 % dlm: Thu May 28 07:51:39 2015 |
5 % (c) 2004 M. Visbeck & A. Thurnherr |
5 % (c) 2004 M. Visbeck & A. Thurnherr |
6 % uE-Info: 52 1 NIL 0 0 72 0 2 8 NIL ofnI |
6 % uE-Info: 169 24 NIL 0 0 72 0 2 8 NIL ofnI |
7 %====================================================================== |
7 %====================================================================== |
8 |
8 |
9 function [d,p]=loadctd(f,d,p) |
9 function [d,p]=loadctd(f,d,p) |
10 % function [d,p]=loadctd(f,d,p) |
10 % function [d,p]=loadctd(f,d,p) |
11 |
11 |
81 % only when elapsed time was used) |
81 % only when elapsed time was used) |
82 % Sep 18, 2008: - BUG: moved code had assumed that nav data were loaded |
82 % Sep 18, 2008: - BUG: moved code had assumed that nav data were loaded |
83 % Jan 7, 2009: - tightened use of exist() |
83 % Jan 7, 2009: - tightened use of exist() |
84 % Jun 16, 2009: - BUG: patching short nav time series did not work correctly |
84 % Jun 16, 2009: - BUG: patching short nav time series did not work correctly |
85 % Mar 21, 2014: - BUG: f.ctd_time_base used p.ctd_time_base set as default |
85 % Mar 21, 2014: - BUG: f.ctd_time_base used p.ctd_time_base set as default |
|
86 % May 27, 2015: - removed confusing diagnostic message regarding adjusting NAV time |
|
87 % May 28, 2015: - added error message when there are no valid vertical velocities |
86 |
88 |
87 % read SEABIRD ctd timeseries file |
89 % read SEABIRD ctd timeseries file |
88 disp(['LOADCTD: load CTD time series ',f.ctd]) |
90 disp(['LOADCTD: load CTD time series ',f.ctd]) |
89 if ~exist(f.ctd,'file') |
91 if ~exist(f.ctd,'file') |
90 warn=([' LOADCTD can not find ',f.ctd]); |
92 warn=([' LOADCTD can not find ',f.ctd]); |
162 length(timctd),median(diff(timctd))*24*3600)); |
164 length(timctd),median(diff(timctd))*24*3600)); |
163 end |
165 end |
164 |
166 |
165 % calc LADCP depth |
167 % calc LADCP depth |
166 w=meannan(d.rw); |
168 w=meannan(d.rw); |
|
169 if sum(isfinite(w)) == 0 |
|
170 error('No valid vertical velocities --- aborting'); |
|
171 end |
167 ii=find(~isfinite(w)); |
172 ii=find(~isfinite(w)); |
168 w(ii)=0; |
173 w(ii)=0; |
169 dt=diff(d.time_jul)*24*3600; |
174 dt=diff(d.time_jul)*24*3600; |
170 dt=mean([0,dt;dt,0]); |
175 dt=mean([0,dt;dt,0]); |
171 z=cumsum(w.*dt); |
176 z=cumsum(w.*dt); |
202 disp(sprintf(' maybe the hour was set wrong: adjusting CTD time by %d days',... |
207 disp(sprintf(' maybe the hour was set wrong: adjusting CTD time by %d days',... |
203 p.ctdtimoff)); |
208 p.ctdtimoff)); |
204 timctd = timctd + p.ctdtimoff; |
209 timctd = timctd + p.ctdtimoff; |
205 end |
210 end |
206 |
211 |
207 if p.navdata & f.nav_time_base == 0 |
212 if p.navdata && f.nav_time_base == 0 |
208 disp(sprintf(' adjusting GPS time to CTD time (%+d seconds)',floor(p.ctdtimoff*24*3600))) |
213 if ~strcmp(f.ctd,f.nav) |
|
214 disp(sprintf(' adjusting GPS time to CTD time (%+d seconds)',floor(p.ctdtimoff*24*3600))) |
|
215 end |
209 d.navtime_jul = d.navtime_jul + p.ctdtimoff; |
216 d.navtime_jul = d.navtime_jul + p.ctdtimoff; |
210 end |
217 end |
211 |
218 |
212 % plot profile |
219 % plot profile |
213 figure(4); |
220 figure(4); |