|
60 | 60 | "cell_type": "code",
|
61 | 61 | "execution_count": null,
|
62 | 62 | "metadata": {},
|
63 |
| - "outputs": [ |
64 |
| - { |
65 |
| - "name": "stderr", |
66 |
| - "output_type": "stream", |
67 |
| - "text": [ |
68 |
| - "C:\\Users\\yirujiao\\AppData\\Local\\Temp\\ipykernel_20432\\1250361022.py:2: DtypeWarning: Columns (4,5,6,10,11,12,47,54) have mixed types. Specify dtype option on import or set low_memory=False.\n", |
69 |
| - " events = pd.read_csv(path_raw + 'FileToUse/InsightTables/Event_Table.csv').set_index('eventID')\n" |
70 |
| - ] |
71 |
| - }, |
72 |
| - { |
73 |
| - "data": { |
74 |
| - "text/html": [ |
75 |
| - "<div>\n", |
76 |
| - "<style scoped>\n", |
77 |
| - " .dataframe tbody tr th:only-of-type {\n", |
78 |
| - " vertical-align: middle;\n", |
79 |
| - " }\n", |
80 |
| - "\n", |
81 |
| - " .dataframe tbody tr th {\n", |
82 |
| - " vertical-align: top;\n", |
83 |
| - " }\n", |
84 |
| - "\n", |
85 |
| - " .dataframe thead th {\n", |
86 |
| - " text-align: right;\n", |
87 |
| - " }\n", |
88 |
| - "</style>\n", |
89 |
| - "<table border=\"1\" class=\"dataframe\">\n", |
90 |
| - " <thead>\n", |
91 |
| - " <tr style=\"text-align: right;\">\n", |
92 |
| - " <th></th>\n", |
93 |
| - " <th>Sub category</th>\n", |
94 |
| - " <th>Originally recorded</th>\n", |
95 |
| - " <th>Subject reconstructed</th>\n", |
96 |
| - " <th>Both subject and object reconstructed</th>\n", |
97 |
| - " </tr>\n", |
98 |
| - " <tr>\n", |
99 |
| - " <th>Event category</th>\n", |
100 |
| - " <th></th>\n", |
101 |
| - " <th></th>\n", |
102 |
| - " <th></th>\n", |
103 |
| - " <th></th>\n", |
104 |
| - " </tr>\n", |
105 |
| - " </thead>\n", |
106 |
| - " <tbody>\n", |
107 |
| - " <tr>\n", |
108 |
| - " <th>Safe interactions</th>\n", |
109 |
| - " <td>SafeBaseline</td>\n", |
110 |
| - " <td>32509</td>\n", |
111 |
| - " <td>10919</td>\n", |
112 |
| - " <td>3893</td>\n", |
113 |
| - " </tr>\n", |
114 |
| - " <tr>\n", |
115 |
| - " <th>Near-crashes</th>\n", |
116 |
| - " <td>NearCrash</td>\n", |
117 |
| - " <td>6160</td>\n", |
118 |
| - " <td>5582</td>\n", |
119 |
| - " <td>4648</td>\n", |
120 |
| - " </tr>\n", |
121 |
| - " <tr>\n", |
122 |
| - " <th>Near-crashes</th>\n", |
123 |
| - " <td>NearCrash-NearCrash</td>\n", |
124 |
| - " <td>512</td>\n", |
125 |
| - " <td>463</td>\n", |
126 |
| - " <td>391</td>\n", |
127 |
| - " </tr>\n", |
128 |
| - " <tr>\n", |
129 |
| - " <th>Near-crashes</th>\n", |
130 |
| - " <td>SecondaryNearCrash</td>\n", |
131 |
| - " <td>123</td>\n", |
132 |
| - " <td>111</td>\n", |
133 |
| - " <td>99</td>\n", |
134 |
| - " </tr>\n", |
135 |
| - " <tr>\n", |
136 |
| - " <th>Near-crashes</th>\n", |
137 |
| - " <td>NearCrash-CrashRelevant</td>\n", |
138 |
| - " <td>112</td>\n", |
139 |
| - " <td>106</td>\n", |
140 |
| - " <td>88</td>\n", |
141 |
| - " </tr>\n", |
142 |
| - " <tr>\n", |
143 |
| - " <th>Near-crashes</th>\n", |
144 |
| - " <td>CrashRelevant-NearCrash</td>\n", |
145 |
| - " <td>31</td>\n", |
146 |
| - " <td>28</td>\n", |
147 |
| - " <td>25</td>\n", |
148 |
| - " </tr>\n", |
149 |
| - " <tr>\n", |
150 |
| - " <th>Near-crashes</th>\n", |
151 |
| - " <td>NearCrash-OtherConflict</td>\n", |
152 |
| - " <td>15</td>\n", |
153 |
| - " <td>14</td>\n", |
154 |
| - " <td>11</td>\n", |
155 |
| - " </tr>\n", |
156 |
| - " <tr>\n", |
157 |
| - " <th>Crashes</th>\n", |
158 |
| - " <td>Crash</td>\n", |
159 |
| - " <td>1726</td>\n", |
160 |
| - " <td>1607</td>\n", |
161 |
| - " <td>1242</td>\n", |
162 |
| - " </tr>\n", |
163 |
| - " <tr>\n", |
164 |
| - " <th>Crashes</th>\n", |
165 |
| - " <td>NearCrash-Crash</td>\n", |
166 |
| - " <td>79</td>\n", |
167 |
| - " <td>74</td>\n", |
168 |
| - " <td>61</td>\n", |
169 |
| - " </tr>\n", |
170 |
| - " <tr>\n", |
171 |
| - " <th>Crashes</th>\n", |
172 |
| - " <td>Crash-NearCrash</td>\n", |
173 |
| - " <td>49</td>\n", |
174 |
| - " <td>43</td>\n", |
175 |
| - " <td>30</td>\n", |
176 |
| - " </tr>\n", |
177 |
| - " <tr>\n", |
178 |
| - " <th>Crashes</th>\n", |
179 |
| - " <td>Crash-Crash</td>\n", |
180 |
| - " <td>46</td>\n", |
181 |
| - " <td>43</td>\n", |
182 |
| - " <td>37</td>\n", |
183 |
| - " </tr>\n", |
184 |
| - " <tr>\n", |
185 |
| - " <th>Crashes</th>\n", |
186 |
| - " <td>SecondaryCrash</td>\n", |
187 |
| - " <td>17</td>\n", |
188 |
| - " <td>16</td>\n", |
189 |
| - " <td>14</td>\n", |
190 |
| - " </tr>\n", |
191 |
| - " <tr>\n", |
192 |
| - " <th>Crashes</th>\n", |
193 |
| - " <td>Crash-OtherConflict</td>\n", |
194 |
| - " <td>11</td>\n", |
195 |
| - " <td>11</td>\n", |
196 |
| - " <td>9</td>\n", |
197 |
| - " </tr>\n", |
198 |
| - " <tr>\n", |
199 |
| - " <th>Crashes</th>\n", |
200 |
| - " <td>CrashRelevant-Crash</td>\n", |
201 |
| - " <td>10</td>\n", |
202 |
| - " <td>9</td>\n", |
203 |
| - " <td>6</td>\n", |
204 |
| - " </tr>\n", |
205 |
| - " <tr>\n", |
206 |
| - " <th>Crashes</th>\n", |
207 |
| - " <td>Crash-CrashRelevant</td>\n", |
208 |
| - " <td>4</td>\n", |
209 |
| - " <td>4</td>\n", |
210 |
| - " <td>3</td>\n", |
211 |
| - " </tr>\n", |
212 |
| - " <tr>\n", |
213 |
| - " <th>Events in total (excluding SafeBaseline)</th>\n", |
214 |
| - " <td>NearCrashNearCrash-NearCrashSecondaryNearCrash...</td>\n", |
215 |
| - " <td>8895</td>\n", |
216 |
| - " <td>8111</td>\n", |
217 |
| - " <td>6664</td>\n", |
218 |
| - " </tr>\n", |
219 |
| - " <tr>\n", |
220 |
| - " <th>Crashes in total</th>\n", |
221 |
| - " <td></td>\n", |
222 |
| - " <td>1942</td>\n", |
223 |
| - " <td>1807</td>\n", |
224 |
| - " <td>1402</td>\n", |
225 |
| - " </tr>\n", |
226 |
| - " <tr>\n", |
227 |
| - " <th>Near-crashes in total</th>\n", |
228 |
| - " <td></td>\n", |
229 |
| - " <td>6953</td>\n", |
230 |
| - " <td>6304</td>\n", |
231 |
| - " <td>5262</td>\n", |
232 |
| - " </tr>\n", |
233 |
| - " </tbody>\n", |
234 |
| - "</table>\n", |
235 |
| - "</div>" |
236 |
| - ], |
237 |
| - "text/plain": [ |
238 |
| - " Sub category \\\n", |
239 |
| - "Event category \n", |
240 |
| - "Safe interactions SafeBaseline \n", |
241 |
| - "Near-crashes NearCrash \n", |
242 |
| - "Near-crashes NearCrash-NearCrash \n", |
243 |
| - "Near-crashes SecondaryNearCrash \n", |
244 |
| - "Near-crashes NearCrash-CrashRelevant \n", |
245 |
| - "Near-crashes CrashRelevant-NearCrash \n", |
246 |
| - "Near-crashes NearCrash-OtherConflict \n", |
247 |
| - "Crashes Crash \n", |
248 |
| - "Crashes NearCrash-Crash \n", |
249 |
| - "Crashes Crash-NearCrash \n", |
250 |
| - "Crashes Crash-Crash \n", |
251 |
| - "Crashes SecondaryCrash \n", |
252 |
| - "Crashes Crash-OtherConflict \n", |
253 |
| - "Crashes CrashRelevant-Crash \n", |
254 |
| - "Crashes Crash-CrashRelevant \n", |
255 |
| - "Events in total (excluding SafeBaseline) NearCrashNearCrash-NearCrashSecondaryNearCrash... \n", |
256 |
| - "Crashes in total \n", |
257 |
| - "Near-crashes in total \n", |
258 |
| - "\n", |
259 |
| - " Originally recorded \\\n", |
260 |
| - "Event category \n", |
261 |
| - "Safe interactions 32509 \n", |
262 |
| - "Near-crashes 6160 \n", |
263 |
| - "Near-crashes 512 \n", |
264 |
| - "Near-crashes 123 \n", |
265 |
| - "Near-crashes 112 \n", |
266 |
| - "Near-crashes 31 \n", |
267 |
| - "Near-crashes 15 \n", |
268 |
| - "Crashes 1726 \n", |
269 |
| - "Crashes 79 \n", |
270 |
| - "Crashes 49 \n", |
271 |
| - "Crashes 46 \n", |
272 |
| - "Crashes 17 \n", |
273 |
| - "Crashes 11 \n", |
274 |
| - "Crashes 10 \n", |
275 |
| - "Crashes 4 \n", |
276 |
| - "Events in total (excluding SafeBaseline) 8895 \n", |
277 |
| - "Crashes in total 1942 \n", |
278 |
| - "Near-crashes in total 6953 \n", |
279 |
| - "\n", |
280 |
| - " Subject reconstructed \\\n", |
281 |
| - "Event category \n", |
282 |
| - "Safe interactions 10919 \n", |
283 |
| - "Near-crashes 5582 \n", |
284 |
| - "Near-crashes 463 \n", |
285 |
| - "Near-crashes 111 \n", |
286 |
| - "Near-crashes 106 \n", |
287 |
| - "Near-crashes 28 \n", |
288 |
| - "Near-crashes 14 \n", |
289 |
| - "Crashes 1607 \n", |
290 |
| - "Crashes 74 \n", |
291 |
| - "Crashes 43 \n", |
292 |
| - "Crashes 43 \n", |
293 |
| - "Crashes 16 \n", |
294 |
| - "Crashes 11 \n", |
295 |
| - "Crashes 9 \n", |
296 |
| - "Crashes 4 \n", |
297 |
| - "Events in total (excluding SafeBaseline) 8111 \n", |
298 |
| - "Crashes in total 1807 \n", |
299 |
| - "Near-crashes in total 6304 \n", |
300 |
| - "\n", |
301 |
| - " Both subject and object reconstructed \n", |
302 |
| - "Event category \n", |
303 |
| - "Safe interactions 3893 \n", |
304 |
| - "Near-crashes 4648 \n", |
305 |
| - "Near-crashes 391 \n", |
306 |
| - "Near-crashes 99 \n", |
307 |
| - "Near-crashes 88 \n", |
308 |
| - "Near-crashes 25 \n", |
309 |
| - "Near-crashes 11 \n", |
310 |
| - "Crashes 1242 \n", |
311 |
| - "Crashes 61 \n", |
312 |
| - "Crashes 30 \n", |
313 |
| - "Crashes 37 \n", |
314 |
| - "Crashes 14 \n", |
315 |
| - "Crashes 9 \n", |
316 |
| - "Crashes 6 \n", |
317 |
| - "Crashes 3 \n", |
318 |
| - "Events in total (excluding SafeBaseline) 6664 \n", |
319 |
| - "Crashes in total 1402 \n", |
320 |
| - "Near-crashes in total 5262 " |
321 |
| - ] |
322 |
| - }, |
323 |
| - "execution_count": 18, |
324 |
| - "metadata": {}, |
325 |
| - "output_type": "execute_result" |
326 |
| - } |
327 |
| - ], |
| 63 | + "outputs": [], |
328 | 64 | "source": [
|
329 | 65 | "meta_both = pd.read_csv(path_processed + 'metadata_birdseye.csv').set_index('event_id')\n",
|
330 | 66 | "events = pd.read_csv(path_raw + 'FileToUse/InsightTables/Event_Table.csv').set_index('eventID')\n",
|
|
350 | 86 | "event_counts.loc['Events in total (excluding SafeBaseline)'] = event_counts.iloc[1:].sum()\n",
|
351 | 87 | "event_counts.loc['Crashes in total'] = event_counts.loc[event_counts.index.str.contains('Crashes')].sum()\n",
|
352 | 88 | "event_counts.loc['Near-crashes in total'] = event_counts.loc[event_counts.index.str.contains('Near-crashes')].sum()\n",
|
353 |
| - "event_counts.loc[['Crashes in total', 'Near-crashes in total'], 'Sub category'] = ['', '']\n", |
| 89 | + "event_counts.loc[['Crashes in total', 'Near-crashes in total', 'Events in total (excluding SafeBaseline)'], 'Sub category'] = ['', '', '']\n", |
354 | 90 | "event_counts.to_csv(path_processed + 'event_counts.csv')\n",
|
355 | 91 | "\n",
|
356 | 92 | "event_categories = meta_both['event_category'].value_counts().index.values[::-1]\n",
|
|
378 | 114 | "print('Mean period before impact: ', round(tta.mean(),2), 's')"
|
379 | 115 | ]
|
380 | 116 | },
|
| 117 | + { |
| 118 | + "cell_type": "markdown", |
| 119 | + "metadata": {}, |
| 120 | + "source": [ |
| 121 | + "## Visualize BEV trajectories" |
| 122 | + ] |
| 123 | + }, |
381 | 124 | {
|
382 | 125 | "cell_type": "code",
|
383 | 126 | "execution_count": null,
|
|
391 | 134 | "fig = reconstruction_error(data_ego, data_sur, event_type)"
|
392 | 135 | ]
|
393 | 136 | },
|
394 |
| - { |
395 |
| - "cell_type": "markdown", |
396 |
| - "metadata": {}, |
397 |
| - "source": [ |
398 |
| - "## Visualize BEV trajectories" |
399 |
| - ] |
400 |
| - }, |
401 | 137 | {
|
402 | 138 | "cell_type": "code",
|
403 | 139 | "execution_count": null,
|
|
0 commit comments