0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % Test ao/smallvectorfit functionality.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % A Monsky, M Hueller 29-03-10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % $Id: test_smallvectorfit.m,v 1.5 2010/04/01 08:29:21 anneke Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % Parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 datafiles = '2008-07-11_12-26';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 test_data = sprintf('%s/example_file.dat', datafiles);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 fs = 800000.0/24640.0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 %% Load data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % unfiltered Data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 disp('*** Loading phase data....')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 dpl = plist('filename', test_data, 'fs', fs, 'columns', 1, 'yunits', '');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 dpl2 = plist('filename', test_data, 'fs', fs, 'columns', 2, 'yunits', '');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 dpl3 = plist('filename', test_data, 'fs', fs, 'columns', 3, 'yunits', '');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 phir = ao(dpl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 phi1 = ao(dpl2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 phi12 = ao(dpl3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 iplot(phir, phi12)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 %% User input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % starttime = input('enter start time: ');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 % endtime = input('enter end time: ');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 starttime = 40;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 endtime = 50;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 %% Split and filter
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 pl = plist('type', 'lowpass', 'order', 1, 'gain', 1.0, 'fs', fs, 'fc', 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 f = mfir(pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 spl = plist('split_type', 'times', 'times',[starttime endtime]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 phi1_split = split(filter(phi1,f), spl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 phi12_split = split(filter(phi12,f), spl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 phir_split = split(filter(phir,f), spl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 %% Compute psi
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 psi1_split = phi1_split - phir_split;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 psi12_split = phi12_split - phir_split;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 %% XYdata
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 xy_psi1 = ao(plist('xvals', phir_split.data.y, 'yvals', psi1_split.data.y, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 'xunits', phir_split.yunits, 'yunits', psi1_split.yunits)); % This could be replaced by ao/scatterData
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 xy_psi12 = ao(plist('xvals', phir_split.data.y, 'yvals', psi12_split.data.y, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 'xunits', phir_split.yunits, 'yunits', psi1_split.yunits)); % This could be replaced by ao/scatterData
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 %% correct for Doppler effect
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 phir_doppler = dopplercorr(phir_split, plist('bin',50));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 phi1_doppler = dopplercorr(phi1_split, plist('bin',50));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 phi12_doppler = dopplercorr(phi12_split, plist('bin',50));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 %% Psi
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 psi1_doppler = phi1_doppler - phir_doppler;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 psi12_doppler = phi12_doppler - phir_doppler;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 psi12_doppler.data.growT;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 %% XYdata
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 xy_psi1_doppler = ao(plist('xvals', phir_doppler.data.y, 'yvals', psi1_doppler.data.y, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 'xunits', phir_doppler.yunits, 'yunits', psi1_doppler.yunits)); % This could be replaced by ao/scatterData
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 xy_psi12_doppler = ao(plist('xvals', phir_doppler.data.y, 'yvals', psi12_doppler.data.y, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 'xunits', phir_doppler.yunits, 'yunits', psi12_doppler.yunits)); % This could be replaced by ao/scatterData
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 iplot(xy_psi1, xy_psi1_doppler)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 %% Fit
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 [fit_psi1 fit_psi12] = smallvectorfit(phir_doppler, phi1_doppler, psi1_doppler, phi12_doppler, psi12_doppler);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 %% Linear combination
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 [svec_psi1 svec_psi12] = smallvector_lincom(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 phir_doppler, phi1_doppler, psi1_doppler, phi12_doppler, psi12_doppler, fit_psi1, fit_psi12);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 %% create an xy data object from the linear combination
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 xy_klvek_psi1 = scatterData(phir_doppler,svec_psi1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 xy_klvek_psi12 = scatterData(phir_doppler,svec_psi12);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 %% Plot data and fit together
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 iplot(xy_psi1_doppler, xy_klvek_psi1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 iplot(xy_psi12_doppler, xy_klvek_psi12)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 %% read out small vector coefficiients
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 fit_klvek_psi1 = find(fit_psi1.procinfo,'coef_psi1');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 fit_klvek_psi12 = find(fit_psi12.procinfo,'coef_psi12');
|