## Python tool to extract data from F1 app

Post here all non technical related topics about Formula One. This includes race results, discussions, testing analysis etc. TV coverage and other personal questions should be in Off topic chat.
Oehrly
32
Joined: Mon Jan 08, 2018 4:53 pm

### Re: Python tool to extract data from F1 app

I've played around with syncing the laps based on the speed trap data now. It seems to work in principle but I haven't yet achieved better accuracy than what we have currently.

So far I've only used two data samples as a reference for calculating the correct time at which the lap starts. I've simply used the one where the speed is still lower than at the speed trap and the one right after, where the speed is higher. And I used linear interpolation to get a more accurate time as the sample rate is only about 5Hz.
There is still too much variation with that approach though.

I think I need to try something slightly more elaborate. Maybe take some samples before and after the speed trap, fit a curve through those points and calculate the time based on that. When plotting the speed trace, it is not exactly smooth. I think the curve fitting could maybe improve the results by smoothing out the speed data.

Oehrly
32
Joined: Mon Jan 08, 2018 4:53 pm

### Re: Python tool to extract data from F1 app

So, this took a while but I finally have some more concrete results on the speed trap synchronization.

The data shown is from this year's Hungary race.
To smooth out the speed trace and for better interpolation results I am fitting a 3rd order polynomial over a 5-second window of data. Through some trial and error this has proven to give the best result.

There are two metrics I use to evaluate the accuracy of the result.
The first is the variance of the finish line position.
The second is what I call "lap time integrity". The lap times are of course know very accurately. The time between the beginning of two subsequent laps should in theory be exactly the lap time. But this is not the case because of some inaccuracies when calculating the time. The difference between the correct lap duration and the calculated lap duration is what is shown in the second comparison.

All comparisons are shown as histograms to easily visualize the distribution of values. (Note that the width of the bins is not exactly the same, but it's close enough to compare the result)

A few things can be observed:
1. The speed trap sync is less accurate. Both distributions are wider than when using the current sync implementation.
2. The average finish line position is about 20-30m earlier in the lap when synchronizing based on the finish line. Which one is more correct is difficult to say. I don't think a 30m error to the actual position would be too much of a problem as long as it is a constant error for all laps.
3. The small extra heap at -1250 in the "X Pos hist orig" are in and out laps.

Conclusion: Synchronizing based on the finish line speed trap is not better than the current way.

Additionally, 5-10m of position variance and about 0.05s of lap time length error are not that bad really. It, of course, means that we can't look at a graph and say "driver ABC is breaking 10m later than some other driver into this corner". I'd really like it if we were able to get the accuracy down to that level but I am starting to doubt it.