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
65b65a9a
Commit
65b65a9a
authored
1 week ago
by
Lennard Geese
Browse files
Options
Downloads
Patches
Plain Diff
Reintegrate deprecated rain-filtering and add documentation
parent
7e7c960f
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
DataAnalyser.py
+11
-4
11 additions, 4 deletions
DataAnalyser.py
DataImporter.py
+36
-13
36 additions, 13 deletions
DataImporter.py
with
47 additions
and
17 deletions
DataAnalyser.py
+
11
−
4
View file @
65b65a9a
...
@@ -122,6 +122,15 @@ class DataAnalyser(DataHandler):
...
@@ -122,6 +122,15 @@ class DataAnalyser(DataHandler):
# ===== Weather =====
# ===== Weather =====
def
isWet
(
self
,
weatherDescription
:
string
):
def
isWet
(
self
,
weatherDescription
:
string
):
"""
Determine if a given weather description describes an event with a wet race session, meaning intermediate or wet
tires were used.
Note: The output of this function is not a guarantee for a wet race session. It only matches keywords such as
"
rain
"
and
"
wet
"
in the string, and returns a True for a wet race if any keywords are matched.
:param weatherDescription: Weather of an event as a string. This should be the weather conditions as listed on
the event
'
s wikipedia page.
:return: Boolean of whether the race event was held in wet conditions or not.
"""
keywords
:
list
[
string
]
=
[
"
rain
"
,
"
wet
"
]
keywords
:
list
[
string
]
=
[
"
rain
"
,
"
wet
"
]
for
keyword
in
keywords
:
for
keyword
in
keywords
:
if
keyword
in
weatherDescription
.
lower
():
return
True
if
keyword
in
weatherDescription
.
lower
():
return
True
...
@@ -164,11 +173,9 @@ class DataAnalyser(DataHandler):
...
@@ -164,11 +173,9 @@ class DataAnalyser(DataHandler):
return
wetEvents
return
wetEvents
# TODO: Rename (other than legacy)
def
filterForRainSessions
(
self
,
sessions
:
list
[
Session
]):
@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
for at least 1 minute
during the session.
Note: The sessions returned are not necessarily sessions that had wet conditions for any meaningful amount of
Note: The sessions returned are not necessarily sessions that had wet conditions for any meaningful amount of
time. Also, sessions that had wet conditions only from leftover rainwater on track are not included in the
time. Also, sessions that had wet conditions only from leftover rainwater on track are not included in the
...
...
This diff is collapsed.
Click to expand it.
DataImporter.py
+
36
−
13
View file @
65b65a9a
...
@@ -105,16 +105,48 @@ class DataImporter(DataHandler, ABC):
...
@@ -105,16 +105,48 @@ class DataImporter(DataHandler, ABC):
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
]
=
[]
for
year
in
range
(
firstYear
,
currentYear
):
# FIXME: Handle exception after new years, when no events have run in current year yet
wetWeatherRacesInYear
:
list
[
Session
]
=
self
.
getWetEventsIn
(
year
)
for
wetWeatherRace
in
wetWeatherRacesInYear
:
rainRaces
.
append
(
wetWeatherRace
)
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
def
getRainRacesSince
(
self
,
firstYear
:
int
):
"""
Retrieve all race sessions since and including given year that had at least one minute of rainfall during the race session.
:param firstYear: First year from which to retrieve race sessions.
:return: List of all race sessions from given year until present that had at least 1 minute of rainfall.
"""
currentYear
=
datetime
.
now
().
year
if
firstYear
>
currentYear
:
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
WetEvent
sIn
(
firstYear
)
wetWeatherRacesInYear
:
list
[
Session
]
=
self
.
get
RainRace
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
):
"""
Retrieve all race sessions from given year that had at least one minute of rainfall during the race session.
:param year: Year from which to retrieve races.
:return: List of all race sessions from given year that had at least 1 minute of rainfall.
"""
events
:
list
[
Event
]
=
self
.
importAllEventsFromYear
(
year
)
events
:
list
[
Event
]
=
self
.
importAllEventsFromYear
(
year
)
races
:
list
[
Session
]
=
[]
races
:
list
[
Session
]
=
[]
for
event
in
events
:
for
event
in
events
:
...
@@ -126,16 +158,7 @@ class DataImporter(DataHandler, ABC):
...
@@ -126,16 +158,7 @@ class DataImporter(DataHandler, ABC):
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
.
filterForRainSessionsLEGACY
(
races
)
rainRaces
:
list
[
Session
]
=
analyser
.
filterForRainSessions
(
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
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