libxrk 0.6.0__cp313-cp313-macosx_11_0_arm64.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.
libxrk/CLAUDE.md ADDED
@@ -0,0 +1,103 @@
1
+ # libxrk API Reference
2
+
3
+ ## Quick Start
4
+
5
+ ```python
6
+ from libxrk import aim_xrk
7
+
8
+ log = aim_xrk('path/to/file.xrk') # or .xrz, bytes, BytesIO
9
+
10
+ # All channels merged into DataFrame
11
+ df = log.get_channels_as_table().to_pandas()
12
+ ```
13
+
14
+ ## LogFile Structure
15
+
16
+ ```python
17
+ log.channels # Dict[str, pa.Table] - channel name -> PyArrow table
18
+ log.laps # pa.Table - columns: num, start_time, end_time (ms)
19
+ log.metadata # Dict[str, str] - session info
20
+ ```
21
+
22
+ ## Channel Tables
23
+
24
+ Each channel table has:
25
+ - `timecodes` column (int64, milliseconds)
26
+ - `<channel_name>` column (values)
27
+
28
+ Channels have different sample rates. Use `get_channels_as_table()` to merge.
29
+
30
+ ## Channel Metadata
31
+
32
+ ```python
33
+ field = log.channels['Engine RPM'].schema.field('Engine RPM')
34
+ units = field.metadata.get(b'units', b'').decode() # e.g., "rpm"
35
+ ```
36
+
37
+ Keys: `b"units"`, `b"dec_pts"`, `b"interpolate"`
38
+
39
+ ## LogFile Methods
40
+
41
+ ### Channel Selection
42
+ ```python
43
+ log.select_channels(['GPS Speed', 'Engine RPM']) # Returns new LogFile
44
+ ```
45
+
46
+ ### Time Filtering
47
+ ```python
48
+ log.filter_by_time_range(60000, 120000) # [start, end) in ms
49
+ log.filter_by_time_range(60000, 120000, channel_names=['GPS Speed'])
50
+ ```
51
+
52
+ ### Lap Filtering
53
+ ```python
54
+ log.filter_by_lap(5) # Filter to lap 5's time range
55
+ log.filter_by_lap(5, channel_names=['GPS Speed'])
56
+ ```
57
+
58
+ ### Resampling
59
+ ```python
60
+ # Resample to a reference channel's timebase
61
+ log.resample_to_channel('GPS Speed')
62
+
63
+ # Resample to custom timebase
64
+ target = pa.array(range(0, 100000, 100), type=pa.int64())
65
+ log.resample_to_timecodes(target)
66
+ ```
67
+
68
+ ### Merging Channels
69
+ ```python
70
+ log.get_channels_as_table() # Returns pa.Table with all channels merged
71
+ ```
72
+
73
+ All methods return new `LogFile` instances, enabling chaining:
74
+ ```python
75
+ df = (log
76
+ .filter_by_lap(5)
77
+ .select_channels(['Engine RPM', 'GPS Speed'])
78
+ .get_channels_as_table()
79
+ .to_pandas())
80
+ ```
81
+
82
+ ## GPS Timing Fix
83
+
84
+ Some AIM loggers have a firmware bug causing 65533ms timestamp gaps in GPS data (16-bit overflow). This is automatically corrected when loading files - no action needed.
85
+
86
+ Affected channels: `GPS Speed`, `GPS Latitude`, `GPS Longitude`, `GPS Altitude`
87
+
88
+ ## Common Patterns
89
+
90
+ ```python
91
+ # Single channel to pandas
92
+ df = log.channels['Engine RPM'].to_pandas()
93
+
94
+ # All channels merged (handles different sample rates)
95
+ df = log.get_channels_as_table().to_pandas()
96
+
97
+ # Load from bytes/BytesIO
98
+ log = aim_xrk(file_bytes)
99
+
100
+ # Filter and analyze a specific lap
101
+ lap5 = log.filter_by_lap(5, ['GPS Speed', 'Engine RPM'])
102
+ df = lap5.get_channels_as_table().to_pandas()
103
+ ```
libxrk/__init__.py ADDED
@@ -0,0 +1,29 @@
1
+ # Copyright 2024, Scott Smith. MIT License (see LICENSE).
2
+
3
+ """
4
+ libxrk - Library for reading AIM XRK and XRZ motorsports telemetry files.
5
+
6
+ This library parses binary telemetry data from AIM data loggers and provides
7
+ the data as PyArrow tables for efficient analysis.
8
+
9
+ Quick Start:
10
+ >>> from libxrk import aim_xrk
11
+ >>> log = aim_xrk('path/to/file.xrk') # or .xrz, bytes, BytesIO
12
+ >>> df = log.get_channels_as_table().to_pandas()
13
+
14
+ Main Components:
15
+ aim_xrk: Function to load XRK/XRZ files, returns a LogFile object
16
+ LogFile: Dataclass containing channels, laps, and metadata
17
+ GPS_CHANNEL_NAMES: List of standard GPS channel names
18
+ """
19
+
20
+ from .aim_xrk import aim_xrk, aim_track_dbg
21
+ from .base import LogFile
22
+ from .gps import GPS_CHANNEL_NAMES
23
+
24
+ __all__ = [
25
+ "aim_xrk",
26
+ "aim_track_dbg",
27
+ "LogFile",
28
+ "GPS_CHANNEL_NAMES",
29
+ ]
Binary file
libxrk/aim_xrk.pyi ADDED
@@ -0,0 +1,38 @@
1
+ # Copyright 2024, Scott Smith. MIT License (see LICENSE).
2
+ """Type stubs for aim_xrk Cython extension module."""
3
+
4
+ import os
5
+ from typing import Any, BinaryIO, Callable, Optional, Union
6
+
7
+ from libxrk.base import LogFile
8
+
9
+ def aim_xrk(
10
+ fname: Union[str, bytes, bytearray, memoryview, BinaryIO, os.PathLike[str]],
11
+ progress: Optional[Callable[[int, int], None]] = None,
12
+ ) -> LogFile:
13
+ """
14
+ Read and parse an AIM XRK file.
15
+
16
+ Args:
17
+ fname: Path to the XRK file, or bytes/BytesIO containing file data.
18
+ Accepts file paths, bytes, bytearray, memoryview, or file-like objects.
19
+ progress: Optional progress callback function that receives (current, total) positions
20
+
21
+ Returns:
22
+ LogFile object containing channels, laps, and metadata
23
+ """
24
+ ...
25
+
26
+ def aim_track_dbg(
27
+ fname: Union[str, bytes, bytearray, memoryview, BinaryIO, os.PathLike[str]],
28
+ ) -> dict[str, Any]:
29
+ """
30
+ Read track information from an AIM XRK file for debugging purposes.
31
+
32
+ Args:
33
+ fname: Path to the XRK file, or bytes/BytesIO containing file data
34
+
35
+ Returns:
36
+ Dictionary of track messages and metadata
37
+ """
38
+ ...