Skip to main content

Library for reading AIM XRK files from AIM automotive data loggers

Project description

libxrk

A Python library for reading AIM XRK and XRZ files from AIM automotive data loggers.

Features

  • Read AIM XRK files (raw data logs)
  • Read AIM XRZ files (zlib-compressed XRK files)
  • Parse track data and telemetry channels
  • GPS coordinate conversion and lap detection
  • High-performance Cython implementation
  • Supports Python 3.10 - 3.14

Installation

Install from PyPI

pip install libxrk

Install from Source

Prerequisites

On Ubuntu/Debian:

sudo apt install build-essential python3-dev

Install with Poetry

poetry install

The Cython extension will be automatically compiled during installation.

Usage

from libxrk import aim_xrk

# Read an XRK file
log = aim_xrk('path/to/file.xrk')

# Read an XRZ file (automatically decompressed)
log = aim_xrk('path/to/file.xrz')

# Access channels (each channel is a PyArrow table with 'timecodes' and value columns)
for channel_name, channel_table in log.channels.items():
    print(f"{channel_name}: {channel_table.num_rows} samples")

# Get all channels merged into a single PyArrow table
# (handles different sample rates with interpolation/forward-fill)
merged_table = log.get_channels_as_table()
print(merged_table.column_names)

# Convert to pandas DataFrame
df = merged_table.to_pandas()

# Access laps (PyArrow table with 'num', 'start_time', 'end_time' columns)
print(f"Laps: {log.laps.num_rows}")
for i in range(log.laps.num_rows):
    lap_num = log.laps.column("num")[i].as_py()
    start = log.laps.column("start_time")[i].as_py()
    end = log.laps.column("end_time")[i].as_py()
    print(f"Lap {lap_num}: {start} - {end}")

# Access metadata
print(log.metadata)

Filtering and Resampling

from libxrk import aim_xrk

log = aim_xrk('session.xrk')

# Select specific channels
gps_log = log.select_channels(['GPS Latitude', 'GPS Longitude', 'GPS Speed'])

# Filter to a time range (milliseconds, inclusive start, exclusive end)
segment = log.filter_by_time_range(60000, 120000)

# Filter to a specific lap
lap5 = log.filter_by_lap(5)

# Combine filtering and channel selection
lap5_gps = log.filter_by_lap(5, channel_names=['GPS Latitude', 'GPS Longitude'])

# Resample all channels to match a reference channel's timebase
aligned = log.resample_to_channel('GPS Speed')

# Resample to a custom timebase
import pyarrow as pa
target = pa.array(range(0, 100000, 100), type=pa.int64())  # 10 Hz
resampled = log.resample_to_timecodes(target)

# Chain operations for analysis workflows
df = (log
    .filter_by_lap(5)
    .select_channels(['Engine RPM', 'GPS Speed'])
    .resample_to_channel('GPS Speed')
    .get_channels_as_table()
    .to_pandas())

All filtering and resampling methods return new LogFile instances (immutable pattern), enabling method chaining for complex analysis workflows.

Development

Quick Check

# Run all quality checks (format check, type check, tests)
poetry run poe check

Code Formatting

This project uses Black for code formatting.

# Format all Python files
poetry run black .

Type Checking

This project uses mypy for static type checking.

# Run type checker on all Python files
poetry run mypy .

Running Tests

This project uses pytest for testing.

# Run all tests
poetry run pytest

# Run tests with verbose output
poetry run pytest -v

# Run specific test file
poetry run pytest tests/test_xrk_loading.py

# Run tests with coverage
poetry run pytest --cov=libxrk

Testing with Pyodide (WebAssembly)

You can test the library in a WebAssembly environment using Pyodide. This requires Node.js to be installed.

# Build and run tests in Pyodide (installs Emscripten SDK to build/emsdk if needed)
poetry run poe pyodide-test

Note: Pyodide tests run automatically in CI via GitHub Actions.

Building

# Build CPython wheel and sdist
poetry build

# Build all wheels (CPython, Pyodide/WebAssembly, and sdist)
poetry run poe build-all

Clean Build

# Clean all build artifacts and rebuild
rm -rf build/ dist/ src/libxrk/*.so && poetry install

Testing

The project includes end-to-end tests that validate XRK and XRZ file loading and parsing.

Test files are located in tests/test_data/ and include real XRK and XRZ files for validation.

Credits

This project incorporates code from TrackDataAnalysis by Scott Smith, used under the MIT License.

License

MIT License - See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libxrk-0.5.0.tar.gz (27.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

libxrk-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

libxrk-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

libxrk-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

Details for the file libxrk-0.5.0.tar.gz.

File metadata

  • Download URL: libxrk-0.5.0.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for libxrk-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8f4079e11adf2e77192022faa63b5589c363f3d398828e70a4189b83a4937ff2
MD5 4a0d88209b809c1387c5efdc46029126
BLAKE2b-256 2988dd1ac15a13b1e0b8f5da60c1221fb2fb288dc27c9fda4ffdd9a6687ab97c

See more details on using hashes here.

Provenance

The following attestation bundles were made for libxrk-0.5.0.tar.gz:

Publisher: publish.yml on m3rlin45/libxrk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libxrk-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for libxrk-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 935da08485bb692072e1ba39c6b10c81880bf1c2ed94ec822d75ff8238a6742a
MD5 d7bd110a5330550c33091b0a463f0d82
BLAKE2b-256 4cfa47112c7c3a600164d4d3521966829506a6ca366bdfa9478b9e9fdbc71459

See more details on using hashes here.

Provenance

The following attestation bundles were made for libxrk-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on m3rlin45/libxrk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libxrk-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for libxrk-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9b79d38e1f3b8ccc2b15b48f261be7c255984a91f4ba1aa5e88e9060ae276fb6
MD5 2c4c97da9d6234836409a168e302fc6c
BLAKE2b-256 7cceb34df0deb50877b2f59281f26f77d7bcae7a4b3d02109f6e506828b75dac

See more details on using hashes here.

Provenance

The following attestation bundles were made for libxrk-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on m3rlin45/libxrk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libxrk-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for libxrk-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4f549ec0d50a660b1a13ade2bddde66339fd4b85328058f6ec26247cf221ab85
MD5 a34c7797918483ca9582f7f7642074d1
BLAKE2b-256 5598257f57ffeef245dfc7c086063752121494c72a92fa60c4477b729cb28803

See more details on using hashes here.

Provenance

The following attestation bundles were made for libxrk-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on m3rlin45/libxrk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page