npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rflafla/motec-ld-reader

v1.0.1

Published

A Node.js library for reading MoTeC .ld telemetry files

Readme

MoTeC LD File Reader

A Node.js library for reading MoTeC .ld telemetry files. This library allows you to parse and extract data from MoTeC data logging files commonly used in motorsports and automotive testing.

Features

  • Parse MoTeC .ld files
  • Access session metadata (driver, vehicle, venue, datetime, etc.)
  • Read channel data (speed, RPM, temperature, etc.)
  • Support for multiple data types (int16, int32, float16, float32)
  • TypeScript support with full type definitions
  • Lazy loading of channel data for efficient memory usage

Installation

npm install
npm run build

Usage

Basic Example

import { LdData } from 'motec-ld-reader';

// Read an .ld file
const data = LdData.fromFile('path/to/file.ld');

// Access metadata
console.log(`Driver: ${data.head.driver}`);
console.log(`Vehicle: ${data.head.vehicleId}`);
console.log(`Date: ${data.head.datetime}`);
console.log(`Venue: ${data.head.venue}`);

// List all channels
console.log('\nAvailable channels:');
data.getChannelNames().forEach(name => {
  console.log(`  - ${name}`);
});

// Access a specific channel by name
const speedChannel = data.getChannel('Ground Speed');
console.log(`\nSpeed channel:`);
console.log(`  Name: ${speedChannel.name}`);
console.log(`  Unit: ${speedChannel.unit}`);
console.log(`  Frequency: ${speedChannel.freq} Hz`);
console.log(`  Data points: ${speedChannel.data.length}`);

// Access channel data
const speeds = speedChannel.data;
console.log(`  Max speed: ${Math.max(...speeds)} ${speedChannel.unit}`);
console.log(`  Avg speed: ${speeds.reduce((a, b) => a + b, 0) / speeds.length} ${speedChannel.unit}`);

Access Channels by Index

// Access channels by numeric index
const firstChannel = data.getChannel(0);
console.log(firstChannel.name);

// Iterate over all channels
for (let i = 0; i < data.channelCount; i++) {
  const channel = data.getChannel(i);
  console.log(`${i}: ${channel.name} (${channel.unit})`);
}

Export to JSON

// Convert to a plain object for JSON serialization
const dataObject = data.toObject();
console.log(JSON.stringify(dataObject, null, 2));

// Or just get the data as a map
const dataMap = data.toDataMap();
console.log(dataMap['Ground Speed']);

Working with Channel Data

// Get multiple channels
const rpm = data.getChannel('Engine RPM').data;
const throttle = data.getChannel('Throttle Pos').data;
const speed = data.getChannel('Ground Speed').data;

// Perform calculations
for (let i = 0; i < Math.min(rpm.length, throttle.length); i++) {
  if (throttle[i] > 80) {
    console.log(`Full throttle at ${i}s: ${speed[i]} km/h, ${rpm[i]} RPM`);
  }
}

Channel Information

Each channel provides the following properties:

  • name: Full channel name
  • shortName: Abbreviated name
  • unit: Unit of measurement
  • freq: Sample frequency in Hz
  • data: Array of data values (lazy loaded)
  • dataLen: Number of data points

Metadata Access

// Event information
if (data.head.event) {
  console.log(`Event: ${data.head.event.name}`);
  console.log(`Session: ${data.head.event.session}`);
  console.log(`Comment: ${data.head.event.comment}`);

  // Venue information
  if (data.head.event.venue) {
    console.log(`Venue: ${data.head.event.venue.name}`);

    // Vehicle information
    if (data.head.event.venue.vehicle) {
      const vehicle = data.head.event.venue.vehicle;
      console.log(`Vehicle ID: ${vehicle.id}`);
      console.log(`Vehicle Type: ${vehicle.type}`);
      console.log(`Weight: ${vehicle.weight}`);
    }
  }
}

API Reference

LdData

Main class for reading .ld files.

Methods

  • static fromFile(filePath: string): LdData - Read and parse an .ld file
  • getChannel(nameOrIndex: string | number): LdChan - Get a channel by name or index
  • getChannelNames(): string[] - Get all channel names
  • toObject() - Convert to plain object for serialization
  • toDataMap(): Record<string, number[]> - Get channel data as name-to-data map

Properties

  • head: LdHead - Header/metadata information
  • channels: LdChan[] - Array of all channels
  • channelCount: number - Number of channels

LdHead

Header information containing metadata about the recording session.

Properties

  • driver: string
  • vehicleId: string
  • venue: string
  • datetime: Date
  • shortComment: string
  • event: LdEvent | null

LdChan

Channel data and metadata.

Properties

  • name: string - Full channel name
  • shortName: string - Abbreviated name
  • unit: string - Unit of measurement
  • freq: number - Sample frequency in Hz
  • data: number[] - Data array (lazy loaded)
  • dataLen: number - Number of data points
  • dtype: DataType - Data type ('int16' | 'int32' | 'float16' | 'float32')

File Format

The .ld file format is a binary format used by MoTeC data loggers. The library handles:

  • File header with session metadata
  • Event, venue, and vehicle information
  • Channel metadata (linked list structure)
  • Binary channel data with various numeric types
  • Data scaling and conversion formulas

Development

# Install dependencies
npm install

# Build the project
npm run build

# Watch mode for development
npm run watch

License

MIT

Credits

This library was created through reverse engineering the MoTeC .ld file format. It is not officially affiliated with MoTeC.