02 02 gap analysis view - VforVitorio/F1_Strat_Manager GitHub Wiki
Gap Analysis View
Relevant source files
- scripts/app/components/competitive_analysis_view.py
- scripts/app/components/gap_analysis_view.py
- scripts/app/components/overview_view.py
- scripts/app/components/report_export.py
- scripts/app/components/team_radio_view.py
- scripts/app/components/time_predictions_view.py
Purpose and Scope
The Gap Analysis View is a critical component of the F1 Strategy Manager dashboard that provides comprehensive visualization and analysis of the gaps between cars throughout a race. This view enables strategists to identify potential undercut and overcut opportunities, analyze gap consistency, and detect strategic windows for pit stops. For information about strategy recommendations derived from gap analysis, see Gap Analysis Rules.
Integration with F1 Strategy Manager
Data Flow Process
Core Components
1. Gap Evolution Visualization
The Gap Evolution visualization shows how the gaps to cars ahead and behind changed throughout the race. This helps identify critical phases where relative performance shifted and potential passing opportunities arose.
2. Undercut Opportunities Detection
The Undercut Opportunities visualization identifies specific windows in the race where undercut or overcut strategies were possible based on gap profiles and tire performance.
3. Gap Consistency Analysis
The Gap Consistency Analysis measures how consistently gaps were maintained over multiple laps, which indicates driver performance and tire management capabilities.
4. Strategic Insights Dashboard
The Strategic Insights dashboard provides a summary of identified opportunities based on the gap analysis, including counts of undercut, overcut, and defensive windows.
User Interface Structure
The Gap Analysis View is organized into four tabs that provide different perspectives on the gap data:
- Gap Evolution: Visualizes how gaps to cars ahead and behind evolved throughout the race
- Undercut Opportunities: Shows windows where undercut or overcut strategies were possible
- Gap Consistency: Analyzes how consistently gaps were maintained over multiple laps
- Strategic Insights: Provides a summary of strategic opportunities identified from gap analysis
Tab Structure Implementation
Strategic Windows Calculation
The Gap Analysis View relies on the calculate_strategic_windows
function to identify potential strategic opportunities based on gap data. This function processes raw gap data and adds the following derived fields:
consistent_gap_ahead_laps
: Number of consecutive laps with a consistent gap to the car aheadconsistent_gap_behind_laps
: Number of consecutive laps with a consistent gap to the car behindundercut_opportunity
: Boolean flag indicating a potential undercut opportunityovercut_opportunity
: Boolean flag indicating a potential overcut opportunitydefensive_needed
: Boolean flag indicating a need for defensive strategy
Strategic Window Data Structure
Field | Type | Description |
---|---|---|
LapNumber | int | Lap number in the race |
GapToCarAhead | float | Gap to car ahead in seconds |
GapToCarBehind | float | Gap to car behind in seconds |
consistent_gap_ahead_laps | int | Consecutive laps with consistent gap ahead |
consistent_gap_behind_laps | int | Consecutive laps with consistent gap behind |
undercut_opportunity | bool | Potential undercut opportunity exists |
overcut_opportunity | bool | Potential overcut opportunity exists |
defensive_needed | bool | Defensive strategy needed |
Integration with Export Functionality
The Gap Analysis View integrates with the report export functionality, allowing users to include gap analysis visualizations in exported strategy reports.
Performance Considerations
The Gap Analysis View is designed to handle potentially large datasets efficiently by:
- Limiting displayed laps to a valid range (1-66)
- Using efficient Plotly visualizations for interactive charts
- Error handling to gracefully manage missing or incomplete data
- Conditional rendering of components based on data availability
Practical Application
The Gap Analysis View is particularly useful for:
- Race Strategists: To identify optimal pit stop windows and passing opportunities
- Performance Engineers: To analyze consistent gap maintenance as a driver performance metric
- Team Principals: To understand race dynamics and strategic decision points
- Post-Race Analysis: To evaluate if all strategic opportunities were correctly identified and executed