1 function new_path_struct = extrapolate_path_pt(ps,new_tign,w)
2 %put one point on the end of each path
3 % input ps - path struct from from ps = graph_dets(w,1);
4 % new_tign - analysis from squish(ps,1)
5 % w - w = read_wrfout_tign(f), wrfout struct with fxlong,fxlat, tign
7 %only extrapolate on paths ending within a day of ps.red.end_datenum
9 %when, beyond red.end_datenum to extraploate to
12 %vector for locations where fuel need to be dried
14 for i = 1:length(ps.paths)
17 if (length(p) > 1) && (ps.red.end_datenum - ps.points(end_pt,3) < 0.25)
18 %fprintf('Path length and end time OK \n')
20 %vector from pt_1 to end_pt
21 %calc 3 line equation : r = r_0 + t*v
22 v = ps.points(end_pt,1:3)-ps.points(pt_1,1:3);
23 %check to make sure time difference is OK
25 num_pts = length(ps.points);
27 new_pt_ct = new_pt_ct +1;
28 t_f = ps.red.end_datenum + time_extend;
29 r_0 = ps.points(end_pt,1:3);
30 t = (t_f-r_0(1,3))/v(1,3);
33 ps.paths(i).p(end+1) = new_pt;
34 %new point in list, sam confidence al last point on the path being extended
35 ps.points(new_pt,:) = ps.points(end_pt,:);
36 ps.points(new_pt,1:3) = r;
37 ps.new_points(new_pt,:)=ps.points(new_pt,:);
38 %fix new point on the grid
39 np = [ps.points(new_pt,1),ps.points(new_pt,2)];
41 [new_i,new_j,new_lat,new_lon] = fixpt(ps.red,np);
42 ps.idx(new_pt,1)=uint8(new_i);ps.idx(new_pt,2)=uint8(new_j);
43 ps.grid_pts(new_pt,1)=new_lon;ps.grid_pts(new_pt,2)=new_lat;
44 if ps.points(new_pt,3)-new_tign(new_i,new_j)<1
45 fast_list = [fast_list;new_pt];
49 % or just duplicate last point in path
50 fprintf('weird point outside of domain or something ..\n')
51 ps.idx(new_pt,:)=ps.idx(end_pt,:);
52 ps.grid_pts(new_pt,:) = ps.grid_pts(end_pt,:);
53 ps.points(new_pt,:) = ps.points(end_pt,:);
54 ps.new_points(new_pt,:)=ps.points(end_pt,:);
59 %kluster the data bakfire, head fire
60 cluster = kmeans(ps.grid_pts(fast_list,:),2);
61 c1 = fast_list(cluster == 1);
62 c2 = fast_list(cluster == 2);
65 fprintf('%d new points were added \n',new_pt_ct)
66 % figure(1),mesh(ps.red.fxlong,ps.red.fxlat,new_tign)
67 % time_mask = ps.points(:,3)>ps.red.end_datenum;
68 % figure(1),hold on,scatter3(ps.points(time_mask,2),ps.points(time_mask,1),ps.points(time_mask,3))
69 % loop to sort new points where we can change FMC
70 figure,mesh(ps.red.fxlong,ps.red.fxlat,new_tign)
71 hold on,scatter3(ps.points(c1,2),ps.points(c1,1),ps.points(c1,3),'b*');
72 hold on,scatter3(ps.points(c2,2),ps.points(c2,1),ps.points(c2,3),'r*');
74 ps.fast_list = fast_list;