JimHokanson / adinstruments_sdk_python

SDK for ADIstruments files in Python
MIT License
19 stars 6 forks source link

adinstruments_sdk_python

Use this code to read .adicht (Labchart) files into Python. Interfacing with the ADIstruments DLL is done via cffi.


Installation

pip install adi-reader

Test code

    import adi
    f = adi.read_file(r'C:\Users\RNEL\Desktop\test\test_file.adicht')
    # All id numbering is 1 based, first channel, first block
    # When indexing in Python we need to shift by 1 for 0 based indexing
    # Functions however respect the 1 based notation ...

    # These may vary for your file ...
    channel_id = 2
    record_id = 1
    data = f.channels[channel_id-1].get_data(record_id)
    import matplotlib.pyplot as plt
    plt.plot(data)
    plt.show()

Dependencies

Setup for other Python versions

For upgrading to 3.8, I installed Python 3.8. Within the interpreter I ran the following:

import subprocess
import sys

#https://stackoverflow.com/questions/12332975/installing-python-module-within-code
def install(package):
    subprocess.call([sys.executable, "-m", "pip", "install", package])

install("cffi")

import os
#This would need to be changed based on where you keep the code
os.chdir('E:/repos/python/adinstruments_sdk_python/adi')

# For 64 bit windows
exec(open("cffi_build.py").read())

#------------------------- ONLY IF 32 BIT WINDOWS -------------------
# For 32 bit windows
exec(open("cffi_build_win32.py").read())

PyPi Notes

Improvements

This was written extremely quickly and is missing some features. Feel free to open pull requests or to open issues.