Skip to main content

Python wrappers around functions in Dewesoft DWDataReaderLib shared library

Project description

DEWESoft, a company making hardware for data acquisition, also provide software applications (Windows) for working with data sets produced with the hardware. Files are in their proprietary formats such as .d7d, .d7z or .dxd. To work with the same data using a programming language like Python it is necessary to first convert them to a portable format such as text. To get around this extra step, DEWESoft provide a shared library called DWDataReaderLib.

dwdat2py is a python package with wrappers around the functions provided in DWDataReaderLib.

Installation

Using pip

pip install dwdat2py

Installing from source

Clone the repo with git clone https://github.com/tomnor/dwdat2py.git, cd into dwdat2py directory (the directory with the setup.py file) and say

pip install .

Libraries are shipped with dwdat2py

By installation of dwdat2py, the Dewesoft libraries are included. Be aware that the libraries are gratis but non-free binary blobs. The libraries come with an EULA that permits use and redistribution in third party projects as far as I understand it.

Libraries are installed in a sub-directory to dwdat2py called libs.

Libraries are retrieved from https://dewesoft.com/download/developer-downloads. Find a record “Dewesoft Data Reader Library” and click the download button to get a zip file (DWDataReader.zip) with the libs. Or skip that, since they are included with dwdat2py.

Usage

from dwdat2py import wrappers as dw

dw.init()
dw.open_data_file('dat1')
# ... other functions to get at data in dat1 ...
dw.close_data_file()
dw.open_data_file('dat2')
# ... other functions to get at data in dat2 ...
dw.close_data_file() # work is done for now
dw.de_init()
# optionally init() again for a new session.

The calls init() and de_init() must be called first and last respectively. Make sure open_data_file(...) is called successfully before close_data_file(...), else don’t call close_data_file.

The highest level function for now in this package is this:

def channel_reduced(channel, reduction, encoding=None):
    """Return a flat list of data for channel reduced to reduction.

    Parameters
    ----------

    channel : int or str
        Either the channel index or the channel name.

    reduction : int
        One of the following
        time_stamp = 0
        ave = 1
        min = 2
        max = 3
        rms = 4

    encoding : str
        encoding to pass to `get_channel_list()`, which see.

    Wraps:
        Nothing explicit. This is a support function to simplify getting
        reduced data from a channel.

    """

And if you happen to know the index or name of the channels, this function should suffice to get at the data, channel by channel. Else you would need to call some helper functions first to prepare for this call.

Access to the wrappers module is also provided as a context manager:

@contextmanager
def wrappersimport(fn, fsencoding=None):
    """Provide context access to the wrappers module.

    Return a handle to the wrappers module in a context manager and file
    `fn` (str) opened for operations (a .dxd file for example).
    Initialization and deinitialization is provided by this context
    manager, as well as opening and closing the file.

    The file information resulting from opening the file is available as
    a module level variable `fileinfo`, (`handle.fileinfo`).

    The function that `wrappers.open_data_file` wraps require bytes as
    file name. `fsencoding` is used in the call to
    `wrappers.open_data_file` but is hopefully not necessary to specify
    since os.fsencode() is used by default.

    Example usage:

    >>> import dwdat2py
    >>> with dwdat2py.wrappersimport(fn) as wi:
    ...    print(wi.fileinfo)
    ...    chlist = wi.get_channel_list(encoding='latin1')
    ...    for chinfo in chlist:
    ...        # print the average values from each channel (1)
    ...        print(wi.channel_reduced(chinfo.index, 1))
    ...    # get the "time stamps" (0)
    ...    time = wi.channel_reduced(chlist[0].index, 0)

    As with importing the wrappers module in the standard way, this will
    fail if the shared library is not found.

    """

Using libs not shipped with dwdat2py

The path to the libs can be specified by setting a variable dwdat2py.DEWELIBDIR to the directory containing the libs:

>>> import dwdat2py
>>> dwdat2py.DEWELIBDIR = '~/latestdwlibs'

for example. This setting must be done before loading a datafile. The structure of the directory should look like this:

$ tree latestdwlibs
latestdwlibs
|-- DWDataReaderLib.dll
|-- DWDataReaderLib.so
|-- DWDataReaderLib64.dll
`-- DWDataReaderLib64.so

Meaning, the shared libraries should sit directly inside the DEWELIBDIR directory. Only one of those files is really necessary depending on the OS and platform.

Contribute

Please report bugs and send suggestions or patches to the author. Or make an issue or pull request on the repo home at Github

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

dwdat2py-0.3.3.tar.gz (704.8 kB view details)

Uploaded Source

Built Distribution

dwdat2py-0.3.3-py3-none-any.whl (710.4 kB view details)

Uploaded Python 3

File details

Details for the file dwdat2py-0.3.3.tar.gz.

File metadata

  • Download URL: dwdat2py-0.3.3.tar.gz
  • Upload date:
  • Size: 704.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for dwdat2py-0.3.3.tar.gz
Algorithm Hash digest
SHA256 27a5dca83537ba41ab8708b0ba29aeaed5cf38f6bfc8dd6d91793dabb2308a16
MD5 ed960a1fa23a7b01b3225f3393746c69
BLAKE2b-256 cc41a9ed1e1de5cc634c394055fecdd32e611bdb0f869a9943f376a21f4fbb79

See more details on using hashes here.

File details

Details for the file dwdat2py-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: dwdat2py-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 710.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for dwdat2py-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d1a254fe6fd0fffe9ec80ff8d059da007e656e58d47460a316a354d08bf84153
MD5 501938590302b8284463a9a0bc47f199
BLAKE2b-256 8f1301a8451dc541900b6df350d9a1e7f36e366afbbb0b1e79bdf4e51b2e218b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page