Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ Viewer2D
* **AndorSCMOSPll**: Andor CCD camera using the SDK3 through the pylablib driver (experimental but already in use,
subject to changes)


Legacy
======
The former plugins replaced by the pylablib based ones (Andor CCD with the SDK2, Shamrock, ShamrockCCD and
ShamrockCCDLegacy) are kept in ``src/pymodaq_plugins_andor/legacy``. They are not loaded by PyMoDAQ and are not runnable
as they are.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


from pymodaq_plugins_andor.daq_viewer_plugins.plugins_2D.daq_2Dviewer_AndorSCMOS import DAQ_2DViewer_AndorSCMOS
from pymodaq_plugins_andor.daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock
from pymodaq_plugins_andor.daq_move_plugins.daq_move_ShamrockPll import DAQ_Move_ShamrockPll

logger = set_logger(get_module_name(__file__))

Expand All @@ -27,9 +27,9 @@ class DAQ_1DViewer_ShamrockSCMOS(DAQ_2DViewer_AndorSCMOS):
--------
utility_classes.DAQ_Viewer_base
"""
supported_platforms = ('win32',) # the Andor SDK3 is loaded with ctypes.windll
param_camera = DAQ_2DViewer_AndorSCMOS.params
params_shamrock = DAQ_Move_Shamrock.params
putils.get_param_dict_from_name(params_shamrock, 'andor_lib', pop=True)
params_shamrock = DAQ_Move_ShamrockPll.params

d = putils.get_param_dict_from_name(params_shamrock, 'spectro_wl')
if d is not None:
Expand All @@ -46,7 +46,7 @@ class DAQ_1DViewer_ShamrockSCMOS(DAQ_2DViewer_AndorSCMOS):

def ini_attributes(self):
self.controller: DAQ_2DViewer_AndorSCMOS = None
self.shamrock_controller: DAQ_Move_Shamrock = None
self.shamrock_controller: DAQ_Move_ShamrockPll = None

self.x_axis: Axis = None
self.is_calibrated = False
Expand Down Expand Up @@ -81,10 +81,11 @@ def ini_detector(self, controller=None):
cam_status, cam_init = super().ini_detector(controller)
QtWidgets.QApplication.processEvents()

self.shamrock_controller = DAQ_Move_Shamrock(None, self.settings.child('sham_settings').saveState())
self.shamrock_controller = DAQ_Move_ShamrockPll(None, self.settings.child('sham_settings').saveState())
self.shamrock_controller.settings = self.settings.child('sham_settings')
self.settings.child('sham_settings', 'controller').hide()
self.shamrock_controller.emit_status = self.emit_status
sham_status, sham_init = self.shamrock_controller.ini_stage(controller)
sham_status, sham_init = self.shamrock_controller.ini_stage()

QtWidgets.QApplication.processEvents()

Expand All @@ -97,21 +98,19 @@ def ini_detector(self, controller=None):
def setCalibration(self):
#setNpixels
width, height = self.get_pixel_size()
err = self.shamrock_controller.controller.SetNumberPixelsSR(0, self.get_ROI_size_x())
err = self.shamrock_controller.controller.SetPixelWidthSR(0, width)
self.shamrock_controller.controller.set_number_pixels(self.get_ROI_size_x())
self.shamrock_controller.controller.set_pixel_width(width)

self.shamrock_controller.get_wavelength()
self.settings.child('sham_settings', 'spectro_settings',
'spectro_wl').setValue(self.shamrock_controller.controller.get_wavelength() * 1e9)
self.x_axis = self.get_xaxis()


def getCalibration(self):

if self.shamrock_controller is not None and self.shamrock_controller.controller is not None:
(err, calib) = self.shamrock_controller.controller.GetCalibrationSR(0, self.get_ROI_size_x())
if err != "SHAMROCK_SUCCESS":
raise Exception(err)

calib = np.array(calib)
self.shamrock_controller.controller.set_number_pixels(self.get_ROI_size_x()) # the ROI may have changed
calib = np.array(self.shamrock_controller.controller.get_calibration()) * 1e9 # m to nm
else:
raise(Exception('controller not defined'))
self.is_calibrated = True
Expand Down Expand Up @@ -158,7 +157,7 @@ def stop(self):
if self.controller is not None:
super().stop()
if self.shamrock_controller is not None:
self.shamrock_controller.stop()
self.shamrock_controller.stop_motion()

def close(self):
self.stop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pymodaq.utils.data import Axis, DataFromPlugins

from ..plugins_2D.daq_2Dviewer_AndorSCMOS import DAQ_2DViewer_AndorSCMOS
from ...daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock
from pymodaq_plugins_andor.legacy.daq_move_Shamrock import DAQ_Move_Shamrock

logger = set_logger(get_module_name(__file__))

Expand All @@ -27,6 +27,7 @@ class DAQ_1DViewer_ShamrockSCMOSLegacy(DAQ_2DViewer_AndorSCMOS, DAQ_Move_Shamroc
--------
utility_classes.DAQ_Viewer_base
"""
supported_platforms = ('win32',) # the Shamrock SDK is loaded with ctypes.windll

