comparison m-toolbox/classes/@ao/ao.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children a71a40911c27 bc767aaa99a8
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % AO analysis object class constructor.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: AO analysis object class constructor.
5 % Create an analysis object.
6 %
7 % Possible constructors:
8 % a = ao() - creates an empty analysis object
9 % a = ao('a1.xml') - creates a new AO by loading a file
10 % a = ao('a1.mat')
11 % a = ao('a1.mat') - creates a new AO by loading the 2-column data .MAT file.
12 % a = ao('file.txt') - creates a new AO by loading the data.
13 % a = ao('file.dat')
14 % a = ao('file',pl) (<a href="matlab:utils.helper.displayMethodInfo('ao', 'ao')">Set: From ASCII File</a>)
15 % a = ao(data) - creates an AO with a data object.
16 % a = ao(constant) - creates an AO from a constant
17 % a = ao(specwin) - creates an AO from a specwin object
18 % a = ao(pzm) - creates an AO from a pole/zero model object
19 % a = ao(pzm,nsecs,fs)
20 % a = ao(smodel) - creates an AO from a symbolic model object
21 % a = ao(pest) - creates an AO from a parameter estimates object
22 % a = ao(x,y) - creates an AO with xy data
23 % a = ao(y, fs) - creates an AO with time-series data
24 % a = ao(x,y,fs) - creates an AO with time-series data
25 % a = ao(x,y,pl) - creates an AO depending from the PLIST (<a href="matlab:utils.helper.displayMethodInfo('ao', 'ao')">Set: From XY Values</a>).
26 % a = ao(plist) - creates an AO from a <a href="matlab:utils.helper.displayMethodInfo('ao', 'ao')">parameter list</a>
27 %
28 % <a href="matlab:utils.helper.displayConstructorExamples('ao')">Examples</a>
29 %
30 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'ao')">Parameters Description</a>
31 %
32 % VERSION: $Id: ao.m,v 1.361 2011/08/22 05:23:45 hewitson Exp $
33 %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
36
37 % AO analysis object class constructor.
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %
40 % DESCRIPTION: AO analysis object class constructor.
41 % Create an analysis object.
42 %
43 % Possible constructors:
44 %
45 % a = ao() - creates an empty analysis object
46 % a = ao('a1.xml') - creates a new analysis object by loading the
47 % analysis object from disk.
48 % a = ao('a1.mat') - creates a new analysis object by loading the
49 % analysis object from disk.
50 % a = ao('a1.mat') - creates a new analysis object by loading the
51 % 2-column data set stored in the .MAT file.
52 % a = ao('file.txt') - creates a new analysis object by loading the
53 % a = ao('file.dat') data in 'file.txt'. The ascii file is assumed
54 % to be an equally sampled two-column file of
55 % time and amplitude. By default, the amplitude
56 % units are taken to be Volts ('V') and the
57 % time samples are assumed to be in seconds.
58 % a = ao('file',pl) - creates a new analysis object by loading the
59 % data in 'file'. The parameter list decide how the
60 % analysis object is created. The valid key values
61 % of the parameter list are:
62 % 'type' 'tsdata','fsdata','xydata'
63 % [default: 'tsdata']
64 % 'fs' if this value is set, the
65 % x-axes is computed by the fs value.
66 % [default: empty array]
67 % 'columns' [1 2 1 4]
68 % Each pair represented the x- and y-axes.
69 % (Each column pair creates an analysis object)
70 % If the value 'fs' is used then
71 % represent each column the y-axes.
72 % (Each column creates an analysis object)
73 % [default: [1] ]
74 % 'comment_char' The comment character in the file
75 % [default: '']
76 % 'description' To set the description in the analysis object
77 % '...' every property where exist a public
78 % set-function in the AO class e.g.
79 % setName, setT0, setYunits, ...
80 % If the constructor creates multiple ao's it is
81 % possible to give each data class its own e.g.
82 % 'name'. In this case the parameter list with the
83 % key 'name' must have cell of the different values
84 % as the name of the different data objects. e.g.
85 % pl = plist('columns', [1 2 1 3], ...
86 % 'name', {'name1' 'name2'}, ...
87 % 'xunits', unit('s'), ...
88 % 'yunits', {unit('V') unit('Hz'}));
89 % This parameter list creates two ao's with tsdata.
90 %
91 % 'Robust' - set this to 'yes' to use (slow)
92 % robust data reading. Useful for
93 % complicated file formats.
94 % [default: 'yes']
95 %
96 % NOTE: Data files with comments at the end of the lines can only be
97 % read if there are no lines with only comments. In this case, do not
98 % specify a comment character. If you really want to load a file like
99 % this, specify the 'Robust' option; this will be very slow for large
100 % files.
101 %
102 % a = ao(data) - creates an analysis object with a data
103 % object. Data object can be one of tsdata,
104 % fsdata, cdata, xydata, xyzdata.
105 % a = ao(data, hist) - creates an analysis object with a data
106 % object and a history object
107 % a = ao(specwin) - creates an analysis object from a specwin
108 % object
109 % a = ao(plist) - creates an analysis object from the description
110 % given in the parameter list
111 %
112 %
113 % VERSION: $Id: ao.m,v 1.361 2011/08/22 05:23:45 hewitson Exp $
114 %
115 % Parameter sets for plist constructor (in order of priority):
116 %
117 % Notes and examples for some parameter sets follow:
118 %
119 % From complex ASCII File
120 % ---------------
121 %
122 % >> ao(plist('filename','data.txt','complex_type','real/imag','type','tsdata')); %!
123 % >> ao(plist('filename','data.txt','complex_type','real/imag','type','fsdata','columns',[1,2,4])); %!
124 %
125 % From Function
126 % -------------
127 %
128 % >> ao(plist('fcn', 'randn(100,1)','yunits','V'));
129 %
130 % From Values
131 % -----------
132 %
133 % >> ao(plist('vals',[1 2 3],'N',10)); % --> cdata
134 % >> ao(plist('xvals',[1 2 3],'yvals',[10 20 30])); % --> xydata
135 % >> ao(plist('xvals',[1 2 3],'yvals',[10 20 30],'type','tsdata')); % --> tsdata
136 % >> ao(plist('xvals',[1 2 3],'yvals',[10 20 30],'type','fsdata')); % --> fsdata
137 % >> ao(plist('fs',1,'yvals',[10 20 30])); % --> tsdata
138 % >> ao(plist('fs',1,'yvals',[10 20 30],'type','fsdata')); % --> fsdata
139 % >> ao(plist('fs',1,'yvals',[10 20 30],'type','fsdata','xunits','mHz','yunits','V'));
140 %
141 % From XY Function
142 % ----------------
143 %
144 % >> ao(plist('xyfcn', 'cos(2*pi*x) + randn(size(x))','x',[1:1e5]));
145 %
146 % From Time-series Function
147 % -------------------------
148 %
149 % >> ao(plist('tsfcn', 'cos(pi*t) + randn(size(t))', 'fs', 1, 'nsecs', 100));
150 % >> ao(plist('fs',10,'nsecs',10,'tsfcn','sin(2*pi*1.4*t)+0.1*randn(size(t))','t0',time('1980-12-01 12:43:12')));
151 %
152 %
153 % From Frequency-series Function
154 % ------------------------------
155 %
156 % >> ao(plist('FSFCN','f','f1',1e-5,'f2',1,'yunits','V'));
157 % >> ao(plist('FSFCN','f','f',[0.01:0.01:1]));
158 %
159 % From Window
160 % -----------
161 %
162 % >> ao(plist('win', specwin('Hannning', 100)));
163 %
164 % From Waveform
165 % -------------
166 %
167 % >> ao(plist('waveform','sine wave','A',3,'f',1,'phi',pi/2,'toff',0.1,'nsecs',10,'fs',100));
168 % >> ao(plist('waveform','noise','type','normal','sigma',2,'nsecs',1000,'fs',1));
169 % >> ao(plist('waveform','chirp','f0',0.1,'f1',1,'t1',1,'nsecs',5,'fs',1000));
170 % >> ao(plist('waveform','gaussian pulse','f0',1','bw',0.2,'nsecs',20,'fs',10));
171 % >> ao(plist('waveform','square wave','f',2,'duty',40,'nsecs',10,'fs',100));
172 % >> ao(plist('waveform','sawtooth','f',1.23,'width',1,'nsecs',10/1.23,'fs',50));
173 %
174 %
175 %
176 % From Repository
177 % ---------------
178 %
179 % >> ao(plist('hostname','123.123.123.123','database','ltpda_test','ID',[1:10],'binary','yes')); %!
180 %
181 %
182 % From Polynomial
183 % ---------------
184 %
185 % Construct an AO from a set of polynomial coefficients.
186 %
187 % 'polyval' - a set of polynomial coefficients. This can also be an AO,
188 % in which case the Y values from the AO are used.
189 % [default: [-0.0001 0.02 -1 -1] ]
190 %
191 % Additional parameters:
192 % 'Nsecs' - number of seconds [default: 10]
193 % 'fs' - sample rate [default: 10]
194 % or
195 % 't' - vector of time vertices. The value can also
196 % be an AO, in which case the X vector is used.
197 % [default: [] ]
198 %
199 % Example:
200 % plist('polyval', [1 2 3], 'Nsecs', 1e2, 'fs', 10)
201 %
202 % From Pzmodel
203 % ------------
204 %
205 % Generates an ao with a timeseries with a prescribed spectrum.
206 %
207 % 'pzmodel' - a pole/zero model which builds the time-series AO
208 %
209 % Additional parameters:
210 % 'Nsecs' - number of seconds to be generated
211 % 'fs' - sampling frequency
212 %
213 % You can also specify optional parameters:
214 % 'xunits' - unit of the x-axis
215 % 'yunits' - unit of the y-axis
216 %
217 % Example: p = [pz(f1,q1) pz(f2,q2)]
218 % z = [pz(f3,q3)]
219 % pzm = pzmodel(gain, p, z)
220 % plist('pzmodel', pzm, 'Nsecs', 1e2, 'Fs', 10)
221 %
222 % From Built-in Model
223 % -------------------
224 %
225 % To get a list of built-in AOs: ao.getBuiltInModels
226 %
227 % Each model has additional parameters that need to be passed. To see the
228 %
229 % Additonal model parameters: >> help ao_model_<model_name>
230 %
231 % Example: >> help ao_model_mdc1_fd_dynamics
232 %
233 % From Plist
234 % ----------
235 %
236 % Examples:
237 %
238 % 1) Normally distributed random noise time-series
239 %
240 % >> p = plist('waveform', 'noise', 'fs', 10, 'nsecs', 1000);
241 % >> a = ao(p);
242 %
243 % Indexing:
244 %
245 % >> b = a(1); % where a is an array of analysis objects
246 % >> d = a.data; % get the data object
247 % >> h = a.hist; % get the history object
248 % >> d = a.data.x(1:20); % get a matrix of data values x;
249 %
250 % 2) Timeseries with a prescribed spectrum
251 %
252 % >> a = ao(plist('pzmodel', pzm, 'fs',10, 'nsecs', 120, 'ndigits', 50)); %!
253 %
254 % fs - sampling frequency
255 % nsecs - number of seconds in time series
256 % ndigits - number of digits for symbolic math toolbox (default: 32)
257 %
258 %
259 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'ao')">Parameters Description</a>
260 %
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
262
263 % See also tsdata, fsdata, xydata, cdata, xyzdata
264
265 % From CSD
266 % ------------
267 %
268 % Example 1D: mod is an AO with the target model power spectrum
269 %
270 % pl = plist('csd', mod, 'Nsecs', 1e3, 'fs', 10);
271 % an = ao(pl);
272 %
273 % Example 2D: mod is a 2x2 matrix of AOs with the target model cross
274 % spectral density.
275 %
276 % pl = plist('csd', mod, 'Nsecs', 1e3, 'fs', 10);
277 % an = ao(pl);
278 %
279
280
281 classdef ao < ltpda_uoh
282
283
284 %------------------------------------------------
285 %-------- Public (read/write) Properties -------
286 %------------------------------------------------
287 properties (Hidden = true)
288 end % End (read/write) Properties
289
290 %------------------------------------------------
291 %---------- Private read-only Properties --------
292 %------------------------------------------------
293 properties (GetAccess = public, SetAccess = protected)
294 data = []; % Data object associated with this AO
295 end % End read only properties
296
297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
298 % Check property setting %
299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
300
301 methods
302 function set.data(obj, val)
303 if ~(isa(val, 'ltpda_data') || isempty(val))
304 error('### The value for the property ''data'' must be a ltpda_data object');
305 end
306 obj.data = val;
307 end
308 end
309
310
311 %------------------------------------------------
312 %---------------- Private Properties ------------
313 %------------------------------------------------
314 properties (GetAccess = protected, SetAccess = protected)
315
316 end
317
318 methods
319 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
320 % Constructor %
321 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
322 function obj = ao(varargin)
323
324 import utils.const.*
325 utils.helper.msg(msg.PROC3, 'running ao/ao');
326
327 % check if the caller was a user of another method
328 callerIsMethod = utils.helper.callerIsMethod;
329
330 % Check the supported version
331 utils.helper.checkMatlabVersion;
332
333 %%% Collect all plists and combine them.
334 [pli, invars, args] = utils.helper.collect_objects(varargin, 'plist');
335
336 if ~isempty(pli)
337 pli = pli.combine();
338 if ~isempty(pli.find('dtype'))
339 warning('LTPDA:ao', 'the parameter name ''dtype'' is now deprecated; please use ''type'' instead.')
340 pli.append('type',pli.find('dtype'));
341 pli.remove('dtype');
342 end
343 if ~isempty(pli.find('use_fs'))
344 warning('LTPDA:ao', 'the parameter name ''use_fs'' is now deprecated; please use ''fs'' instead.')
345 pli.append('fs',pli.find('use_fs'));
346 pli.remove('use_fs');
347 end
348 %%% Append the plist to the input-arguments
349 args{end+1} = pli;
350 end
351
352 %%% Execute appropriate constructor
353 switch numel(args)
354 case 0
355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
356 %%%%%%%%%%%%%%%%%%%%%%%%%%% no input %%%%%%%%%%%%%%%%%%%%%%%%%%%%
357 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
358 obj.addHistory(ao.getInfo('ao', 'None'), plist(), [], []);
359
360 case 1
361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
362 %%%%%%%%%%%%%%%%%%%%%%%%%%% one input %%%%%%%%%%%%%%%%%%%%%%%%%%%
363 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
364
365 if ischar(args{1})
366 %%%%%%%%%% a1 = ao('foo.mat') %%%%%%%%%%
367 %%%%%%%%%% a1 = ao('foo.xml') %%%%%%%%%%
368 %%%%%%%%%% a1 = ao('foo.txt') %%%%%%%%%%
369 %%%%%%%%%% a1 = ao('foo.dat') %%%%%%%%%%
370 utils.helper.msg(msg.OPROC1, 'constructing from file %s', varargin{1});
371 obj = fromFile(obj, args{1});
372
373 elseif isa(args{1}, 'ao')
374 %%%%%%%%%% a1 = ao(ao) %%%%%%%%%%
375 utils.helper.msg(msg.PROC1, 'copying %s', args{1}.name);
376 obj = copy(args{1},1);
377 for kk = 1:numel(args{1})
378 obj(kk).addHistory(ao.getInfo('ao', 'None'), [], [], obj(kk).hist);
379 end
380
381 elseif isstruct(args{1})
382 %%%%%%%%%% a1 = ao(struct) %%%%%%%%%%
383 utils.helper.msg(msg.PROC1, 'constructing from struct');
384 obj = fromStruct(obj, varargin{1});
385
386 elseif isnumeric(args{1})
387 %%%%%%%%%% a1 = ao(constant) %%%%%%%%%%
388 %%%%%%%%%% a1 = ao([1 2; 3 4]) %%%%%%%%%%
389
390 utils.helper.msg(msg.PROC3, 'constructing from values');
391 obj = fromVals(obj, plist('VALS', args{1}), callerIsMethod);
392
393 elseif isa(args{1}, 'pzmodel')
394 %%%%%%%%% ao(pzmodel) %%%%%%%%%%%%
395 obj = obj.fromPzmodel(plist('pzmodel', args{1}));
396
397
398 elseif isa(args{1}, 'plist')
399 %%%%%%%%%% a1 = ao(plist-object) %%%%%%%%%%
400 utils.helper.msg(msg.PROC1, 'constructing from plist');
401 pl = args{1};
402
403 if pl.isparam('filename')
404
405 %-----------------------------------------------------
406 %--- Construct from file
407 %-----------------------------------------------------
408 utils.helper.msg(msg.PROC2, 'constructing from file %s', pl.find('filename'));
409 obj = fromFile(obj, args{1});
410
411 elseif pl.isparam('built-in')
412
413 %--- Construct from model
414 utils.helper.msg(msg.PROC2, 'constructing from built-in model');
415 obj = obj.fromModel(pl);
416
417 elseif pl.isparam('fcn')
418
419 %-----------------------------------------------------
420 %--- Construct from function
421 %-----------------------------------------------------
422 utils.helper.msg(msg.PROC2, 'constructing from function %s', pl.find('fcn'));
423 obj = fromFcn(obj, pl);
424
425 elseif pl.isparam('vals')
426
427 %-----------------------------------------------------
428 %--- Construct from Values
429 %-----------------------------------------------------
430 utils.helper.msg(msg.PROC2, 'constructing from values');
431 obj = obj.fromVals(pl, callerIsMethod);
432
433 elseif pl.isparam('xvals') || pl.isparam('yvals')
434
435 %-----------------------------------------------------
436 %--- Construct from X and Y Values
437 %-----------------------------------------------------
438 utils.helper.msg(msg.PROC2, 'constructing from X and Y values');
439 obj = fromXYVals(obj, pl, callerIsMethod);
440
441 elseif pl.isparam('tsfcn')
442
443 %-----------------------------------------------------
444 %--- Construct from Time-series function
445 %-----------------------------------------------------
446 utils.helper.msg(msg.PROC2, 'constructing from fcn(t) %s', pl.find('tsfcn'));
447 obj = fromTSfcn(obj, pl);
448
449 elseif pl.isparam('xyfcn')
450
451 %-----------------------------------------------------
452 %--- Construct from XY function
453 %-----------------------------------------------------
454 utils.helper.msg(msg.PROC2, 'constructing from fcn(x) %s', pl.find('xyfcn'));
455 obj = obj.fromXYFcn(pl);
456
457 elseif pl.isparam('fsfcn')
458
459 %-----------------------------------------------------
460 %--- Construct from frequency-series function
461 %-----------------------------------------------------
462 utils.helper.msg(msg.PROC2, 'constructing from fcn(f) %s', pl.find('fsfcn'));
463 obj = obj.fromFSfcn(pl);
464
465 elseif pl.isparam('win')
466
467 %-----------------------------------------------------
468 %--- Construct from Window
469 %-----------------------------------------------------
470 utils.helper.msg(msg.PROC2, 'constructing from window %s', char(pl.find('win')));
471 obj = obj.fromSpecWin(pl);
472
473 elseif pl.isparam('waveform')
474
475 %-----------------------------------------------------
476 %--- Construct from Waveform
477 %-----------------------------------------------------
478 utils.helper.msg(msg.PROC2, 'constructing from waveform %s', pl.find('waveform'));
479 obj = fromWaveform(obj, pl, callerIsMethod);
480
481 elseif pl.isparam('hostname') || pl.isparam('conn')
482
483 %-----------------------------------------------------
484 %--- Construct from repository
485 %-----------------------------------------------------
486 utils.helper.msg(msg.PROC2, 'constructing from repository %s', pl.find('hostname'));
487 obj = obj.fromRepository(pl);
488
489 elseif pl.isparam('polyval')
490
491 %-----------------------------------------------------
492 %--- Construct from polynomial
493 %-----------------------------------------------------
494 utils.helper.msg(msg.PROC2, 'constructing from polynomial ');
495 obj = obj.fromPolyval(pl);
496
497 elseif pl.isparam('plist')
498
499 %-----------------------------------------------------
500 %--- Construct from plist
501 %-----------------------------------------------------
502 obj = ao(pl.find('plist'));
503
504 elseif pl.isparam('pzmodel')
505
506 %-----------------------------------------------------
507 %--- Construct from pzmodel
508 %-----------------------------------------------------
509 utils.helper.msg(msg.PROC2, 'constructing from pzmodel %s', char(pl.find('pzmodel')));
510 obj = obj.fromPzmodel(pl);
511
512 elseif pl.isparam('model')
513
514 %-----------------------------------------------------
515 %--- Construct from smodel
516 %-----------------------------------------------------
517 utils.helper.msg(msg.PROC2, 'constructing from symbolic model %s', char(pl.find('smodel')));
518 obj = obj.fromSModel(pl, callerIsMethod);
519
520 elseif pl.isparam('Pest')
521
522 %-----------------------------------------------------
523 %--- Construct from pest
524 %-----------------------------------------------------
525 utils.helper.msg(msg.PROC2, 'constructing from pest object %s', char(pl.find('pest')));
526 obj = obj.fromPest(pl);
527
528
529 elseif pl.isparam('parameter')
530
531 utils.helper.msg(msg.PROC2, 'constructing from parameter');
532 obj = obj.fromParameter(pl);
533
534 else
535 % build a no-data ao from the plist and default values
536 ii = ao.getInfo('ao', 'Default');
537 pl = applyDefaults(ii.plists, pl);
538 obj.setObjectProperties(pl);
539 obj.addHistory(ao.getInfo('ao', 'None'), pl, [], []);
540 end
541
542 elseif isa(args{1}, 'specwin')
543 %%%%%%%%%% a1 = ao(specwin) %%%%%%%%%%
544 utils.helper.msg(msg.PROC1, 'constructing from spectral window %s', char(args{1}));
545 obj = obj.fromSpecWin(plist('win', args{1}));
546
547 elseif isa(args{1}, 'smodel')
548 %%%%%%%%%% a1 = ao(smodel) %%%%%%%%%%
549 utils.helper.msg(msg.PROC1, 'constructing from smodel %s', char(args{1}));
550 obj = obj.fromSModel(plist('model', args{1}), callerIsMethod);
551
552 elseif isa(args{1}, 'pest')
553 %%%%%%%%%% a1 = ao(pest) %%%%%%%%%%
554 utils.helper.msg(msg.PROC1, 'constructing from pest %s', char(args{1}));
555 obj = obj.fromPest(plist('pest', args{1}));
556
557 elseif isa(args{1}, 'ltpda_data')
558 %%%%%%%%%% a1 = ao(ltpda_data-object) %%%%%%%%%%
559 %%%%%%%%%% a1 = ao(cdata) %%%%%%%%%%
560 %%%%%%%%%% a1 = ao(fsdata) %%%%%%%%%%
561 %%%%%%%%%% a1 = ao(tsdata) %%%%%%%%%%
562 %%%%%%%%%% a1 = ao(xydata) %%%%%%%%%%
563 %%%%%%%%%% a1 = ao(xyzdata) %%%%%%%%%%
564 utils.helper.msg(msg.PROC1, 'constructing from data object %s', class(args{1}));
565 obj = ao;
566 obj.data = args{1};
567 obj.addHistory(ao.getInfo('ao', 'None'), [], [], []);
568
569 elseif islogical(args{1})
570 %%%%%%%%%%% a1 = ao(true) %%%%%%%%%%%%%
571 utils.helper.msg(msg.PROC3, 'constructing from logical');
572 obj = fromVals(obj, plist('VALS', args{1}), callerIsMethod);
573
574 else
575 error('### Unknown single input constructor');
576 end
577
578 case 2
579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
580 %%%%%%%%%%%%%%%%%%%%%%%%%%% two inputs %%%%%%%%%%%%%%%%%%%%%%%%%%
581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
582
583 if isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')
584 %%%%%%%%%% ao(database-object, [IDs]) %%%%%%%%%%
585 utils.helper.msg(msg.PROC1, 'constructing from database object');
586 pl = plist('conn', varargin{1}, 'id', varargin{2});
587 obj = obj.fromRepository(pl);
588
589 elseif isnumeric(args{1}) && isnumeric(args{2}) && numel(args{1}) == numel(args{2})
590 %%%%%%%%%% ao(x-vector, y-vector) %%%%%%%%%%
591 utils.helper.msg(msg.PROC1, 'constructing from X and Y values');
592 obj = obj.fromXYVals(plist('XVALS', args{1}, 'YVALS', args{2}), callerIsMethod);
593
594 elseif isnumeric(args{1}) && isnumeric(args{2}) && numel(args{2}) == 1
595 %%%%%%%%%% ao(y-vector, fs) %%%%%%%%%%
596 utils.helper.msg(msg.PROC1, 'constructing from Y values and fs');
597 obj = obj.fromXYVals(plist('YVALS', args{1}, 'fs', args{2}, 'xunits', 's'), callerIsMethod);
598
599 elseif isa(args{1}, 'pzmodel') && isa(args{2}, 'plist')
600 %%%%%%%%%% f = ao(pzmodel-object, plist-object) %%%%%%%%%%
601 utils.helper.msg(msg.OPROC1, 'constructing from pzmodel %s', args{1}.name);
602 obj = obj.fromPzmodel(combine(plist('pzmodel', args{1}), args{2}));
603 elseif isnumeric(args{1}) && isa(args{2}, 'plist')
604 %%%%%%%%%% ao(<double>, pl) %%%%%%%%%%
605 utils.helper.msg(msg.PROC1, 'constructing from constant values and plist');
606 obj = obj.fromVals(combine(plist('VALS', args{1}), args{2}), callerIsMethod);
607
608 elseif ischar(args{1}) && isa(args{2}, 'plist')
609 %%%%%%%%%%% ao('foo.txt', pl) %%%%%%%%%%
610 utils.helper.msg(msg.PROC1, 'constructing from filename and plist');
611 pl = combine(plist('filename', args{1}), args{2});
612 obj = obj.fromFile(pl);
613
614 elseif isa(args{1}, 'ao') && isa(args{2}, 'ao')
615 %%%%%%%%%%% ao(ao-object, ao-object) %%%%%%%%%%
616 % Do we have a list of AOs as input
617 obj = ao([args{1}, args{2}]);
618
619 % elseif isa(args{1}, 'ao') && isa(args{2}, 'plist') && isempty(args{2}.params)
620 % % pass to copy constructor
621 % a = ao(args{1});
622 %
623
624 elseif isa(args{1}, 'ao') && isa(args{2}, 'plist') && isempty(varargin{2}.params)
625 %%%%%%%%%% f = ao(ao-object, <empty plist>) %%%%%%%%%%
626 obj = ao(varargin{1});
627
628 elseif isa(args{1}, 'org.apache.xerces.dom.DeferredElementImpl') && ...
629 isa(args{2}, 'history')
630 %%%%%%%%%% obj = ao(DOM node, history-objects) %%%%%%%%%%
631 obj = fromDom(obj, args{1}, args{2});
632
633 elseif isa(args{1}, 'ltpda_uoh') && isa(args{2}, 'plist')
634 %%%%%%%%%%% ao(<ltpda_uoh>-object, plist-object) %%%%%%%%%%
635 % always recreate from plist
636
637 % If we are trying to load from file, and the file exists, do
638 % that. Otherwise, copy the input object.
639 if args{2}.isparam('filename')
640 if exist(fullfile('.', find(args{2}, 'filename')), 'file')==2
641 obj = ao(args{2});
642 else
643 obj = ao(args{1});
644 end
645 else
646 obj = ao(args{2});
647 end
648 else
649 error('### Unknown constructor with two inputs');
650 end
651
652 case 3
653 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
654 %%%%%%%%%%%%%%%%%%%%%%%%%% three inputs %%%%%%%%%%%%%%%%%%%%%%%%%
655 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
656
657 if isnumeric(args{1}) && isnumeric(args{2}) && isnumeric(args{3}) && ...
658 numel(args{1}) == numel(args{2}) && numel(args{3}) == 1
659 %%%%%%%%%% ao(x-vector, y-vector, fs) %%%%%%%%%%
660
661 utils.helper.msg(msg.PROC1, 'constructing from X and Y values and frequency.');
662 obj = obj.fromXYVals(plist('XVALS', args{1}, 'YVALS', args{2}, 'FS', args{3}), callerIsMethod);
663
664 elseif isnumeric(args{1}) && isnumeric(args{2}) && isa(args{3}, 'plist')
665 %%%%%%%%%% ao(x-vector, y-vector, plist) %%%%%%%%%%
666
667 utils.helper.msg(msg.PROC1, 'constructing from X and Y values and frequencies.');
668 pl = combine(plist('XVALS', args{1}, 'YVALS', args{2}), args{3});
669 obj = obj.fromXYVals(pl, callerIsMethod);
670
671 elseif isa(args{1}, 'pzmodel') && isnumeric(args{2}) && isnumeric(args{3})
672 %%%%%%%%%% ao(pzmodel, nsecs, fs) %%%%%%%%%%
673
674 utils.helper.msg(msg.PROC2, 'constructing from pzmodel %s', char(args{1}));
675 pl = plist('pzmodel', args{1}, 'Nsecs', args{2}, 'fs', args{3});
676 obj = obj.fromPzmodel(pl);
677
678 else
679
680 [aoi, invars, rest] = utils.helper.collect_objects(args, 'ao');
681
682 %%% Do we have a list of AOs as input
683 if ~isempty(aoi) && isempty(rest)
684 obj = ao(aoi);
685 else
686 error('### Unknown constructor with three inputs');
687 end
688 end
689
690 otherwise
691 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
692 %%%%%%%%%%%%%%%%%%%%%%%%%% other inputs %%%%%%%%%%%%%%%%%%%%%%%%%
693 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
694
695 [aoi, invars, rest] = utils.helper.collect_objects(args, 'ao');
696
697 %%% Do we have a list of AOs as input
698 if ~isempty(aoi) && isempty(rest)
699 obj = ao(aoi);
700 else
701 error('### Unknown number of arguments.');
702 end
703 end
704
705 end % End constructor
706 end % End public methods
707
708
709 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
710 % Methods (static) %
711 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
712 methods (Static = true)
713
714 function n = randn(varargin)
715 % RANDN convenient constructor of an AO containing random numbers.
716 %
717 % CALL:
718 % n = ao.randn(nsamples) % cdata AO
719 % n = ao.randn(nsecs, fs) % tsdata AO
720 %
721 switch nargin
722 case 1
723 % cdata(nsamples)
724 n = ao(plist('vals', randn(varargin{1},1)));
725 case 2
726 n = ao(plist('tsfcn', 'randn(size(t))', 'fs', varargin{2}, 'nsecs', varargin{1}));
727 otherwise
728 error('Unknown input arguments');
729 end
730
731
732 end
733
734 function n = sinewave(varargin)
735 % SINEWAVE convenient constructor of an AO containing a sine wave.
736 %
737 % CALL:
738 % n = ao.sinewave(nsecs, fs, f0, phi) % tsdata AO
739 %
740 switch nargin
741 case 4
742 n = ao(plist('waveform', 'sine wave', ...
743 'f', varargin{3}, 'phi', varargin{4}, ...
744 'fs', varargin{2}, 'nsecs', varargin{1}));
745 otherwise
746 error('Unknown input arguments');
747 end
748 end
749
750
751 function mdls = getBuiltInModels(varargin)
752 mdls = ltpda_uo.getBuiltInModels('ao');
753 end
754
755 function out = SETS()
756 out = [SETS@ltpda_uoh, ...
757 {'From MAT Data File'}, ...
758 {'From ASCII File'}, ...
759 {'From Complex ASCII File'}, ...
760 {'From Function'}, ...
761 {'From Values'}, ...
762 {'From XY Values'}, ...
763 {'From Time-series Function'}, ...
764 {'From XY Function'}, ...
765 {'From Frequency-series Function'}, ...
766 {'From Window'}, ...
767 {'From Waveform'}, ...
768 {'From Polynomial'}, ...
769 {'From Pzmodel'}, ...
770 {'From Smodel'}, ...
771 {'From Pest'}, ...
772 {'From Parameter'} ...
773 ];
774 % {'From CSD'}, ...
775 end
776
777 function out = VEROUT()
778 out = '$Id: ao.m,v 1.361 2011/08/22 05:23:45 hewitson Exp $';
779 end
780
781 function ii = getInfo(varargin)
782 ii = utils.helper.generic_getInfo(varargin{:}, 'ao');
783 end
784
785 % Return the plist for a particular parameter set
786 function plout = getDefaultPlist(set)
787 persistent pl;
788 persistent lastset;
789 if exist('pl', 'var')==0 || isempty(pl) || ~strcmp(lastset, set)
790 pl = ao.buildplist(set);
791 lastset = set;
792 end
793 plout = pl;
794 end
795
796 function out = buildplist(set)
797
798 if ~utils.helper.ismember(lower(ao.SETS), lower(set))
799 error('### Unknown set [%s]', set);
800 end
801
802 out = plist();
803 out = ao.addGlobalKeys(out);
804 out = buildplist@ltpda_uoh(out, set);
805
806 % Otherwise we try to find a set for this constructor
807 switch lower(set)
808 case 'from mat data file'
809 % filename
810 p = param({'filename','MAT data filename.'}, paramValue.EMPTY_STRING);
811 out.append(p);
812
813 % filepath
814 p = param({'filepath','Path to the data file in case the filename is a relative path.'}, paramValue.EMPTY_STRING);
815 out.append(p);
816
817 % type
818 p = param({'type','Choose the data type.'}, paramValue.DATA_TYPES);
819 out.append(p);
820
821 % columns
822 p = param({'columns', ['Specify column pairs for the <tt>x-y</tt> variables, e.g. [1 2 1 4].<br>',...
823 'Each column pair creates an analysis object.<br>',...
824 'If the value ''fs'' is set then each column represents only the <tt>y</tt>-axes.<br>']}, ...
825 {1, {[]}, paramValue.OPTIONAL});
826 out.append(p);
827
828 % Xunits
829 p = param({'xunits','Unit on X axis.'}, paramValue.STRING_VALUE('s'));
830 out.append(p);
831
832 % Yunits
833 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
834 out.append(p);
835
836 % Fs
837 p = param({'fs','If this value is set, the x-axes is computed from the fs value.'}, paramValue.EMPTY_DOUBLE);
838 out.append(p);
839
840 case 'from ascii file'
841
842 % filename
843 p = param({'filename','ASCII filename.'}, paramValue.EMPTY_STRING);
844 out.append(p);
845
846 % filepath
847 p = param({'filepath','Path to the data file in case the filename is a relative path.'}, paramValue.EMPTY_STRING);
848 out.append(p);
849
850 % type
851 p = param({'type','Choose the data type.'}, paramValue.DATA_TYPES);
852 out.append(p);
853
854 % columns
855 p = param({'columns', ['Specify column pairs for the <tt>x-y</tt> variables, e.g. [1 2 1 4].<br>',...
856 'Each column pair creates an analysis object.<br>',...
857 'If the value ''fs'' is set then each column represents only the <tt>y</tt>-axes.<br>']}, ...
858 {1, {[]}, paramValue.OPTIONAL});
859 out.append(p);
860
861 % Xunits
862 p = param({'xunits','Unit on X axis.'}, paramValue.STRING_VALUE(''));
863 out.append(p);
864
865 % Yunits
866 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
867 out.append(p);
868
869 % Comment char
870 p = param({'comment_char','The comment character in the file.'}, paramValue.EMPTY_STRING);
871 out.append(p);
872
873 % Maximum number of lines
874 p = param({'maxlines', 'Maximum number of lines which should be read.'}, paramValue.EMPTY_DOUBLE);
875 out.append(p);
876
877 % Fs
878 p = param({'fs','If this value is set, the x-axes is computed from the fs value.'}, paramValue.EMPTY_DOUBLE);
879 out.append(p);
880
881 % Robust
882 p = param({'Robust',['Set this to ''yes'' to use (slow) robust data reading.<br>',...
883 'Useful for complicated file formats.']}, paramValue.YES_NO);
884 p.val.setValIndex(2);
885 out.append(p);
886
887 % Delimiter
888 p = param({'Delimiter', 'Field delimiter character(s).'}, paramValue.STRING_VALUE(''));
889 out.append(p);
890
891 % T0
892 p = param({'T0', ['The UTC time of the first sample.<br>' ...
893 'For data types other than tsdata, this is ignored.']}, {1, {'1970-01-01 00:00:00.000'}, paramValue.OPTIONAL});
894 out.append(p);
895
896
897
898 %------------------------------------------
899 %--- Read from complex ASCII file
900 %------------------------------------------
901 case 'from complex ascii file'
902
903 % Filename
904 p = param({'filename','ASCII filename.'}, paramValue.EMPTY_STRING);
905 out.append(p);
906
907 % filepath
908 p = param({'filepath','Path to the data file in case the filename is a relative path.'}, paramValue.EMPTY_STRING);
909 out.append(p);
910
911 % Complex type
912 p = param({'complex_type','String defining the format of the complex data.'}, ...
913 {1, {'real/imag', 'abs/deg', 'dB/deg', 'abs/rad', 'dB/rad'}, paramValue.SINGLE});
914 out.append(p);
915
916 % Type
917 p = param({'type','String defining the data type'}, paramValue.DATA_TYPES);
918 p.val.setValIndex(2);
919 out.append(p);
920
921 % columns
922 p = param({'columns',['Colums to consider inside the file. <br>',...
923 'It must be 3 or a multiple: the first column defines the x-axis and the next <br>',...
924 'two columns the complex y-axis. If a multiple of 3 columns are specified, <br>',...
925 'the constructor will output multiple aos. (e.g. [1 2 3])']}, ...
926 {1, {[1 2 3]}, paramValue.OPTIONAL});
927 out.append(p);
928
929 % Xunits
930 p = param({'xunits','Unit on X axis.'}, paramValue.STRING_VALUE('Hz'));
931 out.append(p);
932
933 % Yunits
934 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
935 out.append(p);
936
937 % Comment char
938 p = param({'comment_char','The comment character in the file.'}, paramValue.EMPTY_STRING);
939 out.append(p);
940
941 % T0
942 p = param({'T0', ['The UTC time of the first sample.<br>' ...
943 'For data types other than tsdata, this is ignored.']}, {1, {'1970-01-01 00:00:00.000'}, paramValue.OPTIONAL});
944 out.append(p);
945
946 %------------------------------------------
947 %--- Create from a function description
948 %------------------------------------------
949 case 'from function'
950
951 % Fcn
952 p = param({'fcn','Any valid MATLAB function. [e.g. ''randn(100,1)'']'}, paramValue.EMPTY_STRING);
953 out.append(p);
954
955 % Yunits
956 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
957 out.append(p);
958
959 % RAND_STREAM
960 p = param({'RAND_STREAM', 'Set the random stream for noise generation. This should be a structure with the fields of the properties for the class RandStream (help RandStream).'}, paramValue.EMPTY_DOUBLE);
961 out.append(p);
962
963 %------------------------------------------
964 %--- Create from a set of values
965 %------------------------------------------
966 case 'from values'
967
968 % Vals
969 p = param({'vals','A set of values.'}, paramValue.EMPTY_DOUBLE);
970 out.append(p);
971
972 % N
973 p = param({'N','Repeat ''N'' times.'}, {1, {1}, paramValue.OPTIONAL});
974 out.append(p);
975
976 % Yunits
977 p = param({'yunits','Unit on Y axis'}, paramValue.STRING_VALUE(''));
978 out.append(p);
979
980 %------------------------------------------
981 %--- Create from a set of values
982 %------------------------------------------
983 case 'from xy values'
984
985 % Type
986 p = param({'type','The data type.'}, {1, {'', 'tsdata', 'fsdata', 'xydata', 'cdata'}, paramValue.SINGLE});
987 out.append(p);
988
989 % Fs
990 p = param({'fs',['Frequency: if this is set, xvals (if passed) will be ignored and the <br>',...
991 'resulting tsdata will contain an X vector sampled according to fs. <br>', ...
992 'For data types other than tsdata, this is ignored.']}, paramValue.EMPTY_DOUBLE);
993 out.append(p);
994
995 % T0
996 p = param({'T0', ['The UTC time of the first sample.<br>' ...
997 'For data types other than tsdata, this is ignored.']}, {1, {'1970-01-01 00:00:00.000'}, paramValue.OPTIONAL});
998 out.append(p);
999
1000 % toffset
1001 p = param({'toffset', ['The offset between the first x sample and t0.<br>' ...
1002 'For data types other than tsdata, this is ignored.']}, paramValue.DOUBLE_VALUE(0));
1003 out.append(p);
1004
1005 % Xvals
1006 p = param({'xvals','A set of x values.'}, paramValue.EMPTY_DOUBLE);
1007 out.append(p);
1008
1009 % Yvals
1010 p = param({'yvals','A set of y values.'}, paramValue.EMPTY_DOUBLE);
1011 out.append(p);
1012
1013 % Xunits
1014 p = param({'xunits','Unit on X axis.'}, paramValue.STRING_VALUE(''));
1015 out.append(p);
1016
1017 % Yunits
1018 p = param({'yunits','Unit on Y axis'}, paramValue.STRING_VALUE(''));
1019 out.append(p);
1020
1021 %------------------------------------------
1022 %--- Create from a XY function
1023 %------------------------------------------
1024 case 'from xy function'
1025
1026 % XY fcn
1027 p = param({'xyfcn','Specify a function of x. (e.g. x.^2)'}, {1, {'x'}, paramValue.OPTIONAL});
1028 out.append(p);
1029
1030 % X
1031 p = param({'X','The x values.'}, paramValue.EMPTY_DOUBLE);
1032 out.append(p);
1033
1034 % Xunits
1035 p = param({'xunits','Unit on X axis.'}, paramValue.STRING_VALUE(''));
1036 out.append(p);
1037
1038 % Yunits
1039 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
1040 out.append(p);
1041
1042 % RAND_STREAM
1043 p = param({'RAND_STREAM', 'Set the random stream for noise generation. This should be a structure with the fields of the properties for the class RandStream (help RandStream).'}, paramValue.EMPTY_DOUBLE);
1044 out.append(p);
1045
1046 %------------------------------------------
1047 %--- Create from a time-series function
1048 %------------------------------------------
1049 case 'from time-series function'
1050
1051 % TS fcn
1052 p = param({'tsfcn','A function of time.'}, {1, {'t'}, paramValue.OPTIONAL});
1053 out.append(p);
1054
1055 % Fs, Nsecs, Xunits
1056 out.append(plist.TSDATA_PLIST);
1057
1058 % Yunits
1059 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
1060 out.append(p);
1061
1062 % RAND_STREAM
1063 p = param({'RAND_STREAM', 'Set the random stream for noise generation. This should be a structure with the fields of the properties for the class RandStream (help RandStream).'}, paramValue.EMPTY_DOUBLE);
1064 out.append(p);
1065
1066 %------------------------------------------
1067 %--- Create from frequency-series function
1068 %------------------------------------------
1069 case 'from frequency-series function'
1070
1071 % FS fcn
1072 p = param({'fsfcn','A function of frequency.'}, {1, {'f'}, paramValue.OPTIONAL});
1073 out.append(p);
1074
1075 % F1
1076 p = param({'f1','The initial frequency.'}, {1, {1e-9}, paramValue.OPTIONAL});
1077 out.append(p);
1078
1079 % F2
1080 p = param({'f2','The final frequency.'}, {1, {10000}, paramValue.OPTIONAL});
1081 out.append(p);
1082
1083 % Nf
1084 p = param({'nf','The number of frequency samples.'}, {1, {1000}, paramValue.OPTIONAL});
1085 out.append(p);
1086
1087 % Scale
1088 p = param({'scale','Choose the frequency spacing.'}, {2, {'lin', 'log'}, paramValue.SINGLE});
1089 out.append(p);
1090
1091 % F
1092 p = param({'f','a vector of frequencies on which to evaluate the function.'}, paramValue.EMPTY_DOUBLE);
1093 out.append(p);
1094
1095 % Xunits
1096 p = param({'xunits','Unit on X axis.'}, paramValue.STRING_VALUE('Hz'));
1097 out.append(p);
1098
1099 % Yunits
1100 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
1101 out.append(p);
1102
1103 % RAND_STREAM
1104 p = param({'RAND_STREAM', 'Set the random stream for noise generation. This should be a structure with the fields of the properties for the class RandStream (help RandStream).'}, paramValue.EMPTY_DOUBLE);
1105 out.append(p);
1106
1107 %------------------------------------------
1108 %--- Create from a window function
1109 %------------------------------------------
1110 case 'from window'
1111 % Win
1112 p = param({'win','A Spectral window name.'}, paramValue.WINDOW);
1113 out.append(p);
1114
1115 % length
1116 p = param({'length','The length of the window (number of samples).'}, paramValue.DOUBLE_VALUE(100));
1117 out.append(p);
1118
1119 % psll
1120 p = param({'psll','If you choose a ''kaiser'' window, you can also specify the peak-sidelobe-level.'}, paramValue.DOUBLE_VALUE(150));
1121 out.append(p);
1122
1123 % level order
1124 p = param({'levelOrder','If you choose a ''levelledHanning'' window, you can also specify the order of the contraction.'}, paramValue.DOUBLE_VALUE(2));
1125 out.append(p);
1126
1127 % Yunits
1128 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
1129 out.append(p);
1130
1131 %------------------------------------------
1132 %--- Create from a set of polynomial coefficients
1133 %------------------------------------------
1134 case 'from polynomial'
1135
1136 % Polyval
1137 p = param({'polyval',['A set of polynomial coefficients. This can also be an AO, <br>',...
1138 'in which case the Y values from the AO are used.']}, paramValue.EMPTY_DOUBLE);
1139 out.append(p);
1140
1141 % Fs
1142 p = param({'fs', 'The sampling frequency of the signal. [for all]'}, paramValue.EMPTY_DOUBLE);
1143 out.append(p);
1144
1145 % Nsecs
1146 p = param({'nsecs', 'The number of seconds of data. [for all]'}, paramValue.EMPTY_DOUBLE);
1147 out.append(p);
1148
1149 % T0
1150 p = param({'T0', 'The UTC time of the first sample. [for all]'}, {1, {'1970-01-01 00:00:00.000'}, paramValue.OPTIONAL});
1151 out.append(p);
1152
1153 % toffset
1154 p = param({'toffset', 'The offset between the first x sample and t0.'}, paramValue.DOUBLE_VALUE(0));
1155 out.append(p);
1156
1157 % T
1158 p = param({'t',['Vector of time vertices for tsdata type. <br>',...
1159 'The value can also be an AO, in which case the X vector is used.']}, paramValue.EMPTY_DOUBLE);
1160 out.append(p);
1161
1162 % X
1163 p = param({'x', 'Vector of X values for xydata type. <br>',...
1164 'The value can also be an AO, in which case the X vector is used.'}, paramValue.EMPTY_DOUBLE);
1165 out.append(p);
1166
1167 % F
1168 p = param({'f', 'Vector of frequency values for fsdata type. <br>',...
1169 'The value can also be an AO, in which case the X vector is used.'}, paramValue.EMPTY_DOUBLE);
1170 out.append(p);
1171
1172 % Type
1173 p = param({'type','The data type. If this is empty, the constructor will attempt to determine the type from the other parameters.'}, {1,{'', 'tsdata', 'fsdata', 'xydata', 'cdata'}, paramValue.SINGLE});
1174 p.setDefaultIndex(1); % Set the default to 'tsdata'
1175 out.append(p);
1176
1177 % Xunits
1178 p = param({'xunits','Unit on X axis.'}, paramValue.EMPTY_STRING);
1179 out.append(p);
1180
1181 % Yunits
1182 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
1183 out.append(p);
1184
1185 %------------------------------------------
1186 %--- Create from a waveform description
1187 %------------------------------------------
1188 case 'from waveform'
1189 % Waveform
1190 p = param({'waveform', 'A waveform description.<br>A special case is the ''<b>sine wave</b>'' because you can create more sinewaves which are summed. For this case you can add several values for ''A'', ''f'', ''phi'', ''nsecs'' and/or ''Toff'''}, ...
1191 {1, {'sine wave', 'noise', 'chirp', 'gaussian pulse', 'square wave', 'sawtooth'}, paramValue.OPTIONAL});
1192 out.append(p);
1193
1194 % A
1195 p = param({'A','Amplitude of the signal. [for ''sine wave''].'}, {1, {1}, paramValue.OPTIONAL});
1196 out.append(p);
1197
1198 % F
1199 p = param({'f', 'Frequency of the signal. [for ''sine wave'', ''square wave'', ''sawtooth''].'}, ...
1200 {1, {1}, paramValue.OPTIONAL});
1201 out.append(p);
1202
1203 % Phi
1204 p = param({'phi','Phase of the signal. [for ''sine wave'']'}, {1, {0}, paramValue.OPTIONAL});
1205 out.append(p);
1206
1207 % Toff
1208 p = param({'Toff', ['Offset of the different sine waves, as [for ''sine wave'']<ul>', ...
1209 '<li>a vector of seconds</li>', ...
1210 '<li>a cell array with the offsets as a string</li>', ...
1211 '<li>a vector time objects</li>', ...
1212 '</ul>Remark: If t0 is not specified then it will be set to the first value of Toff.<br><br>Offset of the signal, in seconds. [for all other]']}, {1, {0}, paramValue.OPTIONAL});
1213 out.append(p);
1214
1215 % gaps
1216 p = param({'gaps', 'Instead of defining an offset it is possible to define a gap before the sine wave. [for ''sine wave'']<br/>'}, paramValue.EMPTY_DOUBLE);
1217 out.append(p);
1218
1219 % Type
1220 p = param({'Type', 'Noise type. [for ''noise'']'}, {1, {'Normal', 'Uniform'}, paramValue.SINGLE});
1221 out.append(p);
1222
1223 % Sigma
1224 p = param({'Sigma', 'The standard deviation of the noise. [for ''noise'']'}, {1, {1}, paramValue.OPTIONAL});
1225 out.append(p);
1226
1227 % F0
1228 p = param({'F0', 'A fundamental/start frequency of the signal. [for ''chirp'', ''gaussian pulse'']'}, ...
1229 {1, {1}, paramValue.OPTIONAL});
1230 out.append(p);
1231
1232 % F1
1233 p = param({'F1', 'The end frequency of the signal. [for ''chirp'']'}, paramValue.EMPTY_DOUBLE);
1234 out.append(p);
1235
1236 % T1
1237 p = param({'T1', 'The end time of the signal. [for ''chirp'']'}, paramValue.EMPTY_DOUBLE);
1238 out.append(p);
1239
1240 % BW
1241 p = param({'BW', 'The bandwidth of the signal. [for ''gaussian pulse'']'}, paramValue.EMPTY_DOUBLE);
1242 out.append(p);
1243
1244 % Duty
1245 p = param({'Duty', 'The duty-cycle of the signal (in %). [for ''square wave'']'}, {1, {50}, paramValue.OPTIONAL});
1246 out.append(p);
1247
1248 % Width
1249 p = param({'Width', 'The width of the signal. [0-1] [for ''sawtooth'']'}, {1, {0.5}, paramValue.OPTIONAL});
1250 out.append(p);
1251
1252 % Fs, Nsecs, Xunits
1253 out.append(plist.TSDATA_PLIST);
1254 out.remove('toffset');
1255
1256 % Yunits
1257 p = param({'yunits','Unit on Y axis. [for all]'}, paramValue.STRING_VALUE(''));
1258 out.append(p);
1259
1260 % RAND_STREAM
1261 p = param({'RAND_STREAM', 'Set the random stream for noise generation. This should be a structure with the fields of the properties for the class RandStream (help RandStream).'}, paramValue.EMPTY_DOUBLE);
1262 out.append(p);
1263
1264 %------------------------------------------
1265 %--- Create from a set of pzm coefficients
1266 %------------------------------------------
1267 case 'from pzmodel'
1268
1269 % PZModel
1270 p = param({'pzmodel','A pole/zero model which builds the time-series AO.'}, {1, {pzmodel}, paramValue.OPTIONAL});
1271 out.append(p);
1272
1273 % Fs, Nsecs, Xunits
1274 out.append(plist.TSDATA_PLIST);
1275
1276 % Yunits
1277 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
1278 out.append(p);
1279
1280 % RAND_STREAM
1281 p = param({'RAND_STREAM', 'Set the random stream for noise generation. This should be a structure with the fields of the properties for the class RandStream (help RandStream).'}, paramValue.EMPTY_DOUBLE);
1282 out.append(p);
1283
1284 %------------------------------------------
1285 %--- Create from a smodel
1286 %------------------------------------------
1287 case 'from smodel'
1288
1289 % Model
1290 p = param({'model', 'The smodel to evaluate and convert to an AO. '}, {1, {smodel()}, paramValue.OPTIONAL});
1291 out.append(p);
1292
1293 % X
1294 p = param({'x','Values for X axis.'}, paramValue.EMPTY_DOUBLE);
1295 out.append(p);
1296
1297 % Xunits
1298 p = param({'xunits','Unit on X axis.'}, paramValue.STRING_VALUE('s'));
1299 out.append(p);
1300
1301 % Type
1302 p = param({'type','Choose the data type.'}, paramValue.DATA_TYPES);
1303 p.val.setValIndex(1);
1304 out.append(p);
1305
1306 %------------------------------------------
1307 %--- Create from a pest
1308 %------------------------------------------
1309 case 'from pest'
1310
1311 % Model
1312 p = param({'pest', 'The pest object to extract the AO from. '}, paramValue.EMPTY_DOUBLE);
1313 out.append(p);
1314
1315 % Parameter
1316 p = param({'parameter',['Name of the parameter(s) to be extracted.<br>' ...
1317 'If empty, all parameters will be extracted into a vector ao AOs.']}, paramValue.STRING_VALUE(''));
1318 out.append(p);
1319
1320 case 'from parameter'
1321
1322 % parameter
1323 p = param({'parameter', ['The parameter or plist to make an AO from. <br>' ...
1324 'If the plist is a built-in one, it is also possible just to input its name.']}, paramValue.EMPTY_STRING);
1325 out.append(p);
1326
1327 % key
1328 p = param({'key', 'The parameter name to extract from the plist. '}, paramValue.EMPTY_STRING);
1329 out.append(p);
1330
1331 end
1332 end % End getDefaultPlist
1333
1334 function obj = initObjectWithSize(n,m)
1335 if numel(n) > 1
1336 obj = ao.newarray([n(1) n(2)]);
1337 else
1338 obj = ao.newarray([n m]);
1339 end
1340 end
1341
1342 end
1343
1344
1345 methods (Hidden = true)
1346 varargout = setData(varargin)
1347 varargout = attachToDom(varargin)
1348 varargout = welch(varargin)
1349 varargout = ifft_core(varargin)
1350 varargout = fft_core(varargin)
1351 varargout = fftfilt_core(varargin)
1352 varargout = xspec(varargin)
1353 end
1354
1355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1356 % Methods (static, private) %
1357 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1358 methods (Static = true, Access = private)
1359 % constructor functions
1360 % Spectral estimate function
1361 [yy, dyy, info] = welchscale(xx, dxx, win, fs, norm, inunits)
1362 [x,M,isreal_x,y,Ly,win,winName,winParam,noverlap,k,L,options] = welchparse(x,esttype,varargin)
1363 [P,f] = computeperiodogram(x,win,nfft,esttype,varargin)
1364 [Xx,f] = computeDFT(xin,nfft,varargin)
1365
1366 % Noise generator functions
1367 varargout = ngconv(varargin)
1368 varargout = ngsetup(varargin)
1369 varargout = ngsetup_vpa(varargin)
1370 varargout = nginit(varargin)
1371 varargout = ngprop(varargin)
1372 varargout = fq2fac(varargin)
1373 varargout = conv_noisegen(varargin)
1374 varargout = mchol(varargin)
1375
1376 % LPSD-type methods
1377 varargout = ltf_plan(varargin)
1378 varargout = mlpsd_mex(varargin)
1379 varargout = mlpsd_m(varargin)
1380 varargout = mltfe(varargin)
1381 varargout = findFsMax(varargin)
1382 varargout = findFsMin(varargin)
1383 varargout = findShortestVector(varargin)
1384 varargout = lxspec(varargin)
1385
1386 varargout = ltpda_fitChiSquare(varargin)
1387
1388 varargout = elementOp(varargin)
1389 varargout = melementOp(varargin)
1390
1391 varargout = applymethod(varargin)
1392
1393 end
1394
1395 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1396 % Methods (static, protected) %
1397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1398
1399 methods (Static = true, Access = protected)
1400 function pl = addGlobalKeys(pl)
1401
1402 % Call super-class
1403 addGlobalKeys@ltpda_uoh(pl);
1404
1405 end
1406
1407 function pl = removeGlobalKeys(pl)
1408
1409 % Call super-class
1410 removeGlobalKeys@ltpda_uoh(pl);
1411
1412 % Remove 'plotinfo'
1413 pl.remove('plotinfo');
1414 end
1415 end
1416
1417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1418 % Methods (static, hidden) %
1419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1420
1421 methods (Static = true, Hidden = true)
1422 varargout = loadobj(varargin)
1423 varargout = update_struct(varargin)
1424 end
1425
1426 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1427 % Methods (public) %
1428 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1429 methods
1430
1431 % Setters
1432 varargout = setXunits(varargin)
1433 varargout = setYunits(varargin)
1434 varargout = setT0(varargin)
1435 varargout = setFs(varargin)
1436 varargout = setXY(varargin)
1437 varargout = setY(varargin)
1438 varargout = setX(varargin)
1439 varargout = setZ(varargin)
1440 varargout = setDy(varargin)
1441 varargout = setDx(varargin)
1442
1443 % Other methods
1444 varargout = copy(varargin)
1445 h = md5(varargin)
1446 val = fromProcinfo(varargin)
1447
1448 end % End public methods
1449
1450
1451 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1452 % Methods (protected) %
1453 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1454 methods (Access = protected)
1455 obj = fromDataInMAT(obj, data, filename)
1456 obj = fromDatafile(obj, pli)
1457 obj = fromComplexDatafile(obj, pli)
1458 obj = fromStruct(obj, a_struct)
1459 varargout = fromDom(varargin)
1460 varargout = csvGenerateData(varargin)
1461 varargout = checkDataType(varargin)
1462 end
1463
1464
1465 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1466 % Methods (private) %
1467 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1468 methods (Access = private)
1469 % Constructors
1470 varargout = fromParameter(varargin)
1471 varargout = fromVals(varargin)
1472 varargout = fromXYVals(varargin)
1473 varargout = fromTSfcn(varargin)
1474 varargout = fromWaveform(varargin)
1475 varargout = fromFcn(varargin)
1476 varargout = fromFSfcn(varargin)
1477 varargout = fromSpecWin(varargin)
1478 varargout = fromPolyval(varargin)
1479 varargout = fromSModel(varargin)
1480 varargout = fromPzmodel(varargin)
1481 varargout = fromXYFcn(varargin)
1482 varargout = fromCSD(varargin)
1483 varargout = fromPest(varargin)
1484
1485 varargout = fixAxisData(varargin)
1486 varargout = smallvec_coef(in,pl)
1487
1488 varargout = setUnitsForAxis(varargin)
1489 varargout = clearErrors(varargin)
1490
1491 % Others
1492 varargout = applyoperator(varargin)
1493 end
1494
1495 end