Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Qudi spectrometer #598

Draft
wants to merge 54 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7bb30d9
Spectro master branch Base
AdrienR09 Apr 7, 2020
cd7e690
hardware spectro Newton 940
pvalvin Apr 7, 2020
76d7761
updating of the camera interface
AdrienR09 Apr 8, 2020
cfec3e0
Spectrum logic update
AdrienR09 Apr 8, 2020
9264da8
Camera complete interface update
AdrienR09 Apr 9, 2020
a3c77d7
Camera complete interface update 2
AdrienR09 Apr 9, 2020
325f4cc
Camera complete interface update 3
AdrienR09 Apr 10, 2020
afca522
Logic module in progress
AdrienR09 Apr 10, 2020
e371764
camera complete interface update4 + Newton940 début de réécriture
pvalvin Apr 10, 2020
d900f12
Logic module
AdrienR09 Apr 10, 2020
f39bec7
Merge branch 'hirondelle_local' into hardware_spectro
AdrienR09 Apr 10, 2020
6e039fc
Complete camera interface update 4
AdrienR09 Apr 10, 2020
1aaf62e
Logic version 1 (ready for review)
AdrienR09 Apr 10, 2020
009627b
Complete interface update 5
AdrienR09 Apr 11, 2020
725fb92
Logic module update 1
AdrienR09 Apr 14, 2020
282b276
Logic version 2 (ready for review again)
AdrienR09 Apr 17, 2020
754e148
Logic version 2 (with little corrections)
AdrienR09 Apr 17, 2020
05b53a6
Updated Interfaces (Camera+Spectro)
AdrienR09 Apr 17, 2020
e6e0684
HW / Newton940 update
pvalvin Apr 20, 2020
ccb316c
Merge remote-tracking branch 'AdrienR09/hardware_spectro' into hardwa…
pvalvin Apr 20, 2020
da7c7b5
Hardware Camera and interface update
pvalvin Apr 20, 2020
2a3f5e0
Added review for spectrum_logic
alrik-durand Apr 22, 2020
7e705fd
Update camera hardware
pvalvin Apr 22, 2020
e8ecf82
GUI module + ui update (old version)
AdrienR09 Apr 22, 2020
9ad9e84
Merge remote-tracking branch 'alrik-durand/logic_gui_spectro' into lo…
AdrienR09 Apr 22, 2020
617cbad
Logic version 3 (ready for comment and protestation)
AdrienR09 Apr 28, 2020
e905b09
Update hardware + interface
AdrienR09 Apr 28, 2020
f379878
Merge branch 'hardware_spectro' into logic_gui_spectro
AdrienR09 Apr 28, 2020
e58d62d
Correction after test 1
pvalvin Apr 28, 2020
6d2c7b8
Update after test
pvalvin Apr 30, 2020
021d531
first pass at andor camera hardware
alrik-durand Apr 30, 2020
5425968
changed camera interface to proposed solution
alrik-durand Apr 30, 2020
1e3a447
started working on newton hardware new version
alrik-durand Apr 30, 2020
62df971
small update interface
alrik-durand Apr 30, 2020
69ceaac
added get_ready_state to the camera interface
alrik-durand May 4, 2020
38467f9
finished working on Andor camera hardware
alrik-durand May 4, 2020
29eca4d
renamed camera interface
alrik-durand May 4, 2020
94ebbc1
added a dummy for spectroscopy camera interface
alrik-durand May 5, 2020
7c2eb6c
small check in newton
alrik-durand May 5, 2020
a0ebcf3
started working on v2 of spectro interface
alrik-durand May 5, 2020
13a3252
fixed bug in dummy and added it to default config
alrik-durand May 5, 2020
e291ad4
correct shutter architecture error in spectro camera_interface
alrik-durand May 5, 2020
d33ee00
v2 of the spectrometer complete interface
alrik-durand May 5, 2020
65ef867
started the v2 of the shamrock, WIP
alrik-durand May 5, 2020
7539ec2
modified the grating spetro interface for simplicity
alrik-durand May 6, 2020
dc031a0
update grating spectro interface again
alrik-durand May 6, 2020
9d1eeac
update shamrock hardware
alrik-durand May 6, 2020
7b619e2
re-organized shamrock module
alrik-durand May 6, 2020
5a079f3
added temperature constraints in camera interface
alrik-durand May 7, 2020
afdb167
Finished v2 of newton, time for testing !
alrik-durand May 7, 2020
711a1da
added the dummy spectro updated
alrik-durand May 11, 2020
e531d1c
removed setup config file from branch
alrik-durand May 11, 2020
d405a87
renamed interfaces
alrik-durand May 11, 2020
b00b491
renamed science camera interface
alrik-durand May 11, 2020
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
3 changes: 3 additions & 0 deletions config/example/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ hardware:

