comparison m-toolbox/test/test_ao_gapfilling.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 % A test script for the gapfilling method
2 %
3 % J Sanjuan 28-01-08
4 %
5 % $Id: test_ao_gapfilling.m,v 1.3 2009/02/02 15:20:38 hewitson Exp $
6 %
7 function test_ao_gapfilling()
8
9 % Make test AOs
10 % stationary data
11 nsecs = 1e4;
12 fs = 1;
13
14 pl = plist();
15 pl.append('nsecs', nsecs);
16 pl.append('fs', fs);
17 pl.append('tsfcn', 'randn(size(t))');
18
19 a1 = ao(pl);
20 a1.setName('a1');
21 %a1.setX(1:1e4);
22
23 %a1x = ao(pl);
24 %a1x.setName('a1x');
25 %a1x.setX(1e4+1:2e4);
26
27 % non-stationary data
28 pl = plist();
29 pl.append('nsecs', nsecs);
30 pl.append('fs', fs);
31 pl.append('tsfcn', '0.001*t+randn(size(t))');
32
33 a2 = ao(pl);
34 a2.setName('a2');
35
36 % non-stationary data (ii)
37 pl = plist();
38 pl.append('nsecs', nsecs);
39 pl.append('fs', fs);
40 pl.append('tsfcn', 'exp(t/2.5e3)+randn(size(t))');
41
42 a3 = ao(pl);
43 a3.setName('a3');
44
45 % Split by time the previous data
46
47 pl = plist('split_type', 'times', 'times', [0.0 6000.0 6000.0 8999 8999 1e4]);
48
49 ao_new = split(a1, pl);
50
51 %times = [0 6000 6000 8999 8999 1e4];
52
53 %pl = plist('times', times);
54
55 b = split(a1, pl);
56
57 Ta_stat = b(1);
58 Ta_stat.setX(1:6000);
59
60 Tc_stat = b(3);
61 Tc_stat.setX(9000:1e4);
62
63 clear b
64
65 b = split(a2, pl);
66
67 Ta_nonstat = b(1);
68 Ta_nonstat.setX(1:6000);
69
70 Tc_nonstat = b(3);
71 Tc_nonstat.setX(9000:1e4);
72
73 clear b
74
75 b = split(a3, pl);
76
77 Tx = b(1);
78 Tx.setX(1:6000);
79
80 Ty = b(3);
81 Ty.setX(9000:1e4);
82
83 % Use gapfilling
84 % parameters list
85 pl = plist('method', 'spline');
86 pl = plist('addnoise', 'yes');
87
88 % stationary data, a1
89 a1_refilled = gapfilling(Ta_stat, Tc_stat) % default parmeters
90 a1_refilled_spline = gapfilling(Ta_stat, Tc_stat, pl); % using pl
91
92 % non-stationary data, a2
93 a2_refilled = gapfilling(Ta_nonstat, Tc_nonstat) % default parmeters
94 a2_refilled_spline = gapfilling(Ta_nonstat, Tc_nonstat, pl); % using pl
95
96 % non-stationary data, a3
97 a3_refilled = gapfilling(Tx, Ty) % default parmeters
98 a3_refilled_spline = gapfilling(Tx, Ty, pl); % using pl
99
100 % Plotting
101 iplot(a1, a1_refilled, a1_refilled_spline);
102 iplot(a2, a2_refilled, a2_refilled_spline);
103 iplot(a3_refilled, a3_refilled_spline);
104
105 % plot history for a1
106 plot(a1_refilled.hist)
107
108 % Reproduce from history
109 a_out = rebuild(a1_refilled);
110 a_out2 = rebuild(a2_refilled);
111
112 iplot(a_out);
113
114 end