TrajectoryMetric.ipynb 21 KB
Newer Older
1
2
{
 "cells": [
3
4
5
6
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
7
8
   "outputs": [],
   "source": [
9
    "# expand the cell of the notebook\n",
10
11
12
13
14
15
16
    "import json\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import math\n",
    "import matplotlib.pyplot as plt\n",
    "from matplotlib.lines import Line2D\n",
    "\n",
17
18
19
20
21
22
23
24
    "from IPython.core.display import display, HTML\n",
    "display(HTML('<style>.container { width:100% !important; }</style>'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
25
    "# Convert Vadere trajectories into a DataFrame"
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def fs_append(pedestrianId, fs, llist):\n",
    "    llist.append([pedestrianId, fs['start']['x'], fs['start']['y'], fs['startTime'], fs['end']['x'], fs['end']['y'], fs['endTime']])\n",
    "   \n",
    "def trajectory_append(pedestrianId, trajectory, llist):\n",
    "    for fs in trajectory:\n",
    "        fs_append(pedestrianId, fs, llist)\n",
    "\n",
    "def trajectories_to_dataframe(trajectories):\n",
    "    llist = []\n",
    "    for pedId in trajectories:\n",
    "        trajectory_append(pedId, trajectories[pedId], llist)\n",
    "    dataframe = pd.DataFrame(llist, columns=['pedestrianId','startX','startY','startTime','endX','endY','endTime'])\n",
46
47
48
49
50
51
52
53
54
55
    "    return dataframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "file = \"./data/TrajectoryMetric/trajectories_simulation.txt\"\n",
56
57
58
    "f = open(file, \"r\")\n",
    "header = f.readline();\n",
    "trajectories = dict({});\n",
59
    "\n",
60
61
62
63
64
    "for row in f:\n",
    "    s = row.split(\" \");\n",
    "    pedId = int(s[0]);\n",
    "    footsteps = json.loads(s[1]);\n",
    "    trajectories[pedId] = footsteps[0]['footSteps'];\n",
65
66
67
68
69
    "\n",
    "ptrajectories = trajectories_to_dataframe(trajectories)\n",
    "ptrajectories.head()"
   ]
  },
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Convert experiment data into a DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def load_experiment(file):\n",
    "    fps = 16\n",
    "    pad = pd.DataFrame([[np.nan, np.nan, np.nan, np.nan, np.nan]], columns=['pedestrianId', 'timeStep', 'x', 'y', 'e'])\n",
    "    data = pd.read_csv(\n",
    "        file, \n",
    "        sep=' ', \n",
    "        names=['pedestrianId', 'timeStep', 'x', 'y', 'e'], \n",
    "        index_col=False, \n",
    "        header=None, \n",
    "        skiprows=0)\n",
    "    \n",
    "    cc = pd.concat([pad, data], ignore_index=True)\n",
    "        \n",
    "    data['endX'] = data['x'] / 100 + 18.7\n",
    "    data['endY'] = data['y'] / 100 + 4.2\n",
    "    data['startX'] = cc['x'] / 100 + 18.7\n",
    "    data['startY'] = cc['y'] / 100 + 4.2\n",
    "    data['startTime'] = data['timeStep'] / fps - 1/fps\n",
    "    data['endTime'] = data['timeStep'] / fps\n",
    "    data = data.drop(columns=['timeStep','x','y','e'])\n",
    "    return data\n",
    "    \n",
    "def to_trajectories(data):\n",
    "    trajectories = dict({})\n",
    "    trajectory = []\n",
    "    for i in range(len(data)-1):\n",
    "        pedId = data['pedestrianId'][i]\n",
    "        if pedId == data['pedestrianId'][i+1]:\n",
    "            pedId = data['pedestrianId'][i]\n",
    "            x1 = data['x'][i]\n",
    "            y1 = data['y'][i]\n",
    "            x2 = data['x'][i+1]\n",
    "            y2 = data['y'][i+1]\n",
    "            startTime = data['timeStep'][i] \n",
    "            endTime = data['timeStep'][i+1]\n",
    "            fs = {'startTime':startTime, 'endTime': endTime, 'start':{'x':x1, 'y':y1}, 'end':{'x':x2, 'y':y2}}\n",
    "            trajectory.append(fs)\n",
    "        else:\n",
    "            trajectories[pedId] = trajectory\n",
    "            trajectory = []\n",
    "            pedId = data['pedestrianId'][i]\n",
    "    return trajectories"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#times = np.linspace(4,10,10)\n",
    "#euclid_d(get_trajectory(1), get_trajectory(1), times)\n",
    "#to_trajectories(load_experiment(real_file))[1]\n",
    "\n",
    "real_file = \"./data/TrajectoryMetric/KO/ko-240-120-240/ko-240-120-240_combined_MB.txt\"\n",
    "trajectoriesReal = load_experiment(real_file)\n",
    "#trajectoriesReal = to_trajectories(data)\n",
    "trajectoriesReal.query('pedestrianId == 1').head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Convert DataFrame to postvis DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def to_postVis(df):\n",
    "    simTimeStep = 0.4\n",
    "    fps = 16\n",
    "    df['timeStep'] = np.ceil(df['endTime'] / (1/fps)).astype(np.int)\n",
    "    df['x'] = df['endX']\n",
    "    df['y'] = df['endY']\n",
    "    df['simTime'] = df['endTime']\n",
    "    df = df.drop(columns=['startX','startY','endX','endY','startTime', 'endTime'])    \n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "to_postVis(trajectoriesReal).to_csv('expteriment_2.trajectories',index=False,sep=' ')\n",
    "to_postVis(trajectoriesReal).head(10)"
   ]
  },
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Helpler method to access parts of the trajectory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_trajectory(pedId, trajectories):\n",
    "    \"\"\"returns a data frame containing the trajectory of one specific agent.\"\"\"\n",
    "    query = 'pedestrianId == ' + str(pedId)\n",
    "    return trajectories.query(query)\n",
    "\n",
    "def get_pedestrianIds(trajectories):\n",
    "    return trajectories['pedestrianId'].unique()\n",
