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

Whoopsie I deleted the changes, here they are back again

parent 461332d6
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ from DataHandler import DataHandler ...@@ -12,7 +12,7 @@ from DataHandler import DataHandler
class DataPlotter(DataHandler): class DataPlotter(DataHandler):
def plotOvertakesWithTireChangeWindow(self, overtakesPerLap: List[int], earliestTireChange: int, latestTireChange: int): def plotOvertakesWithTireChangeWindow(self, overtakesPerLap: List[int], earliestTireChange: int, latestTireChange: int, raceName: str):
overtakesPerLap.insert(0, 0) # Insert 0th lap, which cannot have overtakes overtakesPerLap.insert(0, 0) # Insert 0th lap, which cannot have overtakes
laps: int = len(overtakesPerLap) laps: int = len(overtakesPerLap)
...@@ -24,6 +24,7 @@ class DataPlotter(DataHandler): ...@@ -24,6 +24,7 @@ class DataPlotter(DataHandler):
axis.set_xlabel('Lap') axis.set_xlabel('Lap')
axis.set_ylabel('Position changes in lap') axis.set_ylabel('Position changes in lap')
plt.title(raceName)
major_ticks_laps = np.arange(0, laps, 5) major_ticks_laps = np.arange(0, laps, 5)
major_ticks_overtakes = np.arange(0, max(overtakesPerLap) + 1, 5) major_ticks_overtakes = np.arange(0, max(overtakesPerLap) + 1, 5)
......
...@@ -19,10 +19,10 @@ class Main: ...@@ -19,10 +19,10 @@ class Main:
def main(self): def main(self):
# contains pairs of season & race number to identify specific races # contains pairs of season & race number to identify specific races
race_indexes = [ race_indexes = [
[2022, 4] # Imola 2022 (DWR) [2022, 4], # Imola 2022 (DWR)
# [2024, 7] # Imola 2024 (SWR) [2024, 7], # Imola 2024 (SWR)
# [2024, 9] # Canada 2024 (DWR) [2024, 9], # Canada 2024 (DWR)
# [2023, 8] # Canada 2023 (SWR)
# TODO: add more races # TODO: add more races
] ]
...@@ -31,10 +31,14 @@ class Main: ...@@ -31,10 +31,14 @@ class Main:
plotter = DataPlotter() plotter = DataPlotter()
for race_index in race_indexes: for race_index in race_indexes:
# Import # Import
raceSession = importer.importRaceSession(race_index) raceSession = importer.importRaceSession(race_index)
raceName: str = f"{raceSession.event['EventName']} {raceSession.event.year}"
print("Import done") print("Import done")
# Analyse # Analyse
overtakesInRaces: List[int] = analyser.analyseRaceForOvertakes(raceSession) overtakesInRaces: List[int] = analyser.analyseRaceForOvertakes(raceSession)
print("Overtake analysis done") print("Overtake analysis done")
...@@ -44,11 +48,13 @@ class Main: ...@@ -44,11 +48,13 @@ class Main:
latestTireChange: int = analyser.getLatestTireChange(raceSession) latestTireChange: int = analyser.getLatestTireChange(raceSession)
print("Last tire change done") print("Last tire change done")
plotter.plotOvertakesWithTireChangeWindow(overtakesInRaces, earliestTireChange, latestTireChange)
print("Plot done")
# Plot
plotter.plotOvertakesWithTireChangeWindow(overtakesInRaces, earliestTireChange, latestTireChange, raceName)
print("Plot done")
# Print data
print(f"\n\n===== Data for race {race_index[0]}/{race_index[1]} =====") print(f"\n\n===== Data for race {race_index[0]}/{race_index[1]} =====")
print("Lap\tOvertakes") print("Lap\tOvertakes")
currentLap = 0 currentLap = 0
...@@ -60,70 +66,6 @@ class Main: ...@@ -60,70 +66,6 @@ class Main:
print(f"Weather change window is therefore: laps {earliestTireChange-1} - {latestTireChange+1}") print(f"Weather change window is therefore: laps {earliestTireChange-1} - {latestTireChange+1}")
def fastF1Example(self):
# Load FastF1's dark color scheme
fastf1.plotting.setup_mpl(mpl_timedelta_support=False, misc_mpl_mods=False,
color_scheme='fastf1')
session = fastf1.get_session(2024, 7, 'R')
session.load(laps=True, weather=True)
figure, axis = plt.subplots(figsize=(8.0, 4.9))
for driver in session.drivers:
driverLaps = session.laps.pick_drivers(driver)
driverAbbreviation = driverLaps['Driver'].iloc[0]
style = fastf1.plotting.get_driver_style(identifier=driverAbbreviation,
style=['color', 'linestyle'],
session=session)
axis.plot(driverLaps['LapNumber'], driverLaps['Position'],
label=driverAbbreviation, **style)
axis.set_ylim([20.5, 0.5])
axis.set_yticks([1, 5, 10, 15, 20])
axis.set_xlabel('Lap')
axis.set_ylabel('Position')
axis.legend(bbox_to_anchor=(1.0, 1.02))
plt.tight_layout()
plt.show()
def oldJavaTransfer(self):
# contains pairs of season & race number to identify specific races
race_indexes = [
[2024, 7], # Imola 2024
[2022, 4] # Imola 2022
# TODO: add more races
]
importer = DataImporter()
checker = DataChecker()
analyser = DataAnalyser()
# plotter = DataPlotter() # Commented as it's not used
races = importer.import_laps_for_races(race_indexes)
checker.check_imported_races(races)
overtakes_in_races = analyser.count_overtakes_in_races(races)
print(f"Data for race {race_indexes[0][1]}/{race_indexes[0][0]}")
for current_lap in range(len(overtakes_in_races[0])):
print(f"Overtakes in lap {current_lap + 1}: {overtakes_in_races[0][current_lap]}")
return overtakes_in_races
if __name__ == '__main__': if __name__ == '__main__':
app = Main() app = Main()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment