Skip to content

Commit

Permalink
Merge pull request #192 from ericmorelle/main
Browse files Browse the repository at this point in the history
basic ST support
  • Loading branch information
ap-- committed May 4, 2023
2 parents 336493e + e824337 commit 2fcd949
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
build/*
dist/*
venv/*
.venv/*
venv*/*
docs/build/*
pip-wheel-metadata/*
Expand Down
2 changes: 2 additions & 0 deletions os_support/10-oceanoptics.rules
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,7 @@ ATTR{idVendor}=="04b4", ATTR{idProduct}=="8613", SYMLINK+="ezUSB-FX2-%n", MODE:=
ATTR{idVendor}=="2457", ATTR{idProduct}=="2003", SYMLINK+="oceanhdx-%n", MODE:="0666"
# Ocean Insight Inc. SR4 spectrometer
ATTR{idVendor}=="0999", ATTR{idProduct}=="1002", SYMLINK+="sr4-%n", MODE:="0666"
# Ocean Insight Inc. ST spectrometer
ATTR{idVendor}=="0999", ATTR{idProduct}=="1000", SYMLINK+="st-%n", MODE:="0666"

LABEL="oceanoptics_rules_end"
30 changes: 30 additions & 0 deletions src/seabreeze/pyseabreeze/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,3 +1224,33 @@ class SR4(SeaBreezeDevice):

# features
feature_classes = (sbf.spectrometer.SeaBreezeSpectrometerFeatureSR4,)


class ST(SeaBreezeDevice):
model_name = "ST"

# communication config
transport = (USBTransport,)
usb_vendor_id = 0x0999
usb_product_id = 0x1000
usb_endpoint_map = EndPointMap(ep_out=0x01, highspeed_in=0x81, highspeed_in2=0x82)
usb_protocol = OBP2Protocol

# spectrometer config
dark_pixel_indices = DarkPixelIndices.from_ranges()
integration_time_min = 1560
integration_time_max = 6000000
integration_time_base = 10
spectrum_num_pixel = 1516
spectrum_raw_length = 1516 * 2 # ??
spectrum_max_value = 16383
# Triggering (from Ocean ST Manual v10-5): Software, External Rising Edge
trigger_modes = TriggerMode.supported("NORMAL", "SOFTWARE", "EDGE")

# features
feature_classes = (
# sbf.eeprom.SeaBreezeEEPromFeatureOOI,
sbf.spectrometer.SeaBreezeSpectrometerFeatureST,
sbf.rawusb.SeaBreezeRawUSBBusAccessFeature,
sbf.nonlinearity.NonlinearityCoefficientsFeatureOBP2,
)
14 changes: 14 additions & 0 deletions src/seabreeze/pyseabreeze/features/nonlinearity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from seabreeze.pyseabreeze.features._base import SeaBreezeFeature
from seabreeze.pyseabreeze.features.eeprom import SeaBreezeEEPromFeatureOOI
from seabreeze.pyseabreeze.protocol import OBP2Protocol
from seabreeze.pyseabreeze.protocol import OBPProtocol
from seabreeze.pyseabreeze.protocol import OOIProtocol

Expand Down Expand Up @@ -59,3 +60,16 @@ def get_nonlinearity_coefficients(self) -> List[float]:
data = self.protocol.query(0x00181101, i)
coeffs.append(struct.unpack("<f", data)[0])
return coeffs


class NonlinearityCoefficientsFeatureOBP2(SeaBreezeNonlinearityCoefficientsFeature):
_required_protocol_cls = OBP2Protocol

def get_nonlinearity_coefficients(self) -> List[float]:
# get nonlinearity coefficients
data = self.protocol.query(0x000_012_00)
num_coeffs = len(data) // 4
assert len(data) % 4 == 0
assert num_coeffs > 1
coeffs = list(struct.unpack("<" + "f" * num_coeffs, data)[1:])
return coeffs
4 changes: 4 additions & 0 deletions src/seabreeze/pyseabreeze/features/spectrometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,3 +671,7 @@ def get_wavelengths(self) -> NDArray[np.float_]:
# and generate the wavelength array
indices = numpy.arange(self._spectrum_length, dtype=numpy.float64)
return sum(wl * (indices**i) for i, wl in enumerate(coeffs)) # type: ignore


class SeaBreezeSpectrometerFeatureST(SeaBreezeSpectrometerFeatureSR4):
pass
1 change: 1 addition & 0 deletions src/seabreeze/pyseabreeze/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ class OBP2Protocol(OBPProtocol):
0x000_00C_01: "<L", # SET_ITIME_USEC
0x000_00D_01: "<B", # SET_TRIG_MODE
0x000_011_00: "", # GET_WL_COEFFS
0x000_012_00: "", # GET_NL_COEFFS
}.items()
} # add more here if you implement new features

Expand Down

0 comments on commit 2fcd949

Please sign in to comment.