1 function a = analyze_paths(ps,new_tign)
2 %looks at the paths in a path struct and figures out some basic statistics
3 % input ps - struct, from ps = cluster_paths(w,1);
4 % new_tign - analysis from squish4(ps)
6 %vector for speeds between points in the paths new_tign
8 %vector for speeds between pts in tigndist = ps.raw_dist(p2,p1);
11 %figure(117),contour(ps.red.fxlong,ps.red.fxlat,ps.red.tign);
13 %loop through the paths, collect ROS info from each path segment
14 %extrapolate one poin on the end of each path
15 for i = 1:length(ps.paths)
17 %fprintf('Path %d, %d points in path \n',i,length(p))
18 %find speed between points in the paths
24 speeds_count = speeds_count + 1;
25 %point pair in path segment
28 path_points(speeds_count,1:2)=[p1,p2];
29 p_speeds(speeds_count) = ps.speeds(p2,p1)/(24*3600);
30 p_fuel_1(speeds_count) = ps.red.nfuel_cat(ps.idx(p1,1),ps.idx(p1,2));
31 p_fuel_2(speeds_count) = ps.red.nfuel_cat(ps.idx(p2,1),ps.idx(p2,2));
32 %plot path on countour
33 %plot(ps.points(p,2),ps.points(p,1),'r','LineWidth',0.5);
34 % find these locations on the grid
36 % t_p1 = ps.red.tign(ps.idx(p1,1),ps.idx(p1,2));
37 % t_p2 = ps.red.tign(ps.idx(p2,1),ps.idx(p2,2));
38 % time at L2 data recording
39 t_p1 = ps.points(j-1,3);
40 t_p2 = ps.points(j,3);
41 % time at the analysis
42 %t_p1 = new_tign(ps.idx(p1,1),ps.idx(p1,2));
43 %t_p2 = new_tign(ps.idx(p2,1),ps.idx(p2,2));
45 dist = ps.raw_dist(p2,p1);
46 %reall, this is the p_speeds
47 t_speeds(speeds_count)= (dist/dt)/(24*3600);
49 e_p1 = ps.red.fhgt(ps.idx(p1,1),ps.idx(p1,2));
50 e_p2 = ps.red.fhgt(ps.idx(p2,1),ps.idx(p2,2));
51 slopes(speeds_count) = (e_p2-e_p1)/dist;
54 %scatter(ps.points(p(end),2),ps.points(p(end),1),'*r')
58 a.path_points = path_points;
59 a.p_speeds = p_speeds';
60 a.t_speeds = t_speeds';
61 a.p_fuel_1 = p_fuel_1';
62 a.p_fuel_2 = p_fuel_2';
63 a.matrix(:,1)=p_speeds';
64 a.matrix(:,2)=p_fuel_1';
65 a.matrix(:,3)=p_fuel_2';
68 %%%%%% wtf happened %%%%
69 %% (figure(117),contour(ps.red.fxlong,ps.red.fxlat,ps.red.tign);;
72 %number by which to multiply standard deviation
75 unq = unique([a.matrix,a.path_points],'rows');
76 common_fuel1 = mode(unq(:,2));
77 common_fuel2 = mode(unq(:,3));
78 fuel_mask = unq(:,2:3) == common_fuel2;
79 avg_speed_common_fuel = mean([p_speeds(fuel_mask(:,1)),p_speeds(fuel_mask(:,2))]);
80 figure,histogram([p_speeds(fuel_mask(:,1)),p_speeds(fuel_mask(:,2))]),title('Histogram ROS in common fuel')
81 %std deviation of ROS in the common fuel type
82 std_speed_common_fuel = std([p_speeds(fuel_mask(:,1)),p_speeds(fuel_mask(:,2))]);
83 fast_common_fuel = avg_speed_common_fuel+std_mult*std_speed_common_fuel;
84 fast_mask = unq(:,1)>fast_common_fuel;
85 %locations where the most common fuel is and ROS is one standard deviation
87 fast_fuel_mask = logical([fast_mask.*fuel_mask(:,1),fast_mask.*fuel_mask(:,2)]);
88 %plot the location of the fast fuel
89 %figure(21),contourf(ps.red.fxlong,ps.red.fxlat,ps.red.tign,'--k');
90 figure(21),mesh(ps.red.fxlong,ps.red.fxlat,new_tign);
92 title('Locations of high ROS in common fuel')
94 point_speeds = unq(:,1);
96 if unq(i,1) > fast_common_fuel
97 fast_count = fast_count+1;
99 %scatter(ps.points(unq(i,5),2),ps.points(unq(i,5),1),'*r')
102 scatter3(ps.points(unq(i,4),2),ps.points(unq(i,4),1),new_tign(ps.idx(idx_1,1),ps.idx(idx_1,2)),'*r')
103 scatter3(ps.points(unq(i,5),2),ps.points(unq(i,5),1),new_tign(ps.idx(idx_2,1),ps.idx(idx_2,2)),'*r')