gitmyhub

f1-race-replay

Python β˜… 6.0k updated 1mo ago

An interactive Formula 1 race visualisation and data analysis tool built with Python! 🏎️

F1 Race Replay is a Python application that plays back Formula 1 race events as an animated visualization on your screen. It pulls real telemetry and timing data from the FastF1 library, which accesses the official F1 data feed, then renders a top-down view of the track with each driver's position moving in real time as the race progresses.

The visualization includes a live leaderboard showing driver positions and tyre compounds, a lap and time counter, and markers for drivers who retire from the race. Interactive controls let you pause, rewind, fast forward, and change playback speed using either keyboard shortcuts or on-screen buttons. You can click on drivers in the leaderboard to highlight them on track and pull up their telemetry data, including speed, gear, and DRS activation status.

The app also models Safety Car deployments. Because the F1 API does not provide GPS coordinates for the Safety Car itself, the application simulates its position by placing it roughly 500 meters ahead of the race leader on the track. Visual cues show the three phases of a Safety Car period: deploying from the pit lane, running on track, and returning to the pits.

Sessions beyond race replays are also supported. Qualifying sessions can be replayed with telemetry overlays showing speed, gear, throttle, and brake over the lap. Sprint sessions and sprint qualifying work through additional command-line flags. A graphical menu lets you pick the year and round without typing commands.

Getting started requires Python 3.11 or later and a few dependencies, installed via pip. The FastF1 cache folder is created automatically on first run, storing downloaded session data so repeat runs load faster. The project is actively developed, with a roadmap file listing planned features.