PitWall
- 11 Devlogs
- 65 Total hours
A website that analyses f1 data from 2018 and onwards such a, h2h, best lap by sectors, weather analysis, tyre choices and so on
A website that analyses f1 data from 2018 and onwards such a, h2h, best lap by sectors, weather analysis, tyre choices and so on
get_rivalry_report combines session pace, consistency , and career h2h across circuits and years and puts it all together, chart_rivalry_report shows the two side by side using make_subplots
get_circuit_evolution loops get_circuit_dna for a range of years for one circuit and then tracks how top speed and average corner speed change over time although when testing it you might see a spike somewhere which probably means that it was affected by rain
get_reliability_trackertakes a season and tallies each driver’s finishing status per race into finishes, DNFs, and other non-finishes (DNS/DSQ or NC)
get_minisector_dominance splits a lap and figures out which driver had the highest average speed in each one chart_minisector_dominance shows it
get_lap1_analysis compares grid position to position at the end of lap 1 to show how many places a driver gained after the start and the first lap as a whole basically chart_lap1_analysis shows it
Anyway this is from the Hungarian gp which was last week:
get_fuel_effect estimates how much lap time a driver gains from burning off fuel across a race, FastF1 doesn’t have a fuel sensor data, so this is an estimate so it’s not as precise as the actual data chart_fuel_effect compares the estimated fuel effect for a few drivers
get_undercut_effectiveness checks whether pitting earlier than a rival actually gained track position or gave them an advantage, finds when each driver pits, confirms driver1 actually pitted first, measures the time gap between them the lap before driver1 stops, then measures it again a few laps after the rival has also boxed, and the difference between those two numbers tells if the undercut worked although you won’t see this every race actually took me some time to think of an example so that i could test the function and it’s not always effective as you will have older tyres then chart_undercut_effectiveness shows the before/after gap
get_tyre_strategy takes a driver’s laps by stint and shows the used compound (medium, soft, hard, inter and so on) , start lap, end lap, and stint length. chart_tyre_strategy shows it compound by compound and also uses the tyre colors
get_corner_speeds reuses the same logic from mistake detection, but instead of finding the nearest corner to one point, it finds the minimum speed near the apex chart_corner_speeds compares multiple drivers’ apex speed corner by corner for a quali lap also i started working on a fuel load estimator using TyreLife
get_drs_effect checks where drs was used in a lap basically when the rear wing was open (drs zones) and calculates the speed gain within each one, entry speed vs peak
get_lap_delta compares two drivers’ laps by interpolating both onto the same distance grid using then subtracts one from the other at every point to get a time gap across the lap.
get_driver_standings and get_constructor_standings basically show the total points accumulated per team and per driver after a certain race
get_championship_battle tracks points for a list of drivers during a season round by round and adds up the points also, tries to load a Sprint session for the same race if it exists it adds those points too, if not it just moves on since most weekends don’t have one. chart_championship_battle is the chart that shows it and it uses the team colors like the other charts and makes the line dashed if there are teammates
get_overtakes looks at every position swap between consecutive laps , for each pair of laps it takes everyone’s position and checks every pair of drivers to see if their order flipped, also i had to exclude inlaps and outlaps since when you pit usually you drop many positions get_overtake_summary is just a counter for the overtakes chart_overtakes shows it
get_track_evolution looks at how the track itself gets faster as a session goes on, takes every driver’s laps together, sorts them by LapStartTime then tracks a running best lap and an average pace over a window chart_track_evolution visualises it
track_evolution functionget_weather compares average qualifying position for a list of drivers across wet sessions vs. dry sessions and calculates a wet_advantage which is basically just dry avg minus wet avg so a positive number means someone performs better in the rain rather than in the dry. chart_weather visualises it
get_tire_degradation takes each stint and calculates lap-time loss per lap of tyre age. The laps are first filtered so that there are no inaccurate laps and that means excluding laps where there was a red flag, yellow/double yellows, exclude inlaps and outlaps and also if there was a safety car/vsc and also TyreLife > 2 to exclude also the first 2 laps of the stint where in general you have to nurse the tires to warm them up. chart_tire_degradation just visualises it.
get_teammate_gap compares best qualifying times between two teammates across a season. Because not every driver reaches Q3, it falls back Q3 - Q2 - Q1 to find each driver’s actual best time for that quali session. chart_teammate_gap visualises it, red or cyan depending on who was faster.
get_fastest_lap_history finds the fastest lap from every quali session since 2018 as that’s how far the data goes. get_driver_circuit_stats does the same thing but for a driver, pulling qualifying position, race position, fastest lap, and finishing result for each year at a given circuit.
get_sector_improvement breaks a driver’s sector times down by stint and tyre age, using the same filtering to exclude some laps as the degradation function, get_pitstop_performance calculates stop duration by matching a driver’s pit-in lap to their next pit-out lap, discarding anything under 15s or over 60s since those aren’t really representative.
get_h2h_career compares two drivers’ qualifying head-to-head win rate at specific circuits across multiple years, returns a win percentage per location. chart_h2h_career again visualises it.
get_quali_improvement tracks a driver’s best lap time across Q1, Q2 and Q3 using session.results which returns the results from the three sessions. chart_quali_improvement calculates each driver’s progression between 2 sessions (Q1 and Q2 and so on)
get_perfect_lap gets its own chart chart_perfect_lap shows the perfect theoretical lap vs actual best lap where the best lap is the three fastest sectors overall per driver
It classifies a circuit based on its traits (power track, high/low df, high/low drag and so on) get_circuit_dna analyzes the fastest lap telemetry from any session and extracts 6 metrics: full throttle percentage, braking percentage, top speed, average corner speed, low speed corner percentage and high speed cornering percentage.
classify_circuit uses those metrics to label a circuit as High Speed, Power Track, High Downforce, Stop/Go or Balanced. Tested across a few circuits as well
chart_circuit_dna shows a radar chart overlaying multiple circuits so you can visually compare their personalities
get_team_circuit_affinity and get_driver_circuit_affinity calculate average qualifying positions per team and driver based on circuit type
session.results which has cleaner segment timesdict.fromkeys() to remove the duplicatesMistake Detector it compares a driver’s telemetry lap by lap at the same point on track. FastF1 gives car data sampled every few milliseconds but the points aren’t evenly spaced by distance, so I used scipy to interpolate both laps onto a common grid every 10 meters, then subtracted one speed trace from the other to find where time was lost.
detect_mistakes finds every zone where speed dropped more than 5 km/h, calculates time lost using distance ÷ speed physics, and maps each mistake to the nearest turn number using FastF1’s circuit info.
chart_track_mistakes draws the full circuit map colored by speed using matplotlib, green for fast, red for slow and with mistake zones highlighted and labeled with turn number and time lost.
get_perfect_lap finds the best individual three sectors from all of a driver’s qualifying laps and combines them into the theoretical fastest possible lap, showing how much time they left on the table.
chart_perfect_lap visualizes this as a grouped bar chart, green for perfect lap sectors, driver’s color for actual best lap.
NOR had 5 mistake zones totalling 0.77 seconds lost between his best and second best lap. Biggest mistake at Turn 18 — 22.7 km/h speed loss, 0.31 seconds gone.
scipy’s interp1d solved itreturn fig accidentally inside a for loop in chart_race_pace and only the first stint would show upSpent this week visualising the data itself and turning it into interactive charts.
chart_race_pace shows a driver’s lap times across the entire race with each stint colored by tire compound. Pit laps are shown as grey X markers so you can see the inlaps and outlaps.
chart_head_to_head overlays two drivers’ pace on the same chart using their official team colors pulled directly from the session data. When comparing teammates who share a color, one line becomes dashed automatically.
chart_consistency compares multiple drivers’ consistency scores as bars. A lower score means that the driver is more consistent.
chart_quali_comparison breaks down each driver’s best qualifying lap into the three sectors side by side, instantly shows where one driver gained or lost time compared to another.
chart_position_change tracks each driver’s position lap by lap through the race, starting from their actual grid position as lap 0 so position gains and losses are accurate.
The position chart was showing drivers starting from the wrong position because FastF1 doesn’t always record lap 1 position data cleanly. Fixed it by pulling the grid position directly from the session info and showing it as lap 0.
The teammate color logic also had to be rethought twice before landing on a simple used_colors list approach that works cleanly.
As an f1 fan and motosports fan in general, I wanted to create something that I’m going to use myself pretty often and work with data that genuinely interests me which is why I’m creating PitWall, a website that analyses data using FastF1, an open source F1 data library. The main idea is to pull real F1 data and let people analyze race pace, quali laps, driver mistakes, simulate alternate race strategies. I’m also going to be using NASA atmospheric data to correlate weather conditions with lap time performance.
Started off by working on analyze.py which for now has 5 functions as the core of the project:
get_clean_lap which filters out sc, vsc laps, track limits and such
get_race_pace calculates the average race pace per stint
get_head_to_head combines 2 drivers’ laps into one table for comparison get_consistency_score uses standard deviation to measure the consistency
get_h2h_summary compares 2 drivers’ pace and tells which one was faster
charts.py to set up the dark F1 color theme and pulled the official team colors from the session data.