ggplot
[wrf-fire-matlab.git] / detection / detection_log_likelihood.m
blobea394b93a36562cade4e0b55fb94d62aac1f2ab0
1 function J=detection_log_likelihood(prefix,w)
2 % loglike=detection_data_log_likelihood(prefix,w)
3 % in
4 %    prefix to search for files, such as 'TIFs/'
5 %    w      file with extracted wrfout data, see detect_fit_level2
6
7 % out
8 %    J      log likelhood
10 % figures switch
11 fig.fig_state=1;
12 fig.fig_map=0;
13 fig.fig_3d=0;
14 fig.fig_interp=0;
16 disp('Subset simulation domain and convert time')
19 red=subset_domain(w);
20 %load red.mat;
21 red.tign_g = w.tign_g;
24 disp('Loading and subsetting detections')
26 p=sort_rsac_files(prefix); 
27 time_bounds=subset_detection_time(red,p);
28 red.time_bounds=time_bounds;
29 g = load_subset_detections(prefix,p,red,time_bounds,fig);
31 %bypass the above line and load computed g
32 %load g.mat
34 % Parameters of the objective function
35 % params.alpha=input_num('penalty coefficient alpha',1/1000);
36 % TC = W/(900*24); % time constant = fuel gone in one hour
37 params.alpha=0;
38 params.TC = 1/24;  % detection time constants in hours
40 %edit the next three lines to remove use input
41 %params.stretch=input_num('Tmin,Tmax,Tneg,Tpos',[0.5,10,5,10]);
42 %params.weight=input_num('water,land,low,nominal,high confidence fire',...
43 %    [-10,-10,0.2,0.6,1]);
44 %params.power=input_num('correction smoothness',1.02);
45 params.stretch=[0.5,10,5,10];
46 params.weight= [-10,-10,0.2,0.6,1];
47 params.power=1.02;
49 params.doplot=0;
50 params.dx=444;
51 params.dy=444;
54 % objective function is penalty minus log likelihood -> min
55 J=-detection_objective(red.tign,0,g,params,red);
56 % new likelihood stand-in
57 J = new_objective(w,red,g);
59 s=sprintf('Data log likelihood %18.11e',J);
60 plot_state(fig.fig_state,red,s,red.tign,g,time_bounds(1:2));
62 end