def plot_phases(mod_freqs, phases, title='', ax=None, **kw): if ax == None: f, ax = plt.subplots() ax.set_title(title) ax.plot(mod_freqs, phases, marker='.') # , c=mod_freqs, cmap=plt.cm.Blues) set_xlabel(ax, 'Modulation frequency', 'Hz') set_ylabel(ax, 'Phase', 'deg')
def render_wave_PSD(self, wave_id, show=True, reload_pulses=True, f_bounds=None, y_bounds=None): if wave_id not in self.LutMap().keys(): wave_id = get_wf_idx_from_name(wave_id, self.LutMap()) if reload_pulses: self.generate_standard_waveforms() fig, ax = plt.subplots(1, 1) f_axis, PSD_I = PSD(self._wave_dict[wave_id][0], 1 / self.sampling_rate()) f_axis, PSD_Q = PSD(self._wave_dict[wave_id][1], 1 / self.sampling_rate()) ax.plot(f_axis, PSD_I, marker=",", label="chI") ax.plot(f_axis, PSD_Q, marker=",", label="chQ") ax.legend() ax.set_yscale("log", nonposy="clip") if y_bounds is not None: ax.set_ylim(y_bounds[0], y_bounds[1]) if f_bounds is not None: ax.set_xlim(f_bounds[0], f_bounds[1]) set_xlabel(ax, "Frequency", "Hz") set_ylabel(ax, "Spectral density", "V^2/Hz") if show: plt.show() return fig, ax
def plot_populations(time, P0, P1, P2, ax, xlabel='Time', xunit='s', ylabel='Population', yunit='', title='', **kw): ax.plot(time, P0, c='C0', linestyle='', label=r'P($|g\rangle$)', marker='v') ax.plot(time, P1, c='C1', linestyle='', label=r'P($|e\rangle$)', marker='^') ax.plot(time, P2, c='C2', linestyle='', label=r'P($|f\rangle$)', marker='d') set_xlabel(ax, xlabel, xunit) set_ylabel(ax, ylabel) ax.legend() ax.set_ylim(-.05, 1.05) ax.set_title(title)
def render_wave_PSD(self, wave_name, show=True, reload_pulses=True, f_bounds=None, y_bounds=None): if reload_pulses: self.generate_standard_waveforms() fig, ax = plt.subplots(1, 1) f_axis, PSD_I = PSD(self._wave_dict[wave_name][0], 1 / self.sampling_rate()) f_axis, PSD_Q = PSD(self._wave_dict[wave_name][1], 1 / self.sampling_rate()) ax.set_title(wave_name) ax.plot(f_axis, PSD_I, marker=',', label='chI') ax.plot(f_axis, PSD_Q, marker=',', label='chQ') ax.legend() ax.set_yscale("log", nonposy='clip') if y_bounds is not None: ax.set_ylim(y_bounds[0], y_bounds[1]) if f_bounds is not None: ax.set_xlim(f_bounds[0], f_bounds[1]) set_xlabel(ax, 'Frequency', 'Hz') set_ylabel(ax, 'Spectral density', 'V^2/Hz') if show: plt.show() return fig, ax
def make_phase_plot(t, phase, phase_err, title, ylim=None, ax=None, **kw): if ax is None: f, ax = plt.subplots() ax.errorbar(t, phase, phase_err, marker='.') ax.set_title(title) set_xlabel(ax, 'Gate separtion', 's') set_ylabel(ax, 'Phase', 'deg') mean_phase_tail = np.nanmean(phase[10:]) ax.axhline(mean_phase_tail, ls='-', c='grey', linewidth=.5) ax.axhline(mean_phase_tail + 10, ls=':', c='grey', label=r'$\pm$10 deg', linewidth=0.5) ax.axhline(mean_phase_tail - 10, ls=':', c='grey', linewidth=0.5) ax.axhline(mean_phase_tail + 5, ls='--', c='grey', label=r'$\pm$5 deg', linewidth=0.5) ax.axhline(mean_phase_tail - 5, ls='--', c='grey', linewidth=0.5) ax.legend() if ylim is None: ax.set_ylim(mean_phase_tail - 60, mean_phase_tail + 40) else: ax.set_ylim(ylim[0], ylim[1])
def plot_ffts(self, ax=None, title='', nyquist_unwrap=False, **kw): if ax is None: ax = plt.gca() if nyquist_unwrap: raise NotImplementedError ax.set_title(title) ffts = np.fft.fft(self.norm_data) freqs = np.arange(len(ffts[0])) * self.sampling_rate / len(ffts[0]) flex_colormesh_plot_vs_xy(xvals=np.array(self.amps), yvals=freqs, zvals=np.abs(ffts).T, ax=ax) ax.scatter(self.filt_amps, self.filt_freqs % self.sampling_rate, color="C1", facecolors='none', label='Dominant freqs.') ax.scatter(self.excl_amps, self.excl_freqs % self.sampling_rate, color="C3", marker='x') aa = np.linspace(min(self.amps), max(self.amps), 300) ax.plot(aa, np.polyval(self.poly_fit, aa) % self.sampling_rate, "r", label='fit') set_xlabel(ax, "Amplitude", 'V') # a.u. set_ylabel(ax, 'Detuning', 'Hz') ax.legend()
def plot_chevron_FFT(x, xunit, fft_freqs, fft_data, freq_fits, freq_fits_std, fit_res, coupling_msg, title, ax, **kw): colormap = ax.pcolormesh( x, fft_freqs, fft_data, cmap='viridis', # norm=norm, linewidth=0, rasterized=True, vmin=0, vmax=5) ax.errorbar(x=x, y=freq_fits, yerr=freq_fits_std, ls='--', c='r', alpha=.5, label='Extracted freqs') x_fine = np.linspace(x[0], x[-1], 200) plot_fit(x, fit_res, ax=ax, c='C1', label='Avoided crossing fit', ls=':') set_xlabel(ax, 'Flux bias', xunit) set_ylabel(ax, 'Frequency', 'Hz') ax.legend(loc=(1.05, .7)) ax.text(1.05, 0.5, coupling_msg, transform=ax.transAxes)
def make_phase_plot(t, phase, phase_err, title, ylim=None, ax=None, **kw): if ax is None: f, ax = plt.subplots() ax.errorbar(t, phase, phase_err, marker='.') ax.set_title(title) set_xlabel(ax, 'Gate separtion', 's') set_ylabel(ax, 'Phase', 'deg') mean_phase_tail = np.nanmean(phase[10:]) ax.axhline(mean_phase_tail, ls='-', c='grey', linewidth=.5) ax.axhline(mean_phase_tail+10, ls=':', c='grey', label=r'$\pm$10 deg', linewidth=0.5) ax.axhline(mean_phase_tail-10, ls=':', c='grey', linewidth=0.5) ax.axhline(mean_phase_tail+5, ls='--', c='grey', label=r'$\pm$5 deg', linewidth=0.5) ax.axhline(mean_phase_tail-5, ls='--', c='grey', linewidth=0.5) ax.legend() if ylim is None: try: ax.set_ylim(np.min([mean_phase_tail-60, np.min(phase)]), np.max([mean_phase_tail+40, np.max(phase)])) except ValueError: logging.warning("could not automatically determine axis limits.") # This happens if there is less than 10 measurements and the # "mean_phase_tail" is np.nan else: ax.set_ylim(ylim[0], ylim[1])
def plot_time_tuples_split(time_tuples, ax=None, time_unit='s', mw_duration=20e-9, fl_duration=240e-9, ro_duration=1e-6, split_op: str = 'meas', align_op: str = 'cw'): ttuple_groups = split_time_tuples_on_operation(time_tuples, split_op=split_op) corr_ttuple_groups = [ substract_time_offset(tt, op_str=align_op) for tt in ttuple_groups ] for i, corr_tt in enumerate(corr_ttuple_groups): if ax is None: f, ax = plt.subplots() plot_time_tuples(corr_tt, ax=ax, time_unit=time_unit, mw_duration=mw_duration, fl_duration=fl_duration, ro_duration=ro_duration, ypos=i) ax.invert_yaxis() set_ylabel(ax, "Kernel idx", "#") return ax
def plot_detuning(self, ax=None, title="Detuning from demodulation frequency", **kw): if ax is None: ax = plt.gca() ax.set_title(title) ax.plot(self.time, self.detuning, ".-", color="C0") set_xlabel(ax, 'Time', 's') set_ylabel(ax, 'Frequency', 'Hz')
def plot_amplitude(self, ax=None, title='Cryoscope amplitude', nyquists=None, style=".-", **kw): if ax is None: ax = plt.gca() ax.set_title(title) amp = self.get_amplitudes() ax.plot(self.time, amp, style) set_xlabel(ax, 'Time', 's') set_ylabel(ax, 'Amplitude', 'V')
def render_wave(self, wave_name, show=True, time_units='lut_index', reload_pulses=True): """ Renders a waveform """ if reload_pulses: self.generate_standard_waveforms() fig, ax = plt.subplots(1, 1) if time_units == 'lut_index': x = np.arange(len(self._wave_dict[wave_name][0])) ax.set_xlabel('Lookuptable index (i)') if self._voltage_min is not None: ax.vlines(2048, self._voltage_min, self._voltage_max, linestyle='--') elif time_units == 's': x = (np.arange(len(self._wave_dict[wave_name][0])) / self.sampling_rate.get()) if self._voltage_min is not None: ax.vlines(2048 / self.sampling_rate.get(), self._voltage_min, self._voltage_max, linestyle='--') ax.set_title(wave_name) if len(self._wave_dict[wave_name]) == 2: ax.plot(x, self._wave_dict[wave_name][0], marker='.', label='chI') ax.plot(x, self._wave_dict[wave_name][1], marker='.', label='chQ') elif len(self._wave_dict[wave_name]) == 4: ax.plot(x, self._wave_dict[wave_name][0], marker='.', label='chGI') ax.plot(x, self._wave_dict[wave_name][1], marker='.', label='chGQ') ax.plot(x, self._wave_dict[wave_name][2], marker='.', label='chDI') ax.plot(x, self._wave_dict[wave_name][3], marker='.', label='chDQ') else: raise ValueError("waveform shape not understood") ax.legend() if self._voltage_min is not None: ax.set_facecolor('gray') ax.axhspan(self._voltage_min, self._voltage_max, facecolor='w', linewidth=0) ax.set_ylim(self._voltage_min * 1.1, self._voltage_max * 1.1) ax.set_xlim(0, x[-1]) if time_units == 's': set_xlabel(ax, 'time', 's') set_ylabel(ax, 'Amplitude', 'V') if show: plt.show() return fig, ax
def plot_raw_data(self, ax=None, title="Raw cryoscope data", style=".-", **kw): if ax is None: ax = plt.gca() ax.set_title(title) ax.plot(self.time, self.data.real, style, label="Re", color="C0") ax.plot(self.time, self.data.imag, style, label="Im", color="C1") ax.legend() set_xlabel(ax, 'Time', 's') set_ylabel(ax, "Amplitude", 'a.u.')
def plot_phase(self, ax=None, title="Cryoscope demodulated phase", wrap=False, **kw): if ax is None: ax = plt.gca() ax.set_title(title) if wrap: ax.plot(self.time, self.phase % (2 * np.pi), ".", color="C0") else: ax.plot(self.time, self.phase, ".", label="Im", color="C0") set_xlabel(ax, 'Time', 's') set_ylabel(ax, 'Phase', 'deg')
def plot_raw_RB_curve(ncl, SI, SX, V0, V1, V2, title, ax, xlabel, xunit, ylabel, yunit, **kw): ax.plot(ncl, SI, label='SI', marker='o') ax.plot(ncl, SX, label='SX', marker='o') ax.plot(ncl[-1] + .5, V0, label='V0', marker='d', c='C0') ax.plot(ncl[-1] + 1.5, V1, label='V1', marker='d', c='C1') ax.plot(ncl[-1] + 2.5, V2, label='V2', marker='d', c='C2') ax.set_title(title) set_xlabel(ax, xlabel, xunit) set_ylabel(ax, ylabel, yunit) ax.legend()
def plot_time_tuples(time_tuples, ax=None, time_unit='s', mw_duration=20e-9, fl_duration=240e-9, ro_duration=1e-6, ypos=None): if ax is None: f, ax = plt.subplots() mw_patch = mpatches.Patch(color='C0', label='Microwave') fl_patch = mpatches.Patch(color='C1', label='Flux') ro_patch = mpatches.Patch(color='C4', label='Measurement') if time_unit == 's': clock_cycle = 20e-9 elif time_unit == 'clocks': clock_cycle = 1 else: raise ValueError() for i, tt in enumerate(time_tuples): t_start, cw, targets, linenum = tt if 'meas' in cw: c = 'C4' width = ro_duration elif isinstance((list(targets)[0]), tuple): # Flux pulses c = 'C1' width = fl_duration else: # Microwave pulses c = 'C0' width = mw_duration if 'prepz' not in cw: for q in targets: if isinstance(q, tuple): for qi in q: ypos_i = qi if ypos is None else ypos ax.barh(ypos_i, width=width, left=t_start*clock_cycle, height=0.6, align='center', color=c, alpha=.8) else: # N.B. alpha is not 1 so that overlapping operations are easily # spotted. ypos_i = q if ypos is None else ypos ax.barh(ypos_i, width=width, left=t_start*clock_cycle, height=0.6, align='center', color=c, alpha=.8) ax.legend(handles=[mw_patch, fl_patch, ro_patch], loc=(1.05, 0.5)) set_xlabel(ax, 'Time', time_unit) set_ylabel(ax, 'Qubit', '#') ax.yaxis.set_major_locator(MaxNLocator(integer=True)) return ax
def plot_transferfunc(mod_freqs, transfunc, title='', ax=None, plot_kw={}, **kw): if ax == None: f, ax = plt.subplots() ax.set_title(title) ax.plot(mod_freqs, transfunc, marker='.', **plot_kw) set_xlabel(ax, 'Modulation frequency', 'Hz') set_ylabel(ax, 'h($\omega$)', 'a.u.')
def plot_phase_circle(mod_freqs, data, title='', ax=None, **kw): if ax == None: f, ax = plt.subplots() ax.set_title(title) ax.scatter(np.real(data), np.imag(data), c=mod_freqs, cmap=plt.cm.Blues, marker='.') # ax.plot(mod_freqs, data_Q, label='Q', marker='.') set_xlabel(ax, 'real', '') set_ylabel(ax, 'imag', '') ax.set_aspect('equal')
def plot_flux_arc(self, ax=None, show=True, plot_cz_trajectory=False): """ Plots the flux arc as used in the lutman based on the polynomial coefficients """ if ax is None: f, ax = plt.subplots() amps = np.linspace(-2.5, 2.5, 101) # maximum voltage of AWG amp mode deltas = self.amp_to_detuning(amps) freqs = self.cz_freq_01_max()-deltas ax.plot(amps, freqs, label='$f_{01}$') ax.axhline(self.cz_freq_interaction(), -5, 5, label='$f_{\mathrm{int.}}$:'+' {:.3f} GHz'.format( self.cz_freq_interaction()*1e-9), c='C1') ax.axvline(0, 0, 1e10, linestyle='dotted', c='grey') ax.fill_between( x=[-5, 5], y1=[self.cz_freq_interaction()-self.cz_J2()]*2, y2=[self.cz_freq_interaction()+self.cz_J2()]*2, label='$J_{\mathrm{2}}/2\pi$:'+' {:.3f} MHz'.format( self.cz_J2()*1e-6), color='C1', alpha=0.25) title = ('Calibration visualization\n{}\nchannel {}'.format( self.AWG(), self.cfg_awg_channel())) if plot_cz_trajectory: self.plot_cz_trajectory(ax=ax, show=False) leg = ax.legend(title=title, loc=(1.05, .7)) leg._legend_box.align = 'center' set_xlabel(ax, 'AWG amplitude', 'V') set_ylabel(ax, 'Frequency', 'Hz') ax.set_xlim(-2.5, 2.5) ax.set_ylim(3e9, np.max(freqs)+500e6) dac_val_axis = ax.twiny() dac_ax_lims = np.array(ax.get_xlim()) * \ self.get_amp_to_dac_val_scale_factor() dac_val_axis.set_xlim(dac_ax_lims) set_xlabel(dac_val_axis, 'AWG amplitude', 'dac') dac_val_axis.axvspan(1, 1000, facecolor='.5', alpha=0.5) dac_val_axis.axvspan(-1000, -1, facecolor='.5', alpha=0.5) f.subplots_adjust(right=.7) if show: plt.show() return ax
def make_zoomed_cryoscope_fig(t, amp, title, ax=None, **kw): # x = ca.time x = t y = amp # y = ca.get_amplitudes() gc = np.mean(y[len(y)//5:4*len(y)//5]) if ax is not None: ax = ax f = plt.gcf() else: f, ax = plt.subplots() ax.plot(x, y/gc, label='Signal') ax.axhline(1.01, ls='--', c='grey', label=r'$\pm$1%') ax.axhline(0.99, ls='--', c='grey') ax.axhline(1.0, ls='-', c='grey', linewidth=.5) ax.axhline(1.001, ls=':', c='grey', label=r'$\pm$ 0.1%') ax.axhline(0.999, ls=':', c='grey') # ax.axvline(10e-9, ls='--', c='k') ax.set_ylim(.95, 1.02) set_xlabel(ax, 'Time', 's') set_ylabel(ax, 'Normalized Amplitude', '') # Create a set of inset Axes: these should fill the bounding box allocated to # them. ax2 = plt.axes([0, 0, 1, 1]) # Manually set the position and relative size of the inset axes within ax1 ip = InsetPosition(ax, [.29, .14, 0.65, .4]) ax2.set_axes_locator(ip) mark_inset(ax, ax2, 1, 3, color='grey') ax2.axhline(1.0, ls='-', c='grey', linewidth=.5) ax2.axhline(1.01, ls='--', c='grey', label=r'$\pm$1%') ax2.axhline(0.99, ls='--', c='grey') ax2.axhline(1.001, ls=':', c='grey', label=r'$\pm$ 0.1%') ax2.axhline(0.999, ls=':', c='grey') ax2.plot(x, y/gc, '-') formatter = ticker.FuncFormatter(lambda x, pos: round(x*1e9, 3)) ax2.xaxis.set_major_formatter(formatter) ax2.set_ylim(0.998, 1.002) ax2.set_xlim(0, min(150e-9, max(t))) ax.legend(loc=1) ax.set_title(title) ax.text(.02, .93, '(a)', color='black', transform=ax.transAxes)
def plot_result(y, dx, title='', ax=None, mode='half', xlabel='', xunit='', ylabel='', yunit='', **kw): if ax == None: f, ax = plt.subplots() ax.set_title(title) _plot_series(ax=ax, y=y, dx=dx, mode=mode) set_xlabel(ax, xlabel, xunit) set_ylabel(ax, ylabel, yunit)
def plot_frequency(self, ax=None, title='Detuning frequency', nyquists=None, style=".-", show_demod_freq=True, **kw): if ax is None: ax = plt.gca() ax.set_title(title) if nyquists is None: nyquists = [self.nyquist_order] for n in nyquists: if show_demod_freq: ax.axhline(-self.demod_freq + self.sampling_rate * n, linestyle='--', c='grey') real_detuning = self.get_real_detuning(n) ax.plot(self.time, real_detuning, style) set_xlabel(ax, 'Time', 's') set_ylabel(ax, 'Frequency', 'Hz')
def plot_freqs(self, ax=None, title='', **kw): if ax is None: ax = plt.gca() ax.set_title(title) amps_sorted = [x for x, _ in sorted( zip(self.filt_amps, self.filt_freqs))] freqs_sorted = [y for _, y in sorted( zip(self.filt_amps, self.filt_freqs))] ax.plot(amps_sorted, freqs_sorted, ".-") ax.scatter(self.excl_amps, self.excl_freqs, marker='x', color='C3') aa = np.linspace(min(self.amps), max(self.amps), 50) ax.plot(aa, np.polyval(self.poly_fit, aa), label='fit') set_xlabel(ax, "Amplitude", 'V') set_ylabel(ax, 'Detuning', 'Hz')
def test_label_scaling(self): """ This test creates a dummy plot and checks if the tick labels are rescaled correctly """ f, ax = plt.subplots() x = np.linspace(-6, 6, 101) y = np.cos(x) ax.plot(x * 1000, y / 1e5) set_xlabel(ax, 'Distance', 'm') set_ylabel(ax, 'Amplitude', 'V') xlab = ax.get_xlabel() ylab = ax.get_ylabel() self.assertEqual(xlab, 'Distance (km)') self.assertEqual(ylab, 'Amplitude (μV)')
def plot_chevron(x, y, Z, xlabel, xunit, ylabel, yunit, zlabel, zunit, title, ax, **kw): colormap = ax.pcolormesh(x, y, Z, cmap='viridis', # norm=norm, linewidth=0, rasterized=True, # assumes digitized readout vmin=0, vmax=1) set_xlabel(ax, xlabel, xunit) set_ylabel(ax, ylabel, yunit) ax.set_title(title) ax_divider = make_axes_locatable(ax) cax = ax_divider.append_axes('right', size='5%', pad='2%') cbar = plt.colorbar(colormap, cax=cax, orientation='vertical') cax.set_ylabel('L1 (%)') set_ylabel(cax, zlabel, zunit)
def make_amp_err_plot(t, amp, timestamp, ax=None, **kw): if ax is None: f, ax = plt.subplots() mean_amp = np.nanmean(amp[len(amp)//2]) ax.plot(t, amp/mean_amp, marker='.') ax.axhline(1.001, ls='--', c='grey', label=r'$\pm$0.1%') ax.axhline(0.999, ls='--', c='grey') ax.axhline(1.0, ls='-', c='grey', linewidth=.5) ax.axhline(1.0001, ls=':', c='grey', label=r'$\pm$ 0.01%') ax.axhline(0.9999, ls=':', c='grey') ax.legend(loc=(1.05, 0.5)) ax.set_title('Normalized to {:.2f}\n {}'.format(mean_amp, timestamp)) set_xlabel(ax, 'Time', 's') set_ylabel(ax, 'Normalized Amplitude')
def plot_cal_points_hexbin(shots_0, shots_1, shots_2, xlabel: str, xunit: str, ylabel: str, yunit: str, title: str, ax, common_clims: bool = True, **kw): # Choose colormap alpha_cmaps = [] for cmap in [pl.cm.Blues, pl.cm.Reds, pl.cm.Greens]: my_cmap = cmap(np.arange(cmap.N)) my_cmap[:, -1] = np.linspace(0, 1, cmap.N) my_cmap = ListedColormap(my_cmap) alpha_cmaps.append(my_cmap) f = plt.gcf() hb2 = ax.hexbin(x=shots_2[0], y=shots_2[1], cmap=alpha_cmaps[2]) cb = f.colorbar(hb2, ax=ax) cb.set_label(r'Counts $|2\rangle$') hb1 = ax.hexbin(x=shots_1[0], y=shots_1[1], cmap=alpha_cmaps[1]) cb = f.colorbar(hb1, ax=ax) cb.set_label(r'Counts $|1\rangle$') hb0 = ax.hexbin(x=shots_0[0], y=shots_0[1], cmap=alpha_cmaps[0]) cb = f.colorbar(hb0, ax=ax) cb.set_label(r'Counts $|0\rangle$') if common_clims: clims = hb0.get_clim(), hb1.get_clim(), hb2.get_clim() clim = np.min(clims), np.max(clims) for hb in hb0, hb1, hb2: hb.set_clim(clim) set_xlabel(ax, xlabel, xunit) set_ylabel(ax, ylabel, yunit) ax.set_title(title)
def plot_2D_ssro_histogram(xvals, yvals, zvals, xlabel, xunit, ylabel, yunit, zlabel, zunit, xlim=None, ylim=None, title='', cmap='viridis', cbarwidth='10%', cbarpad='5%', no_label=False, ax=None, cax=None, **kw): if ax is None: f, ax = plt.subplots() if not no_label: ax.set_title(title) # Plotting the "heatmap" out = flex_colormesh_plot_vs_xy(xvals, yvals, zvals, ax=ax, plot_cbar=True, cmap=cmap) # Adding the colorbar if cax is None: ax.ax_divider = make_axes_locatable(ax) ax.cax = ax.ax_divider.append_axes( 'right', size=cbarwidth, pad=cbarpad) else: ax.cax = cax ax.cbar = plt.colorbar(out['cmap'], cax=ax.cax) # Setting axis limits aspect ratios and labels ax.set_aspect(1) set_xlabel(ax, xlabel, xunit) set_ylabel(ax, ylabel, yunit) set_cbarlabel(ax.cbar, zlabel, zunit) if xlim is None: xlim = np.min([xvals, yvals]), np.max([xvals, yvals]) ax.set_xlim(xlim) if ylim is None: ylim = np.min([xvals, yvals]), np.max([xvals, yvals]) ax.set_ylim(ylim)
def plot_cz_trajectory(self, axs=None, show=True, which_gate="NE"): """ Plots the cz trajectory in frequency space. """ q_J2 = self.get("q_J2_%s" % which_gate) if axs is None: f, axs = plt.subplots(figsize=(5, 7), nrows=3, sharex=True) dac_amps = self._wave_dict["cz_%s" % which_gate] t = np.arange(0, len(dac_amps)) * 1 / self.sampling_rate() CZ_amp = dac_amps * self.get_dac_val_to_amp_scalefactor() CZ_eps = self.calc_amp_to_eps(CZ_amp, "11", "02", which_gate=which_gate) CZ_theta = wfl.eps_to_theta(CZ_eps, q_J2) axs[0].plot(t, np.rad2deg(CZ_theta), marker=".") axs[0].fill_between(t, np.rad2deg(CZ_theta), color="C0", alpha=0.5) set_ylabel(axs[0], r"$\theta$", "deg") axs[1].plot(t, CZ_eps, marker=".") axs[1].fill_between(t, CZ_eps, color="C0", alpha=0.5) set_ylabel(axs[1], r"$\epsilon_{11-02}$", "Hz") axs[2].plot(t, CZ_amp, marker=".") axs[2].fill_between(t, CZ_amp, color="C0", alpha=0.1) set_xlabel(axs[2], "Time", "s") set_ylabel(axs[2], r"Amp.", "V") # axs[2].set_ylim(-1, 1) axs[2].axhline(0, lw=0.2, color="grey") CZ_amp_pred = self.distort_waveform(CZ_amp)[:len(CZ_amp)] axs[2].plot(t, CZ_amp_pred, marker=".") axs[2].fill_between(t, CZ_amp_pred, color="C1", alpha=0.3) if show: plt.show() return axs
def run_full_analysis(self, normalize=False, plot_linecuts=True, linecut_log=False, colorplot_log=False, plot_all=True, save_fig=True, transpose=False, figsize=None, filtered=False, subtract_mean_x=False, subtract_mean_y=False, **kw): ''' Args: linecut_log (bool): log scale for the line cut? Remember to set the labels correctly. colorplot_log (string/bool): True/False for z axis scaling, or any string containing any combination of letters x, y, z for scaling of the according axis. Remember to set the labels correctly. ''' close_file = kw.pop('close_file', True) self.fig_array = [] self.ax_array = [] for i, meas_vals in enumerate(self.measured_values[:1]): if filtered: # print(self.measured_values) # print(self.value_names) if self.value_names[i] == 'Phase': self.measured_values[ i] = dm_tools.filter_resonator_visibility( x=self.sweep_points, y=self.sweep_points_2D, z=self.measured_values[i], **kw) if (not plot_all) & (i >= 1): break # Linecuts are above because somehow normalization applies to both # colorplot and linecuts otherwise. if plot_linecuts: fig, ax = plt.subplots(figsize=figsize) self.fig_array.append(fig) self.ax_array.append(ax) savename = 'linecut_{}'.format(self.value_names[i]) fig_title = '{} {} \nlinecut {}'.format( self.timestamp_string, self.measurementstring, self.value_names[i]) a_tools.linecut_plot( x=self.sweep_points, y=self.sweep_points_2D, z=self.measured_values[i], y_name=self.parameter_names[1], y_unit=self.parameter_units[1], log=linecut_log, # zlabel=self.zlabels[i], fig=fig, ax=ax, **kw) ax.set_title(fig_title) set_xlabel(ax, self.parameter_names[0], self.parameter_units[0]) # ylabel is value units as we are plotting linecuts set_ylabel(ax, self.value_names[i], self.value_units[i]) if save_fig: self.save_fig(fig, figname=savename, fig_tight=False, **kw) # Heatmap fig, ax = plt.subplots(figsize=figsize) self.fig_array.append(fig) self.ax_array.append(ax) if normalize: print("normalize on") self.ax_array.append(ax) savename = 'Heatmap_{}'.format(self.value_names[i]) fig_title = '{} {} \n{}'.format(self.timestamp_string, self.measurementstring, self.value_names[i]) if "xlabel" not in kw: kw["xlabel"] = self.parameter_names[0] if "ylabel" not in kw: kw["ylabel"] = self.parameter_names[1] if "zlabel" not in kw: kw["zlabel"] = self.value_names[0] if "x_unit" not in kw: kw["x_unit"] = self.parameter_units[0] if "y_unit" not in kw: kw["y_unit"] = self.parameter_units[1] if "z_unit" not in kw: kw["z_unit"] = self.value_units[0] # subtract mean from each row/column if demanded plot_zvals = meas_vals.transpose() if subtract_mean_x: plot_zvals = plot_zvals - np.mean(plot_zvals, axis=1)[:, None] if subtract_mean_y: plot_zvals = plot_zvals - np.mean(plot_zvals, axis=0)[None, :] a_tools.color_plot( x=self.sweep_points, y=self.sweep_points_2D, z=plot_zvals, # zlabel=self.sweept_val[i],u fig=fig, ax=ax, log=colorplot_log, transpose=transpose, normalize=normalize, **kw) ax.set_title(fig_title) set_xlabel(ax, kw["xlabel"], kw["x_unit"]) set_ylabel(ax, kw["ylabel"], kw["y_unit"]) if save_fig: self.save_fig(fig, figname=savename, fig_tight=False, **kw)