-
Notifications
You must be signed in to change notification settings - Fork 48
/
merger.py
149 lines (104 loc) · 2.62 KB
/
merger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import argos.io as io
import math
import argos.plot as tplot
import argos.util as util
import argos.noise as reduc
import argos.cluster as cluster
from argos.tool.stopwatch import Stopwatch
id = 0
id_list = []
traj_list = []
for i in range(7):
filename = "%s.traj" % i
traj_dict = io.load(filename)
reduc.shorten(traj_dict)
reduc.remove_noise(traj_dict)
for key in traj_dict:
id_list.append( (id, key))
id += 1
path = traj_dict[key]["path"]
traj_list.append(path)
io.save(traj_list, "%s_traj.dt" % i)
reduc.segmentation_list(traj_list)
io.save(traj_list, "%s_traj_seg.dt" % i)
traj_list = []
io.save(id_list, "id_list.dt")
exit(0)
s = Stopwatch()
n = 100
traj_dict = io.load("1.traj")
util.summary_traj_dict(traj_dict)
reduc.shorten(traj_dict)
util.summary_traj_dict(traj_dict)
reduc.remove_noise(traj_dict)
util.summary_traj_dict(traj_dict)
reduc.remove_noise(traj_dict)
reduc.shorten(traj_dict)
util.summary_traj_dict(traj_dict)
traj_list = util.traj_dict_to_traj_list(traj_dict)
util.summary_traj_list(traj_list)
s.start()
D1 = cluster.calculate_distance_matrix(traj_list[:n], 80000)
s.stop()
reduc.segmentation_list(traj_list)
util.summary_traj_list(traj_list)
traj_list = traj_list[:n]
s.start()
D2 = cluster.calculate_distance_matrix(traj_list, 80000)
s.stop()
sum = 0
diff_count = 0
for i in range(n):
for j in range(i, n):
diff = abs( D1[i,j] - D2[i, j])
sum += diff
if diff > 1000:
diff_count += 1
print(diff_count)
print(sum)
exit(0)
countFlied = 0
countFlied2 = 0
traj_list = []
suspi = None
for key in traj_dict.keys():
path = traj_dict[key]["path"]
count = 0
flied = False
start = path[0]
end = path[len(path) - 1]
if abs(start[0] - end[0]) > 30000 or abs(start[1] - end[1]) > 30000:
countFlied2 += 1
for point in path:
if point[2] < 1 and point[5] < 1:
count += 1
if not flied and point[5] > 5:
flied = True
countFlied += 1
if not flied:
suspi = path
traj_list.append(path)
print(countFlied)
print(countFlied2)
'''
for traj in traj_list:
tplot.plot_traj(traj)
'''
print(suspi)
tplot.plot_traj(suspi)
tplot.plot_map()
exit(0)
filename1 = "3.traj"
filename2 = "6.traj"
d1 = io.load(filename1)
d2 = io.load(filename2)
key1 = set(d1.keys())
key2 = set(d2.keys())
common = key1.intersection(key2)
print(len(common))
for key in common:
d1[key]["path"] = d1[key]["path"] + d2[key]["path"]
d1[key]["count"] = d1[key]["count"] + d2[key]["count"]
d2.pop(key)
io.save(d1, filename1)
io.save(d2, filename2)