comments to describe arguments
[wrf-fire-matlab.git] / cycling / make_tign.m
blob8e43e4985ca37c1b68939627690c877f4afa2962
1 function [t,n_diff] = make_tign(ps,alpha,p_param,grid_fraction)
2 %create palusible fire arrival time from detections
3 %inputs - 
4 %    ps = cluster_paths(w,1,grid_size)
5 %    alpha - blending between initial estimate and estimate made using paths
6 %    p_param - parameter of smoothing spline
7 %    grid_fraction - shrink factor fore grid size
8 ps1 = interp_paths(ps,p_param);
9 %ps1 = ps;
10 %%% move to smaller grid
11 [m,n] = size(ps1.red.fxlong);
12 %grid_fraction = 0.25
13 ys = round(grid_fraction*m);
14 xs = round(grid_fraction*n);
15 ps1.red = subset_small(ps1.red,ys,xs);
16 new_points = fixpoints2grid(ps1.red,[ps1.points(:,1), ps1.points(:,2)]);
17 ps1.idx = new_points(:,1:2);
18 ps1.grid_pts = new_points(:,3:4);
22 % if ~exist('an_base.mat','file')
23 %     an = estimate_tign(ps1);
24 %     save an_base.mat an
25 % else
26 %     load an_base.mat
27 % end
28 an = estimate_tign(ps1);
29 %put new estimate in ps1.red
30 ps1.red.tign = an;
31 t = squish4(ps1,1,0);
33 %alpha = 0.4;
34 t = alpha*t+(1-alpha)*an;
35 %t = smooth_up(t,a,b);
36 %t = imgaussfilt(an,1);
37 figure,mesh(ps1.red.fxlong,ps1.red.fxlat,t);
38 %title('Squish4')
39 hold on
40 scatter3(ps.points(:,2),ps.points(:,1),ps.points(:,3),'*r');
41 title('Tign from polygons and paths')
42 xlabel('Lon'),ylabel('Lat'),zlabel('Datenum')
44 %resize estimate
45 if size(t) ~= size(ps.red.fxlong)
46     F = scatteredInterpolant(ps1.red.fxlong(:),ps1.red.fxlat(:),t(:));
47     t = F(ps.red.fxlong,ps.red.fxlat);
48 end
49 %fix the ripple on the top
50 r_mask = t >=max(t(:))-0.05;
51 t(r_mask) = max(t(:));
53 %compute norms of difference
54 n_diff = norm(ps.red.tign-t)/norm(ps.red.tign-min(ps.red.tign(:)));
55 fprintf('relative error: %f percent\n',100*n_diff)
57 end %function