1 function [t,n_diff] = make_tign(ps,alpha,p_param,grid_fraction)
2 %create palusible fire arrival time from detections
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);
10 %%% move to smaller grid
11 [m,n] = size(ps1.red.fxlong);
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);
28 an = estimate_tign(ps1);
29 %put new estimate in ps1.red
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);
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')
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);
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)