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

Italian GP FP2 Sainz Data #41

Closed
nicZox opened this issue Sep 11, 2021 · 2 comments
Closed

Italian GP FP2 Sainz Data #41

nicZox opened this issue Sep 11, 2021 · 2 comments

Comments

@nicZox
Copy link

nicZox commented Sep 11, 2021

Hi, I'm trying to see the data of Sainz' accident but there are no data and times for that lap. I checked on the app and the data is there. Do you know how to solve this?

@theOehrly
Copy link
Owner

The reason why the data isn't available as usual is that there is no full lap with start and end time anymore for the lap where he crashed. So fastf1 doesn't know about this lap and can't provide a telemetry slice. But the telemetry data is still there, you just need to get the relevant part manually. Here's what you'll want to do:

import datetime

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

plotting.setup_mpl()

ff1.Cache.enable_cache('tmp_cache')
session = ff1.get_session(2021, "Monza", 'FP2')

laps = session.load_laps(with_telemetry=True)
last_lap_sai = laps.pick_driver('SAI').iloc[-1]

car_data_sai = session.car_data['55']

t_begin = last_lap_sai['Time']
t_end = t_begin + datetime.timedelta(seconds=90)
car_data_crash = car_data_sai.slice_by_time(t_begin, t_end)

plt.plot(car_data_crash['Time'], car_data_crash['Speed'])
plt.show()

Explanation:
All car data is available in full in Session.car_data (see the list of attributes in the docs for Session)
You can create a telemetry slice using a start and end time (session time). See https://theoehrly.github.io/Fast-F1/core.html#fastf1.core.Telemetry.slice_by_time
Use the end time of his last full lap as a reference. It is the start time of the last partial lap. Also, if you add a few seconds to it to get an end time. Of course you could adjust that time window as you like.

@theOehrly
Copy link
Owner

Fixed in new release v2.1.9

The last lap will now be the lap during which the session was aborted, not the lap before.

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

2 participants