Skip to content

Latest commit

 

History

History
81 lines (65 loc) · 1.88 KB

readme.md

File metadata and controls

81 lines (65 loc) · 1.88 KB

pydatatamer

View data_tamer mcap files as numpy array

Supported Platforms

  • Linux (for now)

Quick Start (from source)

  1. Clone pydata_tamer
git clone https://github.com/raghavauppuluri13/pydatatamer.git
cd pydata_tamer
  1. Install pydata_tamer (also builds pybind11)
pip3 install -e .
  1. Run example
cd examples
python3 read_data.py

Add new snapshot types

  1. Update include/mcap_types.hpp with your new snapshot type
struct Point {
    double x;
    double y;

    Point() {}

    inline void update(std::string name,
                       const DataTamerParser::VarNumber &data) {
        if (name == "x")) {
            position = std::get<double>(data);
        } else if (name == "y") {
            velocity = std::get<double>(data);
        } else {
            std::cerr << "unknown series name: " << name << std::endl;
            throw std::runtime_error("Unknown series!");
        }
    }
};
  1. Update mcap_reader.cpp's PYBIND11_MODULE->McapReader with your new snapshot type template
py::class_<Point>(m, "Point")
    .def(py::init<>())
    .def_readwrite("x", &Point::x)
    .def_readwrite("y", &Point::y);
PYBIND11_NUMPY_DTYPE(Point, x, y);
py::class_<McapTamer<Point>>(m, "McapTamer")
    .def(py::init<>())
    .def("init", &McapTamer<Point>::init)
    .def("parse", &McapTamer<Point>::parse);
  1. pip install again to build
  2. Read in python
from pydatatamer.mcap_tamer import McapTamer
import numpy as np
mcap_tamer = McapTamer()
mcap_tamer.init("points.mcap")
# structured array
points_data = mcap_tamer.parse()
print(points)

Credits