@@ -697,3 +697,44 @@ class SeaBreezeSpectrometerFeatureSR6(SeaBreezeSpectrometerFeatureOBP2):
697
697
698
698
class SeaBreezeSpectrometerFeatureST (SeaBreezeSpectrometerFeatureOBP2 ):
699
699
pass
700
+
701
+
702
+ class SeaBreezeSpectrometerFeatureHR2 (SeaBreezeSpectrometerFeatureOBP ):
703
+ def _get_spectrum_raw (self ) -> NDArray [np .uint8 ]:
704
+ timeout = int (
705
+ self ._integration_time * 1e-3 + self .protocol .transport .default_timeout_ms
706
+ )
707
+ datastring = self .protocol .query (0x000_01C_00 , timeout_ms = timeout )
708
+ return numpy .frombuffer (datastring , dtype = numpy .uint8 )
709
+
710
+ def get_intensities (self ) -> NDArray [np .float_ ]:
711
+ tmp = self ._get_spectrum_raw ()
712
+ # 32byte metadata block at beginning
713
+ ret = tmp [32 :].view (numpy .dtype ("<H" )).astype (numpy .double )
714
+ return ret * self ._normalization_value
715
+
716
+ def set_trigger_mode (self , mode : int ) -> None :
717
+ if mode in self ._trigger_modes :
718
+ self .protocol .send (0x000_00D_01 , mode , request_ack = True )
719
+ else :
720
+ raise SeaBreezeError ("Only supports: %s" % str (self ._trigger_modes ))
721
+
722
+ def set_integration_time_micros (self , integration_time_micros : int ) -> None :
723
+ t_min = self ._integration_time_min
724
+ t_max = self ._integration_time_max
725
+ if t_min <= integration_time_micros < t_max :
726
+ self ._integration_time = integration_time_micros
727
+ i_time = int (integration_time_micros / self ._integration_time_base )
728
+ self .protocol .send (0x000_00C_01 , i_time )
729
+ else :
730
+ raise SeaBreezeError (f"Integration not in [{ t_min :d} , { t_max :d} ]" )
731
+
732
+ def get_wavelengths (self ) -> NDArray [np .float_ ]:
733
+ data = self .protocol .query (0x000_011_00 )
734
+ num_coeffs = len (data ) // 4
735
+ assert len (data ) % 4 == 0 # ???
736
+ assert num_coeffs > 1 # ???
737
+ coeffs = struct .unpack ("<" + "f" * num_coeffs , data )[1 :]
738
+ # and generate the wavelength array
739
+ indices = numpy .arange (self ._spectrum_length , dtype = numpy .float64 )
740
+ return sum (wl * (indices ** i ) for i , wl in enumerate (coeffs )) # type: ignore
0 commit comments