0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % JOIN multiple AOs into a single AO.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % DESCRIPTION: JOIN multiple AOs into a single AO.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % If any two AOs overlap, then the values from the first appear
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % in the output AO.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % Note: If the input AOs are of type 'tsdata', then they will
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % be sorted in ascending order according the t0 of each
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % object.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % CALL: bs = join(a1,a2,a3,...,pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % bs = join(as,pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % bs = as.join(pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % INPUTS: aN - input analysis objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % as - input analysis objects array
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % pl - input parameter list
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % OUTPUTS: b - output analysis object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'join')">Parameters Description</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % REMARK: Input AOs should be of the same type; if not, only AOs of the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 % type of the first input AO will be joined together to produce
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % the output.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 % VERSION: $Id: join.m,v 1.60 2011/09/02 11:11:51 ingo Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 % PARAMETERS: 'zerofill' - Fills with zeros the gaps between the data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 % points of the subsequent aos. [Default: 'no']
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 % 'sameT0' - Does not recalculate t0 but uses the common
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 % one. [Default: 'no']
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 % Note: the t0 among different objects must be the same!
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 function varargout = join(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 % Check if this is a call for parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 if utils.helper.isinfocall(varargin{:})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 varargout{1} = getInfo(varargin{3});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 import utils.const.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 % Collect input variable names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 in_names = cell(size(varargin));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 for ii = 1:nargin,in_names{ii} = inputname(ii);end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 % Collect all AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 pl = utils.helper.collect_objects(varargin(:), 'plist', in_names);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 % Combine plists
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 pl = parse(pl, getDefaultPlist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 %----------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 % Get data type from the first AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 dtype = class(as(1).data);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 % Sort the input AOs by t0, if applicable
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 if strcmp(dtype, 'tsdata')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 times = as.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 [~, idx] = sort(times);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 as = as(idx);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 %----------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 % Go through each AO and collect the data of type 'dtype'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 histin = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 xo = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 yo = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 dxo = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 dyo = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 enbw0 = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 fs = -1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 aname = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 adescr = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 plotinfo = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 if as(1).data.isprop('xunits')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 xunitsSimple = simplify(as(1).data.xunits);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 xunits = as(1).data.xunits;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 yunitsSimple = simplify(as(1).data.yunits);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 yunits = as(1).data.yunits;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 % Get the tolerance for considering fs equal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 fstol = find(pl, 'fstol');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 % Compute time offset for tsdata objects to avoid rounding errors later
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 minT0milli = getMinT0(as);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 % loop over AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 for jj=1:numel(as)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 % Only get the data type we want
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 if isa(as(jj).data, dtype)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 switch lower(dtype)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 case 'tsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 % here we concatonate time-series
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 t0 = (as(jj).data.t0.utc_epoch_milli - minT0milli)/1000;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 % make proper time vector
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 x = as(jj).x + t0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 % only add samples past the end of existing (first loop)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 if isempty(xo)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 yo = as(jj).y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 xo = x;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 if numel(as(jj).dx) == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 dxo = zeros(numel(as(jj).x),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 elseif numel(as(jj).dx) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 dxo = ones(numel(as(jj).x),1) .* as(jj).dx;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 dxo = as(jj).dx;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 if numel(as(jj).dy) == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 dyo = zeros(numel(as(jj).y),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 elseif numel(as(jj).dy) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 dyo = ones(numel(as(jj).y),1) .* as(jj).dy;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 dyo = as(jj).dy;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 idxPost = find(x > max(xo));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 idxPre = find(x < min(xo));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 %%%%%%%%%% Fill the gaps with zeros %%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 zerofill = utils.prog.yes2true(find(pl, 'zerofill'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 if zerofill
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 % Check if there is a gap between the x-values and the pre-values.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 if ~isempty(idxPre)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 interStart = x(idxPre(end));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 interEnd = xo(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 nsecsPre2no = interEnd - interStart;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 % The gap must be larger than 1/fs in order to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 % fill the gap with zeros
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 if nsecsPre2no > 1/fs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 x_interPre = linspace(interStart+1/fs, interEnd-1/fs, nsecsPre2no*fs-2*1/fs).';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 y_interPre = zeros(length(x_interPre), 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 x_interPre = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 y_interPre = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 x_interPre = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 y_interPre = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 % Check if there is a gap between the x-values and the post-values.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 if ~isempty(idxPost)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 interStart = xo(end);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 interEnd = x(idxPost(1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 nsecsPost2no = interEnd - interStart;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 % The gap must be larger than 1/fs in order to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 % fill the gap with zeros
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 if nsecsPost2no > 1/fs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 x_interPost = linspace(interStart+1/fs, interEnd-1/fs, nsecsPost2no*fs-1/fs).';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 y_interPost = zeros(length(x_interPost), 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 x_interPost = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 y_interPost = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 x_interPost = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 y_interPost = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 %%%%%%%%%% Don't fill the gaps with zeros %%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 x_interPre = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 y_interPre = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 x_interPost = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 y_interPost = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 xo = [x(idxPre); x_interPre; xo; x_interPost; x(idxPost)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 yo = [as(jj).data.getY(idxPre); y_interPre; yo; y_interPost; as(jj).data.getY(idxPost)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 %%% Collect errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 if numel(as(jj).dx) == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 dx = zeros(numel(as(jj).x),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 elseif numel(as(jj).dx) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 dx = ones(numel(as(jj).x),1) .* as(jj).dx;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 dx = as(jj).dx;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 if numel(as(jj).dy) == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 dy = zeros(numel(as(jj).y),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 elseif numel(as(jj).dy) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 dy = ones(numel(as(jj).y),1) .* as(jj).dy;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 dy = [dyo; as(jj).dy];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 x_interPre = zeros(numel(x_interPre),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 y_interPre = zeros(numel(y_interPre),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 x_interPost = zeros(numel(x_interPost),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 y_interPost = zeros(numel(y_interPost),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 dxo = [dx(idxPre); x_interPre; dxo; x_interPost; dx(idxPost)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 dyo = [dy(idxPre); y_interPre; dyo; y_interPost; dy(idxPost)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 % check fs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 if (fs > 0) && (abs(as(jj).fs - fs) > fstol*fs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 error('### Data has different sample rates');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 % store fs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 fs = as(jj).fs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 % check xunits
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 if ~eq(xunitsSimple, simplify(as(jj).xunits))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 error('### The x-units of the analysis objects are not the same %s <-> %s', char(xunits), char(as(jj).xunits));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 % check yunits
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 if ~eq(yunitsSimple, simplify(as(jj).yunits))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 error('### The y-units of the analysis objects are not the same %s <-> %s', char(yunits), char(as(jj).yunits));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 % store T0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 T0s(jj) = as(jj).t0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 case 'fsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 %%% Collect all fsdata samples
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 if isempty(xo)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 idxBefore = 1:numel(as(jj).x);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 idxAfter = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 idxBefore = find(as(jj).x < xo(1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 idxAfter = find(as(jj).x > xo(end));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 xo = [as(jj).x(idxBefore); xo; as(jj).x(idxAfter)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 yo = [as(jj).y(idxBefore); yo; as(jj).y(idxAfter)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 %%% Collect all errors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 % dx
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 if numel(as(jj).dx) == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 dx = zeros(numel(as(jj).x),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 elseif numel(as(jj).dx) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 dx = ones(numel(as(jj).x),1) .* as(jj).dx;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 dx = as(jj).dx;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 dxo = [dx(idxBefore); dxo; dx(idxAfter)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 % dy
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 if numel(as(jj).dy) == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 dy = zeros(numel(as(jj).y),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 elseif numel(as(jj).dy) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 dy = ones(numel(as(jj).y),1) .* as(jj).dy;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 dy = as(jj).dy;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 dyo = [dy(idxBefore); dyo; dy(idxAfter)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 % enbw
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 if numel(as(jj).data.enbw) == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 enbw = NaN(numel(as(jj).y),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 elseif numel(as(jj).data.enbw) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 enbw = ones(numel(as(jj).y),1) .* as(jj).data.enbw;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 enbw = as(jj).data.enbw;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 enbw0 = [enbw(idxBefore); enbw0; enbw(idxAfter)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 % check fs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 if (fs > 0) && (abs(as(jj).fs - fs) > fstol*fs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 error('### Data has different sample rates');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 % store fs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 fs = as(jj).fs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 % check xunits
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 if ~eq(xunitsSimple, simplify(as(jj).xunits))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 error('### The x-units of the analysis objects are not the same %s <-> %s', char(xunits), char(as(jj).xunits));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 % check yunits
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 if ~eq(yunitsSimple, simplify(as(jj).yunits))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 error('### The y-units of the analysis objects are not the same %s <-> %s', char(yunits), char(as(jj).yunits));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 case 'xydata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 xo = [xo; as(jj).x];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 yo = [yo; as(jj).y];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 if numel(as(jj).dx) == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 dx = zeros(numel(as(jj).x),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 elseif numel(as(jj).dx) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 dx = ones(numel(as(jj).x),1) .* as(jj).dx;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 dx = as(jj).dx;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 dxo = [dxo; dx];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 if numel(as(jj).dy) == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 dy = zeros(numel(as(jj).y),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 elseif numel(as(jj).dy) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 dy = ones(numel(as(jj).y),1) .* as(jj).dy;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 dy = as(jj).dy;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 dyo = [dyo; dy];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 % check xunits
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 if ~eq(xunitsSimple, simplify(as(jj).xunits))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 error('### The x-units of the analysis objects are not the same %s <-> %s', char(xunits), char(as(jj).xunits));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 % check yunits
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 if ~eq(yunitsSimple, simplify(as(jj).yunits))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 error('### The y-units of the analysis objects are not the same %s <-> %s', char(yunits), char(as(jj).yunits));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 case 'cdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 yo = [yo; as(jj).y];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 if numel(as(jj).dy) == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 dy = zeros(numel(as(jj).y),1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 elseif numel(as(jj).dy) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 dy = ones(numel(as(jj).y),1) .* as(jj).dy;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 dy = as(jj).dy;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 dyo = [dyo; dy];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 catch E
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 disp(E.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 error('### It is not possible to join the data or error because they have different dimensions.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 % check yunits
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 if ~eq(yunitsSimple, simplify(as(jj).yunits))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 error('### The y-units of the analysis objects are not the same %s <-> %s', char(yunits), char(as(jj).yunits));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 error('### Unknown data type');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 % Collect this input history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 histin = [histin as(jj).hist];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 % Collect the 'plotinfo'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 if ~isempty(as(jj).plotinfo)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 plotinfo = combine(plotinfo, as(jj).plotinfo);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 % Collect the descriptions
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 adescr = strcat(adescr, as(jj).description);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 % Collect names, invars
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 if ~isempty(aname)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 if ~strcmp(aname, as(jj).name)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355 aname = [aname ',' as(jj).name];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 aname = as(jj).name;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 warning('!!! Ignoring AO input with data type %s', dtype);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 %----------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 % Now sort output vectors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 if ~isempty(xo)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 [xos, idx] = sort(xo);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 yos = yo(idx);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 dxos = dxo(idx);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 dyos = dyo(idx);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 xos = xo;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 yos = yo;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 dxos = dxo;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 dyos = dyo;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379 if all(dxos == 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 dxos = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381 elseif all(diff(dxos) == 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 dxos = dxos(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 if all(dyos == 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 dyos = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 elseif all(diff(dyos) == 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387 dyos = dyos(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 % Keep the data shape if the input AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 if size(as(1).data.y,1) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392 xos = xos.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 yos = yos.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 %%% Build output data object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 switch lower(dtype)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398 case 'tsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 sameT0 = utils.prog.yes2true(find(pl, 'sameT0'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 % % Check that all objects share the t0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 % for kk = 1:numel(T0s)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 % if ne(T0s(kk), T0s(1))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 % sameT0 = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 % if sameT0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408 % data = tsdata(xos, yos, fs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 % data.setT0(minT0milli/1000);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 % else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 % get t0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 % toffset = xos(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 % xos = xos - toffset;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 data = tsdata(xos, yos, fs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415 data.setT0((minT0milli/1000));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 % data.setToffset(toffset*1000);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 data.setDx(dxos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 data.setDy(dyos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 data.setXunits(xunits);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 data.setYunits(yunits);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422 data.collapseX;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 case 'fsdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 if all(isnan(enbw0))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425 enbw0 = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 elseif all(diff(enbw0) == 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427 enbw0 = enbw0(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429 data = fsdata(xos, yos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430 data.setDx(dxos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 data.setDy(dyos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 data.setEnbw(enbw0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 data.setFs(fs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 data.setXunits(xunits);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 data.setYunits(yunits);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 case 'xydata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437 data = xydata(xos, yos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 data.setDx(dxos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 data.setDy(dyos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 data.setXunits(xunits);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441 data.setYunits(yunits);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 case 'cdata'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443 data = cdata(yos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 data.setDy(dyos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 data.setYunits(yunits);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 %----------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 % Build output AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450 if nargout == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 a = as(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 a.data = data;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 a = ao(data);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456 % Set name
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 a.name = aname;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 % Set description
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 a.description = adescr;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 % Set plotinfo
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461 a.plotinfo = plotinfo;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 % Add history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463 a.addHistory(getInfo('None'), pl, ao_invars, histin);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465 %----------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 % set output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 varargout{1} = a;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 % Get Info Object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 function ii = getInfo(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 if nargin == 1 && strcmpi(varargin{1}, 'None')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475 sets = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 pl = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 sets = {'Default'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 pl = getDefaultPlist;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 % Build info object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.helper, '$Id: join.m,v 1.60 2011/09/02 11:11:51 ingo Exp $', sets, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 ii.setArgsmin(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487 % Get Default Plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489 function plout = getDefaultPlist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 persistent pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491 if exist('pl', 'var')==0 || isempty(pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 pl = buildplist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 plout = pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 function pl = buildplist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499 pl = plist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501 % Zero fill
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502 p = param({'zerofill','Fills with zeros the gaps between the data points of the subsequent aos.'}, paramValue.YES_NO);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503 p.val.setValIndex(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506 % Same T0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 p = param({'sameT0', ['Does not recalculate t0 but uses the common one.<br>', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508 'Note: the t0 among different objects must be the same!']}, paramValue.YES_NO);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509 p.val.setValIndex(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512 % fstol
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 p = param({'fstol', ['Relative tolerance between sampling frequency of different objects.<br>', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514 'Jitter in the sampling frequency by less than this amount will be neglected.<br>', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515 'If the difference is more than the set value, an error will occur.']}, paramValue.DOUBLE_VALUE(1e-6));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 pl.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521 % Get Offset of this set of time-vectors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523 function Toff = getMinT0(as)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524 Toff = min(double(as.t0))*1e3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
525 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
526
|