197
198
    "\n",
    "def get_footstep(trajectory, i):\n",
199
200
    "    \"\"\"returns the i-ths footstep.\"\"\"\n",
    "    return trajectory.iloc[i];\n",
201
    "\n",
202
203
204
205
206
207
    "def get_footstep_by_time(trajectory, time):\n",
    "    \"\"\"returns the footstep which happens at time or nothing (None).\"\"\"\n",
    "    query = 'startTime <= ' + str(time) + ' and ' + str(time) + ' < endTime'\n",
    "    fs = trajectories.query(query)\n",
    "    assert len(fs) >= 1\n",
    "    return fs\n",
208
    "\n",
209
210
211
    "def start_time(trajectory):\n",
    "    \"\"\"returns the time of the first footstep of the trajectory.\"\"\"\n",
    "    return get_footstep(trajectory, 0)['startTime'];\n",
212
213
    "\n",
    "def end_time(trajectory):\n",
214
215
216
217
218
219
    "    return get_footstep(trajectory, len(trajectory)-1)['endTime'];\n",
    "\n",
    "def max_start_time(trajectories):\n",
    "    \"\"\"returns the time of the first footstep of the trajectory which starts last.\"\"\"\n",
    "    pedestrianIds = get_pedestrianIds(trajectories)\n",
    "    return max(map(lambda pedId: start_time(get_trajectory(pedId, trajectories)), pedestrianIds))\n",
220
221
    "\n",
    "def min_end_time(trajectories):\n",
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
    "    \"\"\"returns the time of the last footstep of the trajectory which ends first.\"\"\"\n",
    "    pedestrianIds = get_pedestrianIds(trajectories)\n",
    "    return min(map(lambda pedId: end_time(get_trajectory(pedId, trajectories)), pedestrianIds))\n",
    "\n",
    "def footstep_is_between(fs, time):\n",
    "    \"\"\"true if the foostep and the intersection with time is not empty.\"\"\"\n",
    "    startTime = fs['startTime'];\n",
    "    endTime = fs['endTime'];\n",
    "    return startTime <= time and time < endTime;\n",
    "\n",
    "def cut(trajectory, sTime, eTime):\n",
    "    query = 'startTime >= ' + str(sTime) + ' and endTime < ' + str(eTime)\n",
    "    return trajectory.query(query)\n",
    "\n",
    "def cut_soft(trajectory, sTime, eTime):\n",
    "    query = 'endTime > ' + str(sTime) + ' and startTime < ' + str(eTime)\n",
    "    return trajectory.query(query)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Helper methods to compute different metrices"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def footstep_length(fs):\n",
    "    \"\"\"Euclidean length of a footstep.\"\"\"\n",
    "    x1 = fs['startX'];\n",
    "    y1 = fs['startY'];\n",
    "    x2 = fs['endX'];\n",
    "    y2 = fs['endY'];\n",
