libxrk 0.7.0__cp314-cp314-win_amd64.whl → 0.8.0__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
libxrk/aim_xrk.pyx CHANGED
@@ -128,7 +128,7 @@ _logger_models = {
128
128
 
129
129
  _unit_map = {
130
130
  1: ('%', 2),
131
- 3: ('G', 2),
131
+ 3: ('g', 2),
132
132
  4: ('deg', 1),
133
133
  5: ('deg/s', 1),
134
134
  6: ('', 0), # number
@@ -767,10 +767,33 @@ def _get_laps(lat_ch, lon_ch, msg_by_type, time_offset, last_time):
767
767
  lap_nums = []
768
768
  start_times = []
769
769
  end_times = []
770
-
771
- if lat_ch and lon_ch:
772
- # If we have GPS, do gps lap insert.
773
770
 
771
+ # Prefer LAP messages when available (matches official DLL behavior)
772
+ if _tokdec('LAP') in msg_by_type:
773
+ for m in msg_by_type[_tokdec('LAP')]:
774
+ # 2nd byte is segment #, see M4GT4
775
+ segment, lap, duration, end_time = struct.unpack('xBHIxxxxxxxxI', m.content)
776
+ end_time -= time_offset
777
+ if segment:
778
+ continue
779
+ elif not lap_nums:
780
+ pass
781
+ elif lap_nums[-1] == lap:
782
+ continue
783
+ elif lap_nums[-1] + 1 == lap:
784
+ pass
785
+ elif lap_nums[-1] + 2 == lap:
786
+ # emit inferred lap
787
+ lap_nums.append(lap - 1)
788
+ start_times.append(end_times[-1])
789
+ end_times.append(end_time - duration)
790
+ else:
791
+ assert False, 'Lap gap from %d to %d' % (lap_nums[-1], lap)
792
+ lap_nums.append(lap)
793
+ start_times.append(end_time - duration)
794
+ end_times.append(end_time)
795
+ elif lat_ch and lon_ch:
796
+ # Fall back to GPS-based lap detection only when no LAP messages exist
774
797
  track = msg_by_type[_tokdec('TRK')][-1].content
775
798
  XYZ = np.column_stack(gps.lla2ecef(np.array(lat_ch.sampledata),
776
799
  np.array(lon_ch.sampledata), 0))
@@ -781,38 +804,21 @@ def _get_laps(lat_ch, lon_ch, msg_by_type, time_offset, last_time):
781
804
  # Use GPS channel's last timecode as session end (already adjusted)
782
805
  # This avoids relying on last_time which may be 0 when no LAP messages exist
783
806
  session_end = int(lat_ch.timecodes[-1]) if len(lat_ch.timecodes) else (last_time - time_offset if last_time else 0)
784
- lap_markers = [0] + lap_markers + [session_end]
785
807
 
786
- for lap, (start_time, end_time) in enumerate(zip(lap_markers[:-1], lap_markers[1:])):
787
- lap_nums.append(lap)
788
- start_times.append(start_time)
789
- end_times.append(end_time)
790
- else:
791
- # otherwise, use the lap data provided.
792
- if _tokdec('LAP') in msg_by_type:
793
- for m in msg_by_type[_tokdec('LAP')]:
794
- # 2nd byte is segment #, see M4GT4
795
- segment, lap, duration, end_time = struct.unpack('xBHIxxxxxxxxI', m.content)
796
- end_time -= time_offset
797
- if segment:
798
- continue
799
- elif not lap_nums:
800
- pass
801
- elif lap_nums[-1] == lap:
802
- continue
803
- elif lap_nums[-1] + 1 == lap:
804
- pass
805
- elif lap_nums[-1] + 2 == lap:
806
- # emit inferred lap
807
- lap_nums.append(lap - 1)
808
- start_times.append(end_times[-1])
809
- end_times.append(end_time - duration)
810
- else:
811
- assert False, 'Lap gap from %d to %d' % (lap_nums[-1], lap)
808
+ # Only add session boundaries if we have detected lap crossings
809
+ # This creates laps from each crossing to the next
810
+ if lap_markers:
811
+ lap_markers = [0] + lap_markers + [session_end]
812
+ for lap, (start_time, end_time) in enumerate(zip(lap_markers[:-1], lap_markers[1:])):
812
813
  lap_nums.append(lap)
813
- start_times.append(end_time - duration)
814
+ start_times.append(start_time)
814
815
  end_times.append(end_time)
815
816
 
817
+ # Normalize lap numbers to 0-based indexing (matches DLL behavior)
818
+ if lap_nums:
819
+ min_lap = min(lap_nums)
820
+ lap_nums = [n - min_lap for n in lap_nums]
821
+
816
822
  # Create PyArrow table
817
823
  return pa.table({
818
824
  'num': pa.array(lap_nums, type=pa.int32()),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libxrk
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: Library for reading AIM XRK files from AIM automotive data loggers
5
5
  License-File: LICENSE
6
6
  Author: Christopher Dewan
@@ -1,12 +1,12 @@
1
1
  libxrk/__init__.py,sha256=WQFJHgC84JOzPQggxb3ZnEIaHHqydN0NABBTbaZs4bo,877
2
- libxrk/aim_xrk.cp314-win_amd64.pyd,sha256=LcEOue-ZMyCGp0KZchnf6EW569ZhjpxreuUzNDFmUU8,404480
2
+ libxrk/aim_xrk.cp314-win_amd64.pyd,sha256=iDZ60RZ70V33uZGnsY9rCrYubWh9zpSjUmYU2jhIJrQ,404992
3
3
  libxrk/aim_xrk.pyi,sha256=vSo9tEZ58n5_PBfQwKtsAlsErsL34Q42-ZelYIVCUa8,1197
4
- libxrk/aim_xrk.pyx,sha256=uZslq0fCrUx1YuuRmy7UfQp1zygxX80acqgJyLzqbJI,42990
4
+ libxrk/aim_xrk.pyx,sha256=E3luMsBwM9GfXEKuxmUVHOMWU-VytUj5FoFUR074swM,43297
5
5
  libxrk/base.py,sha256=GXlysZzOJUrcLQFdskU5xfj111ryazUlJXn4Mh8h3T8,13042
6
6
  libxrk/CLAUDE.md,sha256=ffQoJfmdq7_z_9t_NRdJ3HrvIwLwxn28QHLOI8RuDlM,3607
7
7
  libxrk/gps.py,sha256=D_opONz_zI8BQJ7DyP0vWeZhmOL8mnjSrkCX9-jeQjg,22880
8
8
  libxrk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- libxrk-0.7.0.dist-info/licenses/LICENSE,sha256=2raWmO-YvfSbuanWCUMU4b5Fe06QhxuKxbEDyKjfzqg,1179
10
- libxrk-0.7.0.dist-info/METADATA,sha256=NGRt5GuPscEapaZTW-5UUDjsHbsBNvKogjiYpV8g8qA,6379
11
- libxrk-0.7.0.dist-info/WHEEL,sha256=uzn_lwJZCIPsIlqGVKdFXfrkk7JnOONWsv8tfcNKHyk,98
12
- libxrk-0.7.0.dist-info/RECORD,,
9
+ libxrk-0.8.0.dist-info/licenses/LICENSE,sha256=2raWmO-YvfSbuanWCUMU4b5Fe06QhxuKxbEDyKjfzqg,1179
10
+ libxrk-0.8.0.dist-info/METADATA,sha256=SN0V19cmNBdXtSRhgAXTa1FuVQF6RM3LY5wj46kvdYk,6379
11
+ libxrk-0.8.0.dist-info/WHEEL,sha256=0ivQVdIpvG14LkRGIC9W_WIGKTwL__pq2rzCtdDx5YE,98
12
+ libxrk-0.8.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.3.0
2
+ Generator: poetry-core 2.3.1
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp314-cp314-win_amd64