param_camera = DAQ_2DViewer_AndorSCMOS.params
params_shamrock = DAQ_Move_Shamrock.params
Expand Down
7 changes: 7 additions & 0 deletions src/pymodaq_plugins_andor/legacy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Legacy plugins

Former instrument plugins of this package, kept for reference: the Andor SDK2 camera (`daq_2Dviewer_AndorCCD`), the Shamrock spectrometer (`daq_move_Shamrock`) and the Shamrock CCD detectors (`daq_1Dviewer_ShamrockCCD`, `daq_1Dviewer_ShamrockCCDLegacy`).

They were replaced by the pylablib based plugins (`daq_2Dviewer_AndorCCDPll`, `daq_move_ShamrockPll`, `daq_1Dviewer_ShamrockCCDPll`).

This folder is outside `daq_move_plugins` and `daq_viewer_plugins`, so PyMoDAQ does not load these modules: they are not runnable as they are. To use one again, move it back to the matching plugin folder and fix its imports (the imports between the modules of this folder point here).
197 changes: 197 additions & 0 deletions src/pymodaq_plugins_andor/legacy/daq_1Dviewer_ShamrockCCD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
import numpy as np
from qtpy import QtWidgets

from pymodaq_utils.logger import set_logger, get_module_name
from pymodaq_utils.utils import ThreadCommand, find_dict_in_list_from_key_val

from pymodaq_gui.parameter import utils as putils

from pymodaq.utils.data import Axis, DataFromPlugins, DataToExport
from pymodaq.control_modules.viewer_utility_classes import main, DAQ_Viewer_base, comon_parameters

from pymodaq_plugins_andor.legacy.daq_2Dviewer_AndorCCD import DAQ_2DViewer_AndorCCD
from pymodaq_plugins_andor.legacy.daq_move_Shamrock import DAQ_Move_Shamrock

logger = set_logger(get_module_name(__file__))


class DAQ_1DViewer_ShamrockCCD(DAQ_2DViewer_AndorCCD):
"""
=============== ==================

=============== ==================

See Also
--------
utility_classes.DAQ_Viewer_base
"""
param_camera = DAQ_2DViewer_AndorCCD.params
params_shamrock = DAQ_Move_Shamrock.params
putils.get_param_dict_from_name(params_shamrock, 'andor_lib', pop=True)

d = putils.get_param_dict_from_name(params_shamrock, 'spectro_wl')
if d is not None:
d['readonly'] = False
d = putils.get_param_dict_from_name(params_shamrock, 'flip_wavelength')
if d is not None:
d['visible'] = True

params = [{'title': 'Get Calibration:', 'name': 'get_calib', 'type': 'bool_push', 'value': False,
'label': 'Update!'},] + param_camera + [
{'title': 'Shamrock Settings:', 'name': 'sham_settings', 'type': 'group', 'children': params_shamrock},
]


def ini_attributes(self):
self.controller: DAQ_2DViewer_AndorCCD = None
self.shamrock_controller: DAQ_Move_Shamrock = None

self.x_axis: Axis = None
self.is_calibrated = False

super().ini_attributes()

def commit_settings(self, param):

if param.name() == 'flip_wavelength':
self.get_xaxis()
elif 'camera_settings' in putils.get_param_path(param):
super().commit_settings(param)
elif 'spectro_settings' in putils.get_param_path(param):
self.shamrock_controller.commit_settings(param)
QtWidgets.QApplication.processEvents()
if param.name() == 'spectro_wl':
self.is_calibrated = False
self.get_xaxis()
elif param.name() == 'zero_order':
self.is_calibrated = False
elif param.name() == 'flip_wavelength':
self.get_xaxis()
elif param.name() == 'readout' or param.name() in \
putils.iter_children(self.settings.child('camera_settings', 'readout_settings')):
self.get_xaxis()
elif param.name() == 'get_calib':
if param.value():
self.get_xaxis()
param.setValue(False)