260
261
262
263
264
    "    dx = x1-x2;\n",
    "    dy = y1-y2;\n",
    "    return np.sqrt(dx*dx + dy*dy);\n",
    "\n",
    "def trajectory_length(trajectory):\n",
265
266
267
268
269
270
271
272
273
274
275
    "    \"\"\"Euclidean length of a trajectory.\"\"\"\n",
    "    dx = trajectory['startX']-trajectory['endX']\n",
    "    dy = trajectory['startY']-trajectory['endY']\n",
    "    return np.sqrt(dx*dx + dy*dy).sum();\n",
    "\n",
    "def footstep_direction(fs):\n",
    "    \"\"\"Vector from start to end position.\"\"\"\n",
    "    x1 = fs['startX'];\n",
    "    y1 = fs['startY'];\n",
    "    x2 = fs['endX'];\n",
    "    y2 = fs['endY'];\n",
276
277
    "    return np.array([x2-x1, y2-y1]);\n",
    "\n",
278
279
    "def footstep_duration(fs):\n",
    "    \"\"\"Duration of a footstep.\"\"\"\n",
280
281
282
283
    "    startTime = fs['startTime'];\n",
    "    endTime = fs['endTime'];\n",
    "    return endTime-startTime;\n",
    "\n",
284
285
286
    "def trajectory_duration(trajectory):\n",
    "    \"\"\"Euclidean length of a trajectory.\"\"\"\n",
    "    return (trajectory['endTime'] - trajectory['startTime']).sum();\n",
287
    "\n",
288
289
290
    "def footstep_speed(fs):\n",
    "    \"\"\"Speed of the footstep.\"\"\"\n",
    "    return footstep_length(fs) / footstep_duration(fs);\n",
291
    "\n",
292
293
294
    "def trajectory_speed(fs):\n",
    "    \"\"\"Speed of the trajectory.\"\"\"\n",
    "    return trajectory_length(fs) / trajectory_duration(fs);\n",
