TIMESHIFT for AO/tsdata objects, shifts the time axis such that x(1) = 0. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: TIMESHIFT for AO/tsdata objects, shifts the time axis such that x(1) = 0. The value of t0 is set appropriately. CALL: b = timeshift(a) M-FILE INFO: Get information about this methods by calling >> ao.getInfo('timeshift') Get information about a specified set-plist by calling: >> ao.getInfo('timeshift', 'None') VERSION: $Id: timeshift.m,v 1.11 2008/09/05 11:05:29 ingo Exp $ HISTORY: 23-02-08 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % TIMESHIFT for AO/tsdata objects, shifts the time axis such that x(1) = 0. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: TIMESHIFT for AO/tsdata objects, shifts the time axis such 0005 % that x(1) = 0. The value of t0 is set appropriately. 0006 % 0007 % CALL: b = timeshift(a) 0008 % 0009 % M-FILE INFO: Get information about this methods by calling 0010 % >> ao.getInfo('timeshift') 0011 % 0012 % Get information about a specified set-plist by calling: 0013 % >> ao.getInfo('timeshift', 'None') 0014 % 0015 % VERSION: $Id: timeshift.m,v 1.11 2008/09/05 11:05:29 ingo Exp $ 0016 % 0017 % HISTORY: 23-02-08 M Hewitson 0018 % Creation 0019 % 0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0021 0022 function varargout = timeshift(varargin) 0023 0024 % Check if this is a call for parameters 0025 if utils.helper.isinfocall(varargin{:}) 0026 varargout{1} = getInfo(varargin{3}); 0027 return 0028 end 0029 0030 import utils.const.* 0031 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); 0032 0033 % Collect input variable names 0034 in_names = cell(size(varargin)); 0035 for ii = 1:nargin,in_names{ii} = inputname(ii);end 0036 0037 % Collect all AOs and plists 0038 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); 0039 0040 % Decide on a deep copy or a modify 0041 bs = copy(as, nargout); 0042 0043 % Check input analysis object 0044 for j=1:numel(bs) 0045 % Which data type do we have 0046 switch class(bs(j).data) 0047 case 'tsdata' 0048 x0 = bs(j).data.getX(1); 0049 t0 = bs(j).data.t0.utc_epoch_milli + 1000*x0; 0050 bs(j).setX(bs(j).data.getX - x0, 'internal'); 0051 bs(j).setT0(t0, 'internal'); 0052 bs(j).data.collapseX; 0053 % Add history 0054 bs(j).addHistory(getInfo, plist(), ao_invars(j), bs(j).hist); 0055 case {'fsdata', 'cdata', 'xydata'} 0056 error('### I don''t work for frequency-series, xy and constant data.'); 0057 otherwise 0058 error('### unknown data type. They can not be addded.') 0059 end 0060 end 0061 0062 % Set outputs 0063 if nargout > 0 0064 varargout{1} = bs; 0065 end 0066 end 0067 0068 %-------------------------------------------------------------------------- 0069 % Get Info Object 0070 %-------------------------------------------------------------------------- 0071 function ii = getInfo(varargin) 0072 if nargin == 1 && strcmpi(varargin{1}, 'None') 0073 sets = {}; 0074 pl = []; 0075 else 0076 sets = {'Default'}; 0077 pl = getDefaultPlist; 0078 end 0079 % Build info object 0080 ii = minfo(mfilename, 'ao', '', utils.const.categories.helper, '$Id: timeshift.m,v 1.11 2008/09/05 11:05:29 ingo Exp $', sets, pl); 0081 end 0082 0083 %-------------------------------------------------------------------------- 0084 % Get Default Plist 0085 %-------------------------------------------------------------------------- 0086 function pl_default = getDefaultPlist() 0087 pl_default = plist(); 0088 end 0089 0090