fillSGMissingGPSDate

PURPOSE ^

FILLSGMISSINGGPSDATE Fill missing date component of Seaglider GPS timestamps.

SYNOPSIS ^

function [stampnum, hhmmss, ddmmyy] = fillSGMissingGPSDate(hhmmss, ddmmyy)

DESCRIPTION ^

FILLSGMISSINGGPSDATE  Fill missing date component of Seaglider GPS timestamps.

  Syntax:
    STAMPNUM = FILLSGMISSINGGPSDATE(DDMMYY, HHMMSS)
    [STAMPNUM, HHMMSS, DDMMYY] = FILLSGMISSINGGPSDATE(HHMMSS, DDMMYY)

  Description:
    STAMPNUM = FILLSGMISSINGGPSDATE(DDMMYY, HHMMSS) fills the date component
    of GPS timestamps given by character arrays or string cell arrays HHMMSS
    and DDMMYY and returns them as serial date numbers in array STARTNUM.
    See note below.

    [STAMPNUM, HHMMSS, DDMMYY] = FILLSGMISSINGGPSDATE(HHMMSS, DDMMYY) also 
    returns the same input arrays HHMMSS and DDMMYY but with the empty
    entries in DDMMYY filled with the corresponding date component value.

  Notes:
    GPS lines in Seaglider log may have no date component and the corresponding
    entries of input DDMMYY will be empty. Those entries are filled computing
    the corresponding date from the next timestamp with a date component and
    taking into account day roll backs inferred from the time components.

  Examples:
    stampvec = fillSGMissingGPSTimestamp(hhmmss, ddmmyy)

  See also:

  Authors:
    Joan Pau Beltran  <joanpau.beltran@socib.cat>

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

fillSGMissingGPSDate.m

SOURCE CODE ^

0001 function [stampnum, hhmmss, ddmmyy] = fillSGMissingGPSDate(hhmmss, ddmmyy)
0002 %FILLSGMISSINGGPSDATE  Fill missing date component of Seaglider GPS timestamps.
0003 %
0004 %  Syntax:
0005 %    STAMPNUM = FILLSGMISSINGGPSDATE(DDMMYY, HHMMSS)
0006 %    [STAMPNUM, HHMMSS, DDMMYY] = FILLSGMISSINGGPSDATE(HHMMSS, DDMMYY)
0007 %
0008 %  Description:
0009 %    STAMPNUM = FILLSGMISSINGGPSDATE(DDMMYY, HHMMSS) fills the date component
0010 %    of GPS timestamps given by character arrays or string cell arrays HHMMSS
0011 %    and DDMMYY and returns them as serial date numbers in array STARTNUM.
0012 %    See note below.
0013 %
0014 %    [STAMPNUM, HHMMSS, DDMMYY] = FILLSGMISSINGGPSDATE(HHMMSS, DDMMYY) also
0015 %    returns the same input arrays HHMMSS and DDMMYY but with the empty
0016 %    entries in DDMMYY filled with the corresponding date component value.
0017 %
0018 %  Notes:
0019 %    GPS lines in Seaglider log may have no date component and the corresponding
0020 %    entries of input DDMMYY will be empty. Those entries are filled computing
0021 %    the corresponding date from the next timestamp with a date component and
0022 %    taking into account day roll backs inferred from the time components.
0023 %
0024 %  Examples:
0025 %    stampvec = fillSGMissingGPSTimestamp(hhmmss, ddmmyy)
0026 %
0027 %  See also:
0028 %
0029 %  Authors:
0030 %    Joan Pau Beltran  <joanpau.beltran@socib.cat>
0031 
0032 %  Copyright (C) 2014-2016
0033 %  ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears
0034 %  <http://www.socib.es>
0035 %
0036 %  This program is free software: you can redistribute it and/or modify
0037 %  it under the terms of the GNU General Public License as published by
0038 %  the Free Software Foundation, either version 3 of the License, or
0039 %  (at your option) any later version.
0040 %
0041 %  This program is distributed in the hope that it will be useful,
0042 %  but WITHOUT ANY WARRANTY; without even the implied warranty of
0043 %  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0044 %  GNU General Public License for more details.
0045 %
0046 %  You should have received a copy of the GNU General Public License
0047 %  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0048 
0049   error(nargchk(2, 2, nargin, 'struct'));
0050   
0051   nodate = cellfun(@isempty, cellstr(ddmmyy));
0052   stampvec(~nodate, :) = ...
0053     datevec(strcat(ddmmyy(~nodate,:),hhmmss(~nodate,:)), 'ddmmyyHHMMSS');
0054   nodate_boundary = find([true; xor(nodate(1:end-1), nodate(2:end))]);
0055   for i = numel(nodate_boundary):-1:2
0056     index_curr = nodate_boundary(i);  
0057     index_prev = nodate_boundary(i-1);  
0058     if nodate(index_prev)
0059       stampvec(index_prev:index_curr-1, :) = ...
0060         datevec(strcat(ddmmyy(index_curr,:), hhmmss(index_prev:index_curr-1,:)), ...
0061                 'ddmmyyHHMMSS');
0062       dateroll = 0 > diff(datenum(stampvec(index_prev:index_curr,:)));
0063       stampvec(index_prev:index_curr-1, 3) = ...
0064         stampvec(index_prev:index_curr-1, 3) - flipud(cumsum(flipud(dateroll)));
0065     end
0066   end
0067   stampnum = datenum(stampvec);
0068   if nargout > 1
0069     if ischar(ddmmyy)
0070       ddmmyy(nodate, 1:6) = datestr(stampnum(nodate), 'ddmmyy');
0071     else
0072       ddmmyy(nodate) = cellstr(datestr(stampnum(nodate), 'ddmmyy'));
0073     end
0074   end
0075   
0076 end

Generated on Fri 06-Oct-2017 10:47:42 by m2html © 2005