Home > classes > @ao > dropduplicates.m

dropduplicates

PURPOSE ^

DROPDUPLICATES drops all duplicate samples in time-series AOs.

SYNOPSIS ^

function varargout = dropduplicates(varargin)

DESCRIPTION ^

 DROPDUPLICATES drops all duplicate samples in time-series AOs.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DROPDUPLICATES drops all duplicate samples in time-series AOs. Duplicates
                are identified by having a two consecutive time stamps
                closer than a set tolerance.

 CALL:        bs = dropduplicates(as)

 INPUTS:      as  - array of analysis objects
              pl  - parameter list (see below)

 OUTPUTS:     bs  - array of analysis objects, one for each input

 PARAMETER LIST:
             'tol'   - specify tolerance (in seconds) for selecting duplicates.
                       [default: 5ms]

 M-FILE INFO: Get information about this methods by calling
              >> ao.getInfo('dropduplicates')

              Get information about a specified set-plist by calling:
              >> ao.getInfo('dropduplicates', 'None')

 VERSION:     $Id: dropduplicates.m,v 1.10 2008/09/05 11:05:29 ingo Exp $

 HISTORY:     22-05-08 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % DROPDUPLICATES drops all duplicate samples in time-series AOs.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DROPDUPLICATES drops all duplicate samples in time-series AOs. Duplicates
0005 %                are identified by having a two consecutive time stamps
0006 %                closer than a set tolerance.
0007 %
0008 % CALL:        bs = dropduplicates(as)
0009 %
0010 % INPUTS:      as  - array of analysis objects
0011 %              pl  - parameter list (see below)
0012 %
0013 % OUTPUTS:     bs  - array of analysis objects, one for each input
0014 %
0015 % PARAMETER LIST:
0016 %             'tol'   - specify tolerance (in seconds) for selecting duplicates.
0017 %                       [default: 5ms]
0018 %
0019 % M-FILE INFO: Get information about this methods by calling
0020 %              >> ao.getInfo('dropduplicates')
0021 %
0022 %              Get information about a specified set-plist by calling:
0023 %              >> ao.getInfo('dropduplicates', 'None')
0024 %
0025 % VERSION:     $Id: dropduplicates.m,v 1.10 2008/09/05 11:05:29 ingo Exp $
0026 %
0027 % HISTORY:     22-05-08 M Hewitson
0028 %                 Creation
0029 %
0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 
0032 function varargout = dropduplicates(varargin)
0033 
0034   % Check if this is a call for parameters
0035   if utils.helper.isinfocall(varargin{:})
0036     varargout{1} = getInfo(varargin{3});
0037     return
0038   end
0039 
0040   import utils.const.*
0041   utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename);
0042   
0043   % Collect input variable names
0044   in_names = cell(size(varargin));
0045   for ii = 1:nargin,in_names{ii} = inputname(ii);end
0046 
0047   % Collect all AOs
0048   [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
0049   [pl, pl_invars] = utils.helper.collect_objects(varargin(:), 'plist', in_names);
0050 
0051   % Decide on a deep copy or a modify
0052   bs = copy(as, nargout);
0053 
0054   % Combine plists
0055   pl = combine(pl, getDefaultPlist);
0056 
0057   % Get tolerance
0058   tol = find(pl, 'tol');
0059 
0060   % Get only tsdata AOs
0061   for j=1:numel(bs)
0062     if isa(bs(j).data, 'tsdata')
0063       d = abs(diff(bs(j).data.getX));
0064       idx = find(d<tol);
0065       utils.helper.msg(msg.PROC1, 'found %d duplicate samples', numel(idx));
0066       % Wipe out x samples
0067       if ~isempty(bs(j).data.x)
0068         bs(j).data.x(idx) = [];
0069       end
0070       % Wipe out y samples
0071       bs(j).data.y(idx) = [];
0072       % Add history
0073       bs(j).addHistory(getInfo, pl, ao_invars(j), bs(j).hist);
0074       % set name
0075       bs(j).setName(sprintf('dropduplicates(%s)', ao_invars{j}), 'internal');
0076     else
0077       warning('!!! Skipping AO %s - it''s not a time-series AO.', ao_invars{j});
0078       bs(j) = [];
0079     end
0080   end
0081 
0082   % Set output
0083   if nargout > 0
0084     varargout{1} = bs;
0085   end
0086 end
0087 
0088 %--------------------------------------------------------------------------
0089 % Get Info Object
0090 %--------------------------------------------------------------------------
0091 function ii = getInfo(varargin)
0092   if nargin == 1 && strcmpi(varargin{1}, 'None')
0093     sets = {};
0094     pl   = [];
0095   else
0096     sets = {'Default'};
0097     pl   = getDefaultPlist;
0098   end
0099   % Build info object
0100   ii = minfo(mfilename, 'ao', '', utils.const.categories.sigproc, '$Id: dropduplicates.m,v 1.10 2008/09/05 11:05:29 ingo Exp $', sets, pl);
0101 end
0102 
0103 %--------------------------------------------------------------------------
0104 % Get Default Plist
0105 %--------------------------------------------------------------------------
0106 function pl = getDefaultPlist()
0107   pl = plist('tol', 5e-3);
0108 end
0109 
0110

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003