loadctd.m
changeset 23 e83393696a24
parent 22 624b1ed6e9c9
equal deleted inserted replaced
22:624b1ed6e9c9 23:e83393696a24
     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: Tue Jan 28 13:22:51 2020
     4 %                    dlm: Thu Apr 29 21:44:11 2021
     5 %                    (c) 2004 M. Visbeck & A. Thurnherr
     5 %                    (c) 2004 M. Visbeck & A. Thurnherr
     6 %                    uE-Info: 94 45 NIL 0 0 72 0 2 8 NIL ofnI
     6 %                    uE-Info: 97 69 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 
    90 %   Jan 28, 2020: - I don't understand Sep 14, 2018 bug any more; fix for that bug 
    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
    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 
    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
    93 %		    times are used); present code works with SR1b repeat cruises, which
    94 %	            all have single gps files
    94 %	            all have single gps files
       
    95 %   Apr 29, 2021: - disable use of bin-1 data for integration of w; this was necessitated
       
    96 %		    by A22 030, which is a shallow profile where bin 1 of the on-deck DL 
       
    97 %	 	    data seems valid, messing up the zmax calculation
    95 
    98 
    96 % read SEABIRD ctd timeseries file
    99 % read SEABIRD ctd timeseries file
    97 disp(['LOADCTD: load CTD time series ',f.ctd])
   100 disp(['LOADCTD: load CTD time series ',f.ctd])
    98 if ~exist(f.ctd,'file')
   101 if ~exist(f.ctd,'file')
    99  warn=([' LOADCTD can not find ',f.ctd]);
   102  warn=([' LOADCTD can not find ',f.ctd]);
   170   disp(sprintf(' interpolated to %d CTD scans; delta_t = %.2f seconds',...
   173   disp(sprintf(' interpolated to %d CTD scans; delta_t = %.2f seconds',...
   171   		length(timctd),median(diff(timctd))*24*3600));
   174   		length(timctd),median(diff(timctd))*24*3600));
   172 end
   175 end
   173 
   176 
   174 % calc LADCP depth
   177 % calc LADCP depth
   175 w=meannan(d.rw);
   178 %	- don't use bin 1, which is contaminated by ringing
       
   179 %	  when zero blanking is used 
       
   180 
       
   181 if length(d.zu)>0 && length(d.zd)>0					% dual-head system
       
   182   w = meannan(d.rw([1:(p.nbin_d-1),(end-p.nbin_u+1):end],:));
       
   183 elseif length(d.zu)>0							% uplooker only(?)
       
   184   w = meannan(d.rw([(end-p.nbin_u+1):end],:));
       
   185 else
       
   186   w = meannan(d.rw([1:(p.nbin_d-1)],:));				% downlooker only
       
   187 end
   176 if sum(isfinite(w)) == 0
   188 if sum(isfinite(w)) == 0
   177     error('No valid vertical velocities --- aborting');
   189     error('No valid vertical velocities --- aborting');
   178 end
   190 end
   179 ii=find(~isfinite(w));
   191 ii=find(~isfinite(w));
   180 w(ii)=0;
   192 w(ii)=0;