libxrk 0.7.0__cp310-cp310-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.
libxrk/CLAUDE.md ADDED
@@ -0,0 +1,133 @@
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
+ ## aim_xrk Function
15
+
16
+ ```python
17
+ aim_xrk(fname, progress=None) -> LogFile
18
+ ```
19
+
20
+ **Parameters:**
21
+ - `fname`: Path to XRK/XRZ file, or bytes/BytesIO containing file data
22
+ - `progress`: Optional callback `(current: int, total: int) -> None` for progress updates
23
+
24
+ ## LogFile Structure
25
+
26
+ ```python
27
+ log.channels # Dict[str, pa.Table] - channel name -> PyArrow table
28
+ log.laps # pa.Table - columns: num, start_time, end_time (ms)
29
+ log.metadata # Dict[str, Any] - session info
30
+ ```
31
+
32
+ ## Metadata Fields
33
+
34
+ Standard metadata fields extracted from XRK files:
35
+
36
+ | Key | Type | Description |
37
+ |-----|------|-------------|
38
+ | Driver | str | Driver name |
39
+ | Vehicle | str | Vehicle name |
40
+ | Venue | str | Track/venue name |
41
+ | Log Date | str | Date of log (DD/MM/YYYY) |
42
+ | Log Time | str | Time of log (HH:MM:SS) |
43
+ | Series | str | Series/competition name |
44
+ | Session | str | Session type |
45
+ | Long Comment | str | User notes |
46
+ | Logger ID | int | Unique logger serial number |
47
+ | Logger Model ID | int | Numeric model code |
48
+ | Logger Model | str or None | Human-readable model name (e.g., "MXP 1.3", "MXm") |
49
+ | Device Name | str | User-configured device name |
50
+ | Odo/* | various | Odometer readings |
51
+
52
+ ## Channel Tables
53
+
54
+ Each channel table has:
55
+ - `timecodes` column (int64, milliseconds)
56
+ - `<channel_name>` column (values)
57
+
58
+ Channels have different sample rates. Use `get_channels_as_table()` to merge.
59
+
60
+ ## Channel Metadata
61
+
62
+ ```python
63
+ field = log.channels['Engine RPM'].schema.field('Engine RPM')
64
+ units = field.metadata.get(b'units', b'').decode() # e.g., "rpm"
65
+ ```
66
+
67
+ Keys: `b"units"`, `b"dec_pts"`, `b"interpolate"`
68
+
69
+ ## LogFile Methods
70
+
71
+ ### Channel Selection
72
+ ```python
73
+ log.select_channels(['GPS Speed', 'Engine RPM']) # Returns new LogFile
74
+ ```
75
+
76
+ ### Time Filtering
77
+ ```python
78
+ log.filter_by_time_range(60000, 120000) # [start, end) in ms
79
+ log.filter_by_time_range(60000, 120000, channel_names=['GPS Speed'])
80
+ ```
81
+
82
+ ### Lap Filtering
83
+ ```python
84
+ log.filter_by_lap(5) # Filter to lap 5's time range
85
+ log.filter_by_lap(5, channel_names=['GPS Speed'])
86
+ ```
87
+
88
+ ### Resampling
89
+ ```python
90
+ # Resample to a reference channel's timebase
91
+ log.resample_to_channel('GPS Speed')
92
+
93
+ # Resample to custom timebase
94
+ target = pa.array(range(0, 100000, 100), type=pa.int64())
95
+ log.resample_to_timecodes(target)
96
+ ```
97
+
98
+ ### Merging Channels
99
+ ```python
100
+ log.get_channels_as_table() # Returns pa.Table with all channels merged
101
+ ```
102
+
103
+ All methods return new `LogFile` instances, enabling chaining:
104
+ ```python
105
+ df = (log
106
+ .filter_by_lap(5)
107
+ .select_channels(['Engine RPM', 'GPS Speed'])
108
+ .get_channels_as_table()
109
+ .to_pandas())
110
+ ```
111
+
112
+ ## GPS Timing Fix
113
+
114
+ 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.
115
+
116
+ Affected channels: `GPS Speed`, `GPS Latitude`, `GPS Longitude`, `GPS Altitude`
117
+
118
+ ## Common Patterns
119
+
120
+ ```python
121
+ # Single channel to pandas
122
+ df = log.channels['Engine RPM'].to_pandas()
123
+
124
+ # All channels merged (handles different sample rates)
125
+ df = log.get_channels_as_table().to_pandas()
126
+
127
+ # Load from bytes/BytesIO
128
+ log = aim_xrk(file_bytes)
129
+
130
+ # Filter and analyze a specific lap
131
+ lap5 = log.filter_by_lap(5, ['GPS Speed', 'Engine RPM'])
132
+ df = lap5.get_channels_as_table().to_pandas()
133
+ ```
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
+ ...