Skip to main content

Formula 1 Race Replay and Visualization Library

Project description

f1-replay

A Python wrapper around the FastF1 library for interactive Formula 1 race replays. View historic races in a 2D map visualization with real-time car positions using telemetry data.

Installation

pip install f1-replay

Or from source:

pip install -e .

Quick Start

from f1_replay import Manager

# Initialize manager
manager = Manager()

# Launch race replay viewer
manager.race(2024, "monaco")      # By event name
manager.race(2024, 8)             # By round number

This opens a Flask-based web viewer showing:

  • 2D track map with live car positions
  • Race progression with telemetry data
  • Driver information and timing

Usage

Browse Available Races

from f1_replay import Manager

manager = Manager()

# List available seasons
print(manager.list_years())

# Get season details
season = manager.get_season(2024)
for race in season.rounds:
    print(f"{race.round_number}. {race.event_name}")

Launch Race Viewer

# Multiple ways to select a race
manager.race(2024, 24)              # By round number
manager.race(2024, "abu dhabi")     # By event name (case-insensitive)
manager.race(2024, "monaco")        # Partial match works too

# Custom host/port
manager.race(2024, 8, host='localhost', port=8080)

# Force refresh data from FastF1
manager.race(2024, 8, force_update=True)

CLI Usage

# Launch viewer from command line
f1-replay race 2024 monaco
f1-replay race 2024 8 --port 8080

Features

  • Interactive 2D race replay with car positions
  • Telemetry-based animation using FastF1 data
  • Support for all session types (Race, Qualifying, Practice, Sprint)
  • Automatic data caching for fast loading
  • Event name or round number lookup

Requirements

  • Python 3.9+
  • FastF1
  • Flask

Advanced Usage

Direct Data Access

For custom analysis or building your own visualizations:

from f1_replay import Manager

manager = Manager()

# Load session data directly
session = manager.load_race(2024, "monaco")

# Access telemetry
telemetry = session.telemetry["VER"]  # Polars DataFrame
print(f"Telemetry points: {len(telemetry)}")

# Access track geometry
track = session.weekend.track
pit_lane = session.weekend.pit_lane

# Access events and results
weather = session.weather
fastest_laps = session.fastest_laps

Data Loading (DataLoader)

For more control over data loading:

from f1_replay.data_loader import DataLoader

loader = DataLoader(cache_dir="race_data")

# TIER 1: Season catalog
seasons = loader.load_seasons()

# TIER 2: Weekend data (circuit geometry)
weekend = loader.load_weekend(2024, 8)
print(f"Track length: {weekend.circuit.circuit_length:.0f}m")

# TIER 3: Session data (telemetry, events, results)
race = loader.load_session(2024, 8, "Race")

Cache Structure

Data is cached to disk for fast subsequent loads:

race_data/
├── seasons.pkl
└── 2024/
    ├── 08_Monaco/
    │   ├── Weekend.pkl    # Circuit + metadata
    │   └── R.pkl          # Race telemetry
    └── ...

Data Models

TIER 1: F1Seasons - Season catalog with race schedule

TIER 2: F1Weekend - Circuit geometry, pit lane, track segments

TIER 3: SessionData - Telemetry (Polars), events, results per driver

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

f1_replay-0.1.1.tar.gz (51.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

f1_replay-0.1.1-py3-none-any.whl (60.0 kB view details)

Uploaded Python 3

File details

Details for the file f1_replay-0.1.1.tar.gz.

File metadata

  • Download URL: f1_replay-0.1.1.tar.gz
  • Upload date:
  • Size: 51.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for f1_replay-0.1.1.tar.gz
Algorithm Hash digest
SHA256 adb205c08f79d5cf32341fa9bf7d4281f1d64b8b29cb6dc22937deccbb906e3c
MD5 753bb75474f9b145d4d14bb3a28fc8b2
BLAKE2b-256 1ef35831de4ea1a148fad34e46d437d433998406eefd33b35e234f80f51cbfbe

See more details on using hashes here.

File details

Details for the file f1_replay-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: f1_replay-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 60.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for f1_replay-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a94b771f6d60258e51dc2deab42ad8245ddbce77a9a8b3b4b22b069dde98fcce
MD5 c2ce82895bfcaf091bb423c1e00e9209
BLAKE2b-256 4d3fa9ed650073e298b1aacd6105ea7850f98d0591e79e2232c92de2e7d7d9a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page