Giter Club home page Giter Club logo

pydmdreader's Introduction

DEWETRON pyDmdReader

pyDmdReader is a Python wrapper for the Dewetron DMD Reader API. It allows to conveniently read DMD files that were recorded with the Dewetron Oxygen measurement software.

Installation

Currently, the package needs to be installed by using github release archives. Direct integration into the Python Package Index is planned in the future.

Microsoft Windows

The pyDmdReader python package can be installed with

python3 -m pip install https://github.com/DEWETRON/pyDmdReader/archive/refs/tags/v0.5.0.tar.gz

Windows binaries (DMD reader DLLs) are installed automatically.

Linux

Currently, we support pyDmdReader for Linux on Debian 10 Buster and Ubuntu 20.04 Focal. Each Linux distribution requires a separate rpm package to ensure no broken dependencies. Contact Dewetron if you need support for another distribution or version.

The dmdreader packages can be found on the current release page. They need to be installed manually using the following command (adapt the filename to the one downloaded from the current release):

sudo apt install ./dewetron-dmd-reader-api_6.0.0-buster_amd64.deb

Now install pyDmdReader:

python3 -m pip install https://github.com/DEWETRON/pyDmdReader/archive/refs/tags/v0.5.0.tar.gz

If pip fails, please try manual installation:

You have to fullfill other python library dependencies:

pip3 install pandas

or run

pip3 install -r requirements.txt

This will automatically install numpy, which is also needed.

Do NOT install these packages using apt. These are outdated and incompatible with pyDmdReader.

Example usage

There are example scripts in the examples subdirectory that show how to read DMD files in Python. A simple example looks like this:

import pyDmdReader

dmd = pyDmdReader.DmdReader('my_recording.dmd')
print(f"Channels found in file: {dmd.channel_names}")

# Read configuration of first channel
first_channel = dmd.channels[dmd.channel_names[0]]
print(f"Name: {first_channel.name}")
print(f"Unit: {first_channel.unit}")
print(f"Samplerate: {first_channel.sample_rate} Hz")

# Read all data from channel 'AI 1/1'
data = dmd.read_dataframe('AI 1/1')
print(data)

# Read data from channel 'AI 1/1' from 1s to 3s after recording start
data = dmd.read_dataframe('AI 1/1', start_time = 1, end_time = 3)

dmd.close()

It is also possible to scope the DMD reader lifetime to avoid forgetting to call close()

import pyDmdReader
with pyDmdReader.DmdReader('name.dmd') as dmd:
    print(f"Channels: {dmd.channel_names}")

Dealing with duplicate channel names

When the DMD file has duplicate channel names, it is not possible to read data by using the channel name as a key (this will throw an exception if duplicate names are found). Instead, it is possible to access channels by a unique ID.

import pyDmdReader

with pyDmdReader.DmdReader('my_recording.dmd') as dmd:
    print(f"Channels found in file: {dmd.channel_names}")

    # Read first two channels
    data = dmd.read_dataframe(dmd.channel_ids[0:2])
    print(data)

In order to retrieve the channel name or other information of a channel with a unique ID, use the allchannels property of the DmdReader, which maps a channel id to the channel information. When there are no duplicate channel names, it is possible to use the channels property, which uses channel names as the map key.

Testing

If you want to try out the DMD Reader and have no DMD files at hand, feel free to use example files from the tests/data directory.

This repository comes with pytest compatible unit tests which can be started by calling pytest (or python -m pytest) from the root directoty of the repository.

Contact

For technical or other DMD reader related questions please contact:

License

MIT License

Copyright (c) 2021-2022 DEWETRON

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. LICENSE (END)

pydmdreader's People

Contributors

dw-systemtest avatar glaure avatar matthiasstraka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.