Data Objects

Season

The Season class represents a Formula 1 season, containing methods to load and manage the season’s meetings and sessions.

Example:

from livef1.models.season import Season

# Initialize a season for the year 2023
season_2023 = Season(year=2023, meetings=[])

# Load the season data
season_2023.load()

# Access the meetings
meetings = season_2023.meetings

Meeting

The Meeting class represents a meeting in a specific season with relevant details and associated sessions.

Example:

from livef1.models.meeting import Meeting

# Initialize a meeting
meeting = Meeting(season=season_2023, year=2023, location="Monaco")

# Load the meeting data
meeting.load()

# Access the sessions
sessions = meeting.sessions

Session

The Session class represents a Formula 1 session, containing methods to retrieve live timing data and process it.

Example:

from livef1.models.session import Session

# Initialize a session
session = Session(season=season_2023, meeting=meeting, name="Practice 1")

# Get topic names
topic_names = session.get_topic_names()

# Load data for a specific topic
data = session.load_data(dataName="Car_Data")

Generating Data

The generate method in the Session class is used to generate and save processed data tables (silver and gold tables) for the session. This is useful for organizing and accessing detailed session data efficiently.

Example:

# Generate silver tables for the session
session.generate(silver=True, gold=False)

# Access the generated data
laps = session.get_laps()
telemetry = session.get_car_telemetry()
weather = session.get_weather()
timing = session.get_timing()

Why Run .generate

Running the .generate method is important for the following reasons:

  1. Data Organization: It organizes raw data into structured tables, making it easier to analyze and visualize.

  2. Efficiency: Preprocessing and storing data in tables reduces the need for repeated data parsing and processing.

  3. Accessibility: Generated tables can be accessed directly through the session object, simplifying data retrieval.

models.Season(year, meetings)

Represents a Formula 1 season, containing methods to load and manage the season's meetings and sessions.

models.Meeting([season, year, code, key, ...])

Represents a meeting in a specific season with relevant details and associated sessions.

models.Session([season, year, meeting, key, ...])

Represents a Formula 1 session, containing methods to retrieve live timing data and process it.

livef1.get_meeting(season: int, meeting_identifier: str = None, meeting_key: int = None) Meeting[source]

Retrieve data for a specific meeting in a given season.

Parameters:
seasonint

The year of the season to retrieve the meeting from.

meeting_identifierstr

The identifier (e.g., circuit name, grand prix name) of the meeting. The identifier is going to be searched in the season’s meeting table columns:

  • “Meeting Official Name”

  • “Meeting Name”

  • “Circuit Short Name”

Therefore, it is suggested to use keywords that is distinguishable among meetings. Another suggestion is using circuit names for querying.

meeting_keyint

The key of the meeting to get the desired meeting whose key is matching.

Returns:
Meeting

A Meeting object containing sessions and metadata for the specified meeting.

Raises:
livef1Exception

If the meeting cannot be found based on the provided parameters.

livef1.get_season(season: int) Season[source]

Retrieve data for a specified Formula 1 season.

Parameters:
seasonint

The year of the season to retrieve.

Returns:
Season

A Season object containing all meetings and sessions for the specified year.

Raises:
livef1Exception

If no data is available for the specified season.

livef1.get_session(season: int, meeting_identifier: str = None, session_identifier: str = None, meeting_key: int = None, session_key: int = None) Session[source]

Retrieve data for a specific session within a meeting and season.

Parameters:
seasonint

The year of the season.

meeting_identifierstr

The identifier (e.g., circuit name, grand prix name) of the meeting. The identifier is going to be searched in the season’s meeting table columns:

  • “Meeting Official Name”

  • “Meeting Name”

  • “Circuit Short Name”

Therefore, it is suggested to use keywords that is distinguishable among meetings. Another suggestion is using circuit names for querying.

meeting_keyint

The key of the meeting to get the desired meeting whose key is matching.

session_identifierstr

The identifier of the session (e.g., “Practice 1”, “Qualifying”). The identifier is going to be searched in the meeting’s sessions table.

session_keyint

The key of the session to get the desired session whose key is matching.

Returns:
Session

A Session object containing data about the specified session.

Raises:
livef1Exception

If the session cannot be found based on the provided parameters.

livef1.set_log_level(level)[source]

Set the logging level for the livef1 logger.

Parameters:
levelUnion[str, int]

The logging level to set. Can be either a string (‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’) or the corresponding integer value.

Examples

>>> set_log_level('DEBUG')  # Set to debug level
>>> set_log_level(logging.INFO)  # Set to info level