295
    "\n",
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
    "#def trajectory_positions(trajectory, times):\n",
    "#    mask = trajectory[['startTime', 'endTime']].mask(lambda x: x**2)\n",
    "#    (df['date'] > '2000-6-1') & (df['date'] <= '2000-6-10')\n",
    "#    duration = trajectory['endTime'] - trajectory['startTime']\n",
    "#    dx = trajectory['endX'] - trajectory['startX']\n",
    "#    dy = trajectory['endY'] - trajectory['startY']\n",
    "#    direction = \n",
    "    \n",
    "def filter_trajectories(trajectories, times):\n",
    "    \"\"\"Filters trajectory by times.\"\"\"\n",
    "    rows = []\n",
    "    for row in trajectories.itertuples():\n",
    "        if len(list(filter(lambda b: b, map(lambda t: row.startTime <= t and t < row.endTime, times)))) > 0:\n",
    "            rows.append(row)\n",
    "    return pd.DataFrame(rows)\n",
    "\n",
    "def trajectories_position(trajectories, times):\n",
    "    \"\"\"Transforms trajectories into positions at each time in times such that each position is computed by linear interpolation.\"\"\"\n",
    "    rows = []\n",
    "    #print(trajectories)\n",
    "    for row in trajectories.itertuples():\n",
    "        llist = list(filter(lambda t: row.startTime <= t and t < row.endTime, times))\n",
    "        assert len(llist) == 1 or len(llist) == 0\n",
    "        if len(llist) > 0:\n",
    "            time = llist[0]\n",
    "            dur = row.endTime - row.startTime\n",
    "            partial_dur = time - row.startTime\n",
    "            ratio = partial_dur / dur\n",
    "            direction = np.array([row.endX - row.startX, row.endY - row.startY])\n",
    "            l = np.linalg.norm(direction)\n",
    "            if l > 0:\n",
    "                partial_l = l * ratio;\n",
    "                v = direction / l * partial_l;\n",
    "                pos = np.array([row.startX, row.startY]) + v;\n",
    "                rows.append([row.pedestrianId, pos[0], pos[1], time])\n",
    "            else:\n",
    "                rows.append([row.pedestrianId, np.nan, np.nan, time])\n",
    "    dataframe = pd.DataFrame(rows, columns=['pedestrianId','x','y','time'])\n",
    "    return dataframe\n",
    "    \n",
    "def euclid_d(trajPos1, trajPos2):\n",
    "    \"\"\"Computes the total (Euclidean) distance between two trajectories.\n",
    "       Assumption: trajectories are both cut acccordingly!   \n",
    "    \"\"\"\n",
    "    assert len(trajPos1) == len(trajPos2)\n",
    "    dx = trajPos1['x'] - trajPos2['x']\n",
    "    dy = trajPos1['y'] - trajPos2['y']\n",
    "    norm = np.sqrt(dx**2 + dy**2)\n",
    "    return norm.sum() / len(dx)\n",
    "\n",
    "def euclid_path_length(trajPos1, trajPos2):\n",
    "    \"\"\"Computes the total (Euclidean) path length difference between two trajectories.\n",
    "       Assumption: trajectories are both cut acccordingly!\n",
    "    \"\"\"\n",
    "    count = len(trajPos1)\n",
    "    pad = pd.DataFrame([[np.nan, np.nan, np.nan, np.nan]], columns=['pedestrianId','x','y','time'])\n",
    "    trajPos1Pad = pd.concat([pad, trajPos1], ignore_index=True)\n",
    "    trajPos2Pad = pd.concat([pad, trajPos1], ignore_index=True)\n",
    "    dx1 = trajPos1['x'] - trajPos1Pad['x']\n",
    "    dy1 = trajPos1['y'] - trajPos1Pad['y']\n",
    "    dx2 = trajPos2['x'] - trajPos2Pad['x']\n",
    "    dy2 = trajPos2['y'] - trajPos2Pad['y']\n",
    "    dx = dx1 - dx2\n",
    "    dy = dy1 - dy2\n",
    "    diff = np.sqrt(dx**2 + dy**2)\n",
    "    return diff.sum()\n",
    "\n",
    "def euclid_len(trajectory, sTime, eTime):\n",
    "    \"\"\"Computes the total (Euclidean) length of the trajectory in between [sTime;eTime].\"\"\"\n",
    "    cut_traj = cut_soft(trajectory, sTime, eTime);\n",
    "    return trajectory_length(cut_traj)\n",
    "    \n",
    "def inter_agent_d(trajPos):\n",
    "    \"\"\"Computes the inter agent (Euclidean) distance between all pairs of agents.\n",
    "       Assumption: the trajectory is cut accordingly, ie the time is equal for\n",
    "       each position.\n",
    "    \"\"\"\n",
    "    s = 0\n",
    "    min_index = min(trajectories.keys())\n",
    "    c = 0\n",
    "    llen = len(trajPos)\n",
    "    for index1, row1 in trajPos.iterrows():\n",
    "        for index2, row2 in trajPos.tail(llen-1-index1).iterrows():\n",
    "            x1 = row1['x']\n",
    "            y1 = row1['y']\n",
    "            x2 = row2['x']\n",
    "            y2 = row2['y']\n",
    "            dx = x1 - x2\n",
    "            dy = y1 - y2\n",
    "            s = s + np.sqrt(dx**2 + dy**2)\n",
    "            c = c + 1\n",
    "    if c == 0:\n",
    "        return 0\n",
    "    else:\n",
    "        return s / c\n",
    "    \n",
    "def total_inter_agent(trajectories1, trajectories2, times):\n",
    "    \"\"\"too expensive! TODO!\"\"\"\n",
