Skip to content
Snippets Groups Projects
Commit 285b7992 authored by Lennard Geese's avatar Lennard Geese
Browse files

Implement plotting multiple weather change windows

parent 049c1042
No related branches found
No related tags found
No related merge requests found
......@@ -18,4 +18,13 @@ class SessionIdentifier:
def __init__(self, year: int, event: int | str, sessionType: str = "R"):
self.year = year
self.event = event
self.sessionType = sessionType
\ No newline at end of file
self.sessionType = sessionType
class WeatherChangeWindow:
firstLap: int
lastLap: int
def __init__(self, firstTireChange: int, lastTireChange: int):
self.firstLap = firstTireChange - 1
self.lastLap = lastTireChange + 1
\ No newline at end of file
......@@ -7,13 +7,11 @@ import matplotlib as mpl
import numpy as np
from matplotlib.colors import ListedColormap
from DataHandler import DataHandler
from DataHandler import DataHandler, WeatherChangeWindow
# TODO: Adjust input parameters for multiple weather change windows
class DataPlotter(DataHandler):
def plotOvertakesWithTireChangeWindow(self, overtakesPerLap: list[int], firstTireChange: int, lastTireChange: int, raceName: str):
firstTireChange -= 1
lastTireChange += 1
def plotOvertakes(self, overtakesPerLap: list[int], raceName: str, weatherChangeWindows: list[WeatherChangeWindow] = None):
# Define variables
laps: int = len(overtakesPerLap)
......@@ -27,7 +25,8 @@ class DataPlotter(DataHandler):
plt.plot(x_values, overtakesPerLap)
# Paint background between first and last tire change
axis.axvspan(firstTireChange, lastTireChange, color='blue', alpha=0.3)
for weatherChangeWindow in weatherChangeWindows:
axis.axvspan(weatherChangeWindow.firstLap, weatherChangeWindow.lastLap, color='blue', alpha=0.3)
# Label stuff
axis.set_xlabel('Lap')
......
......@@ -3,6 +3,7 @@
- [x] Adjust for pitstop discrepancies
- [x] Fetch rain races via API, not Reddit
- [x] Paint back of graph for weather change window
- Also implemented for multiple weather changes
- [ ] Adjust for position changes caused by crashes (keep out of calculation similarly to PCs due to pitstops ?)
- [ ] Include safety car periods & driver crashes
- [ ] Automatically determine if race is DWR or SWR
......
from fastf1.core import Session
from fastf1.events import Event
import DataHandler
from DataAnalyser import DataAnalyser
from DataChecker import DataChecker
from DataHandler import SessionIdentifier
......@@ -63,7 +64,8 @@ class Main:
# Plot
dataHandler.plotter.plotOvertakesWithTireChangeWindow(overtakesInRaces, earliestTireChange, latestTireChange, grandPrixName)
weatherChangeWindow = DataHandler.WeatherChangeWindow(earliestTireChange, latestTireChange)
dataHandler.plotter.plotOvertakes(overtakesInRaces, grandPrixName, [weatherChangeWindow])
print("Plot done")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment