"""Canonical raw names consumed by the supplied training compressor.""" from types import MappingProxyType MEAN_COLUMNS: tuple[str, ...] = ( "RPM", "Speed", "nGear", "Throttle", "Brake", "DRS", "X", "Y", "Z", "DistanceToDriverAhead", "AirTemp", "TrackTemp", "Humidity", "Pressure", "WindDirection", "WindSpeed", ) LAST_COLUMNS: tuple[str, ...] = ( "Date", "SessionTime", "Time", "Distance", "RelativeDistance", "DriverAhead", "TrackStatus", "Driver", "DriverNumber", "Team", "LapNumber", "Stint", "Compound", "TyreLife", "FreshTyre", "LapTime", "Sector1Time", "Sector2Time", "Sector3Time", "Sector1SessionTime", "Sector2SessionTime", "Sector3SessionTime", "SpeedI1", "SpeedI2", "SpeedFL", "SpeedST", "IsPersonalBest", "Position", "PitInTime", "PitOutTime", "LapStartTime", "LapStartDate", ) SUM_COLUMNS: tuple[str, ...] = ("DifferentialDistance",) MAX_COLUMNS: tuple[str, ...] = ("Rainfall",) # The compressor contract contains 50 unique fields. The source artifact that # proves the names of all 54 original CSV columns is not stored in this repo, so # the four unused names must remain explicitly unknown rather than guessed. PIPELINE_RAW_COLUMNS: tuple[str, ...] = tuple( dict.fromkeys(MEAN_COLUMNS + LAST_COLUMNS + SUM_COLUMNS + MAX_COLUMNS) ) ORIGINAL_RAW_COLUMN_COUNT = 54 UNIDENTIFIED_UNUSED_RAW_COLUMN_COUNT = ( ORIGINAL_RAW_COLUMN_COUNT - len(PIPELINE_RAW_COLUMNS) ) # Live-only state fields are normalized for lifecycle tracking but are not part # of the compressor or model feature contract. LIVE_STATE_COLUMNS: tuple[str, ...] = ( "SessionStatus", "CurrentLap", "TotalLaps", ) NORMALIZED_RAW_COLUMNS: tuple[str, ...] = PIPELINE_RAW_COLUMNS + LIVE_STATE_COLUMNS NUMERIC_RAW_COLUMNS: frozenset[str] = frozenset( MEAN_COLUMNS + SUM_COLUMNS + MAX_COLUMNS + ( "Distance", "RelativeDistance", "DriverNumber", "LapNumber", "Stint", "TyreLife", "LapTime", "Sector1Time", "Sector2Time", "Sector3Time", "Sector1SessionTime", "Sector2SessionTime", "Sector3SessionTime", "SpeedI1", "SpeedI2", "SpeedFL", "SpeedST", "IsPersonalBest", "Position", "CurrentLap", "TotalLaps", ) ) BOOLEAN_RAW_COLUMNS: frozenset[str] = frozenset( {"FreshTyre", "IsPersonalBest", "Rainfall"} ) STRING_RAW_COLUMNS: frozenset[str] = frozenset( { "Driver", "DriverAhead", "Team", "Compound", "TrackStatus", "SessionStatus", } ) # Add provider-specific aliases here after inspecting real LiveF1 samples. FIELD_ALIASES = MappingProxyType( { "Date": ("Date", "Utc", "UTC", "date", "timestamp"), "Driver": ("Driver", "Tla", "NameAcronym", "driver"), "DriverNumber": ( "DriverNumber", "DriverNo", "RacingNumber", "driver_number", ), "LapNumber": ("LapNumber", "NumberOfLaps", "lap_number"), "RPM": ("RPM", "Rpm", "rpm"), "Speed": ("Speed", "speed"), "nGear": ("nGear", "Gear", "gear", "n_gear"), "Throttle": ("Throttle", "throttle"), "Brake": ("Brake", "brake"), "DRS": ("DRS", "Drs", "drs"), "X": ("X", "x"), "Y": ("Y", "y"), "Z": ("Z", "z"), "AirTemp": ("AirTemp", "air_temperature", "air_temp"), "TrackTemp": ("TrackTemp", "track_temperature", "track_temp"), "Humidity": ("Humidity", "humidity"), "Pressure": ("Pressure", "pressure"), "WindDirection": ("WindDirection", "wind_direction"), "WindSpeed": ("WindSpeed", "wind_speed"), "Rainfall": ("Rainfall", "rainfall"), "Position": ("Position", "position"), "Compound": ("Compound", "compound"), "TyreLife": ("TyreLife", "tyre_age"), "Stint": ("Stint", "StintNumber", "stint_number"), "TrackStatus": ("TrackStatus", "track_status"), "SessionStatus": ("SessionStatus", "session_status"), "CurrentLap": ("CurrentLap", "current_lap"), "TotalLaps": ("TotalLaps", "total_laps"), } )