Spaces:
Runtime error
Runtime error
kbberendsen
commited on
Commit
•
6389acd
1
Parent(s):
7c48fa6
plot gearshift
Browse files
f1.py
CHANGED
@@ -11,4 +11,33 @@ session = ff1.get_session(2023, 'Austria', 'R')
|
|
11 |
session.load()
|
12 |
|
13 |
lap = session.laps.pick_fastest()
|
14 |
-
tel = lap.get_telemetry()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
session.load()
|
12 |
|
13 |
lap = session.laps.pick_fastest()
|
14 |
+
tel = lap.get_telemetry()
|
15 |
+
|
16 |
+
#converting data to numpy data tables
|
17 |
+
x = np.array(tel['X'].values)
|
18 |
+
y = np.array(tel['Y'].values)
|
19 |
+
|
20 |
+
points = np.array([x, y]).T.reshape(-1, 1, 2)
|
21 |
+
segments = np.concatenate([points[:-1], points[1:]], axis=1)
|
22 |
+
gear = tel['nGear'].to_numpy().astype(float)
|
23 |
+
|
24 |
+
cmap = cm.get_cmap('Paired')
|
25 |
+
lc_comp = LineCollection(segments, norm=plt.Normalize(1, cmap.N+1), cmap=cmap)
|
26 |
+
lc_comp.set_array(gear)
|
27 |
+
lc_comp.set_linewidth(4)
|
28 |
+
|
29 |
+
plt.gca().add_collection(lc_comp)
|
30 |
+
plt.axis('equal')
|
31 |
+
plt.tick_params(labelleft=False, left=False, labelbottom=False, bottom=False)
|
32 |
+
|
33 |
+
title = plt.suptitle(
|
34 |
+
f"Fastest Lap Gear Shift Visualization\n"
|
35 |
+
f"{lap['Driver']} - {session.event['EventName']} {session.event.year}"
|
36 |
+
)
|
37 |
+
|
38 |
+
cbar = plt.colorbar(mappable=lc_comp, label="Gear", boundaries=np.arange(1, 10))
|
39 |
+
cbar.set_ticks(np.arange(1.5, 9.5))
|
40 |
+
cbar.set_ticklabels(np.arange(1, 9))
|
41 |
+
|
42 |
+
|
43 |
+
plt.show()
|