# python-seabreeze > Expert guidance for working with the python-seabreeze library and Ocean Optics spectrometers. Use this skill when you need to: (1) Connect to or list Ocean Optics spectrometers, (2) Configure acquisition parameters like integration time, (3) Capture spectral data (wavelengths and intensities), (4) Troubleshoot connection or backend issues (cseabreeze vs pyseabreeze), or (5) Develop new features or fix bugs in the python-seabreeze codebase. - Author: tazomatalax - Repository: tazomatalax/python-seabreeze - Version: 20260123170223 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/tazomatalax/python-seabreeze - Web: https://mule.run/skillshub/@@tazomatalax/python-seabreeze~python-seabreeze:20260123170223 --- --- name: python-seabreeze description: "Expert guidance for working with the python-seabreeze library and Ocean Optics spectrometers. Use this skill when you need to: (1) Connect to or list Ocean Optics spectrometers, (2) Configure acquisition parameters like integration time, (3) Capture spectral data (wavelengths and intensities), (4) Troubleshoot connection or backend issues (cseabreeze vs pyseabreeze), or (5) Develop new features or fix bugs in the python-seabreeze codebase." --- # python-seabreeze This skill provides specialized knowledge for using and developing the `python-seabreeze` library to control Ocean Optics spectrometers. ## Core Concepts ### Backends The library supports two main backends: 1. **cseabreeze**: A Cython wrapper around the official Ocean Optics SeaBreeze C library. Generally faster and more robust on supported platforms. 2. **pyseabreeze**: A pure-python implementation using `pyusb`. Useful for easy extension and platforms where the C library is hard to deploy. Select a backend before importing `seabreeze.spectrometers`: ```python import seabreeze seabreeze.use('pyseabreeze') # or 'cseabreeze' import seabreeze.spectrometers as sb ``` ### Essential Workflow #### 1. Device Discovery List all connected devices: ```python import seabreeze.spectrometers as sb devices = sb.list_devices() ``` #### 2. Connection Connect to the first available spectrometer or by serial number: ```python spec = sb.Spectrometer.from_first_available() # OR # spec = sb.Spectrometer.from_serial_number("SERIAL_NUMBER") ``` #### 3. Configuration The most common parameter is integration time (in microseconds): ```python spec.integration_time_micros(20000) # 20ms ``` #### 4. Data Acquisition Retrieve wavelengths and intensities as NumPy arrays: ```python wavelengths = spec.wavelengths() intensities = spec.intensities() ``` ## Troubleshooting ### Windows Connection Issues - **Drivers**: Ensure the correct WinUSB or libusb filters are applied if using `pyseabreeze`. - **Backend Mismatch**: If a device isn't found, try switching between `cseabreeze` and `pyseabreeze`. - **Permissions**: On Linux, ensure udev rules are installed (see [os_support/10-oceanoptics.rules](os_support/10-oceanoptics.rules)). ## Development Guide ### Project Structure - `src/seabreeze/`: Python source code. - `src/libseabreeze/`: C++ source for the `cseabreeze` backend. - `src/seabreeze/pyseabreeze/`: Python implementation of the protocol. - `tests/`: Extensive test suite. ### Adding New Features When adding support for new features or spectrometers: 1. Check `pyseabreeze/features/` for existing feature implementations. 2. Update `protocol.py` if new USB commands are required. 3. Add corresponding wrapping in `spectrometers.py`. ## Reference Resources - [capture_spectrum.py](capture_spectrum.py): Example script for data capture. - [test_connection.py](test_connection.py): Script for verifying spectrometer visibility.