Skip to main content

A software emulator for the `python-seabreeze` package

Project description

SeaTease

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 python-seabreeze 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.cseatease and seatease.spectrometers respectively), but more functionality is planned in later versions. Additionally, the hardware emulator currently assumes only a single USB2000-like spectrometer is connected (though this can be changed, see seatease.cseatease.hardware).

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 apparent number of counts.

Installing

To install the current stable version:

 $ pip3 install seatease

Basic Use

It is highly advised that one references the python-seabreeze documentatation, as many of the quirks of seatease are intended so as to mimic the actual python-seabreeze package.

Also see the examples folder for slightly more details.

Frontend functionality

The main frontend functionality provided is the seatease.spectrometers.Spectrometer class, which hosts all the main calls to the underlying (emulated) hardware device, instances can be created three ways:

# Get any spectrometer
import seatease.spectrometers as s

spec = s.Spectrometer.from_first_available()

# Get a specific spectrometer
spec = s.Spectrometer.from_serial_number("your-serial-number")

# List the devices, and instantiate one of them
dev_list = s.list_devices()
print(dev_list) # Prints list of available devices
spec = s.Spectrometer(dev_list[0])

With the spectrometer instance, the exposed methods allow retrial 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())

Have fun!

Backend functionality

Again, the Backend API for the seabreeze.cseabreeze package is helpful in understanding the following:

SeaTeaseDevice

The main backend functionality provided is the seatease.cseatease.SeaTeaseDevice 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 seabreeze) be instantiated directly, but rather the instances are instantiated when the module is imported, and a reference to these instances are kept in the seatease.cseatease.SeaTeaseAPI instances. So, to actually get a SeaTeaseDevice instance:

from seatease.cseatease import SeaTeaseAPI
dev_list = SeaTeaseAPI().list_devices()
print(dev_list) # Prints available devices
dev = dev_list[0]

.f Functionality

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()

.features Functionality

Alternatively, the same attributes are exposed in dictionary form in dev.features

# Get wavelengths
dev.features["spectrometer"][0].get_wavelengths()

# Set integration time
dev.features["spectrometer"][0].set_integration_time_micros(100*1000) # 100 ms

# Get intensities
dev.features["spectrometer"][0].get_intensities()

Development

We are happy for any contributions from others! In particular, those with experience using other Ocean Optics spectrometers (besides just the USB2000) with python-seabreeze 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.

Using 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

PyPI

Create the source files and upload:

 (venv) $ python3 setup.py sdist bdist_wheel
 (venv) $ python3 -m twine upload dist/*

See: here for more details.

Acknowledgements

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seatease-0.4.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distributions

seatease-0.4.0-py3.7.egg (16.7 kB view details)

Uploaded Source

seatease-0.4.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file seatease-0.4.0.tar.gz.

File metadata

  • Download URL: seatease-0.4.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for seatease-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d2d6483ef54025853dcdf5a8ef1b3b9cd4f4648605292703c8368a9fe7708e5f
MD5 d22265b88ac12b2c4074d3406b3e815e
BLAKE2b-256 e05fa3bc847e05106fbbf5222c3e96e95dd50c0aaee5fd9ac6ad999c81892778

See more details on using hashes here.

File details

Details for the file seatease-0.4.0-py3.7.egg.

File metadata

  • Download URL: seatease-0.4.0-py3.7.egg
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for seatease-0.4.0-py3.7.egg
Algorithm Hash digest
SHA256 f18434966c803495bcf637ed77a0545acf9963ad06bdb369ac6f91cfcd6ddcc0
MD5 6510bbd33ade4cd8caa88718212688b2
BLAKE2b-256 a386c5ac4e7e1ebe6d5fe36dfaffc90c29447fbdf186e7470c3ad002a6f02bdd

See more details on using hashes here.

File details

Details for the file seatease-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: seatease-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for seatease-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87657a098c695ad19bc1ba166782a59d2e88e96f335ce75cac013a54d2b6afe4
MD5 17701a8d49e6d9b83c879711ae073392
BLAKE2b-256 c2d3f449c565b5f1c80a167b4ceb05a400fd3c8945e1dcd71da69ad07db6774a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page