Skip to content

SpectroscopyTool

Description

Represents an Ocean Optics Spectroscopy Tool (Spectrometer, Light Source, and Probe) integrated with the Jubilee system. Uses the proprietary OceanDirectAPI SDK (closed-source) for hardware communication.

Handles setting acquisition parameters, collecting spectra at precise deck locations, dark spectrum correction, and file saving/loading for downstream analysis.

Constructor

python
SpectroscopyTool(index, name)
ParameterTypeDescription
indexintTool index for the spectroscopy module.
namestrTool name.

Key Properties

PropertyTypeDescription
_api_versionstrAPI version of the Ocean Insight SDK.
_usb_devicelistList of detected connected USB devices.
_device_idlistDevice IDs of connected spectrometers.
_modelstrModel name of the spectrometer.
_serial_numberstrSerial number of the spectrometer.
_integration_timeintCurrent integration time setting (in microseconds).
wavelengthslistList of measured wavelengths (nm).

Important Methods

MethodReturnsDescription
_open_device()deviceOpens and connects to available Ocean Insight spectrometer devices.
integration_time(t, units)NoneSet integration time (supports us, ms, s units).
scans_to_average(n)NoneSet the number of scans to average per spectrum.
boxcar_width(w)NoneSet or query boxcar smoothing width.
lamp_shutter(open=True)NoneOpen/close the spectrometer’s light source shutter (if supported).
_take_spectrum(open=True)arrayCollects a raw intensity spectrum.
dark_spectrum(int_time, scan_num, boxcar_w, ...)arrayCollects and stores a dark (background) spectrum.
collect_spectrum(location, int_time, scan_num, boxcar_w, ...)arrayMoves to a specified location and collects a corrected spectrum.
save_to_file(data, dark=False, path=None, filename=None)NoneSaves spectrum and metadata to a .txt file.
read_from_file(filepath, scale=True, reference_spectrum=None)tupleLoads and optionally scales a saved spectrum.
scale_intensity(data, reference_spectrum)listScales intensities based on a reference spectrum.

Method Details

Set Integration Time

python
integration_time(t: float, units: str = "ms")

Set the spectrometer’s integration time. Supports microseconds (us), milliseconds (ms), and seconds (s).

Collect Spectrum

python
collect_spectrum(location, int_time, scan_num, boxcar_w, ...)

Move the machine head to the specified location and collect a spectrum under current settings.

  • Corrects for dark counts if available.
  • Optionally saves the spectrum and metadata to disk.

Collect Dark Spectrum

python
dark_spectrum(int_time, scan_num, boxcar_w, save=False, path=None, filename=None)

Collect a dark background spectrum with the light source shutter closed.

  • Automatically used to correct future measurements.

Save and Load Spectrum

python
save_to_file(data, dark=False, path=None, filename=None)
read_from_file(filepath, scale=True, reference_spectrum=None)

Save measured spectra with full metadata or reload previous measurements. Supports intensity scaling by reference spectrum when loading.

Usage Flow Example

python
# Initialize SpectroscopyTool
spec_tool = SpectroscopyTool(index=2, name="ocean_optics_probe")

# Set acquisition parameters
spec_tool.integration_time(100, units="ms")
spec_tool.scans_to_average(5)
spec_tool.boxcar_width(2)

# Take a dark spectrum
spec_tool.dark_spectrum(int_time=100, scan_num=5, boxcar_w=2)

# Move to a well and collect sample spectrum
spectrum = spec_tool.collect_spectrum(my_well, int_time=100, scan_num=5, boxcar_w=2, save=True)

# Save or reload data
spec_tool.save_to_file(spectrum)
metadata, measurements = spec_tool.read_from_file("./saved_spectrum.txt", scale=True)

Important Notes

  • OceanDirectAPI must be installed separately; it is not open-source.
  • The system automatically applies dark correction if a dark spectrum has been previously collected.
  • Integration time must be within the hardware-supported limits (validated automatically).
  • Some light sources may not have a controllable shutter; error messages are handled gracefully.

Pre-release documentation · Internal research use only · Not authorized for redistribution.