A software emulator for the `python-seabreeze` package
A software emulator for the
python-seabreeze : Python module for Ocean Optics spectrometers.
The purpose of this library is to create an all-software emulator of the
library, so that developers (like the authors) who wish create packages which utilize
seabreeze need not have a physical spectrometer on-hand to test their software.
Currently only parts of the
seabreeze.cseabreeze backend and parts of the
seabreeze.spectrometers modules are emulated (here as
seatease.spectrometers respectively), but more functionality is planned in
later versions. Additionally, the emulator currently assumes only a single USB2000-like
spectrometer is connected (though this can be changed, see
This USB2000-like device is treated like it is constantly measuring a 500nm spectral feature with constant photon flux, so changing the integration time will change the peak's appearent number of counts.
To install the current stable version:
$ pip3 install seatease
It is highly advised that one references the
documentatation, as many of the quirks of
seatease are intended so as to mimic the
Also see the examples folder for slightly more details.
The main frontend functionality provided is the
class, which hosts all the main calls to the underlying (emulated) hardware device,
instances can be created three ways:
# Get any spectrometer spec = seatease.spectrometers.Spectrometer.from_first_available() # Get a specific spectrometer spec = seatease.spectrometers.Spectrometer.from_serial_number("your-serial-number") # List the devices, and instantiate one of them dev_list = seatease.spectrometers.list_devices() print(dev_list) # Prints list of available devices spec = seatease.spectrometers.Spectrometer(dev_list)
With the spectrometer instance, the exposed methods allow retrival of emulated hardware attributes:
# Print wavelengths print(spec.wavelengths()) # Set integration time spec.integration_time_micros(10*1000) # 10 ms # Print intensities print(spec.intensities())
Again, the Backend API
seabreeze.cseabreeze package is helpful in understanding the following:
The main backend functionality provided is the
class, which hosts all the main calls to the underlying (emulated) hardware device.
However, it cannot (or rather, should not when trying to faithfully emulate
be instantiated directly, but rather the instances are instantiated when the module is
imported, and a reference to these instances are kept in the
instances. So, to actually get a
dev_list = sb.cseatease.SeaTeaseAPI.list_devices() print(dev_list) # Prints available devices dev = dev_list
All the features of the device are stored as attributes of the
dev.f, for example:
# Get wavelengths dev.f.spectrometer.get_wavelengths() # Set integration time dev.f.spectrometer.set_integration_time_micros(100*1000) # 100 ms # Get intensities dev.f.spectrometer.get_intensities()
Alternatively, the same attributes are exposed in dictionary form in
# Get wavelengths dev.features["spectrometer"].get_wavelengths() # Set integration time dev.features["spectrometer"].set_integration_time_micros(100*1000) # 100 ms # Get intensities dev.features["spectrometer"].get_intensities()
We are happy for any contributions from others! In particular, those with experience
using other Ocean Optics spectrometers (besides just the USB2000) with
who can shed light on the expected features and functionality from those devices.
Also, just fleshing out the rest of the backend API.
For development, clone this directory, setup a python virtual environment in the main directory and install:
$ python3 -m venv venv $ source venv/bin/activate (venv) $ python3 setup.py install
After making changes to the source, re-run that last line to re-install.
venv in Jupyter Lab
If you want to use jupyter lab to edit and test, add the venv kernel to jupyter's local files so that you can run the .ipynb files:
(venv) $ pip3 install ipykernel (venv) $ python3 -m ipykernel install --user --name=venv
To remove the kernel when you are done:
(venv) $ jupyter kernelspec uninstall venv
Create the source files and upload:
(venv) $ python3 setup.py sdist bdist_wheel (venv) $ python3 -m twine upload dist/*
See: here for more details.
The authors would like to thank Andreas Poehlmann and collaborators for creating the original
python-seabreeze package, which this library emulates in software. His package has been indispensable to our research.
The authors would also like to thank Caylee Van Schenck for the excellent pun after which this library is named.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size seatease-0.3-py3-none-any.whl (9.8 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size seatease-0.3.tar.gz (8.8 kB)||File type Source||Python version None||Upload date||Hashes View|