Merge branch 'fixf'
[wrf-fire-matlab.git] / detect_ignition / new_likelihood / test_script.m
blob41d37bf6a9e545b2a7660240147bd445f4b04be1
1 % testing whether the new likelihood works to find ignition point\r
2 \r
3 domain_size = 1000;\r
4 \r
5 %set up true values\r
6 ignition_time = 300;\r
7 ignition_x = 500;\r
8 ignition_y = 500;\r
9 true_tign = make_times(ignition_x,ignition_y,ignition_time,domain_size);\r
10 t_now = 700;\r
11 %mesh(true_tign);\r
13 %make fire mask\r
14 mask = zeros(domain_size,domain_size);\r
15 centers = [187 751;128 653;106 539;639 126;842 301;783 219];\r
16 [m n] = size(centers);\r
17 pixel_size = 1;\r
18 for ic = 1:m\r
19     for ii = centers(ic,1)-pixel_size:centers(ic,1)+pixel_size\r
20         for jj = centers(ic,2)-pixel_size:centers(ic,2)+pixel_size\r
21             mask(ii,jj) = 1;\r
22         end\r
23     end\r
24 end\r
26 close all\r
27 hold on\r
28 contour(mask)\r
29 contour(true_tign)\r
31 % set up "simlulation grid"\r
32 dx = 100; x_steps = 9;\r
33 dy = 100; y_steps = 9;\r
34 dt = 100; time_steps = 3;\r
36 data = [];\r
37 counter = 0;\r
39 data_spec = 'data_%d_%d_%d';\r
40 file_spec = 'data_%d_%d_%d.mat';\r
41 save_spec = 'C:\cygwin64\home\paulc\wrf-fire\other\Matlab\detect_ignition\new_likelihood\data\data_%d_%d_%d.mat';\r
43 load files.mat\r
44 %files = [];\r
45 \r
46 % %create and save data for "simulations"\r
47 % for ig_time = 0:time_steps\r
48 %     ignition_time = ig_time*dt+100;\r
49 %     for ig_x = 1:x_steps\r
50 %         ignition_x = ig_x*dx;\r
51 %         for ig_y = 1:y_steps\r
52 %             ignition_y = ig_y*dy;\r
53 %             counter = counter + 1;\r
54 %             \r
55 %             tign = make_times(ignition_x,ignition_y,ignition_time,domain_size);\r
56 %             data.tign = tign;\r
57 %             name = sprintf(data_spec,ignition_time,ignition_x,ignition_y);\r
58 %             data.name = name;\r
59 %             file = sprintf(file_spec,ignition_time,ignition_x,ignition_y);\r
60 %             files{counter} = file;\r
61 %             %save_str = sprintf(save_spec,ignition_time,ignition_x,ignition_y);\r
62 %             \r
63 %             \r
64 %             \r
65 %             %saving the data\r
66 %             cd('data')\r
67 %             save(file,'data')\r
68 %             cd('../')\r
69 %             \r
70 %             \r
71 %             %close all\r
72 %             %mesh(tign)\r
73 %             \r
74 %             \r
75 %         end\r
76 %     end\r
77 % end\r
79 %compute likelihoods\r
81 %get weights first\r
82 radius = 10;\r
83 weight = gauss_weight(radius);\r
85 %loop to compute\r
86 [mm nn] = size(files);\r
87 like_list = zeros(nn,1);\r
88 for i=1:nn\r
89     cd('data')\r
90     clear('tign')\r
91     load(files{i})\r
92     cd('../')\r
93     \r
94     i\r
95     heat = make_heats(data.tign,t_now);\r
96     like = compute_likelihood(heat,mask,radius,weight)\r
98     like_list(i) = like;\r
99     %contour(heat);\r
100     \r
101     \r
102     \r
103 end\r
105 hold off\r
106 % figure\r
107 % contour(reshape(like_list(1:81,1),[9 9]))\r
108 % figure\r
109 % contour(reshape(like_list(82:2*81,1),[9 9]))\r
110 % figure\r
111 % contour(reshape(like_list(163:3*81,1),[9 9]))\r
113 g_points = x_steps*y_steps;\r
114 for figs =1:time_steps+1\r
115     figure\r
116     contour(reshape(like_list((figs-1)*g_points+1:figs*g_points,1),[x_steps y_steps]))\r
117 end\r
119 for figs =1:time_steps+1\r
120     figure\r
121     mesh(reshape(like_list((figs-1)*g_points+1:figs*g_points,1),[x_steps y_steps]))\r
122 end\r
125     \r