diff --git a/DataAnalyser.py b/DataAnalyser.py index 38f4c9e90338ef3d2d4fc6c795bda9eab16cd87d..ee480342fc4693c8576ab3b72fa1505833eecfe3 100644 --- a/DataAnalyser.py +++ b/DataAnalyser.py @@ -110,60 +110,6 @@ class DataAnalyser(DataHandler): - - def getGridPositions(self, race: Session): - sessionResults = race.results - gridPositions: dict[str, int] = {} # driverId & lapNumber - for i in range(self.numberOfDrivers): - driverPosition = sessionResults['GridPosition'].iloc[i] - driverAbbreviation = sessionResults['Abbreviation'].iloc[i] - gridPositions[driverAbbreviation] = driverPosition - - if self.activateDebugOvertakeAnalysis: - print(f"\nLap: 0") - for i in range(len(gridPositions)): - position: int = i + 1 - gridPositions.values() - driverAtPosition = self.getDriverByPositionFromMap(gridPositions, position) - print(f"P{position}: {driverAtPosition}") - - return gridPositions - - def getRunningLapsPositions(self, race: Session): - runningLapsPositions: list[dict[str, int]] = [] - allRaceLaps = race.laps - - for raceLapIndex in range(race.total_laps): - runningLapPositions: dict[str, int] = {} # driverId & lapNumber - for driver in race.drivers: - raceLap = allRaceLaps.pick_laps(raceLapIndex + 1) # Lap 0 doesn't exist - raceLap = raceLap.pick_drivers(driver) - try : - driverAbbreviation = raceLap['Driver'].iloc[0] - driverPosition = raceLap['Position'].iloc[0] - runningLapPositions[driverAbbreviation] = driverPosition - except: # triggered when not all drivers that took part reached lap end (i.e. when value is NaN), probably by crashing or being behind - x = 0 # do nothing - runningLapsPositions.append(runningLapPositions) - - # debug - if self.activateDebugOvertakeAnalysis: - for raceLapIndex in range(race.total_laps): - print(f"\nLap: {raceLapIndex + 1}") - runningLapPositions = runningLapsPositions[raceLapIndex] - for i in range(len(runningLapPositions)): - runningLapPositions.values() - position: int = i + 1 - driverAtPosition = self.getDriverByPositionFromMap(runningLapPositions, position) - print(f"P{position}: {driverAtPosition}") - - return runningLapsPositions - - def getDriverByPositionFromMap(self, positions: dict[str, int], position: int): - driver = list(positions.keys())[list(positions.values()).index(position)] - return driver - - # ===== Weather ===== def analyseRacesForWeather(self, races: list[Session]): @@ -177,6 +123,8 @@ class DataAnalyser(DataHandler): x = 0 return 0 + + # ===== Tire Changes ===== def getEarliestTireChanges(self, races: list[Session]): @@ -272,11 +220,15 @@ class DataAnalyser(DataHandler): if startingCompound == 'SLICK': return self.slickCompounds return startingCompound + + # ===== Crashes ===== def analyseRacesForCrashes(self, races): x = 0 + + # ===== Events ===== def analyseRacesForSafetyCars(self, races):