def ini_detector(self, controller=None):
cam_status, cam_init = super().ini_detector(controller)
QtWidgets.QApplication.processEvents()

self.shamrock_controller = DAQ_Move_Shamrock(None, self.settings.child('sham_settings').saveState())
self.shamrock_controller.settings = self.settings.child('sham_settings')
self.shamrock_controller.emit_status = self.emit_status
sham_status, sham_init = self.shamrock_controller.ini_stage(controller)

QtWidgets.QApplication.processEvents()


initialized = sham_init and cam_init

self.setCalibration()
return sham_status + cam_status, initialized

def setCalibration(self):
#setNpixels
width, height = self.get_pixel_size()
err = self.shamrock_controller.controller.SetNumberPixelsSR(0, self.get_ROI_size_x())
err = self.shamrock_controller.controller.SetPixelWidthSR(0, width)

self.shamrock_controller.get_wavelength()
self.x_axis = self.get_xaxis()


def getCalibration(self):

if self.shamrock_controller is not None and self.shamrock_controller.controller is not None:
(err, calib) = self.shamrock_controller.controller.GetCalibrationSR(0, self.get_ROI_size_x())
if err != "SHAMROCK_SUCCESS":
raise Exception(err)

calib = np.array(calib)
else:
raise(Exception('controller not defined'))
self.is_calibrated = True
return calib

def get_xaxis(self):
"""
Obtain the horizontal axis of the image.

Returns
-------
1D numpy array
Contains a vector of integer corresponding to the horizontal camera pixels.
"""

if self.shamrock_controller is None or np.abs(self.settings.child('sham_settings', 'spectro_settings', 'spectro_wl').value()) < 1e-3:
nx = self.get_ROI_size_x()
calib = np.linspace(0, nx, nx-1)
self.x_axis = Axis(data=calib, label='Wavelength (nm)')
else:
calib = self.getCalibration()

if (calib.astype('int') != 0).all(): # check if calib values are equal to zero
if self.settings.child('sham_settings', 'spectro_settings', 'flip_wavelength').value():
calib = calib[::-1]

else:
self.settings.child('sham_settings', 'spectro_settings', 'flip_wavelength').setValue(False)
#self.emit_status(ThreadCommand('Update_Status', ['Impossible to flip wavelength', "log"]))

self.x_axis = Axis(data=calib, label='Wavelength (nm)')
return self.x_axis

def get_exposure_ms(self):
#for compatibility with PyMoDAQ Spectro module
self.emit_status(ThreadCommand('exposure_ms', [self.settings.child('camera_settings', 'exposure').value()]))

def set_exposure_ms(self, exposure):
self.settings.child('camera_settings', 'exposure').setValue(exposure)
QtWidgets.QApplication.processEvents()
self.emit_status(ThreadCommand('exposure_ms', [self.settings.child('camera_settings', 'exposure').value()]))

def stop(self):
if self.controller is not None:
super().stop()
if self.shamrock_controller is not None:
self.shamrock_controller.stop()

def close(self):
self.stop()
if self.shamrock_controller is not None:
self.shamrock_controller.close()
super().close()

def grab_data(self, Naverage=1, **kwargs):
if not self.is_calibrated:
self.get_xaxis()
super().grab_data( Naverage, **kwargs)

def emit_data(self):
"""
overloadded function from DAQ_2DViewer_AndorCCD
"""
try:
self.ind_grabbed += 1
sizey = self.settings.child('camera_settings', 'image_size', 'Ny').value()
sizex = self.settings.child('camera_settings', 'image_size', 'Nx').value()
self.controller.GetAcquiredDataNumpy(self.data_pointer, sizex * sizey)
self.dte_signal.emit(
DataToExport('Spectro',
data=[
DataFromPlugins(name='Camera',
data=[np.atleast_1d(np.squeeze(self.data.reshape(
(sizey, sizex)))).astype(float)],
dim=self.data_shape,
axes=[self.x_axis]),
]))
QtWidgets.QApplication.processEvents() # here to be sure the timeevents are executed even if in continuous grab mode

except Exception as e:
self.emit_status(ThreadCommand('Update_Status', [str(e), 'log']))


if __name__ == '__main__':
main(__file__, True)
Loading
Loading