Ejemplo n.º 1
0
def summary(s, set_qubit=None, directory=None, plot=False, Brass=False,
            falling=False, set_amps=None, frequencies=False):
    dataDirsTFunc = []
    longZdataSets = []

    # Directory to look for settle times:
    if directory is None:
        dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'NGQ', '141020'])
    else:
        dataDirsTFunc.append(directory)

    cxn = s._cxn
    plt1 = plt.figure()
    counter = 0
    colors = ['r', 'b', 'g', 'c', 'm', 'y', 'k', 'r', 'b', 'g', 'c', 'm', 'y',
              'k', 'r', 'b', 'g', 'c', 'm', 'y', 'k', 'r', 'b', 'g', 'c', 'm',
              'y', 'k', 'r', 'b', 'g', 'c', 'm', 'y', 'k', 'r', 'b', 'g', 'c',
              'm', 'y', 'k', 'r', 'b', 'g', 'c', 'm', 'y', 'k', 'r', 'b', 'g',
              'c', 'm', 'y', 'k', 'r', 'b', 'g', 'c', 'm', 'y', 'k', 'r', 'b',
              'g', 'c', 'm', 'y', 'k', 'r', 'b', 'g', 'c', 'm', 'y', 'k', 'r',
              'b', 'g', 'c', 'm', 'y', 'k', 'r', 'b', 'g', 'c', 'm', 'y', 'k',
              'r', 'b', 'g', 'c', 'm', 'y', 'k', 'r', 'b', 'g', 'c', 'm', 'y',
              'k', 'r', 'b', 'g', 'c', 'm', 'y', 'k']
    ordering = []
    t0s = []
    t1s = []
    t2s = []
    a0s = []
    a1s = []
    a2s = []
    zamps = []
    for dataDirTFunc in dataDirsTFunc:
        d = dvw(dataDirTFunc, cxn)

        # Pull out all data sets of this type in the directory
        settleDataSets = (d[int(x[:5])] for x in d.keys() if
                          'Z Settle Time Long Rise' in x)

        if falling:
            settleDataSets = (d[int(x[:5])] for x in d.keys() if
                              'Spectroscopy Z settle falling' in x)

        for data in settleDataSets:

            biasvals = []
            freqvals = []
            freqvals2 = []
            timevals = []

            print 'dir: {}'.format(dataDirTFunc)
            print 'DATA SET:', data.name
            # get data set from data vault
            qubit = data.parameters['measure'][0]
            q = data.parameters[qubit]

            # Get spec peaks
            fit_gauss_max = lambda x, y: fitting.getMaxGauss(x, y,
                                                             fitToMax=True)
            spectroscopylen = data.parameters[qubit]['spectroscopyLen']['ns']
            times, freqs = fitting.minima_cuts(data, 0, method=fit_gauss_max, plot=False)
            times += 50 + spectroscopylen/2.

            z_amplitude = float(
                data.parameters['stack']['frame0']['arg']['z_amplitude'])

            conditions = True
            if set_qubit is not None:
                if qubit != set_qubit:
                    conditions = False
            if set_amps is not None:
                if float(
                    data.parameters['stack']['frame0']['arg']['z_amplitude']) not in set_amps:
                    conditions = False
                    print 'set_amp: {}; data_amp: {}'.format(set_amps, float(
                    data.parameters['stack']['frame0']['arg']['z_amplitude']))

            if len(times) > 50 and conditions:
                zamps.append(z_amplitude)
                # get zfunc and inverse zfunc
                Z = zfuncs.TransmonFrequency(q['zFuncAna'])

                def fitSettle(ts, a0, t0, a1, t1, a2, t2, b):
                    outp = []
                    for t in ts:
                        # outp.append((a0 * np.exp(-t/t0)) + (a1 * np.exp(-t/t1)) + (a2 * np.exp(-t/t2)) + b)
                        # two Tau fit.
                        outp.append(
                            (a1 * np.exp(-t / t1)) + (a2 * np.exp(-t / t2)) + b)
                    return np.array(outp)

                # seed estimates [A0, T0, A1, T1, A2, T2, B]
                # A0 ~ 5 MHz
                # A1 ~ 5 MHz
                # A2 ~ 1 MHz
                # T0 ~ 10 nsec
                # T1 ~ 1000 nsec
                # T2 ~ 50000 nsec
                # B ~ a frequency.

                popt1, pcov1 = curve_fit(fitSettle, times, freqs,
                                         p0=[5, 10, 5, 1000, 1, 50000,
                                             freqs[-1]], maxfev=5200)

                f_step_amp = ((Z.amp_to_freq(0.0)['GHz']) * 1000) - popt1[6]
                a0s.append(popt1[0] / f_step_amp)
                a1s.append(popt1[2] / f_step_amp)
                a2s.append(popt1[4] / f_step_amp)
                t0s.append(popt1[1])
                t1s.append(popt1[3])
                t2s.append(popt1[5])

                print 'a0: ', a0s[-1]
                print 't0: ', t0s[-1]
                print 'a1: ', a1s[-1]
                print 't1: ', t1s[-1]
                print 'a2: ', a2s[-1]
                print 't2: ', t2s[-1]
                print 'b: ', popt1[6]
                ordering.append((popt1[1] < popt1[3] and popt1[3] < popt1[5]))
                print 'correct ordeR???', ordering[-1]
                infSettleZ = Z.freq_to_amp((popt1[6] / 1000) * GHz)

                xs = np.array(times)
                ys = np.array(freqs)
                x_vals = np.linspace(np.min(times), np.max(times), 10000)
                y_vals = fitSettle(x_vals, popt1[0], popt1[1], popt1[2],
                                   popt1[3], popt1[4], popt1[5], popt1[6])
                y_vals = Z.freq_to_amp((np.array(y_vals) / 1000) * GHz)
                y_vals = y_vals / infSettleZ
                decay_time = np.floor(popt1[2] / 100) / 10

                shortAmp = ((popt1[0] / f_step_amp) * 100)
                shortTime = np.floor(popt1[2] / 100) / 10
                print 'Decay short amp:  %s percent' % shortAmp
                print 'Decay short time:  ', shortTime, 'us'

                longAmp = ((popt1[5] / f_step_amp) * 100)
                longTime = np.floor(popt1[6] / 100) / 10
                print 'Decay long amp:  %s percent' % longAmp
                print 'Decay long time:  ', longTime, 'us'

                print qubit
                # Amplitude of step from DAC
                z_amplitude = float(
                    data.parameters['stack']['frame0']['arg']['z_amplitude'])
                print ' z_amplitude', z_amplitude

                # Amplitude of step according to zfunc
                zfunc_amplitudes = (Z.freq_to_amp((np.array(freqs) / (1000)) * GHz))
                zfunc_amplitudes = zfunc_amplitudes / infSettleZ

                counter = int(z_amplitude * 10)

                #  data
                # plt.semilogx(times/1000,zfunc_amplitudes*100, color = colors[counter], lw = 0, marker = 's',markeredgecolor='none', label = labels[counter])
                # plt.semilogx(times/1000,zfunc_amplitudes*100, color = colors[counter], lw = 0, marker = 's',markeredgecolor='none', label = 'z_step_amp: %0.1f ;Tshort %.5f us; Ashort: %0.2d; Tlong %02d us; Along: %0.2d'%(z_amplitude,float(shortTime), np.float(shortAmp), longTime, np.float(longAmp)))
                f_step_amp = np.int(f_step_amp*10.)/10.
                if frequencies:
                    plt.semilogx(times / 1000., freqs,
                                 color=colors[counter], lw=0, marker='s',
                                 label='<{}> {}: z_amplitude: {}; f_step_amp: {} MHz'.format(
                                     np.int(data.name.split()[0]), qubit,
                                     z_amplitude, f_step_amp))
                    plt.ylabel('Qubit Frequency (MHz)', fontsize=18)
                else:
                    plt.semilogx(times / 1000., zfunc_amplitudes * 100,
                                 color=colors[counter], lw=0, marker='s',
                                 label='<{}> {}: z_amplitude: {}; f_step_amp: '
                                       '{} MHz'.format(
                                     np.int(data.name.split()[0]), qubit,
                                     z_amplitude, f_step_amp))
                    plt.ylabel('Z Amp (% of step)', fontsize=18)
                    # plt.axis([0.03, 24000, 90, 102])
                print type(z_amplitude), type(shortTime)
                #  fit
                # plt.semilogx(x_vals/1e3,y_vals*100, color = colors[counter], lw = 2, marker = None, label = 'z_step_amp: %s ;Tshort %s us; Ashort: %s; Tlong %s us; Along: %s'%(str(z_amplitude),str(shortTime), str(shortAmp), str(longTime), str(longAmp)))
                plt.semilogx(x_vals / 1000, y_vals * 100, color=colors[counter],
                             lw=2, marker='s', markeredgecolor='none')
                counter += 1
                # plt.title(dataDirTFunc, fontsize=18)
                # plt.xlabel('Time (us)', fontsize=18)
                # plt.tick_params(labelsize=15)
                # plt.legend(numpoints=1, loc=4)
                # plt.tight_layout
                # plt.show()

    if plot:
        plt.title(dataDirTFunc, fontsize=18)
        plt.xlabel('Time (us)', fontsize=18)
        plt.tick_params(labelsize=15)
        plt.legend(numpoints=1, loc=4)
        plt.tight_layout()
        plt.show()

    if False:
        plt.figure()
        plt.title(
            'Settle Amplitude vs Step Amplitude: a0*exp(-t/t0) + a1*exp(-t/t1) + a2*exp(-t/t2)',
            fontsize=11)
        plt.ylabel('Settle amplitude (% of step)')
        plt.xlabel('Step amplitude (DAC units)')
        plt.plot(zamps, a0s, 'rs', label='a0s')
        plt.plot(zamps, a1s, 'bs', label='a1s')
        plt.plot(zamps, a2s, 'gs', label='a2s')
        plt.legend(numpoints=1, loc=2)
        plt.axis([-1.0, 1.0, -0.5, 0.5])
        plt.tight_layout()
        plt.show()

        plt.figure()
        plt.title(
            'Settle Amplitude vs Step Amplitude: a0*exp(-t/t0) + a1*exp(-t/t1) + a2*exp(-t/t2)',
            fontsize=11)
        plt.ylabel('Settle amplitude (% of step)')
        plt.xlabel('Step amplitude (DAC units)')
        plt.semilogy(zamps, np.abs(a0s), 'rs', label='a0s')
        plt.semilogy(zamps, np.abs(a1s), 'bs', label='a1s')
        plt.semilogy(zamps, np.abs(a2s), 'gs', label='a2s')
        plt.legend(numpoints=1, loc=3)
        # plt.axis([-1.0,1.0, 0, 10])
        plt.tight_layout()
        plt.show()

        plt.figure()
        plt.title(
            'Settle Times vs Step Amplitude: a0*exp(-t/t0) + a1*exp(-t/t1) + a2*exp(-t/t2)',
            fontsize=11)
        plt.ylabel('Settle Time nsec')
        plt.xlabel('Step amplitude (DAC units)')
        plt.semilogy(zamps, t0s, 'rs', label='t0s')
        plt.semilogy(zamps, t1s, 'bs', label='t1s')
        plt.semilogy(zamps, t2s, 'gs', label='t2s')
        plt.legend(numpoints=1, loc=2)
        # plt.axis([-1.0,1.0, 0, 10])
        plt.tight_layout()
        plt.show()

    return zamps, a0s, a1s, a2s, t0s, t1s, t2s

    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AlBoxViasPCB', '160415'])
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AlBoxViasPCB', '160415'])
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AlBoxViasPCB', '160415'])
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AlBoxViasPCB', '160415'])
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AlBoxViasPCB', '160415'])
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AlBoxViasPCB', '160415'])
    # longZdataSets.append(63)
    # longZdataSets.append(64)
    # longZdataSets.append(65)
    # longZdataSets.append(66)
    # longZdataSets.append(67)
    # longZdataSets.append(68)
    # longZdataSets.append(69)



    # # title_plot = 'Al Box, Copper vias Q2'
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AlBoxAlCuPCB', '160305'])
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AlBoxAlCuPCB', '160305'])
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AlBoxAlCuPCB', '160305'])
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AlBoxAlCuPCB', '160305'])
    # longZdataSets.append(77)
    # longZdataSets.append(78)
    # longZdataSets.append(79)
    # longZdataSets.append(80)

    # # machined Al box, Q3
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AndrewsChip', 'D1', '160304'])
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AndrewsChip', 'D1', '160304'])
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'AndrewsChip', 'D1', '160304'])
    # longZdataSets.append(17)
    # longZdataSets.append(13)
    # longZdataSets.append(13)

    #  Brass box Cu Vias, Al PCB
    # dataDirsTFunc.append(['', 'Brooks', 'qubitData', 'BrassBoxCuViasAlPCB', '160418'])
    # # Amp = 0.4
    # longZdataSets.append(90)
Ejemplo n.º 2
0
def plot_settle_datasets(sample, set_qubits=None, set_amps=None, first=False,
                         directories=None, dir_sets=None,
                         plot=False, frequencies=False, title='', autoscale=True,
                         labels=None, plot_axes=[1, 5e5, 90.0, 100.4],
                         use_legend=True, leg_loc=4):
    if directories is None:
        directories = [sample._dir]

    colors = ['r', 'b', 'g', 'c', 'm', 'y', 'k']


    if dir_sets is not None:
        for dir_set in dir_sets:
            d = dvw(dir_set[0], sample._cxn)
            data = d[dir_set[1]]
            if 'Z Settle Time Long Rise' not in data.name:
                raise Exception('Error, this is not Z-settle dataset. Requested'
                                'data set is: {}'.format(data.name))

            qubit = data.parameters['measure'][0]
            q = data.parameters[qubit]

            # Get spec peaks
            fit_gauss_max = lambda x, y: fitting.getMaxGauss(x, y,
                                                             fitToMax=True)
            times, freqs_MHz = fitting.minima_cuts(data, 0, method=fit_gauss_max,
                                               plot=False)
            # offset datavault times by 50ns + spectroscopyLen/2
            spectroscopylen = data.parameters[qubit]['spectroscopyLen']['ns']
            times += 50 + spectroscopylen/2.

            # get zfunc and inverse zfunc
            Z = zfuncs.TransmonFrequency(q['zFuncAna'])

            def fit_settle(ts, a0, t0, a1, t1, a2, t2, b):
                outp = []
                for t in ts:
                    outp.append((a0 * np.exp(-t/t0)) + (a1 * np.exp(-t/t1)) + (a2 * np.exp(-t/t2)) + b)
                return np.array(outp)

            # seed estimates [A0, T0, A1, T1, A2, T2, B]
            # A0 ~ 5 MHz
            # A1 ~ 5 MHz
            # A2 ~ 1 MHz
            # T0 ~ 10 nsec
            # T1 ~ 1000 nsec
            # T2 ~ 50000 nsec
            # B ~ a frequency.

            # fit qubit frequency vs time
            popt1, pcov1 = curve_fit(fit_settle, times, freqs_MHz,
                                     p0=[5., 10., 5., 100., 1000., 50000.,
                                         freqs_MHz[-1]], maxfev=5200)

            # calculate step amplitude in frequency
            a0, t0, a1, t1, a2, t2, f_inf = popt1


            ordering = t0 < t1 and t1 < t2
            # if not ordering:
            #     raise Exception('Error! Time constants out of order! t0: {} ns;'
            #                     ' t1: {} ns; t2: {} ns'.format(t0, t1, t2))

            z_amp_inf = Z.freq_to_amp((f_inf / 1000.) * GHz)

            # plot_times
            plot_times = np.linspace(np.min(times), np.max(times), 1000)
            # compute frequencies for fit plot
            plot_frequencies = fit_settle(plot_times, a0, t0, a1, t1, a2, t2, f_inf)
            # scale fit frequencies to
            plot_z_amplitudes = Z.freq_to_amp((plot_frequencies / 1000.) * GHz)
            # scale z_amps to fraction
            plot_percent = plot_z_amplitudes * 100. / z_amp_inf

            # Amplitude of step from DAC
            z_amplitude = float(data.parameters['stack']['frame0']['arg']['z_amplitude'])

            if np.abs(z_amplitude-z_amp_inf) > 0.03:
                raise Exception('Error!  Requested amplitude ({}) and measured '
                                'amplitude ({}) do not match!'
                                ''.format(z_amplitude, z_amp_inf))

            # Amplitude of step according to zfunc
            zfunc_amplitudes = Z.freq_to_amp(freqs_MHz / 1000. * GHz)
            # normalized z_func_amplitudes
            zfunc_percent = 100. * zfunc_amplitudes / z_amp_inf

            # convert settle amplitudes to fraction of step
            f_step_amp = ((Z.amp_to_freq(0.0)['GHz']) * 1000.) - f_inf
            a0 /= f_step_amp
            a1 /= f_step_amp
            a2 /= f_step_amp

            f_step_amp = np.int(f_step_amp*10.)/10.
            # data plot
            if frequencies:
                plt.semilogx(times, freqs_MHz, lw=0, marker='s',
                             label='{}: z_amp: {}; f_amp: {} MHz'.format(
                                 qubit,
                                 z_amplitude, f_step_amp))
                plt.ylabel('Qubit Frequency (MHz)', fontsize=18)

                if not autoscale:
                    plt.axis(plot_axes)
                if len(dir_sets) == 1:
                    plt.semilogx(plot_times, plot_frequencies, lw=2, marker='s',
                                 markeredgecolor='none')

            else:
                plt.semilogx(times, zfunc_percent, lw=0, marker='s',
                             label='{}; {} MHz'.format(
                                 z_amplitude, f_step_amp))
                plt.ylabel('Z Amp (% of step)', fontsize=18)
                if not autoscale:
                    plt.axis(plot_axes)
            #  fit
            # plt.semilogx(x_vals/1e3,y_vals*100, color = colors[counter], lw = 2, marker = None, label = 'z_step_amp: %s ;Tshort %s us; Ashort: %s; Tlong %s us; Along: %s'%(str(z_amplitude),str(shortTime), str(shortAmp), str(longTime), str(longAmp)))
                if len(dir_sets) == 1:
                    plt.semilogx(plot_times, plot_percent, lw=2, marker='s', markeredgecolor='none')

        if plot:
            plt.title(title,
                      fontsize=18)

            plt.xlabel('Time (ns)', fontsize=18)
            plt.tick_params(labelsize=15)
            if use_legend:
                if labels is not None:
                    plt.legend(labels, numpoints=1, loc=leg_loc)
                else:
                    plt.legend(numpoints=1, loc=leg_loc)
            plt.tight_layout()
            plt.show()

        if False:
            plt.figure()
            plt.title(
                'Settle Amplitude vs Step Amplitude: a0*exp(-t/t0) + a1*exp(-t/t1) + a2*exp(-t/t2)',
                fontsize=11)
            plt.ylabel('Settle amplitude (% of step)')
            plt.xlabel('Step amplitude (DAC units)')
            plt.plot(zamps, a0s, 'rs', label='a0s')
            plt.plot(zamps, a1s, 'bs', label='a1s')
            plt.plot(zamps, a2s, 'gs', label='a2s')
            plt.legend(numpoints=1, loc=2)
            plt.axis(plot_axes)
            plt.tight_layout()
            plt.show()

            plt.figure()
            plt.title(
                'Settle Amplitude vs Step Amplitude: a0*exp(-t/t0) + a1*exp(-t/t1) + a2*exp(-t/t2)',
                fontsize=11)
            plt.ylabel('Settle amplitude (% of step)')
            plt.xlabel('Step amplitude (DAC units)')
            plt.semilogy(zamps, np.abs(a0s), 'rs', label='a0s')
            plt.semilogy(zamps, np.abs(a1s), 'bs', label='a1s')
            plt.semilogy(zamps, np.abs(a2s), 'gs', label='a2s')
            plt.legend(numpoints=1, loc=3)
            # plt.axis([-1.0,1.0, 0, 10])
            plt.tight_layout()
            plt.show()

            plt.figure()
            plt.title(
                'Settle Times vs Step Amplitude: a0*exp(-t/t0) + a1*exp(-t/t1) + a2*exp(-t/t2)',
                fontsize=11)
            plt.ylabel('Settle Time nsec')
            plt.xlabel('Step amplitude (DAC units)')
            plt.semilogy(zamps, t0s, 'rs', label='t0s')
            plt.semilogy(zamps, t1s, 'bs', label='t1s')
            plt.semilogy(zamps, t2s, 'gs', label='t2s')
            plt.legend(numpoints=1, loc=2)
            # plt.axis([-1.0,1.0, 0, 10])
            plt.tight_layout()
            plt.show()

    return times, zfunc_percent