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