dataset

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package dataset loads ULog streams into eager, column-oriented views.

Use Read when an entire log fits in memory and analysis needs repeated or column-wise access. Use ulog.Reader when data records can be processed without materialising the complete log. Numeric arrays and nested formats are flattened into stable column paths; character arrays remain string columns.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	// contains filtered or unexported fields
}

Column is a nullable dataset column. Column.Values returns one of []int8, []uint8, []int16, []uint16, []int32, []uint32, []int64, []uint64, []float32, []float64, []bool, or []string. Character arrays use []string; scalar characters use []uint8.

func (Column) ArrayLength added in v0.2.0

func (c Column) ArrayLength() int

ArrayLength returns the fixed byte width of a character array, or zero for a scalar value.

func (Column) Len

func (c Column) Len() int

Len returns the number of rows in the column.

func (Column) Name

func (c Column) Name() string

Name returns the flattened field path for the column.

func (Column) Type

func (c Column) Type() ulog.Type

Type returns the ULog primitive type stored by the column.

func (Column) Value

func (c Column) Value(index int) (any, bool)

Value returns one value and whether it is valid. It returns nil, false for a null or out-of-range row.

func (Column) Values

func (c Column) Values() any

Values returns an independent copy of the typed values. Null rows contain the primitive type's zero value; use Column.Value to distinguish them.

type Dataset

type Dataset struct {
	// contains filtered or unexported fields
}

Dataset contains every record for one format name and multi ID. Numeric arrays and nested formats are flattened into stable paths; character arrays remain string-valued Column values. A record that omits compatible trailing fields contributes nulls to the corresponding columns.

func (*Dataset) Column

func (d *Dataset) Column(name string) (Column, bool)

Column returns a flattened scalar column by its case-sensitive path, such as "q[0]" or "position.x".

func (*Dataset) Columns

func (d *Dataset) Columns() []Column

Columns returns the flattened, non-padding columns in wire order. Mutating the returned slice does not change the dataset.

func (*Dataset) Format

func (d *Dataset) Format() ulog.Format

Format returns an independent copy of the ulog.Format that defined the dataset's first record.

func (*Dataset) Len

func (d *Dataset) Len() int

Len returns the number of data records in the dataset, including records with null trailing fields.

func (*Dataset) MultiID

func (d *Dataset) MultiID() uint8

MultiID returns the format's instance identifier. Zero is the first and default instance.

func (*Dataset) Name

func (d *Dataset) Name() string

Name returns the case-sensitive format name used to group the dataset.

func (*Dataset) WriteCSV added in v0.2.0

func (d *Dataset) WriteCSV(destination io.Writer) error

WriteCSV writes the dataset as one CSV table. Column names form the header in wire order, records remain in source order, and null values are empty fields. WriteCSV does not close destination.

type File

type File struct {
	// contains filtered or unexported fields
}

File owns the datasets and metadata loaded from one complete ULog stream.

func Read

func Read(source io.Reader) (*File, error)

Read consumes source to the end and groups records by format name and multi ID. It returns no partial File if the ULog stream is invalid. Read does not close source.

Example
package main

import (
	"fmt"
	"os"

	"github.com/sunfish-robotics/ulog/pkg/dataset"
)

func main() {
	source, err := os.Open("flight.ulg")
	if err != nil {
		panic(err)
	}
	defer func() {
		if err := source.Close(); err != nil {
			panic(err)
		}
	}()

	file, err := dataset.Read(source)
	if err != nil {
		panic(err)
	}
	attitude, err := file.Dataset("vehicle_attitude", 0)
	if err != nil {
		panic(err)
	}
	timestamps, ok := attitude.Column("timestamp")
	if !ok {
		panic("timestamp column is missing")
	}
	values := timestamps.Values().([]uint64)
	fmt.Printf("%d attitude samples, from %d µs\n", attitude.Len(), values[0])
}

func (*File) Dataset

func (f *File) Dataset(name string, multiID uint8) (*Dataset, error)

Dataset returns the dataset for the case-sensitive format name and instance identifier, or an error if Read saw no matching data record.

func (*File) Datasets

func (f *File) Datasets() []*Dataset

Datasets returns datasets in order of their first data record.

func (*File) DefaultParameters

func (f *File) DefaultParameters() []ulog.DefaultParameter

DefaultParameters returns independent copies of the parameter defaults in file order. Missing defaults are not synthesised.

func (*File) Dropouts

func (f *File) Dropouts() []ulog.Dropout

Dropouts returns the periods of lost logging messages in file order.

func (*File) Header

func (f *File) Header() ulog.Header

Header returns the ULog version and logging start time read by Read.

func (*File) Information

func (f *File) Information() []ulog.KeyValue

Information returns independent copies of the typed metadata entries in file order.

func (*File) Logs

func (f *File) Logs() []ulog.LogEntry

Logs returns the tagged and untagged text messages in file order.

func (*File) MultiInformation added in v0.2.0

func (f *File) MultiInformation() []ulog.MultiInformationGroup

MultiInformation returns independent copies of grouped multi-information values in the order each group started.

func (*File) Parameters

func (f *File) Parameters() []ulog.KeyValue

Parameters returns independent copies of the initial parameter values and later changes in file order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL