diff --git a/.gitignore b/.gitignore index 07f028b..8330e7b 100644 --- a/.gitignore +++ b/.gitignore @@ -110,3 +110,7 @@ venv.bak/ # pycharm .idea/ .idea/* + +*yacctab.py +*lextab.py + diff --git a/src/pymodaq_plugins_teaching/hardware/spectrometer.py b/src/pymodaq_plugins_teaching/hardware/spectrometer.py index ed1c8a7..370caa7 100644 --- a/src/pymodaq_plugins_teaching/hardware/spectrometer.py +++ b/src/pymodaq_plugins_teaching/hardware/spectrometer.py @@ -4,21 +4,34 @@ class Spectrometer: axis = ['lambda0'] + gratings = ['G300', 'G1200'] + Nactuators = len(axis) Nx = 256 + infos = 'Spectrometer Controller Wrapper 0.0.1' - def __init__(self, positions=[632.], noise=0.1, amp=10, wh=20): + def __init__(self, positions=[632.], noise=0.1, amp=10, wh=20, grating=gratings[0]): super().__init__() if positions is None: self.current_positions = dict(zip(self.axis, [0. for ind in range(self.Nactuators)])) else: assert isinstance(positions, list) assert len(positions) == self.Nactuators - self.current_positions = positions + self.current_positions = dict(zip(self.axis, positions)) self._amp = amp self._noise = noise self._wh = wh + self._grating = grating + + @property + def grating(self): + return self._grating + + @grating.setter + def grating(self, grat): + if grat in self.gratings: + self._grating = grat @property def amplitude(self): @@ -47,25 +60,31 @@ def width(self, value): if value > 0.: self._wh = value + def set_wavelength(self, value, set_type='abs'): + if value < 0: + raise ValueError('Wavelength cannot be negative') - def check_position(self, axis): - return self.current_positions[axis] - - def move_abs(self, position, axis): - self.current_positions[axis] = position + if set_type == 'abs': + self.current_positions['lambda0'] = value + else: + self.current_positions['lambda0'] += value - def move_rel(self, position, axis): - self.current_positions[axis] += position + def get_wavelength(self): + return self.current_positions['lambda0'] def get_xaxis(self): - return (np.linspace(0, self.Nx, self.Nx, endpoint=False) - self.Nx / 2) * 0.25 +\ + if self._grating == 'G300': + coeff = 0.7 + elif self._grating == 'G1200': + coeff = 0.25 + return (np.linspace(0, self.Nx, self.Nx, endpoint=False) - self.Nx / 2) * coeff +\ self.current_positions['lambda0'] def set_Mock_data(self): """ """ x_axis = self.get_xaxis() - return self._amp * gauss1D(x_axis, self.current_positions['H'], self._wh) +\ + return self._amp * gauss1D(x_axis, self.current_positions['lambda0'], self._wh) +\ self._noise * np.random.rand(self.Nx) def get_data_output(self, data=None):