cameradummy:
module.Class: 'camera.camera_dummy.CameraDummy'

spectroscopy_camera_dummy:
module.Class: 'spectroscopy_camera_dummy.Main'
logic:
simpledatalogic:
module.Class: 'simple_data_logic.SimpleDataLogic'
Expand Down
227 changes: 227 additions & 0 deletions gui/PLspectrum/PL_spectrum_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
# -*- coding: utf-8 -*-
"""
This module contains a GUI for operating the spectrum logic module.

Qudi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Qudi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Qudi. If not, see <http://www.gnu.org/licenses/>.

Copyright (c) the Qudi Developers. See the COPYRIGHT.txt file at the
top-level directory of this distribution and at <https://github.com/Ulm-IQO/qudi/>
"""

import os
import pyqtgraph as pg
import numpy as np

from core.connector import Connector
from core.statusvariable import StatusVar
from core.util import units

from gui.colordefs import QudiPalettePale as palette
from gui.guibase import GUIBase
from qtpy import QtCore
from qtpy import QtWidgets
from qtpy import uic


class MainWindow(QtWidgets.QMainWindow):

def __init__(self):
""" Create the laser scanner window.
"""
# Get the path to the *.ui file
this_dir = os.path.dirname(__file__)
ui_file = os.path.join(this_dir, 'ui_PLspectrum.ui')

# Load it
super().__init__()
uic.loadUi(ui_file, self)
self.show()


class PLspectrumGUI(GUIBase):
"""
"""

# declare connectors
spectrumlogic = Connector(interface='SpectrumLogic')

def __init__(self, config, **kwargs):
super().__init__(config=config, **kwargs)

def on_activate(self):
""" Definition and initialisation of the GUI.
"""

# connect the logic module from the declared connector
self._spectrum_logic = self.spectrumlogic()

# setting up the window
self._mw = MainWindow()
self._mw.centralwidget.hide()
self._mw.setDockNestingEnabled(True)


# giving the plots names allows us to link their axes together
self._spec = self._mw.spectrumPlot
self._img = self._mw.imagePlot
self._spec_item = self._spec.plotItem
self._img_item = self._img.ImageItem

# create a new ViewBox, link the right axis to its coordinate system
self._right_axis = pg.ViewBox() # Create a ViewBox right axis
self._spec_item.showAxis('right') # Show the right axis of plotItem
self._spec_item.scene().addItem(self._right_axis) # associate the ViewBox right axis to the plotItem
self._spec_item.getAxis('right').linkToView(self._right_axis) # link this right axis to the ViewBox
self._right_axis.setXLink(self._spec_item) # link the ViewBox object to the plotItem x axis

# create a new ViewBox, link the top axis to its coordinate system (same procedure)
self._top_axis = pg.ViewBox()
self._spec_item.showAxis('top')
self._spec_item.scene().addItem(self._top_axis)
self._spec_item.getAxis('top').linkToView(self._top_axis)
self._top_axis.setYLink(self._spec_item)
self._top_axis.invertX(b=True) # We force the x axis to be rightward

# label plot axis :

self._spec.setLabel('left', 'Signal intensity', units='counts/s')
self._spec.setLabel('right', 'Number of Points', units='#')
self._spec.setLabel('bottom', 'Wavelength', units='m')
self._spec.setLabel('top', 'Relative Frequency', units='Hz')

# Create 2 empty plot curve to be filled later, set its pen (curve style)
self._curve1 = self._spec.plot()
self._curve1.setPen(palette.c1, width=2)

# Connect signals :
# Action (spectro):
self._mw.actionRun.triggered.connect(self.run_spectrum_acquisition)
self._mw.actionStop_Run.triggered.connect(self.stop_spectrum_acquisition)
# Button (image):
#self._mw.runImageButton.clicked.connect(self.run_image_acquisition())
#self._mw.stopImageButton.clicked.connect(self.stop_image_acquisition())

self.read_settings()

self.show()

self._save_PNG = True

