1 function tign = estimate_tign(ps)
2 %tries to draw a reasonable tign based on locations and times of detections
3 % inputs - locations nd times of detections, sorted by increasing time
4 % ps = graph_dets(w,0) or ps = cluster_paths(w,0)
7 times = ps.points(:,3);
10 lats = ps.points(:,1);
11 lons = ps.points(:,2);
13 %sort detections by time
14 [st_1,st_2]=sort(times);
21 end_time = max(max(times),ps.red.end_datenum);%+0.01;
22 start_time = min(times);
23 %total_time = ceil(end_time-start_time);
25 tign = end_time*ones(size(ps.red.fxlong));
31 % for i = 1:total_time
32 % pt_set = (times-start_time) < i;
33 % lons_set = [lons_set;lons(pt_set)];
34 % lats_set = [lats_set;lats(pt_set)];
35 % % times_set = [times_set;times(pt_set)];
36 % % lons_set = lons(pt_set);
37 % % lats_set = lats(pt_set);
38 % times_set = times(pt_set);
39 % %figure,scatter3(lons_set,lats_set,times_set)
40 % [in,on] = inpolygon(ps.red.fxlat,ps.red.fxlong,lats_set,lons_set);
41 % temp_tign(in) = max(times_set);
42 % temp_tign(~in) = end_time;
43 % tign = min(tign,temp_tign);
44 % %tign = imgaussfilt(tign,3);
45 % mesh(ps.red.fxlong,ps.red.fxlat,tign)
48 %going by every 5 detections
49 det_steps = max(5,round(length(ps.points)/30));
51 pt_set = times <= times(i);
52 lons_set = [lons_set;lons(pt_set)];
53 lats_set = [lats_set;lats(pt_set)];
54 % times_set = [times_set;times(pt_set)];
55 % lons_set = lons(pt_set);
56 % lats_set = lats(pt_set);
57 times_set = [times_set;times(pt_set)];
58 %figure,scatter3(lons_set,lats_set,times_set)
60 %add new points to polygon set
61 % p = make_poly(lons_set,lats_set,5);
62 % in = inpolygon(ps.red.fxlat,ps.red.fxlong,p(:,2),p(:,1));
65 % k = boundary(lons_set,lats_set,1);
66 % lon_perim = lons_set(k,1);
67 % lat_perim = lats_set(k,1);
68 % in = inpolygon(ps.red.fxlat,ps.red.fxlong,lat_perim,lon_perim);
70 in = inpolygon(ps.red.fxlat,ps.red.fxlong,lats_set,lons_set);
71 in = inpolygon(ps.red.fxlat,ps.red.fxlong,ps.red.fxlat(in),ps.red.fxlong(in));
72 temp_tign(in) = max(times_set);
73 temp_tign(~in) = end_time;
74 tign = min(tign,temp_tign);
75 %tign = imgaussfilt(tign,1/8);
79 %tign = imgaussfilt(tign,1);%-0.25;
80 tign = smooth_up(tign);
81 figure,mesh(ps.red.fxlong,ps.red.fxlat,tign);
83 scatter3(lons,lats,times,'*r')