From 09a811fff65ec2befc2c28e6a6fa01386c487999 Mon Sep 17 00:00:00 2001 From: cjsha Date: Fri, 12 Apr 2024 14:36:40 -0400 Subject: [PATCH] Update AnalogIODevice workflow - New AnalogIODevice.bonsai (from Jon) saves data - Added a Python file (from Jon) to read data --- .../Bonsai.ONIX/Nodes/AnalogIODevice.rst | 5 ++++ .../_static/bonsai/workflows/AnalogIO.bonsai | 23 +++++++++++++++++-- source/_static/bonsai/workflows/AnalogIO.svg | 4 ++-- .../bonsai/workflows/load-analog-data.py | 14 +++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 source/_static/bonsai/workflows/load-analog-data.py diff --git a/source/Software Guide/Bonsai.ONIX/Nodes/AnalogIODevice.rst b/source/Software Guide/Bonsai.ONIX/Nodes/AnalogIODevice.rst index 78ce0bd0..dbd421ce 100644 --- a/source/Software Guide/Bonsai.ONIX/Nodes/AnalogIODevice.rst +++ b/source/Software Guide/Bonsai.ONIX/Nodes/AnalogIODevice.rst @@ -73,3 +73,8 @@ options. - The direction of the channel. If set to Output, the measured voltage is automatically looped back through the analog input. +Loading Scripts +-------------------------- +The following scripts can be used to load the data produced by this workflow in Python (using Numpy): + +- :download:`load-analog-data.py <../../../_static/bonsai/workflows/load-analog-data.py>` diff --git a/source/_static/bonsai/workflows/AnalogIO.bonsai b/source/_static/bonsai/workflows/AnalogIO.bonsai index 1776309a..3c14f4e1 100644 --- a/source/_static/bonsai/workflows/AnalogIO.bonsai +++ b/source/_static/bonsai/workflows/AnalogIO.bonsai @@ -1,7 +1,8 @@  - @@ -69,14 +70,32 @@ Data + + + analog-data_.raw + Timestamp + false + ColumnMajor + + Clock + + + analog-clock_.raw + Timestamp + false + ColumnMajor + + - + + + \ No newline at end of file diff --git a/source/_static/bonsai/workflows/AnalogIO.svg b/source/_static/bonsai/workflows/AnalogIO.svg index 0a134fc1..0e3c5e01 100644 --- a/source/_static/bonsai/workflows/AnalogIO.svg +++ b/source/_static/bonsai/workflows/AnalogIO.svg @@ -1,3 +1,3 @@ -]>ONI Context(riffa,0)DataClockAnalogIODeviceRealTimeFunctionGenerator \ No newline at end of file + +]>ONI Context(riffa/0)MatrixWriterMatrixWriterDataClockAnalogIODeviceRealTimeFunctionGenerator \ No newline at end of file diff --git a/source/_static/bonsai/workflows/load-analog-data.py b/source/_static/bonsai/workflows/load-analog-data.py new file mode 100644 index 00000000..6deeb963 --- /dev/null +++ b/source/_static/bonsai/workflows/load-analog-data.py @@ -0,0 +1,14 @@ +import numpy as np +import matplotlib.pyplot as plt + +# Load data from AnalogIO workflow +suffix = '2024-04-11T12_24_25'; # Change to match file names' suffix + +analog_time = np.fromfile('analog-clock_' + suffix + '.raw', dtype=np.uint64) / 250e6 +analog_data = np.fromfile('analog-data_' + suffix + '.raw', dtype=np.float32) +analog_data = np.reshape(analog_data, (-1, 12)) + + +# plot the first 100k samples on each channel (1 second of data) +plt.close('all') +plt.plot(analog_time[0:100000], analog_data[0:100000, :])