394
395
396
397
398
399
400
401
402
    "    return sum(map(lambda t: inter_agent_d(trajectories_position(trajectories1, [t])) - inter_agent_d(trajectories_position(trajectories2, [t])), times)) / len(times)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
    "#start_time(get_trajectory(1, ptrajectories))\n",
    "#max_start_time(ptrajectories)\n",
    "#end_time(get_trajectory(1, ptrajectories))\n",
    "#foot_step_length(get_footstep(get_trajectory(1, ptrajectories), 0))\n",
    "#trajectory_length(get_trajectory(1, ptrajectories))\n",
    "#trajectory_speed(get_trajectory(1, ptrajectories))\n",
    "cutTraj = cut(get_trajectory(1, ptrajectories), 0.0, 10.0)[['startTime', 'endTime']]\n",
    "#cutTraj.mask(cutTraj['startTime'] <= 4 and 4 > cutTraj['endTime'])\n",
    "#start_time(get_trajectory(1, ptrajectories))\n",
    "#trajectories_position(ptrajectories, [1,2,3,4]).head()\n",
    "trajPos1 = trajectories_position(get_trajectory(2, ptrajectories), [1,2,3,4,5,6,8,9,10,11,12,13])\n",
    "trajPos2 = trajectories_position(get_trajectory(7, ptrajectories), [1,2,3,4,5,6,8,9,10,11,12,13])\n",
    "trajPos1 = trajPos1[~np.isnan(trajPos1.x)]\n",
    "trajPos2 = trajPos2[~np.isnan(trajPos2.x)]\n",
    "euclid_path_length(trajPos1, trajPos2)\n",
    "euclid_len(ptrajectories,0,10000)\n",
    "#print(total_inter_agent(ptrajectories, ptrajectories, [1,2]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "code_folding": []
   },
   "outputs": [],
   "source": [
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
    "def greedy_match(trajectories1, trajectories2, times, f):\n",
    "    \"\"\"Computes a match of trajectories by using a greedy algorithm.\"\"\"\n",
    "    assert len(trajectories1) == len(trajectories2)\n",
    "    min_index1 = min(trajectories1.keys())\n",
    "    min_index2 = min(trajectories2.keys())\n",
    "    match = {}\n",
    "    indexSet = set(range(min_index2, len(trajectories2)))\n",
    "    for i in range(min_index1, len(trajectories1)):\n",
    "        traj1 = trajectories1[i]\n",
    "        minVal = None\n",
    "        minIndex = None\n",
    "        for j in indexSet:\n",
    "            traj2 = trajectories2[j]\n",
    "            if overlap(traj1, traj2, 0.4):\n",
    "                val = f(traj1, traj2, times)\n",
    "                if(minVal == None or val < minVal):\n",
    "                    minIndex = j\n",
    "                    minVal = val\n",
    "        match[i] = minIndex\n",
    "        indexSet.remove(minIndex)\n",
450
    "    return match"
451
452
453
   ]
  },
  {
454
   "cell_type": "markdown",
455
456
   "metadata": {},
   "source": [
457
    "# Plot trajectories"
458
459
460
461
462
463
464
465
466
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def to_line(trajectory, xleft):\n",
467
468
469
    "    \"\"\"Transforms a trajectory into a Line2D.\"\"\"\n",
    "    x = trajectory['endX'].values\n",
    "    y = trajectory['endY'].values\n",
470
471
472
473
474
475
    "    if x[0] < xleft:\n",
    "        c = current_palette[2]\n",
    "    else:\n",
    "        c = current_palette[0]\n",
    "    return x, y, Line2D(x, y, color=c, linewidth=0.2)\n",
    "\n",
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
    "def add_lines(trajectories, xleft, ax):\n",
    "    grouped = trajectories.groupby(['pedestrianId'])\n",
    "    for name, group in grouped:\n",
    "        x, y, line = to_line(group, xleft)\n",
    "        ax.add_line(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import seaborn as sns\n",
    "sns.set(style=\"ticks\")\n",
491
    "\n",
492
    "current_palette = sns.color_palette()\n",
493
494
495
    "\n",
    "x_vcenter = 17.5\n",
    "y_vcenter = 5.2\n",
496
497
498
499
    "\n",
    "fig1 = plt.figure(figsize=(10,10))\n",
    "ax1 = fig1.add_subplot(111)\n",
    "add_lines(trajectoriesReal, 14, ax1)\n",
500
501
    "ax1.set_xlim(x_vcenter-5, x_vcenter+5)\n",
    "ax1.set_ylim(y_vcenter-4, y_vcenter+4)\n",
502
503
504
505
    "ax1.set_aspect(1)\n",
    "\n",
    "fig2 = plt.figure(figsize=(10,10))\n",
    "ax2 = fig2.add_subplot(111)\n",
506
    "add_lines(ptrajectories, 14, ax2)\n",
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
    "ax2.set_xlim(x_vcenter-5, x_vcenter+5)\n",
    "ax2.set_ylim(y_vcenter-4, y_vcenter+4)\n",
    "ax2.set_aspect(1)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "times = np.arange(0,80,2)\n",
    "y = list(map(lambda t: inter_agent_d(trajectories, t), times))\n",
    "plt.plot(times, y, 'o')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "start_time(trajectories[1])\n",
    "print(max_start_time(trajectories))\n",
    "print(min_end_time(trajectories))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(position(map(lambda traj: traj[\"startTime\"], trajectories)[1], 0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
551
    "pd.DataFrame([[1,2,3,4,5],[6,7,8,9,10]], columns=['pedestrianId','timeStep','x','y','time'])"
552
553
554
555
556
557
558
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
559
   "source": []
560
561
562
563
564
565
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
566
   "source": []
567
568
569
570
571
572
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
588
589
590
591
592
593
594
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
595
    "to_postVis(data)"
596
597
598
599
600
601
602
603
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
604
    "1 in [1,2,3]"
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}