Skip to content

Commit

Permalink
Merge pull request #223 from magnium/main
Browse files Browse the repository at this point in the history
thermo_electric feature to the list of feature classes in NIRQUEST512
  • Loading branch information
ap-- authored Nov 28, 2023
2 parents fc107d3 + 04de15c commit 538b8d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/seabreeze/pyseabreeze/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ class NIRQUEST512(SeaBreezeDevice):
sbf.eeprom.SeaBreezeEEPromFeatureOOI,
sbf.spectrometer.SeaBreezeSpectrometerFeatureNIRQUEST512,
sbf.rawusb.SeaBreezeRawUSBBusAccessFeature,
sbf.thermoelectric.ThermoElectricFeatureOOI,
)


Expand Down
37 changes: 21 additions & 16 deletions src/seabreeze/pyseabreeze/features/spectrometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def __init__(
self._spectrum_max_value = kwargs["spectrum_max_value"]
self._trigger_modes = kwargs["trigger_modes"]

self._integration_time = self._integration_time_max

def set_trigger_mode(self, mode: int) -> None:
if mode in self._trigger_modes:
self.protocol.send(0x0A, mode)
Expand All @@ -117,6 +119,7 @@ def set_integration_time_micros(self, integration_time_micros: int) -> None:
t_min = self._integration_time_min
t_max = self._integration_time_max
if t_min <= integration_time_micros < t_max:
self._integration_time = integration_time_micros
i_time = int(integration_time_micros / self._integration_time_base)
self.protocol.send(0x02, i_time)
else:
Expand Down Expand Up @@ -160,8 +163,7 @@ def _get_spectrum_raw(self) -> NDArray[np.uint8]:
), "current impl requires USBTransport"

