def set_sweep_with_calibration(self, repetition=False, plot_average=False, **kw): self.plot_average = plot_average for i in range(self.qubit_number): d = i if i == 1 else 2 self.plot.append( QtPlot(window_title='raw plotting qubit_%d' % d, remote=False)) # self.plot.append(MatPlot(figsize = (8,5))) if plot_average: # self.average_plot.append(QtPlot(window_title = 'average data qubit_%d'%d, remote = False)) self.average_plot.append(MatPlot(figsize=(8, 5))) for seq in range(len(self.sequencer)): self.sequencer[seq].set_sweep() self.make_all_segment_list(seq) if repetition is True: count = kw.pop('count', 1) Count_Calibration = StandardParameter(name='Count', set_cmd=self.function) Sweep_Count_Calibration = Count_Calibration[1:2:1] Count = StandardParameter(name='Count', set_cmd=self.delete) Sweep_Count = Count[1:count + 1:1] self.digitizer, self.dig = set_digitizer(self.digitizer, len(self.X_sweep_array), self.qubit_number, self.seq_repetition) loop1 = Loop(sweep_values=Sweep_Count_Calibration).each(self.dig) Loop_Calibration = loop1.with_bg_task( bg_final_task=self.update_calibration, ) calibrated_parameter = update_calibration if self.Loop is None: self.Loop = Loop(sweep_values=Sweep_Count).each( calibrated_parameter, self.dig) else: raise TypeError('calibration not set') return True
def _do_measurement(loop: Loop, set_params: tuple, meas_params: tuple, do_plots: Optional[bool]=True, use_threads: bool=True) -> Tuple[QtPlot, DataSet]: """ The function to handle all the auxiliary magic of the T10 users, e.g. their plotting specifications, the device image annotation etc. The input loop should just be a loop ready to run and perform the desired measurement. The two params tuple are used for plotting. Args: loop: The QCoDeS loop object describing the actual measurement set_params: tuple of tuples. Each tuple is of the form (param, start, stop) meas_params: tuple of parameters to measure do_plots: Whether to do a live plot use_threads: Whether to use threads to parallelise simultaneous measurements. If only one thing is being measured at the time in loop, this does nothing. Returns: (plot, data) """ try: parameters = [sp[0] for sp in set_params] + list(meas_params) _flush_buffers(*parameters) # startranges for _plot_setup try: startranges = {} for sp in set_params: minval = min(sp[1], sp[2]) maxval = max(sp[1], sp[2]) startranges[sp[0].full_name] = {'max': maxval, 'min': minval} except Exception: startranges = None interrupted = False data = loop.get_data_set() if do_plots: try: plot, _ = _plot_setup(data, meas_params, startranges=startranges) except (ClosedError, ConnectionError): log.warning('Remote process crashed png will not be saved') else: plot = None try: if do_plots: _ = loop.with_bg_task(plot.update).run(use_threads=use_threads) else: _ = loop.run(use_threads=use_threads) except KeyboardInterrupt: interrupted = True print("Measurement Interrupted") if do_plots: # Ensure the correct scaling before saving try: plot.autorange() plot.save() except (ClosedError, ConnectionError): log.warning('Remote process crashed png will not be saved') if 'pdf_subfolder' in CURRENT_EXPERIMENT or 'png_subfolder' in CURRENT_EXPERIMENT: _do_MatPlot(data,meas_params) if CURRENT_EXPERIMENT.get('device_image'): log.debug('Saving device image') save_device_image(tuple(sp[0] for sp in set_params)) # add the measurement ID to the logfile with open(CURRENT_EXPERIMENT['logfile'], 'a') as fid: print("#[QCoDeS]# Saved dataset to: {}".format(data.location), file=fid) if interrupted: raise KeyboardInterrupt except: log.exception("Exception in doND") raise return plot, data
def _do_measurement(loop: Loop, set_params: tuple, meas_params: tuple, do_plots: bool = True, use_threads: bool = True) -> Tuple[QtPlot, DataSet]: """ The function to handle all the auxiliary magic of the T10 users, e.g. their plotting specifications, the device image annotation etc. The input loop should just be a loop ready to run and perform the desired measurement. The two params tuple are used for plotting. Args: loop: The QCoDeS loop object describing the actual measurement set_params: tuple of tuples. Each tuple is of the form (param, start, stop) meas_params: tuple of parameters to measure do_plots: Whether to do a live plot use_threads: Whether to use threads to parallelise simultaneous measurements. If only one thing is being measured at the time in loop, this does nothing. Returns: (plot, data) """ try: parameters = [sp[0] for sp in set_params] + list(meas_params) _flush_buffers(*parameters) # startranges for _plot_setup startranges = {} for sp in set_params: minval = min(sp[1], sp[2]) maxval = max(sp[1], sp[2]) startranges[sp[0].full_name] = {'max': maxval, 'min': minval} interrupted = False data = loop.get_data_set() if do_plots: try: plot, _ = _plot_setup(data, meas_params, startranges=startranges) except (ClosedError, ConnectionError): log.warning('Remote process crashed png will not be saved') else: plot = None try: if do_plots: _ = loop.with_bg_task(plot.update).run(use_threads=use_threads) else: _ = loop.run(use_threads=use_threads) except KeyboardInterrupt: interrupted = True print("Measurement Interrupted") if do_plots: # Ensure the correct scaling before saving try: plot.autorange() plot.save() except (ClosedError, ConnectionError): log.warning('Remote process crashed png will not be saved') plt.ioff() pdfplot, num_subplots = _plot_setup(data, meas_params, useQT=False) # pad a bit more to prevent overlap between # suptitle and title pdfplot.rescale_axis() pdfplot.fig.tight_layout(pad=3) title_list = plot.get_default_title().split(sep) title_list.insert(-1, CURRENT_EXPERIMENT['pdf_subfolder']) title = sep.join(title_list) pdfplot.save("{}.pdf".format(title)) if pdfdisplay['combined'] or (num_subplots == 1 and pdfdisplay['individual']): pdfplot.fig.canvas.draw() plt.show() else: plt.close(pdfplot.fig) if num_subplots > 1: _save_individual_plots(data, meas_params, pdfdisplay['individual']) plt.ion() if CURRENT_EXPERIMENT.get('device_image'): log.debug('Saving device image') save_device_image(tuple(sp[0] for sp in set_params)) # add the measurement ID to the logfile with open(CURRENT_EXPERIMENT['logfile'], 'a') as fid: print("#[QCoDeS]# Saved dataset to: {}".format(data.location), file=fid) if interrupted: raise KeyboardInterrupt except: log.exception("Exception in doND") raise return plot, data
def _do_measurement(loop: Loop, set_params: tuple, meas_params: tuple, do_plots: Optional[bool]=True, use_threads: bool=True, auto_color_scale: Optional[bool]=None, cutoff_percentile: Optional[Union[Tuple[Number, Number], Number]]=None) -> Tuple[QtPlot, DataSet]: """ The function to handle all the auxiliary magic of the T10 users, e.g. their plotting specifications, the device image annotation etc. The input loop should just be a loop ready to run and perform the desired measurement. The two params tuple are used for plotting. Args: loop: The QCoDeS loop object describing the actual measurement set_params: tuple of tuples. Each tuple is of the form (param, start, stop) meas_params: tuple of parameters to measure do_plots: Whether to do a live plot use_threads: Whether to use threads to parallelise simultaneous measurements. If only one thing is being measured at the time in loop, this does nothing. auto_color_scale: if True, the colorscale of heatmap plots will be automatically adjusted to disregard outliers. cutoff_percentile: percentile of data that may maximally be clipped on both sides of the distribution. If given a tuple (a,b) the percentile limits will be a and 100-b. See also the plotting tuorial notebook. Returns: (plot, data) """ try: parameters = [sp[0] for sp in set_params] + list(meas_params) _flush_buffers(*parameters) # startranges for _plot_setup try: startranges = {} for sp in set_params: minval = min(sp[1], sp[2]) maxval = max(sp[1], sp[2]) startranges[sp[0].full_name] = {'max': maxval, 'min': minval} except Exception: startranges = None interrupted = False data = loop.get_data_set() if do_plots: try: plot, _ = _plot_setup(data, meas_params, startranges=startranges, auto_color_scale=auto_color_scale, cutoff_percentile=cutoff_percentile) except (ClosedError, ConnectionError): log.warning('Remote process crashed png will not be saved') # if remote process crashed continue without plots do_plots = False else: plot = None try: if do_plots: _ = loop.with_bg_task(plot.update).run(use_threads=use_threads) else: _ = loop.run(use_threads=use_threads) except KeyboardInterrupt: interrupted = True print("Measurement Interrupted") if do_plots: # Ensure the correct scaling before saving try: plot.autorange() plot.save() except (ClosedError, ConnectionError): log.warning('Remote process crashed png will not be saved') # if remote process crashed continue without plots do_plots = False if 'pdf_subfolder' in CURRENT_EXPERIMENT or 'png_subfolder' in CURRENT_EXPERIMENT: _do_MatPlot(data,meas_params, auto_color_scale=auto_color_scale, cutoff_percentile=cutoff_percentile) if CURRENT_EXPERIMENT.get('device_image'): log.debug('Saving device image') save_device_image(tuple(sp[0] for sp in set_params)) log.info("#[QCoDeS]# Saved dataset to: {}".format(data.location)) if interrupted: raise KeyboardInterrupt except: log.exception("Exception in doND") raise return plot, data
def _do_measurement(loop: Loop, set_params: tuple, meas_params: tuple, do_plots: Optional[bool]=True) -> Tuple[QtPlot, DataSet]: """ The function to handle all the auxiliary magic of the T10 users, e.g. their plotting specifications, the device image annotation etc. The input loop should just be a loop ready to run and perform the desired measurement. The two params tuple are used for plotting. Args: loop: The QCoDeS loop object describing the actual measurement set_params: tuple of tuples. Each tuple is of the form (param, start, stop) meas_params: tuple of parameters to measure Returns: (plot, data) """ parameters = [sp[0] for sp in set_params] + list(meas_params) _flush_buffers(*parameters) # startranges for _plot_setup startranges = dict(zip((sp[0].label for sp in set_params), ((sp[1], sp[2]) for sp in set_params))) interrupted = False data = loop.get_data_set() if do_plots: plot, _ = _plot_setup(data, meas_params, startranges=startranges) else: plot = None try: if do_plots: _ = loop.with_bg_task(plot.update).run() else: _ = loop.run() except KeyboardInterrupt: interrupted = True print("Measurement Interrupted") if do_plots: # Ensure the correct scaling before saving for subplot in plot.subplots: vBox = subplot.getViewBox() vBox.enableAutoRange(vBox.XYAxes) cmap = None # resize histogram for trace in plot.traces: if 'plot_object' in trace.keys(): if (isinstance(trace['plot_object'], dict) and 'hist' in trace['plot_object'].keys()): cmap = trace['plot_object']['cmap'] max = trace['config']['z'].max() min = trace['config']['z'].min() trace['plot_object']['hist'].setLevels(min, max) trace['plot_object']['hist'].vb.autoRange() if cmap: plot.set_cmap(cmap) # set window back to original size plot.win.resize(1000, 600) plot.save() pdfplot, num_subplots = _plot_setup(data, meas_params, useQT=False) # pad a bit more to prevent overlap between # suptitle and title pdfplot.fig.tight_layout(pad=3) pdfplot.save("{}.pdf".format(plot.get_default_title())) pdfplot.fig.canvas.draw() if num_subplots > 1: _save_individual_plots(data, meas_params) if CURRENT_EXPERIMENT.get('device_image'): log.debug('Saving device image') save_device_image(tuple(sp[0] for sp in set_params)) # add the measurement ID to the logfile with open(CURRENT_EXPERIMENT['logfile'], 'a') as fid: print("#[QCoDeS]# Saved dataset to: {}".format(data.location), file=fid) if interrupted: raise KeyboardInterrupt return plot, data