Skip to main content

Python API for the Open Acquisition System for IEPE Sensors (OASIS)

Project description

OASIS Board Python Package

Used in the following packages:

  • oasis-gui
  • oasis-tui
                    +-------------------+
                    |     oasis-api     |
                    |  (Python library) |
                    +-------------------+
                             ^
         +-------------------+---------------------+
         |                   |                     |
  +----------------+   +----------------+   +----------------+
  |   oasis-cli    |   |   oasis-tui    |   |   oasis-gui    |
  | (flags & args) |   | (guided menus) |   | (desktop/web)  |
  +----------------+   +----------------+   +----------------+

HDF5 File Format for OASIS Measurements

Overview

Measurement data is stored in HDF5 files in a tidy data format, making it easy to analyze, visualize, and share.

Structure

  • The main dataset is stored at the root as /data.
  • The file contains attributes describing metadata and the measurement setup.

Data Table: /data

  • Shape: (N, ) where N = number of channels × number of time points

  • Each row represents a single observation:

    • channel: Integer (1–8), channel number
    • time: Float (seconds), timestamp of the sample
    • signal: Float (volts), measured signal value

Example (first few rows):

channel time signal
1 0.00000 0.0324
1 0.00100 0.0451
... ... ...
8 9.99900 0.0078
  • Units:

    • The signal column is stored in volts.

File Attributes (Metadata)

  • schema_version: HDF5 schema version used by the file
  • duration_s: Duration of acquisition (in seconds)
  • sampling_frequency_hz: Sampling frequency (in Hz)
  • voltage_ranges: Array of voltage ranges for each channel (in volts)
  • channels: Number of channels (typically 8)
  • board_count: Number of contributing boards in the file
  • channels_per_board: Channel counts per contributing board
  • format description: Human-readable schema description
  • Merged files additionally store source_files, source_labels, and merge_align_mode

Why Tidy Data?

  • Each variable forms a column: channel, time, signal
  • Each observation forms a row: one reading from one channel at one time
  • Each type of observational unit forms a table: all data is in /data
  • This format makes the data easy to filter, aggregate, and visualize in Python (Pandas), R, MATLAB, etc.

How to Read the File (Python Example)

import h5py
import numpy as np

with h5py.File("measurement.h5", "r") as f:
    data = f["data"][:]
    print("Fields:", data.dtype.names)  # ('channel', 'time', 'signal')
    print("First row:", data[0])
    print("Sampling frequency:", f.attrs["sampling_frequency_hz"])
    print("Voltage ranges:", f.attrs["voltage_ranges"])

Viewing

  • Use HDFView or Vitables to inspect your data and metadata visually.

Compatibility

  • oasis-api v4.0.0-b1 targets OASIS firmware v4 boards.
  • Stored serial acquisitions require USB CDC+MSC firmware support (>= 4.0.0.a2).
  • The current serial acquisition path does not support legacy v3 CDC payload transfer boards.
  • load_h5() expects the current tidy schema with the signal field; legacy v3 HDF5 files written with voltage are not supported by this release.

Device Information

Device information is written with one direct API call; the firmware no longer opens an interactive serial menu for OASIS.SetDeviceInfo().

board.set_device_info(
    architecture_id=2,  # 0=Original OASIS, 1=OASIS-UROS, 2=OASIS-ERIS
    hw_major=1,
    hw_minor=0,
    adc_bits=18,
    teds=0,
    wss=0,
    device_name="OASIS-01",
)

Distributed Acquisition Helpers

OasisBoard now includes helpers for multi-board distributed workflows:

  • This release line is intended for firmware v4 boards.

  • Stored acquisitions in mode="serial" require firmware >= 4.0.0.a2 on OASIS USB CDC+MSC devices.

  • Measurement payload is copied from USB MSC volumes, not transferred over CDC.

  • Live streaming remains CDC-based.

  • acquire(...)

    • Standard acquisition call; on firmware >= 4.0.0.a2 this also performs one-wire distributed primary-board signaling automatically.
  • collect_distributed_serial_files(...)

    • Copies .OASISraw/.OASISmeta from multiple board-specific USB MSC volumes and writes local files.
  • stack_distributed_measurements(...)

    • Loads multiple distributed files and stacks them into a single array.
  • collect_and_stack_distributed(...)

    • One-shot helper for USB MSC collection by board serial port + optional manual file sources + stacking.
  • merge_h5_files(...)

    • Merges multiple OASIS .h5 files into one consistent dataset with global channel numbering.
    • Stores merge metadata (board_count, channels_per_board, source_files, source_labels).

Example:

from oasis_api import OasisBoard

primary = OasisBoard(mode="serial", port="/dev/cu.usbmodem11101", baudrate=1000000)
resolved = "dist_run"
primary.acquire(t_sample=0.25, f_sample=2000, custom_filename=resolved)

result = primary.collect_and_stack_distributed(
    filename=resolved,
    serial_ports=["/dev/cu.usbmodem11101", "/dev/cu.usbmodem11201"],
    t_sample=0.25,
    f_sample=2000,
    output_dir="./distributed_pull",
)

stacked = result["stacked"]      # (n_devices, 8, n_samples)
flattened = result["flattened"]  # (n_devices*8, n_samples)

Merge Existing H5 Files

from oasis_api import OasisBoard

result = OasisBoard.merge_h5_files(
    input_files=["board1.h5", "board2.h5"],
    output_file="merged.h5",
    align="truncate",  # or "pad"
    overwrite=True,
)
print(result)

Merged files can be loaded and plotted without prior knowledge of board count:

board = OasisBoard(mode="offline")
board.load_h5("merged.h5")
board.plot_data()  # adapts to total channel count with board-aware labels (e.g. board_1:CH1)

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

oasis_api-4.0.0b1.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

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

oasis_api-4.0.0b1-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file oasis_api-4.0.0b1.tar.gz.

File metadata

  • Download URL: oasis_api-4.0.0b1.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for oasis_api-4.0.0b1.tar.gz
Algorithm Hash digest
SHA256 56b75f4f32f6abedfac9e343c12040c51c7e51628d2f93e78ffdc86da6015a3a
MD5 5bb7b7f0f8a619c8f69029f7c021341a
BLAKE2b-256 e6b5aaff114addf556e9648a9a280a2a8681acfdc1fc33a829a660ab9ca52920

See more details on using hashes here.

File details

Details for the file oasis_api-4.0.0b1-py3-none-any.whl.

File metadata

  • Download URL: oasis_api-4.0.0b1-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for oasis_api-4.0.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 d2af26ec4654dbfe5c3287e7445eab02a5418fa9e2cdb8d59638d6376af03002
MD5 b4a7c7f314330570f2fee2c3e4068585
BLAKE2b-256 1b7ae7627c18ae1c2d7fb28afa8fb4891a1cbbb24ebea0b601f7ab931a65c2b5

See more details on using hashes here.

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