timeout = int(
self._integration_time_max * 1e-3
+ self.protocol.transport.default_timeout_ms
self._integration_time * 1e-3 + self.protocol.transport.default_timeout_ms
)
# noinspection PyProtectedMember
tmp[:] = bytearray(
Expand Down Expand Up @@ -227,8 +229,7 @@ class SeaBreezeSpectrometerFeatureOOIFPGA4K(SeaBreezeSpectrometerFeatureOOIFPGA)
def _get_spectrum_raw(self) -> NDArray[np.uint8]:
tmp = numpy.empty((self._spectrum_raw_length,), dtype=numpy.uint8)
timeout = int(
self._integration_time_max * 1e-3
+ self.protocol.transport.default_timeout_ms
self._integration_time * 1e-3 + self.protocol.transport.default_timeout_ms
)
self.protocol.send(0x09)
assert isinstance(
Expand Down Expand Up @@ -382,6 +383,8 @@ def __init__(
self._spectrum_max_value = kwargs["spectrum_max_value"]
self._trigger_modes = kwargs["trigger_modes"]

self._integration_time = self._integration_time_max

def set_trigger_mode(self, mode: int) -> None:
if mode in self._trigger_modes:
self.protocol.send(0x00110110, mode, request_ack=True)
Expand All @@ -392,6 +395,7 @@ def set_integration_time_micros(self, integration_time_micros: int) -> None:
t_min = self._integration_time_min
t_max = self._integration_time_max
if t_min <= integration_time_micros < t_max:
self._integration_time = integration_time_micros
i_time = int(integration_time_micros / self._integration_time_base)
self.protocol.send(0x00110010, i_time)
else:
Expand Down Expand Up @@ -430,8 +434,7 @@ def get_intensities(self) -> NDArray[np.float_]:

def _get_spectrum_raw(self) -> NDArray[np.uint8]:
timeout = int(
self._integration_time_max * 1e-3
+ self.protocol.transport.default_timeout_ms
self._integration_time * 1e-3 + self.protocol.transport.default_timeout_ms
)
datastring = self.protocol.query(0x00101100, timeout_ms=timeout)
return numpy.frombuffer(datastring, dtype=numpy.uint8)
Expand Down Expand Up @@ -557,8 +560,7 @@ class SeaBreezeSpectrometerFeatureSTS(SeaBreezeSpectrometerFeatureOBP):
class SeaBreezeSpectrometerFeatureQEPRO(SeaBreezeSpectrometerFeatureOBP):
def _get_spectrum_raw(self) -> NDArray[np.uint8]:
timeout = int(
self._integration_time_max * 1e-3
+ self.protocol.transport.default_timeout_ms
self._integration_time * 1e-3 + self.protocol.transport.default_timeout_ms
)
datastring = self.protocol.query(0x00100928, timeout_ms=timeout)
return numpy.frombuffer(datastring, dtype=numpy.uint8)
Expand All @@ -581,8 +583,7 @@ class SeaBreezeSpectrometerFeatureSPARK(SeaBreezeSpectrometerFeatureOBP):
class SeaBreezeSpectrometerFeatureHDX(SeaBreezeSpectrometerFeatureOBP):
def _get_spectrum_raw(self) -> NDArray[np.uint8]:
timeout = int(
self._integration_time_max * 1e-3
+ self.protocol.transport.default_timeout_ms
self._integration_time * 1e-3 + self.protocol.transport.default_timeout_ms
)
# the message type is different than the default defined in the protocol,
# requires addition of a new message type in protocol to work
Expand All @@ -607,8 +608,7 @@ def get_intensities(self) -> NDArray[np.float_]:
class SeaBreezeSpectrometerFeatureSR2(SeaBreezeSpectrometerFeatureOBP):
def _get_spectrum_raw(self) -> NDArray[np.uint8]:
timeout = int(
self._integration_time_max * 1e-3
+ self.protocol.transport.default_timeout_ms
self._integration_time * 1e-3 + self.protocol.transport.default_timeout_ms
)
datastring = self.protocol.query(0x000_01C_00, timeout_ms=timeout)
return numpy.frombuffer(datastring, dtype=numpy.uint8)
Expand All @@ -629,6 +629,7 @@ def set_integration_time_micros(self, integration_time_micros: int) -> None:
t_min = self._integration_time_min
t_max = self._integration_time_max
if t_min <= integration_time_micros < t_max:
self._integration_time = integration_time_micros
i_time = int(integration_time_micros / self._integration_time_base)
self.protocol.send(0x000_00C_01, i_time)
else:
Expand All @@ -645,11 +646,10 @@ def get_wavelengths(self) -> NDArray[np.float_]:
return sum(wl * (indices**i) for i, wl in enumerate(coeffs)) # type: ignore


class SeaBreezeSpectrometerFeatureSR4(SeaBreezeSpectrometerFeatureOBP):
class SeaBreezeSpectrometerFeatureOBP2(SeaBreezeSpectrometerFeatureOBP):
def _get_spectrum_raw(self) -> NDArray[np.uint8]:
timeout = int(
self._integration_time_max * 1e-3
+ self.protocol.transport.default_timeout_ms
self._integration_time * 1e-3 + self.protocol.transport.default_timeout_ms
)
datastring = self.protocol.query(0x000_01C_00, timeout_ms=timeout)
return numpy.frombuffer(datastring, dtype=numpy.uint8)
Expand All @@ -670,6 +670,7 @@ def set_integration_time_micros(self, integration_time_micros: int) -> None:
t_min = self._integration_time_min
t_max = self._integration_time_max
if t_min <= integration_time_micros < t_max:
self._integration_time = integration_time_micros
i_time = int(integration_time_micros / self._integration_time_base)
self.protocol.send(0x000_00C_01, i_time)
else:
Expand All @@ -686,5 +687,9 @@ def get_wavelengths(self) -> NDArray[np.float_]:
return sum(wl * (indices**i) for i, wl in enumerate(coeffs)) # type: ignore


class SeaBreezeSpectrometerFeatureST(SeaBreezeSpectrometerFeatureSR4):
class SeaBreezeSpectrometerFeatureSR4(SeaBreezeSpectrometerFeatureOBP2):
pass


class SeaBreezeSpectrometerFeatureST(SeaBreezeSpectrometerFeatureOBP2):
pass

0 comments on commit 538b8d3

Please sign in to comment.