Merge branch 'fixf'
[wrf-fire-matlab.git] / detect_ignition / new_likelihood / test2.m
blobd25224312ffda330e1bd26dc31c8dfd61b0e3905
1 % second test script looking for tails???\r
2 \r
3 \r
4 domain_size = 1000;\r
5 \r
6 \r
7 \r
8 %create fire mask\r
9 mask = zeros(domain_size,domain_size);\r
10 strip = ones(domain_size,1);\r
11 mask(:,round(domain_size/2)) = strip;\r
13 %make heat map\r
14 heat = zeros(domain_size,domain_size);\r
15 heat_strip = zeros(1,domain_size);\r
16 a = 0.01;\r
17 fire_start = 300;\r
18 for i = fire_start:domain_size\r
19     heat_strip(1,i) = exp(-(i-fire_start)*a);\r
20 end\r
21 for i = 1:domain_size\r
22     heat(i,:) = heat_strip;\r
23 end\r
24 figure, plot(heat(50,:)), title('Heat fraction')\r
25 %make probability matrix\r
26 detection_probs = zeros(domain_size,domain_size);\r
28 for i = 1:domain_size\r
29     for j = 1:domain_size\r
30         detection_probs(i,j) = detection_probability(heat(i,j));\r
31     end\r
32 end\r
33 figure,plot(detection_probs(round(domain_size/2),:)),title('Detection probability')\r
35     \r
38 %set up of likelihood stuff\r
39 like = [];\r
40 radius = 30;\r
41 weight = gauss_weight(radius);\r
44 %loop to make likelihoods\r
45 counter = 1;\r
46 for i=radius+1:domain_size-radius\r
47     \r
48 %     counter\r
49     l =  compute_pixel_probability(round(domain_size/2),i,heat,radius, weight, detection_probs );\r
50     like(counter) = log(l);\r
51     counter = counter +1;\r
52 end\r
54 figure,plot(like)\r
57     \r
58 % testing region\r
59 % x = 1:domain_size;\r
60 % center = fire_start*ones(1,domain_size);\r
61 % g = @(x,x_0,sig) exp(-(x-x_0).^2/2/sig^2);\r
62 \r
63 % sig = 16;\r
64 % y = g(x,center,sig);\r
65 % figure,plot(y),title('gaussian');\r
66 % yg = log(y(1,1:940));\r
67 % log_prob = log(detection_probs(round(domain_size/2),1:940));\r
68 % liker = yg+log_prob;\r
69 \r
70 % figure,plot(yp),title('prob');\r
71 % figure,plot(liker),title('like')\r