Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils.delta_time function returns KeyError #17

Closed
RahulJois opened this issue Mar 28, 2021 · 5 comments
Closed

utils.delta_time function returns KeyError #17

RahulJois opened this issue Mar 28, 2021 · 5 comments

Comments

@RahulJois
Copy link

RahulJois commented Mar 28, 2021

import fastf1 as ff1
from fastf1 import plotting
from matplotlib import pyplot as plt
from fastf1 import utils

plotting.setup_mpl()
quali = ff1.get_session(2021, 'Bahrain', 'Q')
laps = quali.load_laps()
lec = laps.pick_driver('LEC').pick_fastest()
ham = laps.pick_driver('HAM').pick_fastest()

delta_time, ref_tel, compare_tel = utils.delta_time(ham, lec)

fig, ax = plt.subplots()

ax.plot(ref_tel['Distance'], ref_tel['Speed'],
color=plotting.TEAM_COLORS[ham['Team']])
ax.plot(compare_tel['Distance'], compare_tel['Speed'],
color=plotting.TEAM_COLORS[lec['Team']])

When executed returns this

core INFO Loading Bahrain Grand Prix - Qualifying
api INFO No cached data found. Downloading...
api INFO Fetching timing data...
api INFO Parsing timing data...
api INFO Data has been written to cache!
api INFO No cached data found. Downloading...
api INFO Fetching timing app data...
api INFO Data has been written to cache!
core INFO Processing timing data...
api INFO No cached data found. Downloading...
api INFO Fetching session status data...
api INFO Data has been written to cache!
api INFO No cached data found. Downloading...
api INFO Fetching track status data...
api INFO Data has been written to cache!
core INFO Loaded data for 20 drivers: ['33', '44', '10', '77', '11', '55', '7', '31', '18', '3', '16', '99', '22', '5', '14', '4', '63', '47', '9', '6']
Traceback (most recent call last):
File "/Users/rahul/testing.py", line 15, in
delta_time, ref_tel, compare_tel = utils.delta_time(ham, lec)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fastf1/utils.py", line 68, in delta_time
ref = reference_lap.get_car_data(interpolate_edges=True).add_distance()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fastf1/core.py", line 1810, in get_car_data
car_data = self.session.car_data[self['DriverNumber']].slice_by_lap(self, **kwargs).reset_index(drop=True)
KeyError: '44'

@theOehrly
Copy link
Owner

You haven't loaded any car telemetry data. You need a recording of the live telemetry from the session for that. The example was not yet updated to show that. I have just updated it.

@RahulJois
Copy link
Author

So, I won't be able to plot unless I have the live timing data ? Is there a way to download the live timing data after the session is over ?

@theOehrly
Copy link
Owner

Last season it was possible to download this data after a session. But it is no longer possible this season sadly.

@FMPete
Copy link

FMPete commented Mar 28, 2021

Could we together make sure that the data is downloaded live and then use it together? Or rather how would this be done in the easiest poossible way? I could happily pay a minor sum if needed to host something etc. As this data is available live, I still don't see any problems with F1-app or FOM interest.

@theOehrly
Copy link
Owner

Could we together make sure that the data is downloaded live and then use it together? Or rather how would this be done in the easiest poossible way? I could happily pay a minor sum if needed to host something etc. As this data is available live, I still don't see any problems with F1-app or FOM interest.

We "could" but this will not happen within the scope of this project and I won't do it. For legal reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants