avatarRaúl García

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

3950

Abstract

is collected from a variety of sensors on the car, including sensors for speed, acceleration, braking, tire temperature and pressure, and engine performance, among others.</p><p id="1cd9">FastF1 organizes telemetry data into a hierarchical data structure, with the top level being the Session object. The Session object contains information about the race, such as the track, weather conditions, and the number of laps. Within each Session object, there are one or more Lap objects, which represent each lap of the race. Each Lap object contains a series of DataFrame objects, which contain the telemetry data for that lap.</p><p id="ebf1">As we can see in the previous code block all the information about the race (Race Results from 2023 Saudi Arabia Grand Prix ), is storage in the <b>session_race</b> FastF1 object.</p><div id="3fb7"><pre>session_race = fastf1.get_session(year, gp, event) session_race.load()</pre></div><p id="fb74">If we want to access to all the information lap per lap of each driver we can use the following command</p><div id="46a9"><pre>session_race.laps</pre></div><figure id="63db"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*G3mKHFfBt8HawaG3vfTq-g.png"><figcaption>Google Colab Notebook (laps data)</figcaption></figure><p id="f0ba">To identify tha available information of each lap, we can use the following command:</p><div id="0335"><pre>session_race.laps.columns</pre></div><figure id="99af"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*0blzu4dChtaHNuOsXnZDDw.png"><figcaption>Google Colab Notebook (laps columns)</figcaption></figure><p id="7a25">FastF1 provides a wide range of data fields for each telemetry parameter, such as speed, throttle position, and brake pressure, among others. These data fields can be accessed using the FastF1 API, allowing users to extract specific pieces of telemetry data for analysis.</p><p id="6cce">The next step before to get the telemetry data, is to get the data of the fastest lap using the following command:</p><div id="b868"><pre>fastest_lap = session_race.laps.pick_fastest() fastest_lap </pre></div><figure id="4528"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*FCSD_LJwEXpQXk9k4akpRg.png"><figcaption></figcaption></figure><p id="a009">As you can see we go from the general to the particular, at first we start with the general information of the race, then we obtain information from all the laps of the race, now we get the data of the fastest lap, and in the following step, we are going to get the data from the fastest lap of an specific driver, including the data of his car.</p><p id="e2bd"><b>Accessing Telemetry Data for a Specific Drive</b>r</p><p id="bfef">One of the key features of FastF1 is its ability to access telemetry data for a specific driver. This allows users to analyze the performance of individual drivers and compare their performance to other drivers in the race.</p><p id="71f9">To access telemetry data for a specific driver, we can use the FastF1 API to filter the telemetry data based on the driver’s name. For example, to access telemetry data for Sergio Perez, we can use the following code:</p><div id="ff33"><pre>driver =<span class="hljs-string">'PER'</span> fastest_lap_per = session_race.laps.pick_driver(driver).pick_fastest() fastest_lap_per</pre></div><figure id="1128"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*Ms-7bpuhGgMYbtmHGz7nLw.png"><figcaption>Google Colab Notebook (Sergio’s Perez Fastest Lap)</figcaption></figure><p id="9e91">In the FastF1 object <b>fastest_lap_per</b> we have all the information about the fastest lap of Segio Perez performed in the race (2023 Saudi Arabia Grand Prix), I mean we can obtain the information of the Qualifying or of any Practice 1, Practice 2 or Practice 3. Right now we are working with the information from the race.</p><p id="037c">Now to get the telemetry, we need to get the data from th

Options

e Sergio’s Perez Car, so we use the following code to get this information considering the fastest lap of Sergio Perez.</p><div id="1ae0"><pre>per_car_data = fastest_lap_per.get_car_data() per_car_data</pre></div><figure id="395d"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*IVHW8Utyu2ZBcODYgUWtyg.png"><figcaption>Google Colab Notebook (Car data from Sergio’s Perez fastest lap)</figcaption></figure><p id="94c1">We can see the available information from the Sergio’s Perez car using the following command:</p><div id="4eda"><pre>per_car_data.columns</pre></div><figure id="d8bb"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*4WTLYqUys6c3y8AndIASkg.png"><figcaption>Google Colab Notebook (Car data from Sergio’s Perez fastest lap)</figcaption></figure><p id="fb26">At this point we have all the information from the specific race that we are analyzing, including the information of each lap, of an specific driver and the telemetry of his car.</p><p id="39b8">with all this infromation we can perform different analysis, comparisons, explanations, stastical inferences, and if we include historical data from several previous years, we can build a machine learning model to make some predictions using machine learning tools.</p><p id="3e18">In the next chapter of this series we are going to work with data visualizations to understand the performance of an specific driver in any specific circuit, and remember that all the information that we are analyzing is available for any f1 event (Practice 1, Practice 2, Practice 3, Qualifying and Race).</p><p id="3406">The Google Colab Notebook with all the commands that we used in this chapter is available in github:</p><div id="dde7" class="link-block"> <a href="https://github.com/RacingDataLabCom/Telemetry-Analysis-for-F1-Enthusiasts/blob/main/Chapter_II_Basic_Usage_of_FastF1.ipynb"> <div> <div> <h2>Telemetry-Analysis-for-F1-Enthusiasts/Chapter_II_Basic_Usage_of_FastF1.ipynb at main ·…</h2> <div><h3>You can't perform that action at this time. You signed in with another tab or window. You signed out in another tab or…</h3></div> <div><p>github.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*ifjfWOtxy-aAVILr)"></div> </div> </div> </a> </div><p id="90cf">If you have an specific doubt or if you want to perform a specific analysis please free to contact me. For more information, please visit RacingDataLab Website:</p><div id="94a3" class="link-block"> <a href="https://racingdatalab.com/"> <div> <div> <h2>RDL</h2> <div><h3>where Business Intelligence & Data Science meets Formula 1</h3></div> <div><p>racingdatalab.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*QqvdIGTRPNua7lcL)"></div> </div> </div> </a> </div><p id="11a3">Follow me in my Social Networks:</p><div id="c3e9" class="link-block"> <a href="https://linktr.ee/raulgarciamx"> <div> <div> <h2>@RaulGarciaMx | Linktree</h2> <div><h3>I enjoy all about data analysis and I want to apply my data science knowledge in one of my prefer hobbies Formula 1 (As…</h3></div> <div><p>linktr.ee</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*Mu48cLcwZ8GoY9Z0)"></div> </div> </div> </a> </div><p id="16a0">Don’t forget this is a race week¡¡ Round 03: Australia | Season 2023</p></article></body>

Telemetry Analysis for F1 Enthusiasts | Chapter II: Basic Usage of FastF1

Chapter II: Basic Usage of FastF1

  • Understanding the data structure and available data fields: In this section, we’ll explore the structure of telemetry data in FastF1, including the available data fields and how they can be used to analyze performance.
  • Accessing telemetry data for a specific driver: Here, we’ll go over the basics of accessing telemetry data for a specific driver or team, including how to extract data for a specific lap or section of the track.

Requirements

To get a better understanding of this section you can read previously the previous article, Telemetry Analysis for F1 Enthusiasts | Chapter I: Introduction.

FastF1

FastF1 is a Python library for analyzing telemetry data from Formula One (F1) races. It provides a wide range of functionalities for working with F1 telemetry data, including loading telemetry data from files, converting data to Pandas DataFrames, and visualizing telemetry data with Matplotlib.

In this article, we will cover the basic usage of FastF1, with a focus on understanding the data structure and accessing telemetry data for a specific driver.

We are going to use the python code that we wrote in Google Colab, in the previous chapter of this series, Telemetry Analysis for F1 Enthusiasts | Chapter I: Introduction.

!pip install fastf1

import fastf1

from google.colab import drive
drive.mount('/content/drive/')

%cd '/content/drive/MyDrive/Colab Notebooks/'

fastf1.Cache.enable_cache('Cache')

year= 2023
gp = 'Saudi Arabia'
event = 'R'
session_race = fastf1.get_session(year, gp, event)
session_race.load()

session_race.results

If you want the Google Colab notebook is available in github:

Understanding the Data Structure and Available Data Fields

Before we can start analyzing telemetry data with FastF1, it’s important to understand the data structure and available data fields. Telemetry data in F1 racing is collected from a variety of sensors on the car, including sensors for speed, acceleration, braking, tire temperature and pressure, and engine performance, among others.

FastF1 organizes telemetry data into a hierarchical data structure, with the top level being the Session object. The Session object contains information about the race, such as the track, weather conditions, and the number of laps. Within each Session object, there are one or more Lap objects, which represent each lap of the race. Each Lap object contains a series of DataFrame objects, which contain the telemetry data for that lap.

As we can see in the previous code block all the information about the race (Race Results from 2023 Saudi Arabia Grand Prix ), is storage in the session_race FastF1 object.

session_race = fastf1.get_session(year, gp, event)
session_race.load()

If we want to access to all the information lap per lap of each driver we can use the following command

session_race.laps
Google Colab Notebook (laps data)

To identify tha available information of each lap, we can use the following command:

session_race.laps.columns
Google Colab Notebook (laps columns)

FastF1 provides a wide range of data fields for each telemetry parameter, such as speed, throttle position, and brake pressure, among others. These data fields can be accessed using the FastF1 API, allowing users to extract specific pieces of telemetry data for analysis.

The next step before to get the telemetry data, is to get the data of the fastest lap using the following command:

fastest_lap = session_race.laps.pick_fastest()
fastest_lap  

As you can see we go from the general to the particular, at first we start with the general information of the race, then we obtain information from all the laps of the race, now we get the data of the fastest lap, and in the following step, we are going to get the data from the fastest lap of an specific driver, including the data of his car.

Accessing Telemetry Data for a Specific Driver

One of the key features of FastF1 is its ability to access telemetry data for a specific driver. This allows users to analyze the performance of individual drivers and compare their performance to other drivers in the race.

To access telemetry data for a specific driver, we can use the FastF1 API to filter the telemetry data based on the driver’s name. For example, to access telemetry data for Sergio Perez, we can use the following code:

driver ='PER'
fastest_lap_per = session_race.laps.pick_driver(driver).pick_fastest()
fastest_lap_per
Google Colab Notebook (Sergio’s Perez Fastest Lap)

In the FastF1 object fastest_lap_per we have all the information about the fastest lap of Segio Perez performed in the race (2023 Saudi Arabia Grand Prix), I mean we can obtain the information of the Qualifying or of any Practice 1, Practice 2 or Practice 3. Right now we are working with the information from the race.

Now to get the telemetry, we need to get the data from the Sergio’s Perez Car, so we use the following code to get this information considering the fastest lap of Sergio Perez.

per_car_data = fastest_lap_per.get_car_data()
per_car_data
Google Colab Notebook (Car data from Sergio’s Perez fastest lap)

We can see the available information from the Sergio’s Perez car using the following command:

per_car_data.columns
Google Colab Notebook (Car data from Sergio’s Perez fastest lap)

At this point we have all the information from the specific race that we are analyzing, including the information of each lap, of an specific driver and the telemetry of his car.

with all this infromation we can perform different analysis, comparisons, explanations, stastical inferences, and if we include historical data from several previous years, we can build a machine learning model to make some predictions using machine learning tools.

In the next chapter of this series we are going to work with data visualizations to understand the performance of an specific driver in any specific circuit, and remember that all the information that we are analyzing is available for any f1 event (Practice 1, Practice 2, Practice 3, Qualifying and Race).

The Google Colab Notebook with all the commands that we used in this chapter is available in github:

If you have an specific doubt or if you want to perform a specific analysis please free to contact me. For more information, please visit RacingDataLab Website:

Follow me in my Social Networks:

Don’t forget this is a race week¡¡ Round 03: Australia | Season 2023

Formula 1
Data Science
Business Analytics
Python
F1
Recommended from ReadMedium