def read_settings(self):
"""
# Initialize widgets slots :
self._mw.gratingNumCombo.setCurrentIndex(self._spectrum_logic.grating)
self._mw.inputPortCombo.setCurrentIndex(self._spectrum_logic.input_port)
self._mw.outputPortCombo.setCurrentIndex(self._spectrum_logic.output_port)
self._mw.readModeCombo.setCurrentIndex(self._spectrum_logic.read_mode)
self._mw.acquModeCombo.setCurrentIndex(self._spectrum_logic.acquisition_mode)
self._mw.triggerModeCombo.setCurrentIndex(self._spectrum_logic.trigger_mode)
self._mw.scanFreqCombo.setCurrentIndex(self._spectrum_logic.
self._mw.accumulationDelayDSpin.setCurrentIndex(self._spectrum_logic.

self._mw.cameraGainSpin.setValue(self._spectrum_logic._camera_gain)
self._mw.numAccumulatedSpin.setValue(self._spectrum_logic.
self._mw.numTrackSpin.setValue(self._spectrum_logic.
self._mw.trackHeightSpin.setValue(self._spectrum_logic.
self._mw.trackOffsetSpin.setValue(self._spectrum_logic.
self._mw.gratingOffsetSpin.setValue(self._spectrum_logic.

self._mw.exposureDSpin.setValue(self._spectrum_logic.
self._mw.numScanDSpin.setValue(self._spectrum_logic.
self._mw.temperatureDSpin.setValue(self._spectrum_logic.
self._mw.inputSlitWidthDSpin.setValue(self._spectrum_logic.
self._mw.outputSlitWidthDSpin.setValue(self._spectrum_logic.
self._mw.wavelengthDSpin.setValue(self._spectrum_logic.

self._mw.coolerButton

self._mw.wavelengthDSpin.setRange(self._spectrum_logic.wavelength_limit)
"""

def update_settings(self):

self._spectrum_logic.center_wavelength = self._mw.wavelengthDSpin.value()
self._spectrum_logic.detector_offset = self._mw.detectorOffsetSpin.value()
self._spectrum_logic.grating = self._mw.gratingNumCombo.currentIndex()
self._spectrum_logic.input_slit = self._mw.inputSlitCombo.currentIndex()
self._spectrum_logic.input_slit_width = self._mw.inputSlitWidthDSpin.value()
self._spectrum_logic.output_slit = self._mw.outputSlitCombo.currentIndex()
self._spectrum_logic.output_slit_width = self._mw.outputSlitWidthDSpin.value()

self._mw.wavelengthDSpin.setRange(self._spectrum_logic.wavelength_limits)

self._mw.gratingNumCombo.setCurrentIndex(self._spectrum_logic.grating)
self._mw.inputPortCombo.setCurrentIndex(self._spectrum_logic.input_port)
self._mw.outputPortCombo.setCurrentIndex(self._spectrum_logic.output_port)
self._mw.readModeCombo.setCurrentIndex(self._spectrum_logic.read_mode)
self._mw.acquModeCombo.setCurrentIndex(self._spectrum_logic.acquisition_mode)
self._mw.triggerModeCombo.setCurrentIndex(self._spectrum_logic.trigger_mode)
self._mw.scanFreqCombo.setCurrentIndex(self._spectrum_logic.
self._mw.accumulationDelayDSpin.setCurrentIndex(self._spectrum_logic.

self._mw.cameraGainSpin.setValue(self._spectrum_logic._camera_gain)
self._mw.numAccumulatedSpin.setValue(self._spectrum_logic.
self._mw.numTrackSpin.setValue(self._spectrum_logic.
self._mw.trackHeightSpin.setValue(self._spectrum_logic.
self._mw.trackOffsetSpin.setValue(self._spectrum_logic.
self._mw.gratingOffsetSpin.setValue(self._spectrum_logic.

self._mw.exposureDSpin.setValue(self._spectrum_logic.
self._mw.numScanDSpin.setValue(self._spectrum_logic.
self._mw.temperatureDSpin.setValue(self._spectrum_logic.
self._mw.inputSlitWidthDSpin.setValue(self._spectrum_logic.
self._mw.outputSlitWidthDSpin.setValue(self._spectrum_logic.
self._mw.wavelengthDSpin.setValue(self._spectrum_logic.

self._mw.coolerButton

self._mw.wavelengthDSpin.setRange(self._spectrum_logic.wavelength_limit)

def on_deactivate(self):
""" Deinitialisation performed during deactivation of the module.
"""

self._mw.close()

def show(self):
"""Make window visible and put it above all other windows.
"""
QtWidgets.QMainWindow.show(self._mw)
self._mw.activateWindow()
self._mw.raise_()

def run_spectrum_acquisition(self):
"""Run the spectrum acquisition called from actionRun
and plot the spectrum data obtained.
"""
self.update_settings()
self._spectrum_logic.start_acquisition()
data = self._spectrum_logic.spectrum_data
wavelength = np.linspace(0, 1, len(data))
self._curve1.setData(wavelength, data[:, 0])

def stop_spectrum_acquisition(self):
"""Stop the spectrum acquisition called from actionStop_Run
"""
self._spectrum_logic.stop_acquisition()

def run_image_acquisition(self):
"""Run the image acquisition called from runImageButton
and plot the spectrum data obtained.
"""
self._spectrum_logic.set_read_mode('IMAGE')
self._spectrum_logic.start_acquisition()
data = self._spectrum_logic._spectrum_data
self._img_item.setImage(data)

Loading