MCAP file reader for JSON data implemented in C++ and Python.
Project description
Read DataBeam MCAP files with ease.
This Python library provides a high performance parser - implemented in C++ - for MCAP files produced by the DataBeam DAQ software: https://github.com/virtual-vehicle/databeam.
databeam_mcap_reader only works for reading MCAP files with JSON-encoded data containing a mandatory schema.
Unfinalized or damaged MCAP files will get automatically repaired by the MCAP-CLI tool.
See official MCAP documentation for more information.
Usage of Reader
Get a reader instance:
import databeam_mcap_reader as mr
reader = mr.McapReader()
Open a file:
reader.open('path/to/file.mcap')
Fetch details about the file:
# print infos
print(reader.get_info_string())
# dict of topics with field names, data-types and message counts
structure = reader.get_structure()
# list of topic names
topics = reader.get_topic_names()
# total number of messages
count = reader.get_total_message_count()
Fetch data from a specific topic:
# get a numpy structured array with data from a topic
data = reader.get_data(topic_name)
Fetch all data:
# get a dict of numpy structured arrays with data from all topics
data = reader.get_all_data()
Fetch a specific amount of data with a start time and number of messages:
data = reader.get_data('testtopic', start_time_ns=0, num_messages=1000)
# fetch next block, starting right after the first
data = reader.get_data('testtopic', start_time_ns=data['ts'][-1] + 1, num_messages=1000)
Example for chunked reader:
for chunk in reader.get_data_chunked("testtopic", chunk_size_megabytes=1000):
print(f'got {chunk.size} messages')
# --> process data chunk (numpy structured array)!
Use matplotlib to plot data:
import matplotlib.pyplot as plt
for topic_name in reader.get_topic_names():
data = reader.get_data(topic_name)
fields = reader.get_structure()[topic_name]['fields']
dtypes = reader.get_structure()[topic_name]['dtypes']
channels = []
for i, field in enumerate(fields):
if dtypes[i] != 'boolean' and dtypes[i] != 'string' and dtypes[i] != 'array':
channels.append(field)
for ch in [ch for ch in channels if ch != 'ts']:
plt.plot(data['ts'], data[ch], label=ch)
plt.xlabel('Time')
plt.ylabel('Value')
plt.legend()
plt.title('Channels over Time')
plt.show()
Please see reader.py - there are examples at the end of the file.
Usage of Data Collector
TODO
Configure Logging
import logging
import databeam_mcap_reader as mr
logging.getLogger('databeam_mcap').setLevel(logging.DEBUG) # or other logging level
Build wheel files
Wheel files must be specifically built for all supported Python versions.
Linux / Docker
Make sure Docker is installed and running: https://docs.docker.com/get-docker/
make linux_wheels
This will run a manylinux Docker container and build the wheel files with the specified Python versions (see Makefile).
Windows
Make sure Python is installed in all required versions and py command is available: https://www.python.org/downloads/windows/
Install Visual Studio 2022 with Python and C++ extensions: https://visualstudio.microsoft.com/downloads/
Install Conan natively: https://conan.io/downloads
conan
conan profile detect --force
Open terminal and run:
.\build_wheels_windows.ps1 <python_version> [<python_version> ...]
Example:
.\build_wheels_windows.ps1 3.10 3.11 3.12 3.13
Development / Testing (Linux)
Build only c++ extension for development
make dev
python3
import build_dev._core as mr
mr.parse_mcap(...)
Test built wheel
make wheel
python3 -m venv venv_test
. ./venv_test/bin/activate
pip install dist/databeam_mcap_readerXXX.whl
python3 -c "import databeam_mcap_reader as mr; import numpy as np; reader = mr.McapReader(); mr.parse_mcap('whee', 't', np.dtype([]), 1)"
OK, if there are no import-errors and it complains, that whee file is missing.
License
Distributed under the MIT license. See LICENSE.txt file for more information.
Contact
Virtual Vehicle Research GmbH: https://www.v2c2.at
Project Lead: Peter Sammer - peter.sammer@v2c2.at
This repository contains only public open-source components: https://github.com/virtual-vehicle/databeam
We gladly offer support, custom installations and extensions for devices, test-benches, experiments and more.
Acknowledgments
Virtual Vehicle Research GmbH has received funding within COMET Competence Centers for Excellent Technologies from the Austrian Federal Ministry for Climate Action, the Austrian Federal Ministry for Labour and Economy, the Province of Styria (Dept. 12) and the Styrian Business Promotion Agency (SFG). The Austrian Research Promotion Agency (FFG) has been authorised for the programme management.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file databeam_mcap_reader-0.3.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: databeam_mcap_reader-0.3.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 7.6 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ca88be9adb66e981130fd0d5af378fdb88356c4c736f7c2e914116a693f55f9
|
|
| MD5 |
858bd9015c6eda251b8ff1126632d539
|
|
| BLAKE2b-256 |
776539789236a6c8bd26746d37a3a978d53fc2310eb9b92d676a8ed75f2afd4e
|
File details
Details for the file databeam_mcap_reader-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: databeam_mcap_reader-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 8.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b587bfe4012ac15bb445f1dd1c120cc2fbc439e6fa4b9af9e459807da2b92dd2
|
|
| MD5 |
4a7886ccea4a7a0b5890f40264bbe17c
|
|
| BLAKE2b-256 |
ad447c68feb401717e20c938e310c13e3b0e1f4d8d6adab2ccd0999c3379a128
|
File details
Details for the file databeam_mcap_reader-0.3.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: databeam_mcap_reader-0.3.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 7.6 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be56627f0f3be982e0d221ba1d58f3dfd71eb44bc1b96f9756db7fb45e2d9427
|
|
| MD5 |
db183070938af22cec8c90ce2468c2bd
|
|
| BLAKE2b-256 |
02e6bc53dd56fad2cc552dbb86d38d7c3294be849823427d6137e9247697de60
|
File details
Details for the file databeam_mcap_reader-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: databeam_mcap_reader-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 8.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fee80c1fa49f89232c9fff6e943d406c050a27d9d4b85dcdef5c1d58d4a55f97
|
|
| MD5 |
045bbc339eb68c3cb53a42de90454d05
|
|
| BLAKE2b-256 |
1bb99028427e54b001b18d1cf5a9c68c2743ae90e927337dbd0ce96ebb9088ef
|
File details
Details for the file databeam_mcap_reader-0.3.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: databeam_mcap_reader-0.3.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 7.6 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16b8bf9b33559c5e966ed0fcd492feb989b846630000bafd47deb4d72b54ef34
|
|
| MD5 |
568080ccfb8f031fd687592f82bfe53a
|
|
| BLAKE2b-256 |
524c1d8273af947ff1724ec79ee302e7a8d9f66c24794275acd6c62ee6ec05e7
|
File details
Details for the file databeam_mcap_reader-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: databeam_mcap_reader-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 8.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59b8cf9ff5ff37e5dc131c44dc31a1641bac1ff2832ffecb38a5cc829ad826f8
|
|
| MD5 |
e7ea470cf2e12b6892ad3155f81e3db3
|
|
| BLAKE2b-256 |
d9086adca29a06ef27b85c8a3b8020c6f6b4c02a1582717cbfeddf55639f6b1a
|
File details
Details for the file databeam_mcap_reader-0.3.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: databeam_mcap_reader-0.3.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 7.6 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b831cb685de10de225d09eb003ea9bbfd6c1c7c503c29ee99026e7fea83ffa8
|
|
| MD5 |
d254c1efda3d305eead19f977932dad5
|
|
| BLAKE2b-256 |
f9e2df8bf31661e076a8cc9e2070689c84fb582ed8b5fe84eebc1faea5d4ffdb
|
File details
Details for the file databeam_mcap_reader-0.3.1-cp310-cp310-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: databeam_mcap_reader-0.3.1-cp310-cp310-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 8.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b5d42c5763f969259d81c588cad222c26f309ef480ab98f18bc366d6cc4644c
|
|
| MD5 |
f776cff4b4306d88c7b97b0ec011e8aa
|
|
| BLAKE2b-256 |
0580238f1e05a79456b5ae4d7c18e7307478d98c147897ad3c9586f72b7f21a9
|