Skip to content
Snippets Groups Projects
Commit 26d376f6 authored by Stephan Philips's avatar Stephan Philips
Browse files

Merge branch 'master' of github.com:stephanlphilips/core_tools

parents 8bcd4978 37915b8d
No related branches found
No related tags found
No related merge requests found
Showing
with 1674 additions and 128 deletions
...@@ -128,3 +128,6 @@ dmypy.json ...@@ -128,3 +128,6 @@ dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
# neglect db files
.db
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>dataviewer</class>
<widget class="QMainWindow" name="dataviewer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1141</width>
<height>631</height>
</rect>
</property>
<property name="windowTitle">
<string>dataviewer</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QSplitter" name="splitter_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="opaqueResize">
<bool>true</bool>
</property>
<widget class="QWidget" name="toppart" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="topbar" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="logfile">
<property name="text">
<string>V2</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="filter_button">
<property name="text">
<string>Filter data</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="filter_input"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTreeView" name="data_view">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
<widget class="QTabWidget" name="tabWidget"/>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="bottompart" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QFormLayout" name="data_select_lay"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="bottombar" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,0,0,0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="data_select"/>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="send_ppt">
<property name="text">
<string>Send data to powerpoint</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="copy_im">
<property name="text">
<string>Copy image to clipboard</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="split_data">
<property name="text">
<string>Split dataset</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1141</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menu_Data">
<property name="title">
<string>&amp;Data</string>
</property>
<addaction name="actionReload_data"/>
<addaction name="actionPreload_all_info"/>
<addaction name="actionQui"/>
</widget>
<widget class="QMenu" name="menuFolder">
<property name="title">
<string>Folder</string>
</property>
<addaction name="actionAdd_directory"/>
</widget>
<addaction name="menu_Data"/>
<addaction name="menuFolder"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionReload_data">
<property name="text">
<string>Reload data</string>
</property>
</action>
<action name="actionPreload_all_info">
<property name="text">
<string>Preload all info</string>
</property>
</action>
<action name="actionQui">
<property name="text">
<string>Quit</string>
</property>
</action>
<action name="actionAdd_directory">
<property name="text">
<string>Add directory</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
# -*- coding: utf-8 -*-
from data_browser_GUI_window import Ui_dataviewer
from PyQt5 import QtCore, QtGui, QtWidgets
from qtpy.QtWidgets import QWidget
from functools import partial
import pyqtgraph as pg
import qcodes
import numpy as np
import qdarkstyle
import logging
import qtt
from core_tools.utility.powerpoint import addPPTslide, addPPT_dataset
import os
from qcodes.plots.pyqtgraph import QtPlot
class data_viewer(QtWidgets.QMainWindow, Ui_dataviewer):
"""docstring for virt_gate_matrix_GUI"""
def __init__(self, datadir=None, window_title='Data browser'):
# set graphical user interface
instance_ready = True
self.app = QtCore.QCoreApplication.instance()
if self.app is None:
instance_ready = False
self.app = QtWidgets.QApplication([])
super(QtWidgets.QMainWindow, self).__init__()
self.app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
self.setupUi(self)
if datadir is None:
datadir = qcodes.DataSet.default_io.base_location
# set-up tree view for data
self._treemodel = QtGui.QStandardItemModel()
self.data_view.setModel(self._treemodel)
self.tabWidget.addTab(QtWidgets.QWidget(), 'metadata')
self.qplot = QtPlot(remote=False)
self.plotwindow = self.qplot.win
self.qplot.max_len = 10
self.horizontalLayout_4.addWidget(self.plotwindow)
# Fix some initializations in the window
self.splitter_2.setSizes([int(self.height()/2)]*2)
self.splitter.setSizes([int(self.width() / 3), int(2 * self.width() / 3)])
# connect callbacks
self.data_view.doubleClicked.connect(self.logCallback)
self.actionReload_data.triggered.connect(self.updateLogs)
self.actionPreload_all_info.triggered.connect(self.loadInfo)
self.actionAdd_directory.triggered.connect(self.selectDirectory)
self.filter_button.clicked.connect(lambda: self.updateLogs(filter_str=self.filter_input.text()))
self.send_ppt.clicked.connect(self.pptCallback)
self.copy_im.clicked.connect(self.clipboardCallback)
self.split_data.clicked.connect(self.split_dataset)
# initialize defaults
self.extensions =['dat', 'hdf5']
self.dataset = None
self.datatag = None
self.datadirlist = []
self.datadirindex = 0
self.color_list = [pg.mkColor(cl) for cl in qcodes.plots.pyqtgraph.color_cycle]
self.current_params = []
self.subpl_ind = dict()
self.splitted = False
# add default directory
self.addDirectory(datadir)
self.updateLogs()
# Launch app
self.show()
if instance_ready == False:
self.app.exec()
def find_datafiles(self,datadir, extensions=['dat', 'hdf5'], show_progress=True):
""" Find all datasets in a directory with a given extension """
dd = []
for e in extensions:
dd += self.findfiles(datadir, e)
dd.sort()
datafiles = sorted(dd)
return datafiles
def loadInfo(self):
logging.debug('loading info')
try:
for row in range(self._treemodel.rowCount()):
index = self._treemodel.index(row, 0)
i = 0
while (index.child(i, 0).data() is not None):
filename = index.child(i, 3).data()
loc = os.path.dirname(filename)
tempdata = qcodes.DataSet(loc)
tempdata.read_metadata()
infotxt = self.getArrayStr(tempdata.metadata)
self._treemodel.setData(index.child(i, 1), infotxt)
i = i + 1
except Exception as e:
logging.warning(e)
def setDatadir(self, newindex):
logging.info(f'Setting datadir with index: {newindex}')
oldindex = self.datadirindex
self.datadirindex = newindex
datadir = self.datadirlist[newindex]
self.io = qcodes.DiskIO(datadir)
logging.info('DataViewer: data directory %s' % datadir)
self.logfile.setText('Log files at %s' % datadir)
self.menuFolder.actions()[oldindex + 1].setText(self.menuFolder.actions()[oldindex + 1].text()[2:])
self.menuFolder.actions()[newindex + 1].setText('>>' + self.menuFolder.actions()[newindex + 1].text())
self.updateLogs()
def selectDirectory(self):
from qtpy.QtWidgets import QFileDialog
d = QtWidgets.QFileDialog(caption='Select data directory')
d.setFileMode(QFileDialog.Directory)
if d.exec():
datadir = d.selectedFiles()[0]
self.addDirectory(datadir)
def addDirectory(self,datadir):
newindex = len(self.datadirlist)
self.datadirlist.append(datadir)
if len(self.datadirlist) == 1:
datadir = '>>' + datadir
new_act = QtWidgets.QAction(datadir, self)
new_act.triggered.connect(partial(self.setDatadir,newindex))
self.menuFolder.addAction(new_act)
self.setDatadir(newindex)
def updateLogs(self, filter_str = None):
''' Update the list of measurements '''
logging.info('updating logs')
model = self._treemodel
self.datafiles=self.find_datafiles(self.datadirlist[self.datadirindex], self.extensions)
dd = self.datafiles
if filter_str:
dd = [s for s in dd if filter_str in s]
logging.info(f'DataViewer: found {len(dd)} files')
model.clear()
model.setHorizontalHeaderLabels(
['Log', 'Arrays', 'location', 'filename'])
logs = dict()
for i, d in enumerate(dd):
try:
datetag, logtag = d.split(os.sep)[-3:-1]
if datetag not in logs:
logs[datetag] = dict()
logs[datetag][logtag] = d
except Exception as e:
print(e)
pass
self.logs = logs
logging.debug('DataViewer: create gui elements')
for i, datetag in enumerate(sorted(logs.keys())[::-1]):
logging.debug(f'DataViewer: datetag {datetag}')
parent1 = QtGui.QStandardItem(datetag)
for j, logtag in enumerate(sorted(logs[datetag])):
filename = logs[datetag][logtag]
child1 = QtGui.QStandardItem(logtag)
child2 = QtGui.QStandardItem('info about plot')
logging.debug(f'datetag: {datetag}, logtag: {logtag}')
child3 = QtGui.QStandardItem(os.path.join(datetag, logtag))
child4 = QtGui.QStandardItem(filename)
parent1.appendRow([child1, child2, child3, child4])
model.appendRow(parent1)
self.data_view.setColumnWidth(0, 240)
self.data_view.setColumnHidden(2, True)
self.data_view.setColumnHidden(3, True)
logging.debug('DataViewer: updateLogs done')
def logCallback(self, index):
""" Function called when. a log entry is selected """
logging.info('logCallback: index %s' % str(index))
oldtab_index = self.tabWidget.currentIndex()
pp = index.parent()
row = index.row()
tag = pp.child(row, 2).data()
filename = pp.child(row, 3).data()
self.filename = filename
self.datatag = tag
if tag is None:
return
logging.debug(f'DataViewer logCallback: tag {tag}, filename {filename}')
try:
logging.debug('DataViewer: load tag %s' % tag)
data = self.loadData(filename, tag)
if not data:
raise ValueError('File invalid (%s) ...' % filename)
self.dataset = data
self.updateMetaTabs()
try:
self.tabWidget.setCurrentIndex(oldtab_index)
except: pass
data_keys = data.arrays.keys()
infotxt = self.getArrayStr(data.metadata)
q = pp.child(row, 1).model()
q.setData(pp.child(row, 1), infotxt)
self.resetComboItems(data, data_keys)
except Exception as e:
print('logCallback! error: %s' % str(e))
logging.exception(e)
def resetComboItems(self, data, keys):
# Clearing old stuff
self.clearLayout(self.data_select_lay)
self.qplot.clear()
self.boxes = dict()
self.box_labels = dict()
self.param_keys = list()
to_plot = list()
# Loop through keys and add graphics items
for key in keys:
if not getattr(data, key).is_setpoint:
box = QtWidgets.QCheckBox()
box.clicked.connect(self.checkbox_callback)
box.setText(key)
label = QtWidgets.QLabel()
self.data_select_lay.addRow(box, label)
self.boxes[key] = box
self.box_labels[key] = label
self.param_keys.append(key)
if key in self.subpl_ind.keys():
self.boxes[key].setChecked(True)
to_plot.append(key)
self.data_select_lay.setLabelAlignment(QtCore.Qt.AlignLeft)
# If no old parameters can be plotted, defined first one
if not to_plot:
def_key = list(self.boxes.values())[0].text()
to_plot.append(self.boxes[def_key].text())
self.boxes[def_key].setChecked(True)
# Update the parameter plots
self.subpl_ind = dict()
self.current_params = list()
self.updatePlots(to_plot)
if self.splitted:
self.split_dataset()
def clearPlots(self):
self.qplot.clear()
self.current_params = list(set(self.current_params) - set(self.subpl_ind.keys()))
self.subpl_ind = dict()
def clearLayout(self, layout):
if layout is not None:
while layout.count():
item = layout.takeAt(0)
widget = item.widget()
if widget is not None:
widget.deleteLater()
else:
self.clearLayout(item.layout())
def checkbox_callback(self, state):
if self.splitted:
self.clearPlots()
self.splitted = False
to_plot = []
for param in self.param_keys:
box = self.boxes[param]
if box.isChecked():
to_plot.append(box.text())
self.updatePlots(to_plot)
def updatePlots(self, param_names):
for param_name in set(param_names + self.current_params):
param = getattr(self.dataset, param_name)
if param_name not in param_names:
self.current_params.remove(param_name)
if param.shape == (1,):
self.removeValue(param_name)
elif len(param.shape) < 3:
self.removePlot(param_name)
elif param_name not in self.current_params:
self.current_params.append(param_name)
if param.shape == (1,):
self.addValue(param_name)
elif len(param.shape) < 3:
self.addPlot(param_name)
def addPlot(self, plot):
logging.info(f'adding param {plot}')
self.subpl_ind[plot] = len(self.subpl_ind)
self.qplot.add(getattr(self.dataset, plot), subplot = len(self.subpl_ind),
color = self.color_list[0])
def removePlot(self,plot):
logging.info(f'removing param {plot}')
# Deleting graphics items
plot_index = self.subpl_ind[plot]
subplot = self.qplot.subplots[plot_index]
subplot.clear()
self.qplot.win.removeItem(subplot)
subplot.deleteLater()
try:
hist = self.qplot.traces[plot_index]['plot_object']['hist']
self.qplot.win.removeItem(hist)
hist.deleteLater()
except: pass
# Own bookkeeping
self.subpl_ind.pop(plot)
# Removing from qcodes qplot (does not have proper function for this)
self.qplot.traces.pop(plot_index)
self.qplot.subplots.remove(subplot)
for (key, val) in self.subpl_ind.items():
if val > plot_index:
self.subpl_ind[key] = val - 1
def addValue(self, plot):
val = getattr(self.dataset, plot).ndarray[0]
self.box_labels[plot].setText(str(val))
def removeValue(self, plot):
self.box_labels[plot].setText('')
def loadData(self, filename, tag):
location = os.path.split(filename)[0]
data = qcodes.data.data_set.load_data(location)
return data
def _create_meta_tree(self, meta_dict):
metatree = QtWidgets.QTreeView()
_metamodel = QtGui.QStandardItemModel()
metatree.setModel(_metamodel)
metatree.setEditTriggers(
QtWidgets.QAbstractItemView.NoEditTriggers)
_metamodel.setHorizontalHeaderLabels(['metadata', 'value'])
try:
self.fill_item(_metamodel, meta_dict)
return metatree
except Exception as ex:
print(ex)
def fill_item(self, item, value):
''' recursive population of tree structure with a dict '''
def new_item(parent, text, val=None):
child = QtGui.QStandardItem(text)
self.fill_item(child, val)
parent.appendRow(child)
if value is None:
return
elif isinstance(value, dict):
for key, val in sorted(value.items()):
if type(val) in [str, float, int] or (type(val) is list and not any(isinstance(el, list) for el in val)):
child = [QtGui.QStandardItem(
str(key)), QtGui.QStandardItem(str(val))]
item.appendRow(child)
else:
new_item(item, str(key), val)
else:
new_item(item, str(value))
def parse_gates(self, gates_obj):
gate_dict = dict()
for (gate, val) in gates_obj['parameters'].items():
if gate != 'IDN':
gate_dict[gate] = val['value']
return gate_dict
def updateMetaTabs(self):
''' Update metadata tree '''
meta = self.dataset.metadata
self.tabWidget.clear()
try:
gate_tree = self.parse_gates(meta['station']['instruments']['gates'])
self.tabWidget.addTab(self._create_meta_tree(gate_tree), 'gates')
except: pass
self.tabWidget.addTab(self._create_meta_tree(meta), 'metadata')
if 'pc0' in meta.keys():
self.pulse_plot = pg.PlotWidget()
self.pulse_plot.addLegend()
legend_names = list()
try:
baseband_freqs = meta['LOs']
except:
pass
for (j, (name, pdict)) in enumerate(meta['pc0'].items()):
legend_name = name.replace('_baseband','').replace('_pulses','')
x = list()
y = list()
ch_type = list()
end_time = max([x['stop'] for y in meta['pc0'].values() for x in y.values()])
if 'baseband' in name:
timepoints = set([x[key] for x in meta['pc0'][name].values() for key in ['start','stop']])
timepoints.add(end_time)
x_plot = list()
y_plot = list()
for tp in sorted(timepoints):
point1 = 0
point2 = 0
for (seg_name,seg_dict) in meta['pc0'][name].items():
if seg_dict['start'] < tp and seg_dict['stop'] > tp: # active segement
point1 += tp/(seg_dict['stop'] - seg_dict['start']) * ( seg_dict['v_stop'] - seg_dict['v_stop'] )
point2 += tp/(seg_dict['stop'] - seg_dict['start']) * ( seg_dict['v_stop'] - seg_dict['v_stop'] )
elif seg_dict['start'] == tp:
point2 += seg_dict['v_start']
elif seg_dict['stop'] == tp:
point1 += seg_dict['v_stop']
x_plot += [tp, tp]
y_plot += [point1, point2]
elif 'pulses' in name:
try:
baseband = baseband_freqs[name.replace('_pulses','')]
except:
logging.warning('No baseband frequency found, assuming 0')
baseband = 0
for (seg_name,seg_dict) in meta['pc0'][name].items():
x_ar = np.arange(seg_dict['start'],seg_dict['stop'])
xx_ar = x_ar-seg_dict['start']
f_rl = (seg_dict['frequency'] - baseband)/1e9
y_ar = np.sin(2*np.pi*f_rl*xx_ar+seg_dict['start_phase'])*seg_dict['amplitude']
x = x + list(x_ar) + [seg_dict['stop']]
y = y + list(y_ar) + [0]
x_plot = x
y_plot = y
self.pulse_plot.setLabel('left', 'Voltage', 'mV')
self.pulse_plot.setLabel('bottom', 'Time', 'ns')
self.pulse_plot.plot(x_plot, y_plot, pen = self.color_list[j], name = legend_name)
self.tabWidget.addTab(self.pulse_plot,'AWG Pulses')
def pptCallback(self):
if self.dataset is None:
print('no data selected')
return
addPPT_dataset(self.dataset, customfig=self.qplot)
def clipboardCallback(self):
self.qplot.copyToClipboard()
def getArrayStr(self, metadata):
params = []
infotxt = ''
try:
if 'loop' in metadata.keys():
sv = metadata['loop']['sweep_values']
params.append('%s [%.2f to %.2f %s]' % (sv['parameter']['label'],
sv['values'][0]['first'],
sv['values'][0]['last'],
sv['parameter']['unit']))
for act in metadata['loop']['actions']:
if 'sweep_values' in act.keys():
sv = act['sweep_values']
params.append('%s [%.2f - %.2f %s]' % (sv['parameter']['label'],
sv['values'][0]['first'],
sv['values'][0]['last'],
sv['parameter']['unit']))
infotxt = ' ,'.join(params) + ' | '
infotxt = infotxt + ', '.join([('%s' % (v['label'])) for (
k, v) in metadata['arrays'].items() if not v['is_setpoint']])
except BaseException:
infotxt = 'info about plot'
return infotxt
def split_dataset(self):
to_split = []
for bp in self.subpl_ind.keys():
plot_shape = getattr(self.dataset, bp).shape
if len(plot_shape) == 2:
to_split.append(bp)
self.clearPlots()
for (i,zname) in enumerate(to_split):
tmp = getattr(self.dataset, zname)
yname = tmp.set_arrays[0].array_id
xname = tmp.set_arrays[1].array_id
try:
ii = np.where(np.isnan(self.dataset.arrays[zname][:,-1])==True)[0][0]
except:
ii = len(self.dataset.arrays[yname][:])
even = list(range(0, ii, 2))
odd = list(range(1, ii, 2))
self.qplot.add(self.dataset.arrays[xname][0], self.dataset.arrays[yname][odd], self.dataset.arrays[zname][odd],
ylabel=self.dataset.arrays[yname].label, xlabel=self.dataset.arrays[xname].label, zlabel=self.dataset.arrays[zname].label+'_odd',
yunit = self.dataset.arrays[yname].unit, zunit=self.dataset.arrays[zname].unit, subplot = 2 * i + 1)
self.qplot.add(self.dataset.arrays[xname][0], self.dataset.arrays[yname][even], self.dataset.arrays[zname][even],
ylabel=self.dataset.arrays[yname].label, xlabel=self.dataset.arrays[xname].label, zlabel=self.dataset.arrays[zname].label+'_even',
yunit = self.dataset.arrays[yname].unit, zunit =self.dataset.arrays[zname].unit, subplot = 2 * i + 2)
self.splitted = True
def findfiles(self, path, extension):
filelist = list()
for dirname, dirnames, filenames in os.walk(path):
# print path to all filenames.
for filename in filenames:
fullfile = os.path.join(dirname, filename)
if fullfile.split('.')[-1] == extension:
filelist.append(fullfile)
return filelist
\ No newline at end of file
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'data_browser_v2.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_dataviewer(object):
def setupUi(self, dataviewer):
dataviewer.setObjectName("dataviewer")
dataviewer.resize(1141, 631)
self.centralwidget = QtWidgets.QWidget(dataviewer)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.splitter_2 = QtWidgets.QSplitter(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.splitter_2.sizePolicy().hasHeightForWidth())
self.splitter_2.setSizePolicy(sizePolicy)
self.splitter_2.setOrientation(QtCore.Qt.Vertical)
self.splitter_2.setOpaqueResize(True)
self.splitter_2.setObjectName("splitter_2")
self.toppart = QtWidgets.QWidget(self.splitter_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.toppart.sizePolicy().hasHeightForWidth())
self.toppart.setSizePolicy(sizePolicy)
self.toppart.setObjectName("toppart")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.toppart)
self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.topbar = QtWidgets.QWidget(self.toppart)
self.topbar.setEnabled(True)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.topbar.sizePolicy().hasHeightForWidth())
self.topbar.setSizePolicy(sizePolicy)
self.topbar.setMinimumSize(QtCore.QSize(0, 0))
self.topbar.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.topbar.setObjectName("topbar")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.topbar)
self.horizontalLayout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.logfile = QtWidgets.QLabel(self.topbar)
self.logfile.setObjectName("logfile")
self.horizontalLayout.addWidget(self.logfile)
spacerItem = QtWidgets.QSpacerItem(3, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.filter_button = QtWidgets.QPushButton(self.topbar)
self.filter_button.setObjectName("filter_button")
self.horizontalLayout.addWidget(self.filter_button)
spacerItem1 = QtWidgets.QSpacerItem(3, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.filter_input = QtWidgets.QLineEdit(self.topbar)
self.filter_input.setObjectName("filter_input")
self.horizontalLayout.addWidget(self.filter_input)
self.verticalLayout.addWidget(self.topbar)
self.splitter = QtWidgets.QSplitter(self.toppart)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.splitter.sizePolicy().hasHeightForWidth())
self.splitter.setSizePolicy(sizePolicy)
self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter.setObjectName("splitter")
self.data_view = QtWidgets.QTreeView(self.splitter)
self.data_view.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
self.data_view.setObjectName("data_view")
self.tabWidget = QtWidgets.QTabWidget(self.splitter)
self.tabWidget.setObjectName("tabWidget")
self.verticalLayout.addWidget(self.splitter)
self.verticalLayout_3.addLayout(self.verticalLayout)
self.bottompart = QtWidgets.QWidget(self.splitter_2)
self.bottompart.setObjectName("bottompart")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.bottompart)
self.verticalLayout_4.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.horizontalLayout_4.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
self.horizontalLayout_4.setSpacing(6)
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.data_select_lay = QtWidgets.QFormLayout()
self.data_select_lay.setObjectName("data_select_lay")
self.horizontalLayout_4.addLayout(self.data_select_lay)
self.verticalLayout_4.addLayout(self.horizontalLayout_4)
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setContentsMargins(0, -1, -1, -1)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.bottombar = QtWidgets.QWidget(self.bottompart)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.bottombar.sizePolicy().hasHeightForWidth())
self.bottombar.setSizePolicy(sizePolicy)
self.bottombar.setMinimumSize(QtCore.QSize(0, 0))
self.bottombar.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.bottombar.setObjectName("bottombar")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.bottombar)
self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_3.setSpacing(0)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
spacerItem2 = QtWidgets.QSpacerItem(3, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem2)
self.send_ppt = QtWidgets.QPushButton(self.bottombar)
self.send_ppt.setObjectName("send_ppt")
self.horizontalLayout_3.addWidget(self.send_ppt)
spacerItem3 = QtWidgets.QSpacerItem(3, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem3)
self.copy_im = QtWidgets.QPushButton(self.bottombar)
self.copy_im.setObjectName("copy_im")
self.horizontalLayout_3.addWidget(self.copy_im)
spacerItem4 = QtWidgets.QSpacerItem(3, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem4)
self.split_data = QtWidgets.QPushButton(self.bottombar)
self.split_data.setObjectName("split_data")
self.horizontalLayout_3.addWidget(self.split_data)
self.verticalLayout_2.addWidget(self.bottombar)
self.verticalLayout_4.addLayout(self.verticalLayout_2)
self.gridLayout.addWidget(self.splitter_2, 0, 0, 1, 1)
dataviewer.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(dataviewer)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1141, 21))
self.menubar.setObjectName("menubar")
self.menu_Data = QtWidgets.QMenu(self.menubar)
self.menu_Data.setObjectName("menu_Data")
self.menuFolder = QtWidgets.QMenu(self.menubar)
self.menuFolder.setObjectName("menuFolder")
dataviewer.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(dataviewer)
self.statusbar.setObjectName("statusbar")
dataviewer.setStatusBar(self.statusbar)
self.actionReload_data = QtWidgets.QAction(dataviewer)
self.actionReload_data.setObjectName("actionReload_data")
self.actionPreload_all_info = QtWidgets.QAction(dataviewer)
self.actionPreload_all_info.setObjectName("actionPreload_all_info")
self.actionQui = QtWidgets.QAction(dataviewer)
self.actionQui.setObjectName("actionQui")
self.actionAdd_directory = QtWidgets.QAction(dataviewer)
self.actionAdd_directory.setObjectName("actionAdd_directory")
self.menu_Data.addAction(self.actionReload_data)
self.menu_Data.addAction(self.actionPreload_all_info)
self.menu_Data.addAction(self.actionQui)
self.menuFolder.addAction(self.actionAdd_directory)
self.menubar.addAction(self.menu_Data.menuAction())
self.menubar.addAction(self.menuFolder.menuAction())
self.retranslateUi(dataviewer)
QtCore.QMetaObject.connectSlotsByName(dataviewer)
def retranslateUi(self, dataviewer):
_translate = QtCore.QCoreApplication.translate
dataviewer.setWindowTitle(_translate("dataviewer", "dataviewer"))
self.logfile.setText(_translate("dataviewer", "V2"))
self.filter_button.setText(_translate("dataviewer", "Filter data"))
self.send_ppt.setText(_translate("dataviewer", "Send data to powerpoint"))
self.copy_im.setText(_translate("dataviewer", "Copy image to clipboard"))
self.split_data.setText(_translate("dataviewer", "Split dataset"))
self.menu_Data.setTitle(_translate("dataviewer", "&Data"))
self.menuFolder.setTitle(_translate("dataviewer", "Folder"))
self.actionReload_data.setText(_translate("dataviewer", "Reload data"))
self.actionPreload_all_info.setText(_translate("dataviewer", "Preload all info"))
self.actionQui.setText(_translate("dataviewer", "Quit"))
self.actionAdd_directory.setText(_translate("dataviewer", "Add directory"))
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>dataviewer</class>
<widget class="QMainWindow" name="dataviewer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1141</width>
<height>631</height>
</rect>
</property>
<property name="windowTitle">
<string>dataviewer</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QSplitter" name="splitter_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="opaqueResize">
<bool>true</bool>
</property>
<widget class="QWidget" name="toppart" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="topbar" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="logfile">
<property name="text">
<string>V2</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="filter_button">
<property name="text">
<string>Filter data</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="filter_input"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTreeView" name="data_view">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
<widget class="QTabWidget" name="tabWidget"/>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="bottompart" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QFormLayout" name="data_select_lay"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="bottombar" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,0,0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="send_ppt">
<property name="text">
<string>Send data to powerpoint</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="copy_im">
<property name="text">
<string>Copy image to clipboard</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="split_data">
<property name="text">
<string>Split dataset</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1141</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menu_Data">
<property name="title">
<string>&amp;Data</string>
</property>
<addaction name="actionReload_data"/>
<addaction name="actionPreload_all_info"/>
<addaction name="actionQui"/>
</widget>
<widget class="QMenu" name="menuFolder">
<property name="title">
<string>Folder</string>
</property>
<addaction name="actionAdd_directory"/>
</widget>
<addaction name="menu_Data"/>
<addaction name="menuFolder"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionReload_data">
<property name="text">
<string>Reload data</string>
</property>
</action>
<action name="actionPreload_all_info">
<property name="text">
<string>Preload all info</string>
</property>
</action>
<action name="actionQui">
<property name="text">
<string>Quit</string>
</property>
</action>
<action name="actionAdd_directory">
<property name="text">
<string>Add directory</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
...@@ -12,7 +12,7 @@ import time ...@@ -12,7 +12,7 @@ import time
class fake_digitizer(MultiParameter): class fake_digitizer(MultiParameter):
"""docstring for fake_digitizer""" """docstring for fake_digitizer"""
def __init__(self, name): def __init__(self, name):
super().__init__(name=name, names = ("chan 1", "chan 2"), shapes = tuple([(20,20)]*2), super().__init__(name=name, names = ("chan_1", "chan_2"), shapes = tuple([(20,20)]*2),
labels = ("chan 1", "chan 2"), units =("mV", "mV"), labels = ("chan 1", "chan 2"), units =("mV", "mV"),
docstring='1D scan parameter for digitizer') docstring='1D scan parameter for digitizer')
......
# -*- coding: utf-8 -*-
from typing import Optional
from core_tools.GUI.param_viewer.param_viewer_GUI_window import Ui_MainWindow from core_tools.GUI.param_viewer.param_viewer_GUI_window import Ui_MainWindow
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
from functools import partial from functools import partial
import qcodes as qc
from qcodes import Station
import numpy as np import numpy as np
from dataclasses import dataclass from dataclasses import dataclass
@dataclass @dataclass
class gate_data_obj: class param_data_obj:
gate_parameter : any param_parameter : any
gui_input_param : any gui_input_param : any
division : any
class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow): class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow):
"""docstring for virt_gate_matrix_GUI""" """docstring for virt_gate_matrix_GUI"""
def __init__(self, gates_object): def __init__(self, station : Station, gates_object: Optional[object] = None):
if type(station) is not Station:
raise Exception('Syntax changed, to support RF_settings now supply station')
self.real_gates = list() self.real_gates = list()
self.virtual_gates = list() self.virtual_gates = list()
self.gates_object = gates_object self.rf_settings = list()
self.station = station
if gates_object:
self.gates_object = gates_object
else:
try:
self.gates_object = self.station.gates
except:
raise ValueError('Default guess for gates object wrong, please supply manually')
self._step_size = 1 #mV self._step_size = 1 #mV
instance_ready = True instance_ready = True
# set graphical user interface # set graphical user interface
self.app = QtCore.QCoreApplication.instance() self.app = QtCore.QCoreApplication.instance()
if self.app is None: if self.app is None:
...@@ -28,33 +42,41 @@ class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -28,33 +42,41 @@ class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow):
super(QtWidgets.QMainWindow, self).__init__() super(QtWidgets.QMainWindow, self).__init__()
self.setupUi(self) self.setupUi(self)
# add RF parameters
for src_name in self.gates_object.hardware.RF_source_names:
inst = getattr(station, src_name)
for RFpar in self.gates_object.hardware.RF_params:
param = getattr(inst, RFpar)
self._add_RFset(param)
# add real gates # add real gates
for gate_name in gates_object.hardware.dac_gate_map.keys(): for gate_name in self.gates_object.hardware.dac_gate_map.keys():
param = getattr(gates_object, gate_name) param = getattr(self.gates_object, gate_name)
self._add_gate(param, False) self._add_gate(param, False)
# add virtual gates # add virtual gates
for virt_gate_set in gates_object.hardware.virtual_gates: for virt_gate_set in self.gates_object.hardware.virtual_gates:
for gate_name in virt_gate_set.virtual_gate_names: for gate_name in virt_gate_set.virtual_gate_names:
param = getattr(gates_object, gate_name) param = getattr(self.gates_object, gate_name)
self._add_gate(param, True) self._add_gate(param, True)
self.step_size.valueChanged.connect(partial(self._update_step, self.step_size.value)) self.step_size.valueChanged.connect(partial(self._update_step, self.step_size.value))
self._finish_gates_GUI() self._finish_gates_GUI()
self.timer = QtCore.QTimer() self.timer = QtCore.QTimer()
self.timer.timeout.connect(partial(self._update_gates)) self.timer.timeout.connect(partial(self._update_parameters))
self.timer.start(500) self.timer.start(500)
self.show() self.show()
if instance_ready == False: if instance_ready == False:
self.app.exec() self.app.exec()
def _update_step(self, value): def _update_step(self, value):
self.update_step(value()) self.update_step(value())
def update_step(self, value): def update_step(self, value : float):
""" Update step size of the parameter GUI elements with the specified value """
self._step_size = value self._step_size = value
for gate in self.real_gates: for gate in self.real_gates:
gate.gui_input_param.setSingleStep(value) gate.gui_input_param.setSingleStep(value)
...@@ -63,7 +85,53 @@ class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -63,7 +85,53 @@ class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow):
self.step_size.setValue(value) self.step_size.setValue(value)
def _add_gate(self, parameter, virtual): def _add_RFset(self, parameter : qc.Parameter):
''' Add a new RF.
Args:
parameter (QCoDeS parameter object) : parameter to add.
'''
i = len(self.rf_settings)
layout = self.layout_RF
name = parameter.full_name
unit = parameter.unit
step_size = 0.5
division = 1
if parameter.name[0:10] == 'frequency':
division = 1e6
step_size = 0.1
unit = f'M{unit}'
_translate = QtCore.QCoreApplication.translate
set_name = QtWidgets.QLabel(self.RFsettings)
set_name.setObjectName(name)
set_name.setMinimumSize(QtCore.QSize(100, 0))
set_name.setText(_translate("MainWindow", name))
layout.addWidget(set_name, i, 0, 1, 1)
set_input = QtWidgets.QDoubleSpinBox(self.RFsettings)
set_input.setObjectName(name + "_input")
set_input.setMinimumSize(QtCore.QSize(100, 0))
# TODO collect boundaries out of the harware
set_input.setRange(-1e9,1e9)
set_input.valueChanged.connect(partial(self._set_set, parameter, set_input.value,division))
set_input.setKeyboardTracking(False)
set_input.setSingleStep(step_size)
layout.addWidget(set_input, i, 1, 1, 1)
set_unit = QtWidgets.QLabel(self.RFsettings)
set_unit.setObjectName(name + "_unit")
set_unit.setText(_translate("MainWindow", unit))
layout.addWidget(set_unit, i, 2, 1, 1)
self.rf_settings.append(param_data_obj(parameter, set_input, division))
def _add_gate(self, parameter : qc.Parameter, virtual : bool):
''' '''
add a new gate. add a new gate.
...@@ -78,7 +146,7 @@ class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -78,7 +146,7 @@ class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow):
if virtual == True: if virtual == True:
i = len(self.virtual_gates) i = len(self.virtual_gates)
layout = self.layout_virtual layout = self.layout_virtual
name = parameter.name name = parameter.name
unit = parameter.unit unit = parameter.unit
...@@ -93,6 +161,7 @@ class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -93,6 +161,7 @@ class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow):
voltage_input = QtWidgets.QDoubleSpinBox(self.virtualgates) voltage_input = QtWidgets.QDoubleSpinBox(self.virtualgates)
voltage_input.setObjectName( name + "_input") voltage_input.setObjectName( name + "_input")
voltage_input.setMinimumSize(QtCore.QSize(100, 0)) voltage_input.setMinimumSize(QtCore.QSize(100, 0))
# TODO collect boundaries out of the harware # TODO collect boundaries out of the harware
voltage_input.setRange(-4000,4000.0) voltage_input.setRange(-4000,4000.0)
voltage_input.valueChanged.connect(partial(self._set_gate, parameter, voltage_input.value)) voltage_input.valueChanged.connect(partial(self._set_gate, parameter, voltage_input.value))
...@@ -104,55 +173,60 @@ class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -104,55 +173,60 @@ class param_viewer(QtWidgets.QMainWindow, Ui_MainWindow):
gate_unit.setText(_translate("MainWindow", unit)) gate_unit.setText(_translate("MainWindow", unit))
layout.addWidget(gate_unit, i, 2, 1, 1) layout.addWidget(gate_unit, i, 2, 1, 1)
if virtual == False: if virtual == False:
self.real_gates.append(gate_data_obj(parameter, voltage_input)) self.real_gates.append(param_data_obj(parameter, voltage_input, 1))
else: else:
self.virtual_gates.append(gate_data_obj(parameter, voltage_input)) self.virtual_gates.append(param_data_obj(parameter, voltage_input, 1))
def _set_gate(self, gate, value): def _set_gate(self, gate, value):
# TODO add support if out of range. # TODO add support if out of range.
gate.set(value()) gate.set(value())
def _finish_gates_GUI(self): def _set_set(self, setting, value, division):
i = len(self.real_gates) + 1 # TODO add support if out of range.
setting.set(value()*division)
self.gates_object.hardware.RF_settings[setting.full_name] = value()*division
self.gates_object.hardware.sync_data()
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) def _finish_gates_GUI(self):
self.layout_real.addItem(spacerItem, i, 0, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) for items, layout_widget in [ (self.real_gates, self.layout_real), (self.virtual_gates, self.layout_virtual),
self.layout_real.addItem(spacerItem1, 0, 3, 1, 1) (self.rf_settings, self.layout_RF)]:
i = len(items) + 1
i = len(self.virtual_gates) + 1 spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
layout_widget.addItem(spacerItem, i, 0, 1, 1)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.layout_virtual.addItem(spacerItem, i, 0, 1, 1) layout_widget.addItem(spacerItem1, 0, 3, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.setWindowTitle(f'Viewer for {self.gates_object}')
self.layout_virtual.addItem(spacerItem1, 0, 3, 1, 1)
def _update_gates(self): def _update_parameters(self):
''' '''
updates the values of all the gates in the parameterviewer periodically updates the values of all the gates in the parameterviewer periodically
''' '''
idx = self.tab_menu.currentIndex() idx = self.tab_menu.currentIndex()
if idx == 0: if idx == 0:
gates = self.real_gates params = self.real_gates
elif idx == 1: elif idx == 1:
gates = self.virtual_gates params = self.virtual_gates
elif idx == 2:
params = self.rf_settings
else: else:
return return
for gate in gates: for param in params:
# do not update when a user clicks on it. # do not update when a user clicks on it.
if not gate.gui_input_param.hasFocus(): if not param.gui_input_param.hasFocus():
gate.gui_input_param.setValue(gate.gate_parameter()) param.gui_input_param.setValue(param.param_parameter()/param.division)
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys
import qcodes as qc import qcodes as qc
from V2_software.drivers.virtual_gates.examples.hardware_example import hardware_example from V2_software.drivers.virtual_gates.examples.hardware_example import hardware_example
from V2_software.drivers.virtual_gates.instrument_drivers.virtual_dac import virtual_dac from V2_software.drivers.virtual_gates.instrument_drivers.virtual_dac import virtual_dac
from V2_software.drivers.virtual_gates.instrument_drivers.gates import gates from V2_software.drivers.virtual_gates.instrument_drivers.gates import gates
...@@ -162,10 +236,13 @@ if __name__ == "__main__": ...@@ -162,10 +236,13 @@ if __name__ == "__main__":
my_dac_4 = virtual_dac("dac_d", "virtual") my_dac_4 = virtual_dac("dac_d", "virtual")
hw = hardware_example("hw") hw = hardware_example("hw")
hw.RF_source_names = []
my_gates = gates("my_gates", hw, [my_dac_1, my_dac_2, my_dac_3, my_dac_4]) my_gates = gates("my_gates", hw, [my_dac_1, my_dac_2, my_dac_3, my_dac_4])
# app = QtWidgets.QApplication(sys.argv) # app = QtWidgets.QApplication(sys.argv)
# MainWindow = QtWidgets.QMainWindow() # MainWindow = QtWidgets.QMainWindow()
ui = param_viewer(my_gates) station=qc.Station(my_gates)
ui = param_viewer(station, my_gates)
# MainWindow.show() # MainWindow.show()
# sys.exit(app.exec_()) # sys.exit(app.exec_())
\ No newline at end of file
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
# Form implementation generated from reading ui file 'param_viewer_GUI_window.ui' # Form implementation generated from reading ui file 'param_viewer_GUI_window.ui'
# #
# Created by: PyQt5 UI code generator 5.13.1 # Created by: PyQt5 UI code generator 5.9.2
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object): class Ui_MainWindow(object):
def setupUi(self, MainWindow): def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow") MainWindow.setObjectName("MainWindow")
...@@ -28,7 +26,7 @@ class Ui_MainWindow(object): ...@@ -28,7 +26,7 @@ class Ui_MainWindow(object):
self.scrollArea.setWidgetResizable(True) self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea") self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget() self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 758, 491)) self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 756, 495))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.gridLayout_6 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents) self.gridLayout_6 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents)
self.gridLayout_6.setObjectName("gridLayout_6") self.gridLayout_6.setObjectName("gridLayout_6")
...@@ -46,6 +44,15 @@ class Ui_MainWindow(object): ...@@ -46,6 +44,15 @@ class Ui_MainWindow(object):
self.layout_virtual.setObjectName("layout_virtual") self.layout_virtual.setObjectName("layout_virtual")
self.gridLayout_5.addLayout(self.layout_virtual, 0, 0, 1, 1) self.gridLayout_5.addLayout(self.layout_virtual, 0, 0, 1, 1)
self.tab_menu.addTab(self.virtualgates, "") self.tab_menu.addTab(self.virtualgates, "")
self.RFsettings = QtWidgets.QWidget()
self.RFsettings.setObjectName("RFsettings")
self.layoutWidget = QtWidgets.QWidget(self.RFsettings)
self.layoutWidget.setGeometry(QtCore.QRect(10, 10, 761, 501))
self.layoutWidget.setObjectName("layoutWidget")
self.layout_RF = QtWidgets.QGridLayout(self.layoutWidget)
self.layout_RF.setContentsMargins(0, 0, 0, 0)
self.layout_RF.setObjectName("layout_RF")
self.tab_menu.addTab(self.RFsettings, "")
self.settings = QtWidgets.QWidget() self.settings = QtWidgets.QWidget()
self.settings.setObjectName("settings") self.settings.setObjectName("settings")
self.gridLayout_3 = QtWidgets.QGridLayout(self.settings) self.gridLayout_3 = QtWidgets.QGridLayout(self.settings)
...@@ -80,7 +87,7 @@ class Ui_MainWindow(object): ...@@ -80,7 +87,7 @@ class Ui_MainWindow(object):
self.gridLayout.addWidget(self.tab_menu, 0, 0, 1, 1) self.gridLayout.addWidget(self.tab_menu, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget) MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 20)) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar") self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar) MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar = QtWidgets.QStatusBar(MainWindow)
...@@ -96,16 +103,8 @@ class Ui_MainWindow(object): ...@@ -96,16 +103,8 @@ class Ui_MainWindow(object):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.tab_menu.setTabText(self.tab_menu.indexOf(self.realgates), _translate("MainWindow", "Normal gates")) self.tab_menu.setTabText(self.tab_menu.indexOf(self.realgates), _translate("MainWindow", "Normal gates"))
self.tab_menu.setTabText(self.tab_menu.indexOf(self.virtualgates), _translate("MainWindow", "Virtual Gates")) self.tab_menu.setTabText(self.tab_menu.indexOf(self.virtualgates), _translate("MainWindow", "Virtual Gates"))
self.tab_menu.setTabText(self.tab_menu.indexOf(self.RFsettings), _translate("MainWindow", "RF Settings"))
self.label.setText(_translate("MainWindow", "Voltage step")) self.label.setText(_translate("MainWindow", "Voltage step"))
self.label_2.setText(_translate("MainWindow", "mV")) self.label_2.setText(_translate("MainWindow", "mV"))
self.tab_menu.setTabText(self.tab_menu.indexOf(self.settings), _translate("MainWindow", "Settings")) self.tab_menu.setTabText(self.tab_menu.indexOf(self.settings), _translate("MainWindow", "Settings"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>758</width> <width>756</width>
<height>491</height> <height>495</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_6"> <layout class="QGridLayout" name="gridLayout_6">
...@@ -59,6 +59,22 @@ ...@@ -59,6 +59,22 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="RFsettings">
<attribute name="title">
<string>RF Settings</string>
</attribute>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>761</width>
<height>501</height>
</rect>
</property>
<layout class="QGridLayout" name="layout_RF"/>
</widget>
</widget>
<widget class="QWidget" name="settings"> <widget class="QWidget" name="settings">
<attribute name="title"> <attribute name="title">
<string>Settings</string> <string>Settings</string>
...@@ -154,7 +170,7 @@ ...@@ -154,7 +170,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>800</width>
<height>20</height> <height>21</height>
</rect> </rect>
</property> </property>
</widget> </widget>
......
from typing import List
from core_tools.GUI.virt_gate_matrix.virt_gate_matrix_window import Ui_MainWindow from core_tools.GUI.virt_gate_matrix.virt_gate_matrix_window import Ui_MainWindow
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
from functools import partial from functools import partial
...@@ -18,7 +19,7 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -18,7 +19,7 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow):
self.gates_object.hardware.AWG_to_dac_conversion = pulse_lib.AWG_to_dac_ratio self.gates_object.hardware.AWG_to_dac_conversion = pulse_lib.AWG_to_dac_ratio
# reassigning since python pointers do not really work in python :( (<3<3<3 c++) # reassigning since python pointers do not really work in python :( (<3<3<3 c++)
pulse_lib.AWG_to_dac_ratio = self.gates_object.hardware.AWG_to_dac_conversion pulse_lib.AWG_to_dac_ratio = self.gates_object.hardware.AWG_to_dac_conversion
# set graphical user interface # set graphical user interface
self.app = QtCore.QCoreApplication.instance() self.app = QtCore.QCoreApplication.instance()
if self.app is None: if self.app is None:
...@@ -31,7 +32,7 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -31,7 +32,7 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow):
for gate in pulse_lib.AWG_to_dac_ratio: for gate in pulse_lib.AWG_to_dac_ratio:
if gate not in pulse_lib.awg_markers: if gate not in pulse_lib.awg_markers:
self.add_gate(gate) self.add_gate(gate)
self.add_spacer() self.add_spacer()
...@@ -80,13 +81,13 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -80,13 +81,13 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow):
db_ratio.setValue(20*np.log10(self.pulse_lib.AWG_to_dac_ratio[gate_name])) db_ratio.setValue(20*np.log10(self.pulse_lib.AWG_to_dac_ratio[gate_name]))
db_ratio.valueChanged.connect(partial(self.update_db_ratio, gate_name)) db_ratio.valueChanged.connect(partial(self.update_db_ratio, gate_name))
self.verticalLayout_3.addWidget(db_ratio) self.verticalLayout_3.addWidget(db_ratio)
self.AWG_attentuation_local_data[gate_name] = (v_ratio, db_ratio) self.AWG_attentuation_local_data[gate_name] = (v_ratio, db_ratio)
def update_db_ratio(self, gate_name): def update_db_ratio(self, gate_name):
''' '''
On change of the db ratio, update the voltage ratio to the corresponding value + update in the virtual gate matrixes. On change of the db ratio, update the voltage ratio to the corresponding value + update in the virtual gate matrixes.
Args: Args:
gate_name (str) : name of the gate the is being updated gate_name (str) : name of the gate the is being updated
''' '''
...@@ -100,7 +101,7 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -100,7 +101,7 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow):
def update_v_ratio(self, gate_name): def update_v_ratio(self, gate_name):
''' '''
On change of the voltage ratio, update the db ratio to the corresponding value + update in the virtual gate matrixes. On change of the voltage ratio, update the db ratio to the corresponding value + update in the virtual gate matrixes.
Args: Args:
gate_name (str) : name of the gate the is being updated gate_name (str) : name of the gate the is being updated
''' '''
...@@ -156,19 +157,19 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -156,19 +157,19 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow):
tableWidget.setRowCount(len(virtual_gate_set)) tableWidget.setRowCount(len(virtual_gate_set))
for i in range(len(virtual_gate_set)): for i in range(len(virtual_gate_set)):
item = QtWidgets.QTableWidgetItem() item = QtWidgets.QTableWidgetItem()
tableWidget.setVerticalHeaderItem(i, item) tableWidget.setHorizontalHeaderItem(i, item)
item.setText(_translate("MainWindow", virtual_gate_set.real_gate_names[i])) item.setText(_translate("MainWindow", virtual_gate_set.real_gate_names[i]))
item = QtWidgets.QTableWidgetItem() item = QtWidgets.QTableWidgetItem()
tableWidget.setHorizontalHeaderItem(i, item) tableWidget.setVerticalHeaderItem(i, item)
item.setText(_translate("MainWindow", virtual_gate_set.virtual_gate_names[i])) item.setText(_translate("MainWindow", virtual_gate_set.virtual_gate_names[i]))
tableWidget.horizontalHeader().setDefaultSectionSize(65) tableWidget.horizontalHeader().setDefaultSectionSize(65)
tableWidget.horizontalHeader().setMaximumSectionSize(100) tableWidget.horizontalHeader().setMaximumSectionSize(100)
tableWidget.horizontalHeader().setMinimumSectionSize(30) tableWidget.horizontalHeader().setMinimumSectionSize(30)
tableWidget.verticalHeader().setDefaultSectionSize(37) tableWidget.verticalHeader().setDefaultSectionSize(37)
gridLayout.addWidget(tableWidget, 0, 0, 1, 1) gridLayout.addWidget(tableWidget, 0, 0, 1, 1)
update_list = [] update_list = []
for i in range(len(virtual_gate_set)): for i in range(len(virtual_gate_set)):
for j in range(len(virtual_gate_set)): for j in range(len(virtual_gate_set)):
...@@ -192,7 +193,7 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -192,7 +193,7 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow):
doubleSpinBox.setSingleStep(0.01) doubleSpinBox.setSingleStep(0.01)
doubleSpinBox.setDecimals(3) doubleSpinBox.setDecimals(3)
doubleSpinBox.setValue(virtual_gate_set.virtual_gate_matrix[i,j]) doubleSpinBox.setValue(virtual_gate_set.virtual_gate_matrix[i,j])
doubleSpinBox.setObjectName("doubleSpinBox") doubleSpinBox.setObjectName(f'doubleSpinBox-{i}-{j}')
doubleSpinBox.valueChanged.connect(partial(self.linked_result, virtual_gate_set.virtual_gate_matrix, i, j, doubleSpinBox)) doubleSpinBox.valueChanged.connect(partial(self.linked_result, virtual_gate_set.virtual_gate_matrix, i, j, doubleSpinBox))
update_list.append((i,j, doubleSpinBox)) update_list.append((i,j, doubleSpinBox))
tableWidget.setCellWidget(i, j, doubleSpinBox) tableWidget.setCellWidget(i, j, doubleSpinBox)
...@@ -207,15 +208,22 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow): ...@@ -207,15 +208,22 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow):
matrix[i,j] = spin_box.value() matrix[i,j] = spin_box.value()
self.gates_object.hardware.sync_data() self.gates_object.hardware.sync_data()
def update_v_gates(self, matrix, update_list): def update_v_gates(self, matrix : np.ndarray, update_list : List[QtWidgets.QDoubleSpinBox]):
for i,j, spin_box in update_list: """ Update the virtual gate matrix elements
spin_box.setValue(matrix[i,j])
Args:
matrix: Array with new values
update_list: List with GUI boxes
"""
for row, column, spin_box in update_list:
if not spin_box.hasFocus():
spin_box.setValue(matrix[row, column])
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys
from V2_software.pulse_lib_config.Init_pulse_lib_debug import return_pulse_lib from V2_software.pulse_lib_config.Init_pulse_lib_debug import return_pulse_lib
import qcodes as qc import qcodes as qc
from V2_software.drivers.virtual_gates.examples.hardware_example import hardware_example from V2_software.drivers.virtual_gates.examples.hardware_example import hardware_example
from V2_software.drivers.virtual_gates.instrument_drivers.virtual_dac import virtual_dac from V2_software.drivers.virtual_gates.instrument_drivers.virtual_dac import virtual_dac
from V2_software.drivers.virtual_gates.instrument_drivers.gates import gates from V2_software.drivers.virtual_gates.instrument_drivers.gates import gates
......
# -*- coding: utf-8 -*-
from dataclasses import dataclass from dataclasses import dataclass
import qcodes as qc import qcodes as qc
import numpy as np import numpy as np
...@@ -110,16 +111,32 @@ class harware_parent(qc.Instrument): ...@@ -110,16 +111,32 @@ class harware_parent(qc.Instrument):
self.sync = shelve.open(sample_name, flag='c', writeback=True) self.sync = shelve.open(sample_name, flag='c', writeback=True)
self.dac_gate_map = dict() self.dac_gate_map = dict()
self.boundaries = dict() self.boundaries = dict()
self.RF_source_names = []
self.RF_params = ['frequency_stepsize', 'frequency', 'power']
self._RF_settings = dict()
# set this one in the GUI. # set this one in the GUI.
self._AWG_to_dac_conversion = dict() self._AWG_to_dac_conversion = dict()
if 'AWG2DAC' in list(self.sync.keys()): if 'AWG2DAC' in list(self.sync.keys()):
self._AWG_to_dac_conversion = self.sync['AWG2DAC'] self._AWG_to_dac_conversion = self.sync['AWG2DAC']
self._virtual_gates = virtual_gates_mgr(self.sync) self._virtual_gates = virtual_gates_mgr(self.sync)
@property @property
def virtual_gates(self): def virtual_gates(self):
return self._virtual_gates return self._virtual_gates
@property
def RF_settings(self):
return self._RF_settings
@RF_settings.setter
def RF_settings(self, RF_settings):
if self._RF_settings.keys() == RF_settings.keys():
RF_settings = self._RF_settings
else:
self._RF_settings = RF_settings
@property @property
def AWG_to_dac_conversion(self): def AWG_to_dac_conversion(self):
return self._AWG_to_dac_conversion return self._AWG_to_dac_conversion
...@@ -131,15 +148,37 @@ class harware_parent(qc.Instrument): ...@@ -131,15 +148,37 @@ class harware_parent(qc.Instrument):
else: else:
self._AWG_to_dac_conversion = AWG_to_dac_ratio self._AWG_to_dac_conversion = AWG_to_dac_ratio
def setup_RF_settings(self, sources):
#TODO: If a module is added, the settings of the previous module are discarded
RF_generated, qc_params = self.gen_RF_settings(sources)
if 'RFsettings' in list(self.sync.keys()) and self.sync['RFsettings'].keys() == RF_generated.keys():
self.RF_settings = self.sync['RFsettings']
for (param,val) in zip(qc_params,self.RF_settings.values()):
param(val)
else:
self.RF_settings = self.gen_RF_settings(sources = sources)
def gen_RF_settings(self, sources):
RF_settings = dict()
qc_params = []
for src in sources:
name = src.name
self.RF_source_names.append(name)
for param in self.RF_params:
qc_param = getattr(src,param)
RF_settings[f'{name}_{param}'] = qc_param()
qc_params.append(qc_param)
return RF_settings,qc_params
def sync_data(self): def sync_data(self):
for item in self.virtual_gates: for item in self.virtual_gates:
self.sync[item.name] = item self.sync[item.name] = item
self.sync['AWG2DAC'] = self._AWG_to_dac_conversion self.sync['AWG2DAC'] = self._AWG_to_dac_conversion
self.sync['RFsettings'] = self._RF_settings
self.sync.sync() self.sync.sync()
def snapshot_base(self, update: bool=False, def snapshot_base(self, update: bool=False,
params_to_skip_update: Sequence[str]=None): params_to_skip_update: Sequence[str]=None):
vg_snap = {} vg_snap = {}
for vg in self.virtual_gates: for vg in self.virtual_gates:
vg_mat = np.reshape(np.frombuffer(vg.virtual_gate_matrix, dtype=float),np.shape(vg.virtual_gate_matrix)) vg_mat = np.reshape(np.frombuffer(vg.virtual_gate_matrix, dtype=float),np.shape(vg.virtual_gate_matrix))
......
...@@ -9,11 +9,11 @@ class data_mgr(): ...@@ -9,11 +9,11 @@ class data_mgr():
''' '''
self.filename_db = db_location + '.sqlite' self.filename_db = db_location + '.sqlite'
self.cal_object = cls_object
self.table_name = cls_object.__class__.__name__ self.table_name = cls_object.__class__.__name__
# self.set_param = cls_object.set_param self.__update_table()
# self.get_param = cls_object.get_param
def __connect(self): def __connect(self):
db = sqlite3.connect(self.filename_db) db = sqlite3.connect(self.filename_db)
cursor = db.cursor() cursor = db.cursor()
...@@ -48,45 +48,26 @@ class data_mgr(): ...@@ -48,45 +48,26 @@ class data_mgr():
db.close() db.close()
return mydata return mydata
def update_table(self): def __update_table(self):
''' '''
function that will construct if not already there the database where the data will be saved. function that will construct if not already there the database where the data will be saved.
Note that is is no problem running this when no update is strictly needed (e.g. when you start up the module) Note that is is no problem running this when no update is strictly needed (e.g. when you start up the module)
NOTE: that existing fields will not be updated. Use stash_table to rename it and create a new one if you want to do that. NOTE: that existing fields will not be updated. Use stash_table to rename it and create a new one if you want to do that.
''' '''
# Get data that needs to be saved. generate_table = "CREATE TABLE IF NOT EXISTS {} (\
base_colomns = [('Time_human_readable','TEXT', 'a.u.')] id data_type PRIMARY KEY,\
all_colls = base_colomns + self.calibration_params meas_time TEXT not NULL)".format(self.table_name)
self.__exec_command(generate_table)
# Connect to the database.
db, cursor = self.__connect()
# Check if table exists of data
cursor.execute("select count(*) from sqlite_master where type='table' and name='%s'"% self.table_name)
exists = True if cursor.fetchall()[0][0]==1 else False
if not exists:
cursor.execute('CREATE TABLE %s (time DOUBLE PRIMARY KEY)' %self.table_name)
cursor.execute('CREATE TABLE %s (varname TEXT, unit TEXT)' %(self.table_name + '_units'))
cursor.execute("INSERT INTO %s VALUES ('%s', '%s')" % (self.table_name + '_units', 'time', 's'))
# Get current columns in the data base: # Get current columns in the data base:
cursor.execute("PRAGMA table_info('%s')"%self.table_name) db_paramters = self.cal_object.set_vals.get_db_column_names() + self.cal_object.get_vals.get_db_column_names()
db_colomn_info = cursor.fetchall() db_column_info = self.__query_db("PRAGMA table_info('%s')"%self.table_name)
db_colomn_names= [i[1].lower() for i in db_colomn_info] db_column_names= [db_column_name[1].lower() for db_column_name in db_column_info]
# Check if all the wanted coloms are there (suppose users made up their mind about the datype they want to use...)
column_to_add = [param_name for param_name in db_paramters if param_name[0].lower() not in db_column_names]
columms_to_add = [i for i in all_colls if i[0].lower() not in db_colomn_names]
# Add missing colomn to table
for i in columms_to_add:
cursor.execute("ALTER TABLE %s ADD COLUMN '%s' %s" % (self.table_name, i[0], i[1]))
cursor.execute("INSERT INTO %s VALUES ('%s', '%s')" % (self.table_name + '_units', i[0], i[2]))
# commit changes for param in column_to_add:
db.commit() self.__exec_command("ALTER TABLE {} ADD COLUMN {} {}".format(self.table_name, param, 'DOUBLE'))
# Close conn
db.close()
def stash_table(self): def stash_table(self):
''' '''
...@@ -95,21 +76,13 @@ class data_mgr(): ...@@ -95,21 +76,13 @@ class data_mgr():
heck if the table has the right entries. heck if the table has the right entries.
''' '''
time = datetime.now().strftime("%Y_%m_%d__%H_%M_%S") time = datetime.now().strftime("%Y_%m_%d__%H_%M_%S")
db, cursor = self.__connect() self.__exec_command("ALTER TABLE %s RENAME TO %s"%(self.table_name, self.table_name + '_' + time))
cursor.execute("ALTER TABLE %s RENAME TO %s"%(self.table_name, self.table_name + '_' + time))
cursor.execute("ALTER TABLE %s RENAME TO %s"%(self.table_name+ '_units', self.table_name + '_units' + '_' + time))
db.commit()
db.close()
def delete_table(self): def delete_table(self):
''' '''
Delete the current table. Delete the current table.
''' '''
db, cursor = self.__connect() self.__exec_command("DROP TABLE %s"% self.table_name)
cursor.execute("DROP TABLE %s"% self.table_name)
cursor.execute("DROP TABLE %s"% (self.table_name + '_units'))
db.commit()
db.close()
def get_all_parameter_names(self): def get_all_parameter_names(self):
''' '''
...@@ -117,10 +90,10 @@ class data_mgr(): ...@@ -117,10 +90,10 @@ class data_mgr():
''' '''
db, cursor = self.__connect() db, cursor = self.__connect()
cursor.execute("PRAGMA table_info('%s')"%self.table_name) cursor.execute("PRAGMA table_info('%s')"%self.table_name)
db_colomn_info = cursor.fetchall() db_column_info = cursor.fetchall()
db_colomn_names= [i[1].lower() for i in db_colomn_info] db_column_names= [i[1].lower() for i in db_column_info]
db.close() db.close()
return db_colomn_names return db_column_names
def save_calib_results(self, data_tuple): def save_calib_results(self, data_tuple):
''' '''
...@@ -201,4 +174,18 @@ class data_mgr(): ...@@ -201,4 +174,18 @@ class data_mgr():
return list(self.__query_db(cmd)[0][1:]) return list(self.__query_db(cmd)[0][1:])
if __name__ == '__main__': if __name__ == '__main__':
d = data_mgr('test', 'test/')
\ No newline at end of file class value_mgr():
def __init__(self, *args):
self.vals = tuple(args)
def get_db_column_names(self):
return self.vals
class test_cal():
def __init__(self):
self.set_vals = value_mgr('frequency', 'amplitude')
self.get_vals = value_mgr('omega_qubit_1')
d = data_mgr(test_cal(), 'test/my_test_db')
print(d.get_all_parameter_names())
\ No newline at end of file
...@@ -160,10 +160,28 @@ if __name__ == '__main__': ...@@ -160,10 +160,28 @@ if __name__ == '__main__':
def set_raw(self, val): def set_raw(self, val):
self._count = val self._count = val
class dummy_multi_parameter_2dawg(qc.MultiParameter):
def __init__(self, name, label=None, unit=None):
super().__init__(name=name,
instrument=None,
names=("test12","test1234"),
shapes=( tuple() , tuple() ),
labels=( "digitzer_response", "D2"),
units=("unit1", "unit2"), )
self.setpoints = ( tuple(), tuple())
self.setpoint_shapes = ( tuple(), tuple())
self.setpoint_labels = ( ("I channel", ), ('Q channel', ))
self.setpoint_units = ( ("mV", ), ("mV", ))
self.setpoint_names = ( ("I_channel", ), ("Q_channel", ))
self.i = 2
def get_raw(self):
self.i +=1
return (self.i, self.i+100)
now = str(datetime.datetime.now()) now = str(datetime.datetime.now())
tutorial_db_path = os.path.join(os.getcwd(), 'linking_datasets_tutorial.db') path = os.path.join(os.getcwd(), 'test.db')
initialise_or_create_database_at(tutorial_db_path) initialise_or_create_database_at(path)
load_or_create_experiment('tutorial ' + now, 'no sample') load_or_create_experiment('tutorial ' + now, 'no sample')
my_param = MyCounter('test_instr') my_param = MyCounter('test_instr')
from qcodes.instrument.specialized_parameters import ElapsedTimeParameter from qcodes.instrument.specialized_parameters import ElapsedTimeParameter
...@@ -173,7 +191,13 @@ if __name__ == '__main__': ...@@ -173,7 +191,13 @@ if __name__ == '__main__':
y = qc.Parameter(name='y', label='Voltage_y', unit='V', y = qc.Parameter(name='y', label='Voltage_y', unit='V',
set_cmd=None, get_cmd=None) set_cmd=None, get_cmd=None)
timer = ElapsedTimeParameter('time') timer = ElapsedTimeParameter('time')
# do0D(my_param).run() my_param_multi_test =dummy_multi_parameter_2dawg('param')
from core_tools.GUI.keysight_videomaps.data_getter.scan_generator_Virtual import construct_1D_scan_fast,construct_2D_scan_fast, fake_digitizer
param_1D = construct_1D_scan_fast("P2", 10,10,5000, True, None, fake_digitizer('test'))
param_2D = construct_2D_scan_fast('P2', 10, 10, 'P5', 10, 10,50000, True, None, fake_digitizer('test'))
data_1D = param_1D.get()
do0D(param_2D).run()
# do1D(x, 0, 100, 50, 0.1 , my_param, reset_param=True).run() # do1D(x, 0, 100, 50, 0.1 , my_param, reset_param=True).run()
do2D(x, 0, 20, 20, 0.0, y, 0, 80, 30, 0.01, my_param).run() # do2D(x, 0, 20, 20, 0.0, y, 0, 80, 30, 0.01, my_param).run()
do2D(x, 0, 20, 20, 0.0, timer, 0, 80, 30, 0.1, my_param).run() # do2D(x, 0, 20, 20, 0.0, timer, 0, 80, 30, 0.1, my_param).run()
\ No newline at end of file \ No newline at end of file
from sample_specific.station import init_station from sample_specific.station import init_station
from sample_specific.station.load_pulse_lib import return_pulse_lib from sample_specific.station.load_pulse_lib import return_pulse_lib
import logging
station = init_station() station = init_station()
pulse = return_pulse_lib(station.hardware, station.AWG1, station.AWG2, station.AWG3) pulse = return_pulse_lib(station.hardware, station.AWG1, station.AWG2, station.AWG3)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment