Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/api_reference/timing_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ for each):
- Session time when the Sector 3 time was set
* - **SpeedI1**
- ``float``
- Speedtrap sector 1 [km/h]
- Speedtrap sector 1 [km/h] (missing under red flag)
* - **SpeedI2**
- ``float``
- Speedtrap sector 2 [km/h]
- Speedtrap sector 2 [km/h] (missing under red flag)
* - **SpeedFL**
- ``float``
- Speedtrap at finish line [km/h]
- Speedtrap at finish line [km/h] (missing under red flag and missing on laps where a driver enters the pits)
* - **SpeedST**
- ``float``
- Speedtrap on longest straight (Not sure) [km/h]
- Speedtrap on longest straight or at a select high speed point, dependent on the circuit [km/h] (missing under red flag)
* - **IsPersonalBest**
- ``bool``
- Flag that indicates whether this lap is the official personal best lap of a driver. If any lap of a driver is quicker than their respective personal best lap, this means that the quicker lap is invalid and not counted. For example, this can happen if the track limits were exceeded.
Expand Down
26 changes: 26 additions & 0 deletions fastf1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,32 @@ def _load_laps_data(self, livedata=None):

self._add_track_status_to_laps(laps)

# fix missing speed trap values, caused by the API data skipping
# over consecutive equivalent values (#775)
for drv in drivers:
drv_mask = laps["DriverNumber"] == drv
# drv_laps = laps[drv_mask]

# forward fill sector 1, sector 2 and the "ST" speed trap for all
# original laps that didn't take place under a red flag
appl_mask = (
~laps.loc[drv_mask, "FastF1Generated"]
& ~laps.loc[drv_mask, "TrackStatus"].str.contains("5")
)
fill_12st = laps.loc[
drv_mask, ("SpeedI1", "SpeedI2", "SpeedST")
].ffill().loc[appl_mask]
laps.loc[
appl_mask & drv_mask,
("SpeedI1", "SpeedI2", "SpeedST")
] = fill_12st

# forward fill finish line speed trap like sector 1 speed trap,
# additionally excluding laps where the driver entered the pits
appl_mask &= pd.isnull(laps.loc[drv_mask, "PitInTime"])
fill_fl = laps.loc[drv_mask, "SpeedFL"].ffill().loc[appl_mask]
laps.loc[appl_mask & drv_mask, "SpeedFL"] = fill_fl

self._laps = Laps(laps, session=self, _force_default_cols=True)
self._check_lap_accuracy()

Expand Down
Loading