loadctd.m
changeset 22 624b1ed6e9c9
parent 17 f5a63c03d9c8
child 23 e83393696a24
equal deleted inserted replaced
21:bce791a17f4e 22:624b1ed6e9c9
     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: Thu May 28 07:51:39 2015
     4 %                    dlm: Tue Jan 28 13:22:51 2020
     5 %                    (c) 2004 M. Visbeck & A. Thurnherr
     5 %                    (c) 2004 M. Visbeck & A. Thurnherr
     6 %                    uE-Info: 169 24 NIL 0 0 72 0 2 8 NIL ofnI
     6 %                    uE-Info: 94 45 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 
    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
    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
    87 %   May 28, 2015: - added error message when there are no valid vertical velocities
       
    88 %   Apr 18, 2018: - BUG: ADCP-time shift warning was meaningless with elapsed time_base
       
    89 %   Sep 14, 2018: - BUG: code move in 2008 broke working with single GPS file for entire cruise
       
    90 %   Jan 28, 2020: - I don't understand Sep 14, 2018 bug any more; fix for that bug 
       
    91 %		    involved moving code to loadnav.m, which does not work because
       
    92 %		    during loadnav p.time_start and end are not known (LADCP turn on/off 
       
    93 %		    times are used); present code works with SR1b repeat cruises, which
       
    94 %	            all have single gps files
    88 
    95 
    89 % read SEABIRD ctd timeseries file
    96 % read SEABIRD ctd timeseries file
    90 disp(['LOADCTD: load CTD time series ',f.ctd])
    97 disp(['LOADCTD: load CTD time series ',f.ctd])
    91 if ~exist(f.ctd,'file')
    98 if ~exist(f.ctd,'file')
    92  warn=([' LOADCTD can not find ',f.ctd]);
    99  warn=([' LOADCTD can not find ',f.ctd]);
   437 
   444 
   438  % decide if the correlation is good enought to shift ADCP time
   445  % decide if the correlation is good enought to shift ADCP time
   439  if abs(lag)<p.ctdmaxlag & co>p.ctdmincorr
   446  if abs(lag)<p.ctdmaxlag & co>p.ctdmincorr
   440   disp(' adjust ADCP time to CTD time and shift depth record ')
   447   disp(' adjust ADCP time to CTD time and shift depth record ')
   441   d.time_jul=d.time_jul+lagdt;
   448   d.time_jul=d.time_jul+lagdt;
   442   if lagdt*24*3600>10
   449   if f.ctd_time_base~=0 && lagdt*24*3600>10
   443    disp('WARNING WARNING WARNING')
   450    disp('WARNING WARNING WARNING')
   444    warn=[' shifted ADCP timeseries by ',int2str(lagdt*24*3600),' seconds '];
   451    warn=[' shifted ADCP timeseries by ',int2str(lagdt*24*3600),' seconds '];
   445    disp(warn)
   452    disp(warn)
   446    p.warn(size(p.warn,1)+1,1:length(warn))=warn;
   453    p.warn(size(p.warn,1)+1,1:length(warn))=warn;
   447   end
   454   end
   538 %	- set start/end positions
   545 %	- set start/end positions
   539 %	- p.navtime_jul should be consistent with both timctd and d.time_jul
   546 %	- p.navtime_jul should be consistent with both timctd and d.time_jul
   540 %	  at this stage
   547 %	  at this stage
   541 %----------------------------------------------------------------------
   548 %----------------------------------------------------------------------
   542 
   549 
   543 if p.navdata
   550 if p.navdata %%%&& f.nav_time_base == 0
   544   if min(d.navtime_jul)>max(d.time_jul) | max(d.navtime_jul)<min(d.time_jul)
   551   if min(d.navtime_jul)>max(d.time_jul) | max(d.navtime_jul)<min(d.time_jul)
   545     disp('NAV timeseries does not overlap WRONG STATION????')
   552     disp('NAV timeseries does not overlap WRONG STATION????')
   546     disp(['  NAV-data : ',datestrj(d.navtime_jul(1)),'	to ',datestrj(d.navtime_jul(end))])
   553     disp(['  NAV-data : ',datestrj(d.navtime_jul(1)),'	to ',datestrj(d.navtime_jul(end))])
   547     disp([' ADCP-data : ',datestrj(d.time_jul(1)),'  to ',datestrj(d.time_jul(end))])
   554     disp([' ADCP-data : ',datestrj(d.time_jul(1)),'  to ',datestrj(d.time_jul(end))])
   548     disp(' will ignore nav data')
   555     disp(' will ignore nav data')
   647 %
   654 %
   648 function a=datestrj(b)
   655 function a=datestrj(b)
   649 % 
   656 % 
   650 % print julian date string
   657 % print julian date string
   651 %
   658 %
   652 a=datestr(b-julian([0 1 0 0 0 0]));
   659 a=datestr(b-julian([0 1 0 0 0 0]));			
   653 
   660 
   654 %
   661 %
   655 %==============================================================
   662 %==============================================================
   656 function [hours]=hms2h(h,m,s);
   663 function [hours]=hms2h(h,m,s);
   657 %HMS2H converts hours, minutes, and seconds to hours
   664 %HMS2H converts hours, minutes, and seconds to hours