def save_changes(self): name = self.name if name in self.loops: # Create a task that checks if loop stop has been request on each measure point of the loop task = Task(self.parent.check_stop_request) # grab data for creating a loop from elements of the widget try: lower = float(self.textbox_lower_limit.text()) upper = float(self.textbox_upper_limit.text()) num = float(self.textbox_num.text()) delay = float(self.textbox_step.text()) sweep_division = float(self.sweep_parameter_divider.text()) except Exception as e: warning_string = "Errm, looks like something went wrong ! \nHINT: Measurement parameters not set. \n" \ + str(e) show_error_message("Warning", warning_string) else: # Create dividres and add them to a dict of dividers (shared with main window) sweep_parameter = self.sweep_parameter_cb.currentData() if sweep_division != 1: full_name = str(sweep_parameter) sweep_parameter = VoltageDivider(sweep_parameter, sweep_division) self.dividers[full_name] = sweep_parameter # create a list and fill it with actions created by user (dividers if they are attached) actions = [] for i in range(len(self.current_loop_actions_dictionary)): action_array = self.current_loop_actions_dictionary[ "action" + str(i)] if action_array is not None: action_parameter = action_array[1].currentData() try: division = float(action_array[2].text()) except Exception as e: show_error_message("Warning", str(e)) else: if division != 1: action_parameter = VoltageDivider( action_parameter, division) actions.append(action_parameter) # append a task that checks for loop stop request actions.append(task) self.loops[name].sweep_values = sweep_parameter.sweep(lower, upper, num=num) self.loops[name].delay = delay self.loops[name].actions = list(actions) self.parent.update_loops_preview(edit=name) else: show_error_message( "Warning", "The loop does not exist. \nNew loop will be created") self.name = "" self.create_loop() self.close()
def __init__(self, name, address, config, **kwargs): super().__init__(name, address, **kwargs) # same as in decadac but without fine mode config_file = config.get('QDAC') for channelNum, channnel in enumerate(self.channels): config_settings = config_file[str(channelNum)].split(",") name = config_settings[0] label = config_settings[1] unit = config_settings[2] divisor = float(config_settings[3]) step = float(config_settings[4]) delay = float(config_settings[5]) rangemin = float(config_settings[6]) rangemax = float(config_settings[7]) param = channel.volt param.label = label param.unit = unit param.set_validator(vals.Numbers(rangemin, rangemax)) if divisor != 1.: # maybe we want a different label setattr(self, name, VoltageDivider(param, divisor, label=label)) param.division_value = divisor param._meta_attrs.extend(["division_value"]) else: setattr(self,name, param)
def __init__(self, name, address, config, **kwargs): super().__init__(name, address, **kwargs) # Define the named channels topo_channel = int( config.get('Channel Parameters', 'topo bias channel')) topo_channel = self.parameters['ch{:02}_v'.format(topo_channel)] self.add_parameter( 'current_bias', label='{} conductance'.format(self.name), # use lambda for late binding get_cmd=lambda: self.parameters['ch40_v'].get() / 10E6 * 1E9, set_cmd=lambda value: self.parameters['ch40_v'].set(value * 1E-9 * 10E6), unit='nA', get_parser=float) # sens_r_channel = int(config.get('Channel Parameters', # 'right sensor bias channel')) # sens_r_channel = self.parameters['ch{:02}_v'.format(sens_r_channel)] # sens_l_channel = int(config.get('Channel Parameters', # 'left sensor bias channel')) # sens_l_channel = self.parameters['ch{:02}_v'.format(sens_l_channel)] self.topo_bias = VoltageDivider( topo_channel, float(config.get('Gain settings', 'dc factor topo')))
def test_scan1D(self, verbose=0): p = Parameter('p', set_cmd=None) q = Parameter('q', set_cmd=None) r = VoltageDivider(p, 4) _ = MultiParameter(instrumentName('multi_param'), [p, q]) gates = VirtualIVVI( name=qtt.measurements.scans.instrumentName('gates'), model=None) station = qcodes.Station(gates) station.gates = gates if verbose: print('test_scan1D: running scan1D') scanjob = scanjob_t({'sweepdata': dict( {'param': p, 'start': 0, 'end': 10, 'step': 2, 'wait_time': 0.}), 'minstrument': [r]}) _ = scan1D(station, scanjob, liveplotwindow=False, verbose=0) scanjob = scanjob_t({'sweepdata': dict( {'param': p, 'start': 0, 'end': 10, 'step': 2, 'wait_time': 0.}), 'minstrument': [q, r]}) _ = scan1D(station, scanjob, liveplotwindow=False, verbose=0) scanjob = scanjob_t({'sweepdata': dict( {'param': 'dac1', 'start': 0, 'end': 10, 'step': 2}), 'minstrument': [r]}) _ = scan1D(station, scanjob, liveplotwindow=False, verbose=0) scanjob = scanjob_t({'sweepdata': dict( {'param': {'dac1': 1}, 'start': 0, 'range': 10, 'step': 2}), 'minstrument': [r]}) data = scan1D(station, scanjob, liveplotwindow=False, verbose=0, extra_metadata={'hi': 'world'}) self.assertTrue('hi' in data.metadata) gates.close()
def attach_divider(self): """ Instantiates a VoltageDivider with specified data (only if division_value_textbox is not equal to 1, in case of it being 1 there is no need for a voltage divider, therefor its not added. Additionaly it adds the newly created divider to a dictionary (dividers) shared with mainWindow parameter: parameter that is gonna get a divider attched to it obtained from the parameter_cb combobox division value: if you dont know what this is, consider other professions obtained from division_value_textbox :return: NoneType """ # fetch the selected parameter from the combo box parameter = self.parameter_cb.currentData() # fetch the division value from the text box if self.division_value_textbox.text() != "1": try: # try to cast division value to float division = float(self.division_value_textbox.text()) except Exception as e: show_error_message("Warning", str(e)) else: # if no exception was raised, create a new divider vd = VoltageDivider(parameter, division) self.dividers[str(parameter)] = vd self.close()
def __init__(self, name, address, config, **kwargs): super().__init__(name, address, **kwargs) # Define the named channels topo_channel = int( config.get('Channel Parameters', 'topo bias channel')) topo_channel = self.channels[topo_channel - 1].v # topo_current_num = int(config.get('Channel Parameters', # 'topo current channel')) # topo_current = self.channels[topo_current_num-1].v # self.add_parameter('current_bias', # label='{} {} conductance'.format(self.name, topo_current_num), # # use lambda for late binding # get_cmd=lambda: topo_current.get()/10E6*1E9, # set_cmd=lambda value: topo_current.set(value*1E-9*10E6), # unit='nA', # get_parser=float) #sens_r_channel = int(config.get('Channel Parameters', # 'right sensor bias channel')) #sens_r_channel = self.channels[sens_r_channel-1].v #sens_l_channel = int(config.get('Channel Parameters', # 'left sensor bias channel')) #sens_l_channel = self.channels[sens_l_channel-1].v self.topo_bias = VoltageDivider( topo_channel, float(config.get('Gain settings', 'dc factor topo')))
def test_scan1D_no_gates(self): p = Parameter('p', set_cmd=None) r = VoltageDivider(p, 4) scanjob = scanjob_t({'sweepdata': {'param': p, 'start': 0, 'end': 10, 'step': 2}, 'minstrument': [r]}) station=qcodes.Station() dataset = scan1D(station, scanjob, liveplotwindow=False, verbose=0) default_record_label = 'scan1D' self.assertTrue(default_record_label in dataset.location)
def __init__(self, name, address, config, **kwargs): self.config = config deca_physical_min = -10 deca_physical_max = 10 kwargs.update({'min_val': deca_physical_min, 'max_val': deca_physical_max}) super().__init__(name, address, **kwargs) ''' config file redesigned to have all channels for overview. Indices in config_settings[] for each channel are: 0: Channels name for deca.{} 1: Channel label 2: Channels unit (included as we are using decadac to control the magnet) 3: Voltage division factor 4: step size 5: delay 6: max value 7: min value 8: Fine or coarse mode channel ''' for channelNum, settings in config.get('Decadac').items(): channel = self.channels[ int(channelNum) ] config_settings = settings.split(',') name = config_settings[0] label = config_settings[1] unit = config_settings[2] divisor = float(config_settings[3]) step = float(config_settings[4]) delay = float(config_settings[5]) rangemin = float(config_settings[6]) rangemax = float(config_settings[7]) fine_mode = config_settings[8] if fine_mode == 'fine': param = channel.fine_volt elif fine_mode == 'coarse': param = channel.volt else: raise RuntimeError('Invalid config file. Need to specify \'fine\' or \'coarse\' not {}'.format(fine_mode)) channel.volt.set_step(step) channel.volt.set_delay(delay) param.label = label param.unit = unit param.set_validator(vals.Numbers(rangemin, rangemax)) if divisor != 1.: # maybe we want a different label setattr(self, name, VoltageDivider(param, divisor, label=label)) param.division_value = divisor param._meta_attrs.extend(["division_value"]) else: setattr(self,name, param)
def test_scanjob_record_label(self): p = Parameter('p', set_cmd=None) r = VoltageDivider(p, 4) record_label='123unittest123' scanjob = scanjob_t({'sweepdata': dict( {'param': p, 'start': 0, 'end': 10, 'step': 2, 'wait_time': 0.}), 'minstrument': [r]}) scanjob['dataset_label']=record_label station=qcodes.Station() dataset = scan1D(station, scanjob, liveplotwindow=False, verbose=0) self.assertTrue(dataset.location.endswith(record_label))
def test_scan2D(verbose=0): p = Parameter('p', set_cmd=None) q = Parameter('q', set_cmd=None) r = VoltageDivider(p, 4) _ = MultiParameter(instrumentName('multi_param'), [p, q]) gates = VirtualIVVI( name=qtt.measurements.scans.instrumentName('gates'), model=None) station = qcodes.Station(gates) station.gates = gates if verbose: print('test_scan2D: running scan2D') scanjob = scanjob_t({'sweepdata': dict( {'param': p, 'start': 0, 'end': 10, 'step': 2}), 'minstrument': [r]}) scanjob['stepdata'] = dict( {'param': q, 'start': 24, 'end': 30, 'step': 1.}) _ = scan2D(station, scanjob, liveplotwindow=False, verbose=0) scanjob = scanjob_t({'sweepdata': dict({'param': { 'dac1': 1, 'dac2': .1}, 'start': 0, 'range': 10, 'step': 2}), 'minstrument': [r]}) scanjob['stepdata'] = dict( {'param': {'dac2': 1}, 'start': 24, 'range': 6, 'end': np.NaN, 'step': 1.}) _ = scan2D(station, scanjob, liveplotwindow=False, verbose=0) scanjob = scanjob_t({'sweepdata': dict( {'param': {'dac1': 1}, 'start': 0, 'range': 10, 'step': 2}), 'minstrument': [r]}) scanjob['stepdata'] = {'param': MultiParameter('multi_param', [gates.dac2, gates.dac3])} scanjob['stepvalues'] = np.array([[2 * i, 3 * i] for i in range(10)]) try: with warnings.catch_warnings(): warnings.simplefilter('ignore') data = scan2D(station, scanjob, liveplotwindow=False, verbose=0) except Exception as ex: print(ex) warnings.warn('MultiParameter test failed!') # not supported: try: scanjob = scanjob_t({'sweepdata': dict({'param': { 'dac1': 1}, 'start': 0, 'range': 10, 'step': 2, 'wait_time': 0.}), 'minstrument': [r]}) scanjob['stepdata'] = dict( {'param': q, 'start': 24, 'range': 6, 'end': np.NaN, 'step': 1.}) _ = scan2D(station, scanjob, liveplotwindow=False, verbose=0) except Exception as ex: if verbose: print('combination of Parameter and vector argument not supported') gates.close()
def test_convert_scanjob_vec_scan2Dfast(self): p = Parameter('p', set_cmd=None) q = Parameter('q', set_cmd=None) r = VoltageDivider(p, 4) _ = MultiParameter(instrumentName('multi_param'), [p, q]) gates = VirtualIVVI( name=qtt.measurements.scans.instrumentName('gates'), model=None) station = qcodes.Station(gates) station.gates = gates scanjob = scanjob_t({ 'scantype': 'scan2Dfast', 'sweepdata': dict({ 'param': p, 'start': 0, 'end': 10, 'step': 4 }), 'minstrument': [r] }) scanjob['stepdata'] = dict({ 'param': q, 'start': 24, 'end': 32, 'step': 1. }) stepvalues, sweepvalues = scanjob._convert_scanjob_vec(station, 3, 5) actual_stepvalues = list(stepvalues) expected_stepvalues = [24.0, 28.0, 32.0] self.assertEqual(expected_stepvalues, actual_stepvalues) self.assertEqual(len(actual_stepvalues), 3) actual_sweepvalues = list(sweepvalues) expected_sweepvalues = [0, 2.5, 5.0, 7.5, 10.0] self.assertEqual(expected_sweepvalues, actual_sweepvalues) self.assertEqual(len(actual_sweepvalues), 5) gates.close()
def __init__(self, name, address, config, **kwargs): super().__init__(name, address, **kwargs) # same as in decadac but without fine mode for attribute, settings in config.get(name).items(): try: channel = getattr(self, attribute) except AttributeError as e: raise AttributeError(e.message + 'config file implementation has changed:\n'+ '\'1 = ... -> chan02 = ...\' make sure to'+ ' increment the channel number!') config_settings = settings.split(',') name = config_settings[0] label = config_settings[1] unit = config_settings[2] divisor = float(config_settings[3]) # step = float(config_settings[4]) # delay = float(config_settings[5]) rangemin = float(config_settings[6]) rangemax = float(config_settings[7]) param = channel.v param.label = label param.unit = unit param.set_validator(vals.Numbers(rangemin, rangemax)) if divisor != 1.: # maybe we want a different label setattr(self, name, VoltageDivider( param, divisor, label=label)) param.division_value = divisor param._meta_attrs.extend(["division_value"]) else: setattr(self, name, param)
def reload_Decadac_settings(): """ Function to update the decadac based on the configuration file """ configs = Config.default configs.reload() station = qc.Station.default deca = station['Decadac'] # Update voltage and ramp safetly limits in software ranges = configs.get('Decadac Channel Limits') ramp_settings = configs.get('Decadac Channel Ramp Setttings') for chan in range(20): try: chan_range = ranges[str(chan)] except KeyError: continue range_minmax = chan_range.split(" ") if len(range_minmax) != 2: raise ValueError("Expected: min max. Got {}".format(chan_range)) else: rangemin = float(range_minmax[0]) rangemax = float(range_minmax[1]) vldtr = Numbers(rangemin, rangemax) deca.channels[chan].volt.set_validator(vldtr) try: chan_ramp_settings = ramp_settings[str(chan)] except KeyError: continue ramp_stepdelay = chan_ramp_settings.split(" ") if len(ramp_stepdelay) != 2: raise ValueError( "Expected: step delay. Got {}".format(chan_ramp_settings)) else: step = float(ramp_stepdelay[0]) delay = float(ramp_stepdelay[1]) deca.channels[chan].volt.set_step(step) deca.channels[chan].volt.set_delay(delay) # Update the channels' labels labels = configs.get('Decadac Channel Labels') for chan, label in labels.items(): deca.channels[int(chan)].volt.label = label # Update variable names to channel number mapping lcut = configs.get('Channel Parameters', 'left cutter') deca.lcut = deca.channels[int(lcut)].volt rcut = configs.get('Channel Parameters', 'right cutter') deca.rcut = deca.channels[int(rcut)].volt jj = configs.get('Channel Parameters', 'central cutter') deca.jj = deca.channels[int(jj)].volt rplg = configs.get('Channel Parameters', 'right plunger') deca.rplg = deca.channels[int(rplg)].volt lplg = configs.get('Channel Parameters', 'left plunger') deca.lplg = deca.channels[int(lplg)].volt # Update voltage divider of source drain dcbias_i = int(configs.get('Channel Parameters', 'source channel')) dcbias = deca.channels[dcbias_i].volt deca.dcbias = VoltageDivider(dcbias, float(configs.get('Gain Settings', 'dc factor'))) deca.dcbias.label = configs.get('Decadac Channel Labels', dcbias_i)
def create_loop(self): """ Creates a new loop from data input by user. Adds newly created loop to "loops" dictionary in MainWindow. Creates action to be executed upon running qcodes and adds it to "actions" list in MainWindow :return: NoneType """ if self.name != "": self.save_changes() else: # otherwise create a new loop and save it to the loops dictionary # Try to fetch user input data and cast it to floats # If it fails, throw an exception # Otherwise, create a loop, add it to the shared dict # Create a task that checks if loop stop has been request on each measure point of the loop task = Task(self.parent.check_stop_request) # grab data for creating a loop from elements of the widget try: lower = float(self.textbox_lower_limit.text()) upper = float(self.textbox_upper_limit.text()) num = float(self.textbox_num.text()) delay = float(self.textbox_step.text()) sweep_division = float(self.sweep_parameter_divider.text()) except Exception as e: warning_string = "Errm, looks like something went wrong ! \nHINT: Measurement parameters not set. \n"\ + str(e) show_error_message("Warning", warning_string) else: # Create dividres and add them to a dict of dividers (shared with main window) sweep_parameter = self.sweep_parameter_cb.currentData() if sweep_division != 1: full_name = str(sweep_parameter) sweep_parameter = VoltageDivider(sweep_parameter, sweep_division) self.dividers[full_name] = sweep_parameter # create a list and fill it with actions created by user (dividers if they are attached) actions = [] for i in range(len(self.current_loop_actions_dictionary)): action_array = self.current_loop_actions_dictionary[ "action" + str(i)] if action_array is not None: action_parameter = action_array[1].currentData() try: division = float(action_array[2].text()) except Exception as e: show_error_message("Warning", str(e)) else: if division != 1: action_parameter = VoltageDivider( action_parameter, division) actions.append(action_parameter) # append a task that checks for loop stop request actions.append(task) # pass dereferenced list of actions to a loops each method if len(self.instruments): lp = qc.Loop(sweep_parameter.sweep(lower, upper, num=num), delay, progress_interval=20).each(*actions) else: show_error_message( "Warning", "U can't make a loop without instruments !") return name = "loop" + str(len(self.parent.shown_loops) + 1) self.loops[name] = lp self.actions.append(lp) self.parent.update_loops_preview() """# if a loop name has been passed to this widget then overwrite that loop in the loops dictionary