comparison m-toolbox/test/test_collection_linlsq.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 % test for ao/linlsq
2 %
3 % 17-11-2009 L Ferraioli
4 % CREATION
5 %
6 %
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8 % $Id: mdc3_exp3_loop_v3.m,v 1.2 2009/09/24 09:48:12 luigi Exp $
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10
11
12 %% Loading data
13
14 fprintf('===== loading data... =====\n')
15
16 % laod parnames and values
17 load C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Models\parnames_10perc.mat
18 load C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Models\exp3_2_10perc_nomvalues.mat
19 load C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Models\exp3_2_10perc_truevalues.mat
20 % load C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Models\usedparams_10perc.mat
21
22
23 % set ordered used parameters
24 usedparams = {'dH','dsH','dS11','dS1D','dSD1','dSDD',...
25 'dh2','dsh2','dx1','dx2'};
26
27 [nonfitparnms,ia,ib] = setxor(parnames,usedparams);
28 nonfitparvals = exp3_nomvalues(ia);
29
30 %% get non-linear response model
31 % the model is non-linear in the parameter dependence
32 fprintf('===== Get TF Model... =====\n')
33
34 H = matrix(plist('built-in','mdc3_ifo2ifo_v2'));
35
36 %% load input signal
37 % those are the same of exp 1
38
39 fprintf('===== Loading input signals... =====\n')
40
41 oi1 = ao('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\signals_noise\exp1_1_oi1.mat');
42 oi1.setName;
43 oi1.setYunits('m');
44 oid = ao('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\signals_noise\exp1_2_oid.mat');
45 oid.setName;
46 oid.setYunits('m');
47
48 %% get signals - true values
49
50 fprintf('===== get true values... =====\n')
51
52 % get response with true params
53 for ii = 1:numel(H.objs)
54 H.objs(ii).setParams(parnames,exp3_truevalues);
55 end
56
57 plfft = plist('Npad',[]);
58
59 s11 = fftfilt(oi1,H.objs(1,1),plfft);
60 s12 = fftfilt(oid,H.objs(1,2),plfft);
61 s21 = fftfilt(oi1,H.objs(2,1),plfft);
62 s22 = fftfilt(oid,H.objs(2,2),plfft);
63
64 % get signals for exp 3.1
65 s1_exp_3_1 = s11;
66 s1_exp_3_1.setName;
67 sd_exp_3_1 = s21;
68 sd_exp_3_1.setName;
69
70 % get signals for exp 3.2
71 s1_exp_3_2 = s12;
72 s1_exp_3_2.setName;
73 sd_exp_3_2 = s22;
74 sd_exp_3_2.setName;
75
76 %% load Coloring filters
77
78 fprintf('===== loading coloring filters... =====\n')
79
80 cf11 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_CF11.mat');
81 cf11.setName;
82 cf12 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_CF12.mat');
83 cf12.setName;
84 cf21 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_CF21.mat');
85 cf21.setName;
86 cf22 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_CF22.mat');
87 cf22.setName;
88
89 %% load Whitening filters
90
91 fprintf('===== loading whitening filters... =====\n')
92
93 wf11 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_WF11.mat');
94 wf11.setName;
95 wf12 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_WF12.mat');
96 wf12.setName;
97 wf21 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_WF21.mat');
98 wf21.setName;
99 wf22 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_WF22.mat');
100 wf22.setName;
101
102 %% Adding noise to signals
103
104 fprintf('===== adding noise to signals... =====\n')
105
106 % get params
107 Nsecs = s1_exp_3_1.nsecs;
108 fs = s1_exp_3_1.fs;
109 plcf = plist('bank','parallel');
110
111 % starting noise generation exp1.1
112 a1_exp_3_1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs));
113 a2_exp_3_1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs));
114
115 % coloring noise exp 1.1
116 na1_exp_3_1 = filter(a1_exp_3_1,cf11,plcf) + filter(a2_exp_3_1,cf12,plcf);
117 na2_exp_3_1 = filter(a1_exp_3_1,cf21,plcf) + filter(a2_exp_3_1,cf22,plcf);
118
119 % starting noise generation exp 1.2
120 a1_exp_3_2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs));
121 a2_exp_3_2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs));
122
123 % coloring noise exp 1.2
124 na1_exp_3_2 = filter(a1_exp_3_2,cf11,plcf) + filter(a2_exp_3_2,cf12,plcf);
125 na2_exp_3_2 = filter(a1_exp_3_2,cf21,plcf) + filter(a2_exp_3_2,cf22,plcf);
126
127 % adding noise to signals
128 o1_exp_3_1 = s1_exp_3_1 + na1_exp_3_1;
129 od_exp_3_1 = sd_exp_3_1 + na2_exp_3_1;
130
131 o1_exp_3_2 = s1_exp_3_2 + na1_exp_3_2;
132 od_exp_3_2 = sd_exp_3_2 + na2_exp_3_2;
133
134 % %%
135 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136 % %%%%% Test on one dimensional data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 %
139 % %% Build input collection
140 %
141 % H11 = H.objs(1,1);
142 % H11.setParams(parnames,exp3_nomvalues);
143 % % subs for non fit parameters
144 % H11.subs(plist('Params', nonfitparnms, 'Values',nonfitparvals));
145 % % linearize
146 % dH11 = linearize(H11);
147 %
148 % H22 = H.objs(2,2);
149 % H22.setParams(parnames,exp3_nomvalues);
150 % % subs for non fit parameters
151 % H22.subs(plist('Params', nonfitparnms, 'Values',nonfitparvals));
152 % % linearize
153 % dH22 = linearize(H22);
154 %
155 % %%
156 % iC1 = collection(o1_exp_3_1,s1_exp_3_1,H11,dH11,wf11);
157 % iC2 = collection(od_exp_3_1,sd_exp_3_1,H22,dH22,wf22);
158 %
159 % oC = linlsq(iC1,iC2,plist('Nloops',3));
160
161 %%
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 %%%%% Test on two dimensional data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165
166 %% Build input collection
167
168 % empty ao
169 eao = ao();
170
171 % subs for non fit parameters
172 for ii=1:numel(H.objs)
173 H.objs(ii).setParams(parnames,exp3_nomvalues);
174 % subs for non fit parameters
175 H.objs(ii).subs(plist('Params', nonfitparnms, 'Values',nonfitparvals));
176 end
177 % linearize
178 dH = linearize(H);
179
180 % whitening filter
181 wf11b = filterbank(plist('filters',wf11,'type','parallel'));
182 wf11b.setName('wf11');
183 wf12b = filterbank(plist('filters',wf12,'type','parallel'));
184 wf12b.setName('wf12');
185 wf21b = filterbank(plist('filters',wf21,'type','parallel'));
186 wf21b.setName('wf21');
187 wf22b = filterbank(plist('filters',wf22,'type','parallel'));
188 wf22b.setName('wf22');
189
190 WF = matrix(wf11b,wf21b,wf12b,wf22b,plist('shape',[2 2]));
191
192 % exp_3_1
193 os1 = matrix(o1_exp_3_1,od_exp_3_1,plist('shape',[2 1]));
194 is1 = matrix(oi1,eao,plist('shape',[2 1]));
195
196 % exp_3_2
197 os2 = matrix(o1_exp_3_2,od_exp_3_2,plist('shape',[2 1]));
198 is2 = matrix(eao,oid,plist('shape',[2 1]));
199
200 iC1 = collection(os1,is1,H,dH,WF);
201 iC2 = collection(os2,is2,H,dH,WF);
202
203 %% add on ground experiments
204
205 dS11 = ao(cdata(0));
206 dS11.setName;
207 dS11.setDy(1e-4);
208
209 dS1D = ao(cdata(0));
210 dS1D.setName;
211 dS1D.setDy(1e-3);
212
213 dSDD = ao(cdata(0));
214 dSDD.setName;
215 dSDD.setDy(1e-3);
216
217 %% do fit
218
219 oC = linlsq(iC1,iC2,dS11,dS1D,dSDD,plist('Nloops',1,'Npad',[]));