theOehrly / Fast-F1

FastF1 is a python package for accessing and analyzing Formula 1 results, schedules, timing data and telemetry
https://docs.fastf1.dev
MIT License
2.29k stars 239 forks source link

[BUG] Timestamp issues for Japanese GP #567

Closed brrrake closed 3 months ago

brrrake commented 3 months ago

Describe the issue:

Either I have missed something, or the source data has changed in the background since the last grand prix weekend during Japan. There are several objects which are now in a different Timestamp or datetime format that are not compatible. Qualifying timestamps differ to FP3 timestamps for telemetry objects.

I have updated to the latest version of FastF1 as well.

The example below is from Qualifying.

Reproduce the code example:

lap = session.laps.pick_driver('VER').pick_fastest()
lap.get_car_data(interpolate_edges=True).add_distance()

Error message:


TypeError Traceback (most recent call last) Input In [27], in <cell line: 2>() 1 lap = session.laps.pick_driver('VER').pick_fastest() ----> 2 lap.get_car_data(interpolate_edges=True).add_distance()

File ~\PycharmProjects\F1Analysis\venv\lib\site-packages\fastf1\core.py:3416, in Lap.get_car_data(self, kwargs) 3399 def get_car_data(self, kwargs) -> Telemetry: 3400 """Car data for this lap 3401 3402 Slices the car data in :attr:Session.car_data using this lap and (...) 3414 instance of :class:Telemetry 3415 """ -> 3416 car_data = self.session.car_data[self['DriverNumber']] \ 3417 .slice_by_lap(self, **kwargs) \ 3418 .reset_index(drop=True) 3419 return car_data

File ~\PycharmProjects\F1Analysis\venv\lib\site-packages\fastf1\core.py:349, in Telemetry.slice_by_lap(self, ref_laps, pad, pad_side, interpolate_edges) 345 else: 346 raise TypeError("Attribute 'ref_laps' needs to be an instance of " 347 "Lap or Laps") --> 349 return self.slice_by_time(start_time, end_time, pad, pad_side, 350 interpolate_edges)

File ~\PycharmProjects\F1Analysis\venv\lib\site-packages\fastf1\core.py:380, in Telemetry.slice_by_time(self, start_time, end_time, pad, pad_side, interpolate_edges) 360 """Slice self to only include data in a specific time frame. 361 362 .. note:: Self needs to contain a 'SessionTime' column. Slicing by (...) 375 :class:Telemetry 376 """ 377 if interpolate_edges: 378 edges = Telemetry({'SessionTime': (start_time, end_time), 379 'Date': (start_time + self.session.t0_date, --> 380 end_time + self.session.t0_date) 381 }, 382 session=self.session).finalize(self) 383 d = self.merge_channels(edges, frequency='original') 385 else:

TypeError: unsupported operand type(s) for +: 'Timestamp' and 'Timestamp'

theOehrly commented 3 months ago

I'm having absolutely no issues with the data. Can you try running the script with the cache disabled? Although, old cached data can't really be a problem with very recent sessions.

I need

After that, you could try reinstalling everything. Either in a new clean environment or by running pip install --upgrade --force-reinstall fastf1.

Please get the result of pip list before you try to reinstall.

brrrake commented 3 months ago

I cannot understand where exactly, but at some point I had overwritten some of the time objects on session.data to a different format. I've spent about an hour and I believe this is an ID10T error on my side. I will go back through and check where I introduced this, but I appear to have resolved it.