Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
F1 Overtake Analyser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lennard Geese
F1 Overtake Analyser
Commits
ee50564e
Commit
ee50564e
authored
1 month ago
by
Lennard Geese
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DataPlotter.py
+2
-1
2 additions, 1 deletion
DataPlotter.py
main.py
+12
-70
12 additions, 70 deletions
main.py
with
14 additions
and
71 deletions
DataPlotter.py
+
2
−
1
View file @
ee50564e
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
main.py
+
12
−
70
View file @
ee50564e
...
@@ -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
\t
Overtakes
"
)
print
(
"
Lap
\t
Overtakes
"
)
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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment