-
Notifications
You must be signed in to change notification settings - Fork 0
/
Telemetry.py
61 lines (47 loc) · 1.93 KB
/
Telemetry.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
import fastf1 as ff1
import matplotlib.font_manager as fm
from fastf1 import plotting
from matplotlib import pyplot as plt
plotting.setup_mpl()
ff1.Cache.enable_cache('cache') # optional but recommended
year = 2021
wknd = 16
ses = 'R'
drv1 = 'BOT'
drv2 = 'BOT'
weekend = ff1.get_session(year, wknd)
session = ff1.get_session(year, wknd, ses)
laps = session.load_laps(with_telemetry=True)
first_driver = laps.pick_driver(drv1)
first_driver_info = session.get_driver(drv1)
first_color = plotting.team_color(first_driver_info.team)
second_driver = laps.pick_driver(drv2)
second_driver_info = session.get_driver(drv2)
second_color = plotting.team_color(second_driver_info.team)
first_driver = laps.pick_driver(drv1).pick_fastest()
first_car = first_driver.get_car_data()
second_driver = laps.pick_driver(drv2).pick_fastest()
second_car = second_driver.get_car_data()
fig, ax = plt.subplots(6)
prop = fm.FontProperties(fname='F1.otf')
fig.suptitle(f'BOTTAS - Fastest lap - {weekend.name} {year} {ses}', fontproperties=prop, size=18)
l1, = ax[0].plot(first_car['Time'], first_car['Speed'], color=first_color)
ax[1].plot(first_car['Time'], first_car['RPM'], color=first_color)
ax[2].plot(first_car['Time'], first_car['nGear'], color=first_color)
ax[3].plot(first_car['Time'], first_car['Throttle'], color=first_color)
ax[4].plot(first_car['Time'], first_car['Brake'], color=first_color)
ax[5].plot(first_car['Time'], first_car['DRS'], color=first_color)
ax[0].set_ylabel("Speed [km/h]")
ax[1].set_ylabel("RPM [#]")
ax[2].set_ylabel("Gear [#]")
ax[3].set_ylabel("Throttle [%]")
ax[4].set_ylabel("Brake [%]")
ax[5].set_ylabel("DRS")
ax[0].get_xaxis().set_ticklabels([])
ax[1].get_xaxis().set_ticklabels([])
ax[2].get_xaxis().set_ticklabels([])
ax[3].get_xaxis().set_ticklabels([])
ax[4].get_xaxis().set_ticklabels([])
fig.align_ylabels()
plt.subplots_adjust(left=0.06 ,right=0.99, top=0.9, bottom=0.05)
plt.show()