>>DOWNLOAD HERE<<
By Nathaniel Westlake For use with Ocean Optics Spectrometers and SmarAct MCS2 stages
This code is made to collect spectrometer data at given positions of the stage, this could be used to take scans with a fiber tip or do a spectrally-resolved Knife edge scan using an integrating sphere, or even an axial optimization of SHG.
Essentially, the GUI will show a X,Y,Z checkboxes to select which axes to include in the scan. The code will generate a 1-3 dimension grid based on the selected axes and will scan over $N_x * N_y * N_z$ points (check your integration time and averaging to speed up the scan)
the scan grid will be CENTERED ABOUT ZERO (so zero your axes where you want to center the scan)
Once you start the scan, the control boxes are disabled, so you will need to stop the scan before you can change settings as you cannot change settings while running.
While running, the center pane will show the current slice spectrum. Use the spinboxes under the spectrometer window to change the wavelength range that you are looking at in that plot. The program will scan in an S-pattern to speed up the scan.
upon finishing, save the data with the save button located on the bottom.
This will save it into a MATLAB .mat
format (compatible with both Python and MATLAB) with each coordinate point [x,y,z] and the spectrum for that point as well as the grid for the wavelength axes.
will automatically set the filename as 'Scan_<scan_axes>_YYYY_MM_DD_HH_mm_ss.mat'
into the folder specified in the GUI
Load the data as such:
Python
from scipy.io import loadmat
def open_scan(file_path):
"""
Load a scan from a .mat file and return data, points, and wavelengths.
"""
mat_contents = loadmat(file_path)
data = mat_contents['data']
points = mat_contents['points']
wavelengths = mat_contents['wavelengths'].flatten() # ensure 1D array
return data, points, wavelengths
MATLAB
S = load(file_path);
data = S.data;
points = S.points;
wavelengths = S.wavelengths;
with:
data.shape == (N_scan, N_wavelenghts)
points.shape == (N_scan, 3)
len(wavelengths) == N_wavelenghts
If this is not packaged as a .exe
with PyInstaller then you will need to run the python itself. You will need the dependencies installed into a venv
x64 Python 3.12 venv (recommend using Anaconda/miniconda) with packages:
seabreeze and pylablib are only installable via pip install (no conda install) as of 7/14/2025
execute inside the venv (sdk_env) PS C:\path\to\gui> python3 SmarAct_Spec_Scan_GUI.py
Also Required:
OceanView (for the spectrometer)
SmarAct Software (Precision Tool Commander) to get the SDK .dll
's under C:\SmarAct\MCS\SDK\lib
- This location is hard-coded into the utils.hardware.ocean_spectrometer.py
file
this uses 3 worker threads and internal widgets to controll the devices individually and not hitch the GUI while waiting for collecting or while stage is moving, etc.
CollectionWorker - Responsible for collecting data - Works in a state machine to send and collect singals from the other workers and the center GUI window
SpectrometerWorker - Responsible for collecting data from the spectrometer as requested by the Collection worker as well as "Live View" in the SpectrometerWidget
StageWorker - Responsible for moving the stage from the StageWidget and the CollectionWorker as well as sending signals to the StageWidget window to display current positions
MainWindow - Holds the 3 panes and manages the center pane with the setup and control for the overall collection
SpectrometerWidget - can work as a standalone program for the spectrometer, but works as an individual control for the spectrometer in this program. Displays the latest output from the SpectrometerWorker
StageWidget - can work as a standalone program for the spectrometer, but works as an individual control for the stage. Displays the latest positon from the StageWorker
uses the custom wrappers under my utils.hardware
to make it easier for me to only have the functions I need for the QTWorker Objects. See the readme there for details