comparison m-toolbox/test/LTPDA_training/topic5/gendata.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % util script to generate training session data for topic 5
2 % L FERRAIOLI 22-02-09
3 %
4 % $Id: gendata.m,v 1.4 2009/10/02 08:31:21 mauro Exp $
5 %
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
8 %% save path
9 data_path = '/Users/MH/Matlab/ltpda_cvs/software/m-toolbox/test/LTPDA_Training/topic5/';
10
11 %% 1) model filter
12
13 % Model Residues and Poles
14 mRes = [2.44554138162509e-011 - 1.79482547894083e-011i;
15 2.44554138162509e-011 + 1.79482547894083e-011i;
16 2.66402334803101e-009 + 1.1025122049153e-009i;
17 2.66402334803101e-009 - 1.1025122049153e-009i;
18 -7.3560293387644e-009;
19 -1.82811618589835e-009 - 1.21803627800855e-009i;
20 -1.82811618589835e-009 + 1.21803627800855e-009i;
21 1.16258677367555e-009;
22 1.65216557639319e-016;
23 -1.78092396888606e-016;
24 -2.80420398962379e-017;
25 9.21305973049041e-013 - 8.24686706827269e-014i;
26 9.21305973049041e-013 + 8.24686706827269e-014i;
27 5.10730060739905e-010 - 3.76571756625722e-011i;
28 5.10730060739905e-010 + 3.76571756625722e-011i;
29 3.45893698149735e-009;
30 3.98139182134446e-014 - 8.25503935419059e-014i;
31 3.98139182134446e-014 + 8.25503935419059e-014i;
32 -1.40595719147164e-011];
33
34 mPoles = [0.843464045655194 - 0.0959986292915475i;
35 0.843464045655194 + 0.0959986292915475i;
36 0.953187595424927 - 0.0190043625473383i;
37 0.953187595424927 + 0.0190043625473383i;
38 0.967176277937188;
39 0.995012027005247 - 0.00268322602801729i;
40 0.995012027005247 + 0.00268322602801729i;
41 0.996564761885673;
42 0.999999366165445;
43 0.999981722418555;
44 0.999921882627659;
45 0.999624431675213 - 0.000813407848742761i;
46 0.999624431675213 + 0.000813407848742761i;
47 0.997312006278751 - 0.00265611346834941i;
48 0.997312006278751 + 0.00265611346834941i;
49 0.990516544257531;
50 0.477796923118318 - 0.311064085401834i;
51 0.477796923118318 + 0.311064085401834i;
52 0];
53
54 f = logspace(-6,log10(5),100).';
55 fs = 10;
56
57 pfparams.type = 'disc';
58 pfparams.freq = f;
59 pfparams.fs = fs;
60 pfparams.res = mRes;
61 pfparams.pol = mPoles;
62 pfparams.dterm = 0;
63
64 % response of the model filter
65 pfr = utils.math.pfresp(pfparams);
66 y = pfr.resp;
67
68 % saving AO
69 rfilt = ao(plist('xvals', f, 'yvals', y, 'fs', fs, 'dtype', 'fsdata'));
70 rfilt.setName;
71
72 %
73 rfilt.save(plist('filename',[data_path 'T5_Ex02_rfilt.mat']));
74 rfilt.save(plist('filename',[data_path 'T5_Ex02_rfilt.xml']));
75
76 %% 2) Peaked model psd
77
78 % Create a psd model with two peak resonance at 5e-2 and 7e-2 Hz
79 func = '(1e-3./(f).^2 + 1e3./(0.001+f) + 1e6.*f.^2).*1e-10 + 1e-5./(1e-3+((f./1e-2).^2-1).^2) + 1e-6./(1e-3+((f./2e-2).^2-1).^2)';
80 pl_data = plist('fsfcn', func, 'f1', 1e-6, 'f2', .5, 'nf', 300);
81 mod = ao(pl_data);
82 iplot(mod)
83
84 %% Building white noise
85
86 a = ao(plist('tsfcn', 'randn(size(t))', 'fs', 1, 'nsecs', 10000, 'yunits', 'm'));
87 a.setName;
88
89 %% Calling the noise generator
90
91 pl = plist(...
92 'model', mod, ... % Multiplication by fs needed to preserve energy
93 'MaxIter', 70, ...
94 'PoleType', 2, ...
95 'MinOrder', 10, ...
96 'MaxOrder', 45, ...
97 'Weights', 2, ...
98 'Plot', false,...
99 'Disp', false,...
100 'RMSEVar', 7,...
101 'FitTolerance', 2);
102
103 ac = noisegen1D(a, pl);
104
105 %%
106
107 acxx = ac.psd(plist('Nfft',2000));
108 iplot(acxx,mod)
109
110 %%
111
112 ac.save(plist('filename',sprintf([data_path 'T5_Ex03_TestNoise.mat'])));
113 ac.save(plist('filename',sprintf([data_path 'T5_Ex03_TestNoise.xml'])));
114
115 %% 3) Generate polynomial tsdata
116
117 % Make fake AO from polyval
118 nsecs = 1000;
119 fs = 1;
120
121 a1 = ao(plist('tsfcn', 'polyval([1e-11 0 -5e-6 -1e-3 -5e-1 0.5], t) + 5e2*randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'm'));
122
123 % iplot(a1)
124
125 a1.save(plist('filename',sprintf([data_path 'T5_Ex04_TestNoise.mat'])));
126 a1.save(plist('filename',sprintf([data_path 'T5_Ex04_TestNoise.xml'])));
127
128 %% 4) Generate tsdata from function
129
130 nsecs = 1000;
131 fs = 1;
132 a2 = ao(plist('tsfcn','5 + 3.*sin(2.*pi.*(1e-4 + 1e-5.*t).*t + 0.3) + randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'm'));
133
134 iplot(a2)
135
136 a2.save(plist('filename',sprintf([data_path 'T5_Ex05_TestNoise.mat'])));
137 a2.save(plist('filename',sprintf([data_path 'T5_Ex05_TestNoise.xml'])));
138
139 %% 5) Temp and Ifo data
140
141 % read ao
142 ifo_rw = ao('ifo_temp_example/ifo_training.dat');
143 ifo_rw.setYunits('rad');
144 T_rw = ao('ifo_temp_example/temp_training.dat');
145 T_rw.setYunits('degC');
146
147 %%
148
149 % Consolidate data
150 [ifo_c,T_c] = consolidate(ifo_rw,T_rw,plist('fs',1));
151 ifo_c.save(plist('filename',sprintf([data_path 'ifo_Ex06.mat'])));
152 ifo_c.save(plist('filename',sprintf([data_path 'ifo_Ex06.xml'])));
153 T_c.save(plist('filename',sprintf([data_path 'T_Ex06.mat'])));
154 T_c.save(plist('filename',sprintf([data_path 'T_Ex06.xml'])));
155
156 %%
157
158 % do TF
159 % pl2 = plist('Nfft', 2000);
160 % tf = tfe(T_c,ifo_c,pl2);
161 tf = tfe(T_c,ifo_c);
162
163
164
165
166