API download log file and convert
-
Moku:Go
Moku:Go Arbitrary Waveform Generator Moku:Go Data Logger Moku:Go Frequency Response Analyzer Moku:Go Logic Analyzer & Pattern Generator Moku:Go Oscilloscope & Voltmeter Moku:Go PID Controller Moku:Go Spectrum Analyzer Moku:Go Waveform Generator Moku:Go Power Supplies Moku:Go Digital Filter Box Moku:Go FIR Filter Builder Moku:Go Lock-in Amplifier Moku:Go General Moku:Go Logic Analyzer/Pattern Generator Moku:Go Time & Frequency Analyzer Moku:Go Laser Lock Box Moku:Go Phasemeter
-
Moku:Lab
Moku:Lab General Moku:Lab Arbitrary Waveform Generator Moku:Lab Data Logger Moku:Lab Digital Filter Box Moku:Lab FIR Filter Builder Moku:Lab Frequency Response Analyzer Moku:Lab Laser Lock Box Moku:Lab Lock-in Amplifier Moku:Lab Oscilloscope Moku:Lab Phasemeter Moku:Lab PID Controller Moku:Lab Spectrum Analyzer Moku:Lab Waveform Generator Moku:Lab Time & Frequency Analyzer Moku:Lab Logic Analyzer/Pattern Generator
-
Moku:Pro
Moku:Pro Arbitrary Waveform Generator Moku:Pro Data Logger Moku:Pro Frequency Response Analyzer Moku:Pro Oscilloscope Moku:Pro PID Controller Moku:Pro Spectrum Analyzer Moku:Pro Waveform Generator Moku:Pro Lock-in Amplifier Moku:Pro Digital Filter Box Moku:Pro FIR Filter Builder Moku:Pro Phasemeter Moku:Pro Multi-instrument Mode Moku:Pro General Moku:Pro Logic Analyzer/Pattern Generator Moku:Pro Time & Frequency Analyzer
- Python API
- MATLAB API
- Arbitrary Waveform Generator
- Data Logger
- Digital Filter Box
- FIR Filter Builder
- Frequency Response Analyzer
- Laser Lock Box
- Lock-in Amplifier
- Oscilloscope
- Phasemeter
- PID Controller
- Spectrum Analyzer
- Time & Frequency Analyzer
- Waveform Generator
- Logic Analyzer & Pattern Generator
- Multi Instrument Mode
- Moku Cloud Compile
- Moku general
- LabVIEW
Log and download .li file
First, start a logging session and download your file
# moku example: Basic Datalogger
# (c) 2025 Liquid Instruments Pty. Ltd.
import os
import time
from moku.instruments import Datalogger
# Connect to your Moku
i = Datalogger('192.168.###.###', force_connect=False)
try:
# Set-up the Datalogger
i.set_samplerate(100)
i.set_acquisition_mode(mode='Precision')
i.generate_waveform(channel=1, type='Sine', amplitude=1, frequency=10e3)
# Start a logging session
logFile = i.start_logging(duration=10)
# Track progress percentage of the data logging session
complete = False
while complete is False:
time.sleep(0.5)
progress = i.logging_progress()
complete = progress['complete']
if 'time_remaining' in progress:
print(f"Remaining time {progress['time_remaining']} seconds")
# Download the .li log from Moku
i.download(logFile['location'], logFile['file_name'],
os.path.join(os.getcwd(), logFile['file_name']))
print(f"Downloaded log file to local directory. {logFile['file_name']}")
except Exception as e:
print(f'Exception occurred: {e}')
finally:
# Close the connection to the Moku device
i.relinquish_ownership()
This will output a trace similar to this:
{'sample_rate': 100.0}
{'mode': 'Precision'}
{'amplitude': 1.0, 'frequency': 10000.0, 'offset': 0.0, 'phase': 0.0, 'type': 'Sine'}
...
Remaining time 0 seconds
Downloaded log file to local directory. MokuDataLoggerData_20250116_102402.li
Mokucli method
Ensure you have mokucli installed, you can download it from the Utilities page.
From your command line, you can convert to your desired file type; csv, npy, mat, or hdf5. We'll be converting to csv for this example. Change directories to where the file is located or use the full file path:
C:\Users\user\Downloads>mokucli convert MokuDataLoggerData_20250116_102402.li --format=csv
[===========================================================================]
Done.
LI File Converter method
Alternatively, you can convert the file using the LI File Converter GUI, this can be accessed from the Moku: App or downloaded from the Utilities page
You can choose the file type, then drag and drop the file to the converter, or open the file from the converter using “File | Open file” or "Ctrl/Cmd + O"
Analyze data
You can then use the converted file to analyze your data.
import os
import csv
import numpy as np
file_name = "MokuDataLoggerData_20250116_102402.csv"
channels = 2
print(file_name)
assert os.path.isfile(file_name), "Convert failed, no file received"
data = {'time':[], 'ch1':[]}
with open(file_name, 'r') as f:
load = csv.reader(f)
file = np.array([[float(row[0])] + [float(row[i]) for i in range(1, channels+1)] for row in load if row[0][0] != '%'])
f.close()
data['time'] = file[:,0]
for i in range(1, channels+1):
data[f'ch{i}'] = file[:,i]
keys = data.keys()
for key in keys:
print(f"'{key}': {str(data[key][:3])[:-1]} ... {data[key][-1]}]")
This will return something similar to
MokuDataLoggerData_20250116_102402.csv
'time': [0. 0.01 0.02 ... 9.99]
'ch1': [0.00063297 0.00077466 0.00071688 ... 0.00067479823461]
'ch2': [0.01406568 0.01389566 0.014152 ... 0.014421103911]
Other file type conversions and reading methods for Python
Here is a cheat-sheet style summary of the file type conversions and how to read them in Python, adjust the file_name
and channels
parameters to match your experiment.
.mat
C:\Users\LItes\Downloads>mokucli convert MokuDataLoggerData_20250116_102402.li --format=mat
[===========================================================================]
Done.
import os
from scipy.io import loadmat
file_name = "MokuDataLoggerData_20250116_102402.mat"
channels = 2
print(file_name)
assert os.path.isfile(file_name), "Convert failed, no file received"
data = {'time':[], 'ch1':[]}
file = loadmat(file_name)
data['time'] = file['moku']['data'][0, 0][:,0]
for i in range(1, channels+1):
data[f'ch{i}'] = file['moku']['data'][0, 0][:,i]
keys = data.keys()
for key in keys:
print(f"'{key}': {str(data[key][:3])[:-1]} ... {data[key][-1]}]")
.npy
C:\Users\LItes\Downloads>mokucli convert MokuDataLoggerData_20250116_102402.li --format=npy
[===========================================================================]
Done.
import os
import numpy as np
file_name = "MokuDataLoggerData_20250116_102402.npy"
channels = 2
print(file_name)
assert os.path.isfile(file_name), "Convert failed, no file received"
data = {'time':[], 'ch1':[]}
load = np.load(file_name)
file = np.array([[load[i][0]] + [load[i][j] for j in range(1, channels+1)] for i in range(len(load))])
data['time'] = file[:,0]
for i in range(1, channels+1):
data[f'ch{i}'] = file[:,i]
keys = data.keys()
for key in keys:
print(f"'{key}': {str(data[key][:3])[:-1]} ... {data[key][-1]}]")
.hdf5
C:\Users\LItes\Downloads>mokucli convert MokuDataLoggerData_20250116_102402.li --format=hdf5
[===========================================================================]
Done.
import os
import numpy as np
import h5py
file_name = "MokuDataLoggerData_20250116_102402.hdf5"
channels = 2
print(file_name)
assert os.path.isfile(file_name), "Convert failed, no file received"
data = {'time':[], 'ch1':[]}
load = h5py.File(file_name, 'r')
file = np.array(list(load['moku']),dtype=np.dtype('float'+',float'*channels))
file.dtype.names=['time'] + [f'ch{i}' for i in range(1, channels+1)]
data['time'] = file['time']
for i in range(1, channels+1):
data[f'ch{i}'] = file[f'ch{i}']
keys = data.keys()
for key in keys:
print(f"'{key}': {str(data[key][:3])[:-1]} ... {data[key][-1]}]")