def load_virtual_gate_matrix_from_snapshot(snapshot, hardware_name, no_norm=False): ''' load virtual gate matrix from a existing datasset. Args: snapshot (dict) : snapshot of the station (loaded JSON) hardware_name (str) : name of hardware in the snapshot present in the dataset ''' virtual_gates = snapshot['station']['instruments'][hardware_name]['virtual_gates'] print('Loading virtual gates matrices from dataset:') for key, value in virtual_gates.items(): if no_norm: try: matrix = value['virtual_gate_matrix_no_norm'].replace('\n', '').replace('[', '').replace(']', '') except: print('no old style matrix found, trying new style') matrix = value['virtual_gate_matrix'] else: matrix = value['virtual_gate_matrix'] matrix.replace('\n', '').replace('[', '').replace(']', '') mat = np.loadtxt(StringIO(matrix), delimiter=',') mat = mat.reshape([int(np.sqrt(mat.size)), int(np.sqrt(mat.size))]) vg = virtual_gate_matrix(key, value['real_gate_names'], value['virtual_gate_names'], mat) vg.save() h = hardware() h.virtual_gates.add(vg.name, vg.gates, vg.v_gates) print(f'\tfound virtual gate matrix named ::\t{key} ({mat.shape[0]}x{mat.shape[1]})')
def load_AWG_to_dac_conversion_from_snapshot(snapshot, hardware_name): hardware_info = snapshot['station']['instruments'][hardware_name] if 'AWG_to_DAC' in hardware_info.keys(): AWG_to_DAC = hardware_info['AWG_to_DAC'] elif 'awg2dac_ratios' in hardware_info.keys(): AWG_to_DAC = hardware_info['awg2dac_ratios'] else: raise ValueError('AWG to DAC conversio not found!') h = hardware() h.awg2dac_ratios.add(AWG_to_DAC.keys()) for gate, value in AWG_to_DAC.items(): h.awg2dac_ratios[gate] = value print('AWG to dac conversions loaded!')
def __init__(self): super().__init__() # self.app = QtGui.QGuiApplication(sys.argv) self.app = QtCore.QCoreApplication.instance() self.instance_ready = True if self.app is None: self.instance_ready = False self.app = QtWidgets.QApplication([]) hw = hardware() self.engine = QtQml.QQmlApplicationEngine() self.attenuation_model = attenuation_model(hw.awg2dac_ratios) self.engine.rootContext().setContextProperty("attenuation_model", self.attenuation_model) if len(hw.virtual_gates) > 0: self.row_header_model = table_header_model( hw.virtual_gates[0].gates) self.column_header_model = table_header_model( hw.virtual_gates[0].v_gates) self.vg_matrix_model = vg_matrix_model(hw.virtual_gates[0]) self.engine.rootContext().setContextProperty( 'row_header_model', self.row_header_model) self.engine.rootContext().setContextProperty( 'column_header_model', self.column_header_model) self.engine.rootContext().setContextProperty( 'vg_matrix_model', self.vg_matrix_model) # grab directory from the import! filename = os.path.join(qml_in.__file__[:-12], "virt_gate_matrix_gui.qml") self.engine.load(QtCore.QUrl.fromLocalFile(filename)) self.win = self.engine.rootObjects()[0] timer = QtCore.QTimer() timer.timeout.connect(lambda: None) timer.start(100) if self.instance_ready == False: self.app.exec_() print('exec')
self._set_voltage(names[i], voltages[i]) if __name__ == '__main__': from core_tools.drivers.virtual_dac import virtual_dac from core_tools.drivers.hardware.hardware import hardware my_dac_1 = virtual_dac("dac_a", "virtual") my_dac_2 = virtual_dac("dac_b", "virtual") my_dac_3 = virtual_dac("dac_c", "virtual") my_dac_4 = virtual_dac("dac_d", "virtual") from core_tools.data.SQL.connect import set_up_local_storage, set_up_remote_storage, set_up_local_and_remote_storage set_up_local_storage('stephan', 'magicc', 'test', 'test_project1', 'test_set_up', 'test_sample') hw = hardware() hw.dac_gate_map = { # dacs for creating the quantum dots -- syntax, "gate name": (dac module number, dac index) 'B0': (0, 1), 'P1': (0, 2), 'B1': (0, 3), 'P2': (0, 4), 'B2': (0, 5), 'P3': (0, 6), 'B3': (0, 7), 'P4': (0, 8), 'B4': (0, 9), 'P5': (0, 10), 'B5': (0, 11), 'P6': (0, 12),
def __init__(self, virtual_gate_name: Union[str, int] = 0): """ Args: virtual_gate_name: Name or index of virtual gate to display """ super().__init__() # self.app = QtGui.QGuiApplication(sys.argv) self.app = QtCore.QCoreApplication.instance() self.instance_ready = True if self.app is None: self.instance_ready = False self.app = QtWidgets.QApplication([]) hw = hardware() self.engine = QtQml.QQmlApplicationEngine() self.attenuation_model = attenuation_model(hw.awg2dac_ratios) self.engine.rootContext().setContextProperty("attenuation_model", self.attenuation_model) if isinstance(virtual_gate_name, int): self.virtual_gate_index = virtual_gate_name else: self.virtual_gate_index = ( hw.virtual_gates.virtual_gate_names).index(virtual_gate_name) if len(hw.virtual_gates) > self.virtual_gate_index: hw = hardware() vg = hw.virtual_gates[self.virtual_gate_index] logging.info( f'creating objects for index {self.virtual_gate_index}') self.vg_matrix_model = vg_matrix_model(vg) self.vg_matrix_model._manipulate_callback = self.set_table_headers self.gates_header_model = table_header_model(vg.gates) self.vgates_header_model = table_header_model(vg.v_gates) root_context = self.engine.rootContext() root_context.setContextProperty('virt_gate_matrix_GUI', self) root_context.setContextProperty('vg_matrix_model', self.vg_matrix_model) root_context.setContextProperty('row_header_model', self.gates_header_model) root_context.setContextProperty('column_header_model', self.vgates_header_model) else: print('virtual gate name {virtual_gate_name} could not be found') # grab directory from the import! filename = os.path.join(qml_in.__file__[:-12], "virt_gate_matrix_gui.qml") logging.info(f'loading qml from {filename}') self.engine.load(QtCore.QUrl.fromLocalFile(filename)) self.win = self.engine.rootObjects()[0] self._mat_inv_switch = self.engine.rootObjects()[0].findChild( QtCore.QObject, "mat_inv_switch") self.set_table_headers() timer = QtCore.QTimer() timer.timeout.connect(lambda: None) timer.start(100) if self.instance_ready == False: self.app.exec_() print('exec')
else: root_context.setContextProperty('row_header_model', self.vgates_header_model) root_context.setContextProperty('column_header_model', self.gates_header_model) if __name__ == "__main__": import numpy as np from core_tools.data.SQL.connect import set_up_local_storage, set_up_remote_storage, set_up_local_and_remote_storage from core_tools.drivers.hardware.hardware import hardware set_up_local_storage('stephan', 'magicc', 'test', 'test_project1', 'test_set_up', 'test_sample') h = hardware() h.dac_gate_map = { # dacs for creating the quantum dots -- syntax, "gate name": (dac module number, dac index) 'B0': (0, 1), 'P1': (0, 2), 'B1': (0, 3), 'P2': (0, 4), 'B2': (0, 5), 'P3': (0, 6), 'B3': (0, 7), 'P4': (0, 8), 'B4': (0, 9), 'P5': (0, 10), 'B5': (0, 11), 'P6': (0, 12), 'B6': (0, 13)