Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TracingInsights/tif1/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Lap class is a pandas Series representing a single lap with timing data and telemetry access. It extends pandas Series to provide convenient access to lap-specific data.
Properties
session
Reference to the parent Session object.
driver
Driver code for this lap (e.g., “VER”, “HAM”).
lap_number
Lap number.
telemetry
lap.telemetry -> Telemetry
Get telemetry data for this lap.
Returns: Telemetry DataFrame with telemetry data:
Time: Time offset from lap start (timedelta)
SessionTime: Time offset from session start (timedelta)
Speed: Speed in km/h (float)
RPM: Engine RPM (int)
nGear: Gear number (int)
Throttle: Throttle position 0-100 (float)
Brake: Brake status (bool or 0-100)
DRS: DRS status (int)
X, Y, Z: Position coordinates (float)
Distance: Distance along track in meters (float)
Returns empty DataFrame if telemetry not available.
Methods
get_telemetry
lap.get_telemetry() -> Telemetry
Get telemetry data with driver-ahead channels added.
Returns: Telemetry DataFrame with additional columns:
DriverAhead: Driver code of the driver ahead
DistanceToDriverAhead: Distance to driver ahead in meters
get_car_data
lap.get_car_data() -> Telemetry
Get car data (alias for telemetry property).
Returns: Telemetry DataFrame
get_pos_data
lap.get_pos_data() -> Telemetry
Get position data (alias for telemetry property).
Returns: Telemetry DataFrame
get_weather_data
lap.get_weather_data() -> pd.Series
Get weather data for this lap.
Returns: Empty pandas Series (weather data is session-level, not lap-specific)
Lap Data Attributes
The Lap object contains the following timing data as pandas Series values:
LapNumber (int): Lap number
LapTime (timedelta): Total lap time
LapTimeSeconds (float): Lap time in seconds
Driver (str): Driver code
Team (str): Team name
Position (int): Position at end of lap
Sector1Time (timedelta): Sector 1 time
Sector2Time (timedelta): Sector 2 time
Sector3Time (timedelta): Sector 3 time
Compound (str): Tyre compound (e.g., “SOFT”, “MEDIUM”, “HARD”)
TyreLife (int): Tyre age in laps
Stint (int): Stint number
TrackStatus (str): Track status code
IsPersonalBest (bool): Whether this is the driver’s personal best
IsAccurate (bool): Whether timing is accurate
PitInTime (timedelta): Pit entry time (if applicable)
PitOutTime (timedelta): Pit exit time (if applicable)
SpeedI1, SpeedI2, SpeedFL, SpeedST (float): Speed trap readings
AirTemp, TrackTemp, Humidity, Pressure (float): Weather conditions
FreshTyre (bool): Whether fresh tyres were fitted
Deleted (bool): Whether lap was deleted
DeletedReason (str): Reason for deletion
Usage Examples
Accessing Lap Data
import tif1
session = tif1.get_session(2025, "Monaco Grand Prix", "Qualifying")
driver = session.get_driver("VER")
lap = driver.get_lap(15)
# Access timing data
print(f"Lap {lap.lap_number}")
print(f"Driver: {lap.driver}")
print(f"Lap time: {lap['LapTime']}")
print(f"Sector 1: {lap['Sector1Time']}")
print(f"Sector 2: {lap['Sector2Time']}")
print(f"Sector 3: {lap['Sector3Time']}")
print(f"Position: {lap['Position']}")
print(f"Compound: {lap['Compound']}")
print(f"Tyre life: {lap['TyreLife']} laps")
Getting Telemetry
lap = driver.get_lap(15)
tel = lap.telemetry
if not tel.empty:
print(f"Telemetry samples: {len(tel)}")
print(f"Max speed: {tel['Speed'].max():.1f} km/h")
print(f"Min speed: {tel['Speed'].min():.1f} km/h")
print(f"Average speed: {tel['Speed'].mean():.1f} km/h")
lap = driver.get_lap(15)
# Get sector times
s1 = lap['Sector1Time'].total_seconds()
s2 = lap['Sector2Time'].total_seconds()
s3 = lap['Sector3Time'].total_seconds()
total = lap['LapTime'].total_seconds()
print(f"Sector 1: {s1:.3f}s ({s1/total*100:.1f}%)")
print(f"Sector 2: {s2:.3f}s ({s2/total*100:.1f}%)")
print(f"Sector 3: {s3:.3f}s ({s3/total*100:.1f}%)")
Telemetry Analysis
lap = driver.get_lap(15)
tel = lap.telemetry
if not tel.empty:
# Speed analysis
max_speed = tel['Speed'].max()
speed_at_finish = tel['Speed'].iloc[-1]
print(f"Max speed: {max_speed:.1f} km/h")
print(f"Speed at finish line: {speed_at_finish:.1f} km/h")
# Throttle analysis
full_throttle = (tel['Throttle'] >= 99).sum()
full_throttle_pct = full_throttle / len(tel) * 100
print(f"Full throttle: {full_throttle_pct:.1f}% of lap")
# Gear usage
gear_counts = tel['nGear'].value_counts().sort_index()
print("Gear usage:")
for gear, count in gear_counts.items():
pct = count / len(tel) * 100
print(f" Gear {gear}: {pct:.1f}%")
# DRS usage
if 'DRS' in tel.columns:
drs_active = (tel['DRS'] > 0).sum()
drs_pct = drs_active / len(tel) * 100
print(f"DRS active: {drs_pct:.1f}% of lap")
Comparing Laps
driver = session.get_driver("VER")
lap1 = driver.get_lap(5)
lap2 = driver.get_lap(15)
# Compare lap times
time_diff = (lap2['LapTime'] - lap1['LapTime']).total_seconds()
print(f"Time difference: {time_diff:+.3f}s")
# Compare sector times
for sector in [1, 2, 3]:
col = f"Sector{sector}Time"
diff = (lap2[col] - lap1[col]).total_seconds()
print(f"Sector {sector} diff: {diff:+.3f}s")
# Compare compounds
print(f"Lap 5 compound: {lap1['Compound']}")
print(f"Lap 15 compound: {lap2['Compound']}")
print(f"Tyre age difference: {lap2['TyreLife'] - lap1['TyreLife']} laps")
Speed Trap Analysis
lap = driver.get_lap(15)
# Check speed traps
speed_traps = {
'Intermediate 1': lap['SpeedI1'],
'Intermediate 2': lap['SpeedI2'],
'Finish Line': lap['SpeedFL'],
'Speed Trap': lap['SpeedST']
}
for trap_name, speed in speed_traps.items():
if not pd.isna(speed):
print(f"{trap_name}: {speed:.1f} km/h")
Checking Lap Validity
lap = driver.get_lap(15)
print(f"Is accurate: {lap['IsAccurate']}")
print(f"Is personal best: {lap['IsPersonalBest']}")
print(f"Is deleted: {lap['Deleted']}")
if lap['Deleted']:
print(f"Deletion reason: {lap['DeletedReason']}")
# Check for pit stop
if not pd.isna(lap['PitInTime']) or not pd.isna(lap['PitOutTime']):
print("This lap includes a pit stop")
if not pd.isna(lap['PitInTime']):
print(f"Pit entry at: {lap['PitInTime']}")
if not pd.isna(lap['PitOutTime']):
print(f"Pit exit at: {lap['PitOutTime']}")
Weather Conditions
lap = driver.get_lap(15)
print(f"Air temp: {lap['AirTemp']:.1f}°C")
print(f"Track temp: {lap['TrackTemp']:.1f}°C")
print(f"Humidity: {lap['Humidity']:.1f}%")
print(f"Pressure: {lap['Pressure']:.1f} mbar")
See Also