0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % CONSOLIDATE resamples all input AOs onto the same time grid.
|
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 % CONSOLIDATE resamples all input AOs onto the same time grid and truncates all
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % time-series to start at the maximum start time of the inputs and end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % at the minimum stop time of the inputs.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % ALGORITHM:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % 1) Drop duplicate samples (ao/dropduplicates)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % 2) Interpolate missing samples (ao/interpmissing)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % 3) Fix uneven sample rate using interpolate (ao/fixfs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % 4) Resample to same fs, either max or specified (ao/resample
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % or ao/interp depending on ratio of old and new sample
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % rate)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % 5) Truncate all vectors to minimum overlap of time-series
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % (ao/split)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % 6) Resample on to the same timing grid (ao/interp)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % 7) Truncate all vectors to same number of samples to correct for
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % any rounding errors in previous steps (ao/select)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % CALL: >> bs = consolidate(as)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % INPUTS: as - array of at least two time-series analysis objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % pl - parameter list (see below)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 % OUTPUTS: bs - array of analysis objects, one for each input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'consolidate')">Parameters Description</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % VERSION: $Id: consolidate.m,v 1.32 2011/04/08 08:56:13 hewitson Exp $
|
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
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 % 't' - specify a new time vector to resample on to. This
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 % will be truncated to fit within the maximum start
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 % time and minimum stop time of the inputs.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 % or
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 function varargout = consolidate(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 % Check if this is a call for parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 if utils.helper.isinfocall(varargin{:})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 varargout{1} = getInfo(varargin{3});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 import utils.const.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 % Collect input variable names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 in_names = cell(size(varargin));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 for ii = 1:nargin,in_names{ii} = inputname(ii);end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 % Collect all AOs and plists
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 [pl, pl_invars] = utils.helper.collect_objects(varargin(:), 'plist', in_names);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 if numel(as) < 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 error('### Consolidate requires at least two time-series AOs to work.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 if nargout == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 error('### Consolidate cannot be used as a modifier. Please give an output variable.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 % Decide on a deep copy or a modify
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 bs = copy(as, nargout);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 na = numel(bs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 % Combine plists
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 pl = parse(pl, getDefaultPlist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 % Get only tsdata AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 inhists = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 if ~isa(bs(j).data, 'tsdata')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 bs(j) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 warning('!!! Skipping AO %s - it''s not a time-series AO.', bs(j).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 % gather the input history objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 inhists = [inhists bs(j).hist];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 % If fs is specified, use it. Otherwise, use max of all
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 % input AOs.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 fs = find(pl, 'fs');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 if isempty(fs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 % compute max fs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 fs = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 if bs(j).data.fs > fs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 fs = bs(j).data.fs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 utils.helper.msg(msg.PROC2, 'resampling all time-series to an fs of %f', fs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 %----------------- Drop all repeated samples
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 utils.helper.msg(msg.PROC1, 'drop duplicates');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 utils.helper.msg(msg.PROC2, 'processing %s', bs(j).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 dropduplicates(bs(j),pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 %----------------- Interpolate all missing samples
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 utils.helper.msg(msg.PROC1, 'interpolate missing samples');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 utils.helper.msg(msg.PROC2, 'processing %s', bs(j).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 interpmissing(bs(j),pl.pset('method', find(pl, 'interp_method')));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 %----------------- Fix uneven sampling
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 utils.helper.msg(msg.PROC1, 'fixing uneven sample rates');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 utils.helper.msg(msg.PROC2, 'processing %s', bs(j).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 fixfs(bs(j),pl.pset('method', find(pl, 'fixfs_method')));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 %----------------- Resample all vectors to same fs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 utils.helper.msg(msg.PROC1, 'resample to same fs');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 % Check the resampling factor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 [P,Q] = utils.math.intfact(fs,bs(j).data.fs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 if P > 100 || Q > 100
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 utils.helper.msg(msg.PROC2, 'resampling factor too high [%g/%g]. Trying interpolation', P, Q);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 N = length(bs(j).data.getX);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 t = linspace(0, (P*N/Q-1)/fs, P*N/Q);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 interp(bs(j), plist('vertices', t));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 resample(bs(j), plist('fsout', fs));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 %---------------- Time properties of AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 % Find max start time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 start = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 dstart = bs(j).data.t0.utc_epoch_milli/1000 + bs(j).data.getX(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 if dstart > start
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 start = dstart;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 % Find min stop time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 stop = 1e20;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 dstop = floor(bs(j).data.t0.utc_epoch_milli/1000 + bs(j).data.getX(end));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 if dstop < stop
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 stop = dstop;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 %----------------- Truncate all vectors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 utils.helper.msg(msg.PROC1, 'truncate all vectors');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 utils.helper.msg(msg.PROC2, 'truncating vectors on interval [%.4f,%.4f]', start, stop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 % split each ao
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 bs = split(bs, plist('timespan', timespan(start, stop)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 %----------------- Resample all vectors on to the same grid
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 utils.helper.msg(msg.PROC1, 'resample to same grid');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 % compute new time grid
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 % get the grid from the first AO
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 toff = start - bs(j).t0.utc_epoch_milli/1000;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 N = length(bs(j).data.getX);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 t = linspace(toff, toff+(N-1)/fs, N);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 interp(bs(j), plist('vertices', t));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 % Now ensure that we have the same data length
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 ns = realmax;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 for jj=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 if len(bs(jj)) < ns
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 ns = len(bs(jj));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 bs = select(bs, 1:ns);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 nsecs = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 if isempty(nsecs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 nsecs = bs(j).data.nsecs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 if nsecs ~= bs(j).data.nsecs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 error('### Something went wrong with the truncation. Vectors don''t span the same time period.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 %----------------- Set history on output AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 for j=1:na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 bs(j).name = sprintf('%s(%s)', mfilename, ao_invars{j});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 bs(j).addHistory(getInfo('None'), pl, ao_invars(j), inhists(j));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 % Set output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 if nargout == numel(bs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 % List of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 for ii = 1:numel(bs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 varargout{ii} = bs(ii);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 % Single output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 varargout{1} = bs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 % Get Info Object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 function ii = getInfo(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 if nargin == 1 && strcmpi(varargin{1}, 'None')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 sets = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 pl = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 sets = {'Default'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 pl = getDefaultPlist;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 % Build info object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.sigproc, '$Id: consolidate.m,v 1.32 2011/04/08 08:56:13 hewitson Exp $', sets, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 ii.setModifier(false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 ii.setArgsmin(2);
|
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 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 % Get Default Plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 function plout = getDefaultPlist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 persistent pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 if exist('pl', 'var')==0 || isempty(pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 pl = buildplist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 plout = pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 function pl_default = buildplist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 pl_default = combine(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 plist({'fs','The target sampling frequency for consolidate'}, paramValue.EMPTY_DOUBLE),...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 plist({'interp_method', 'The method for the interpolation step'}, {2, {'nearest', 'linear', 'spline', 'cubic'}, paramValue.SINGLE}), ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 plist({'fixfs_method', 'The method for the fixfs step'}, {1, {'Time', 'Samples'}, paramValue.SINGLE}), ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 ao.getInfo('dropduplicates').plists,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 ao.getInfo('interpmissing').plists,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 ao.getInfo('fixfs').plists);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251
|