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
7e7c960f
Commit
7e7c960f
authored
2 weeks ago
by
Lennard Geese
Browse files
Options
Downloads
Patches
Plain Diff
Integrate new weather fetching from wikipedia into active weather analysis
parent
4143b8eb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
DataAnalyser.py
+22
-1
22 additions, 1 deletion
DataAnalyser.py
DataImporter.py
+17
-5
17 additions, 5 deletions
DataImporter.py
main.py
+8
-7
8 additions, 7 deletions
main.py
with
47 additions
and
13 deletions
DataAnalyser.py
+
22
−
1
View file @
7e7c960f
...
@@ -4,6 +4,7 @@ import string
...
@@ -4,6 +4,7 @@ import string
import
pandas
as
pandas
import
pandas
as
pandas
from
fastf1.core
import
Session
,
Lap
,
Laps
,
DataNotLoadedError
from
fastf1.core
import
Session
,
Lap
,
Laps
,
DataNotLoadedError
from
bs4
import
BeautifulSoup
from
bs4
import
BeautifulSoup
from
fastf1.events
import
Event
from
DataHandler
import
DataHandler
from
DataHandler
import
DataHandler
...
@@ -145,7 +146,27 @@ class DataAnalyser(DataHandler):
...
@@ -145,7 +146,27 @@ class DataAnalyser(DataHandler):
raise
KeyError
(
"
No weather entry found
"
)
raise
KeyError
(
"
No weather entry found
"
)
def
filterForRainSessions
(
self
,
sessions
:
list
[
Session
]):
def
filterForWetEvents
(
self
,
events
:
list
[
Event
]):
"""
Filter out & return only those events from input list that had wet conditions in any notable capacity according
to their respective wikipedia pages.
:param sessions: List of sessions from which to pick out sessions with rain.
:return: List of sessions which had rain falling during the session for any amount of time.
"""
from
DataImporter
import
DataImporter
# here due to circular dependency
wetEvents
:
list
[
Event
]
=
[]
importer
=
DataImporter
()
for
event
in
events
:
print
(
f
"
Filtering
{
event
.
year
}
{
event
[
"
EventName
"
]
}
"
)
weatherDescription
:
string
=
importer
.
fetchWeather
(
event
)
if
self
.
isWet
(
weatherDescription
):
wetEvents
.
append
(
event
)
return
wetEvents
# TODO: Rename (other than legacy)
@DeprecationWarning
def
filterForRainSessionsLEGACY
(
self
,
sessions
:
list
[
Session
]):
"""
"""
Filter out & return only those sessions from input list that had rain falling at any point during the session.
Filter out & return only those sessions from input list that had rain falling at any point during the session.
...
...
This diff is collapsed.
Click to expand it.
DataImporter.py
+
17
−
5
View file @
7e7c960f
...
@@ -100,18 +100,20 @@ class DataImporter(DataHandler, ABC):
...
@@ -100,18 +100,20 @@ class DataImporter(DataHandler, ABC):
session
.
load
(
laps
=
laps
,
telemetry
=
telemetry
,
weather
=
weather
,
messages
=
messages
)
session
.
load
(
laps
=
laps
,
telemetry
=
telemetry
,
weather
=
weather
,
messages
=
messages
)
return
session
return
session
def
get
RainRace
sSince
(
self
,
firstYear
:
int
):
def
get
WetEvent
sSince
(
self
,
firstYear
:
int
):
currentYear
=
datetime
.
now
().
year
currentYear
=
datetime
.
now
().
year
if
firstYear
>
currentYear
:
if
firstYear
>
currentYear
:
raise
ValueError
(
"
Cannot get race data from the future :)
"
)
raise
ValueError
(
"
Cannot get race data from the future :)
"
)
rainRaces
:
list
[
Session
]
=
[]
rainRaces
:
list
[
Session
]
=
[]
for
firstYear
in
range
(
firstYear
,
currentYear
):
# FIXME: Handle exception after new years, when no events have run in current year yet
for
firstYear
in
range
(
firstYear
,
currentYear
):
# FIXME: Handle exception after new years, when no events have run in current year yet
wetWeatherRacesInYear
:
list
[
Session
]
=
self
.
get
RainRace
sIn
(
firstYear
)
wetWeatherRacesInYear
:
list
[
Session
]
=
self
.
get
WetEvent
sIn
(
firstYear
)
for
wetWeatherRace
in
wetWeatherRacesInYear
:
for
wetWeatherRace
in
wetWeatherRacesInYear
:
rainRaces
.
append
(
wetWeatherRace
)
rainRaces
.
append
(
wetWeatherRace
)
return
rainRaces
return
rainRaces
# TODO: Rename (other than legacy)
@DeprecationWarning
def
getRainRacesIn
(
self
,
year
:
int
):
def
getRainRacesIn
(
self
,
year
:
int
):
events
:
list
[
Event
]
=
self
.
importAllEventsFromYear
(
year
)
events
:
list
[
Event
]
=
self
.
importAllEventsFromYear
(
year
)
races
:
list
[
Session
]
=
[]
races
:
list
[
Session
]
=
[]
...
@@ -120,10 +122,20 @@ class DataImporter(DataHandler, ABC):
...
@@ -120,10 +122,20 @@ class DataImporter(DataHandler, ABC):
try
:
try
:
raceSession
:
Session
=
self
.
importSessionWeather
(
raceIdentifier
)
raceSession
:
Session
=
self
.
importSessionWeather
(
raceIdentifier
)
races
.
append
(
raceSession
)
races
.
append
(
raceSession
)
except
ValueError
:
# Needed as long as weather data for races before 2018 hasn't been supplemented
except
ValueError
:
# Needed as long as weather data for races before 2018 hasn't been supplemented
print
(
f
"
Weather for
{
event
[
"
EventName
"
]
}
{
event
.
year
}
could not be determined
"
)
print
(
f
"
Weather for
{
event
[
"
EventName
"
]
}
{
event
.
year
}
could not be determined
"
)
analyser
:
DataAnalyser
=
DataAnalyser
()
analyser
:
DataAnalyser
=
DataAnalyser
()
rainRaces
:
list
[
Session
]
=
analyser
.
filterForRainSessions
(
races
)
rainRaces
:
list
[
Session
]
=
analyser
.
filterForRainSessionsLEGACY
(
races
)
return
rainRaces
def
getWetEventsIn
(
self
,
year
:
int
):
print
(
f
"
Fetching wet events in
{
year
}
"
)
events
:
list
[
Event
]
=
self
.
importAllEventsFromYear
(
year
)
analyser
:
DataAnalyser
=
DataAnalyser
()
rainRaces
:
list
[
Session
]
=
analyser
.
filterForWetEvents
(
events
)
return
rainRaces
return
rainRaces
\ No newline at end of file
This diff is collapsed.
Click to expand it.
main.py
+
8
−
7
View file @
7e7c960f
...
@@ -31,9 +31,9 @@ class Main:
...
@@ -31,9 +31,9 @@ class Main:
#dataHandler = Main.DataHandlingPackage()
#dataHandler = Main.DataHandlingPackage()
#dataHandler.plotter.plotBackgroundPaintTest()
#dataHandler.plotter.plotBackgroundPaintTest()
self
.
testNewRainRaceFetching
()
#
self.testNewRainRaceFetching()
#
self.print
RainRace
s()
self
.
print
WetEvent
s
()
#self.overtakeAnalysis(racesToAnalyse)
#self.overtakeAnalysis(racesToAnalyse)
...
@@ -45,13 +45,14 @@ class Main:
...
@@ -45,13 +45,14 @@ class Main:
isWet
:
bool
=
dataHandler
.
analyser
.
isWet
(
w
)
isWet
:
bool
=
dataHandler
.
analyser
.
isWet
(
w
)
print
(
isWet
)
print
(
isWet
)
def
print
RainRace
s
(
self
):
def
print
WetEvent
s
(
self
):
dataHandler
:
Main
.
DataHandlingPackage
=
Main
.
DataHandlingPackage
()
dataHandler
:
Main
.
DataHandlingPackage
=
Main
.
DataHandlingPackage
()
year
:
int
=
2015
year
:
int
=
2015
rainRaces
:
list
[
Session
]
=
dataHandler
.
importer
.
getRainRacesSince
(
year
)
wetEvents
:
list
[
Event
]
=
dataHandler
.
importer
.
getWetEventsSince
(
year
)
print
(
f
"
Rain races since
{
max
(
year
,
2018
)
}
"
)
print
(
f
"
Wet races since
{
year
}
(according to wikipedia):
"
)
for
rainRace
in
rainRaces
:
for
wetEvent
in
wetEvents
:
print
(
rainRace
)
print
(
f
"
{
wetEvent
.
year
}
{
wetEvent
[
"
EventName
"
]
}
"
)
def
overtakeAnalysis
(
self
,
raceSessionIdentifiers
:
list
[
SessionIdentifier
]):
def
overtakeAnalysis
(
self
,
raceSessionIdentifiers
:
list
[
SessionIdentifier
]):
dataHandler
:
Main
.
DataHandlingPackage
=
self
.
DataHandlingPackage
()
dataHandler
:
Main
.
DataHandlingPackage
=
self
.
DataHandlingPackage
()
...
...
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