Skip to content

Commit

Permalink
added functionnalities to spectrometer
Browse files Browse the repository at this point in the history
  • Loading branch information
seb5g committed Oct 11, 2021
1 parent d82034c commit abd3a3d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ venv.bak/
# pycharm
.idea/
.idea/*

*yacctab.py
*lextab.py

41 changes: 30 additions & 11 deletions src/pymodaq_plugins_teaching/hardware/spectrometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit abd3a3d

Please sign in to comment.