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
SpectroscopyTool(index, name)| Parameter | Type | Description |
|---|---|---|
index | int | Tool index for the spectroscopy module. |
name | str | Tool name. |
Key Properties
| Property | Type | Description |
|---|---|---|
_api_version | str | API version of the Ocean Insight SDK. |
_usb_device | list | List of detected connected USB devices. |
_device_id | list | Device IDs of connected spectrometers. |
_model | str | Model name of the spectrometer. |
_serial_number | str | Serial number of the spectrometer. |
_integration_time | int | Current integration time setting (in microseconds). |
wavelengths | list | List of measured wavelengths (nm). |
Important Methods
| Method | Returns | Description |
|---|---|---|
_open_device() | device | Opens and connects to available Ocean Insight spectrometer devices. |
integration_time(t, units) | None | Set integration time (supports us, ms, s units). |
scans_to_average(n) | None | Set the number of scans to average per spectrum. |
boxcar_width(w) | None | Set or query boxcar smoothing width. |
lamp_shutter(open=True) | None | Open/close the spectrometer’s light source shutter (if supported). |
_take_spectrum(open=True) | array | Collects a raw intensity spectrum. |
dark_spectrum(int_time, scan_num, boxcar_w, ...) | array | Collects and stores a dark (background) spectrum. |
collect_spectrum(location, int_time, scan_num, boxcar_w, ...) | array | Moves to a specified location and collects a corrected spectrum. |
save_to_file(data, dark=False, path=None, filename=None) | None | Saves spectrum and metadata to a .txt file. |
read_from_file(filepath, scale=True, reference_spectrum=None) | tuple | Loads and optionally scales a saved spectrum. |
scale_intensity(data, reference_spectrum) | list | Scales intensities based on a reference spectrum. |
Method Details
Set Integration Time
integration_time(t: float, units: str = "ms")Set the spectrometer’s integration time. Supports microseconds (us), milliseconds (ms), and seconds (s).
Collect Spectrum
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
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
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
# 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.