Beispiel #1
0
    def go(self):
        if self.liveplot_enabled:
            self.plotter.clear()

        print("Prep Instruments")
        self.readout.set_frequency(self.cfg['readout']['frequency'])
        self.readout.set_power(self.cfg['readout']['power'])
        self.readout.set_ext_pulse(mod=True)

        self.drive.set_frequency(
            self.cfg['qubit']['frequency'] -
            self.cfg['pulse_info'][self.pulse_type]['iq_freq'])
        self.drive.set_power(self.cfg[self.expt_cfg_name]['power'])
        self.drive.set_ext_pulse(mod=False)
        self.drive.set_output(True)

        try:
            self.awg.set_amps_offsets(self.cfg['cal']['iq_amps'],
                                      self.cfg['cal']['iq_offsets'])
        except:
            print("self.awg not loaded.")

        print("Prep Card")
        adc = Alazar(self.cfg['alazar'])

        attenpts = arange(self.cfg[self.expt_cfg_name]['atten_start'],
                          self.cfg[self.expt_cfg_name]['atten_stop'],
                          self.cfg[self.expt_cfg_name]['atten_step'])
        freqpts = arange(self.cfg[self.expt_cfg_name]['freq_start'],
                         self.cfg[self.expt_cfg_name]['freq_stop'],
                         self.cfg[self.expt_cfg_name]['freq_step'])
        num_bins = self.cfg[self.expt_cfg_name]['num_bins']

        for xx, atten in enumerate(attenpts):
            #self.im.atten.set_attenuator(atten)
            try:
                self.readout_atten.set_attenuator(atten)
            except:
                print("Digital attenuator not loaded.")

            max_contrast_data = zeros(len(freqpts))

            if self.liveplot_enabled:
                self.plotter.clear('max contrast')

            for yy, freq in enumerate(freqpts):
                self.readout.set_frequency(freq)
                #self.readout_shifter.set_phase(self.cfg['readout']['start_phase'] , freq)
                self.readout_shifter.set_phase(
                    (self.cfg['readout']['start_phase'] +
                     self.cfg['readout']['phase_slope'] *
                     (freq - self.cfg['readout']['frequency'])) % 360, freq)

                #tpts, ch1_pts, ch2_pts = adc.acquire_avg_data_by_record(prep_function=self.awg.stop_and_prep, start_function=self.awg.run,excise=None)

                tpts, ch1_pts, ch2_pts = adc.acquire_avg_data_by_record(
                    prep_function=self.awg_prep,
                    start_function=self.awg_run,
                    excise=self.cfg['readout']['window'])

                if self.liveplot_enabled:
                    self.plotter.plot_z("current", ch1_pts)

                # with self.datafile() as f:
                #     f.append('time_trace', ch1_pts)
                ss_data = zeros((len(self.expt_pts), num_bins))
                sss_data = zeros((len(self.expt_pts), num_bins))

                # ss1, ss2 = adc.acquire_singleshot_data(prep_function=None, start_function=None,
                #                                        excise=self.cfg['readout']['window'])
                ss1, ss2 = adc.acquire_singleshot_data(
                    prep_function=self.awg_prep,
                    start_function=self.awg_run,
                    excise=self.cfg['readout']['window'])

                ss1 = reshape(ss1,
                              (self.cfg['alazar']['recordsPerAcquisition'] /
                               len(self.expt_pts), len(self.expt_pts))).T
                histo_range = (ss1.min() / 1.5, ss1.max() * 1.5)
                for jj, ss in enumerate(ss1):
                    sshisto, ssbins = np.histogram(ss,
                                                   bins=num_bins,
                                                   range=histo_range)
                    ss_data[jj] += sshisto
                    sss_data[jj] = cumsum(ss_data[[jj]])
                    if self.liveplot_enabled:
                        self.plotter.plot_xy('histogram %d' % jj, ssbins[:-1],
                                             ss_data[jj])
                        self.plotter.plot_xy('cum histo %d' % jj, ssbins[:-1],
                                             sss_data[jj])

                if self.liveplot_enabled:
                    self.plotter.plot_xy(
                        'contrast', ssbins[:-1],
                        abs(sss_data[0] - sss_data[1]) / ss_data[0].sum())
                max_contrast_data[yy] = abs(
                    ((sss_data[0] - sss_data[1]) / ss_data[0].sum())).max()
                if self.liveplot_enabled:
                    self.plotter.append_xy('max contrast', freq,
                                           max_contrast_data[yy])
            if len(attenpts) > 1:
                if self.liveplot_enabled:
                    print("plotting max contrast 2")
                    self.plotter.append_z(
                        'max contrast 2',
                        max_contrast_data,
                        start_step=((attenpts[0], attenpts[1] - attenpts[0]),
                                    (freqpts[0] / 1.0e9,
                                     (freqpts[1] - freqpts[0]) / 1.0e9)))

            with self.datafile() as f:
                f.append_pt('atten', atten)
                f.append_line('freq', freqpts)
                f.append_line('max_contrast_data', max_contrast_data)
                f.close()
    def go(self):
        #self.plotter.clear()

        print("Prep Instruments")
        self.readout.set_frequency(self.cfg['readout']['frequency'])
        self.readout.set_power(self.cfg['readout']['power'])
        self.readout.set_ext_pulse(mod=True)


        self.drive.set_frequency(self.cfg['qubit']['frequency'] - self.cfg['pulse_info'][self.pulse_type]['iq_freq'])
        self.drive.set_power(self.cfg[self.expt_cfg_name]['power'])
        self.drive.set_ext_pulse(mod=True)
        self.drive.set_output(True)

        self.awg.set_amps_offsets(self.cfg['cal']['iq_amps'], self.cfg['cal']['iq_offsets'])

        print("Prep Card")
        adc = Alazar(self.cfg['alazar'])

        attenpts = arange(self.cfg[self.expt_cfg_name]['atten_start'], self.cfg[self.expt_cfg_name]['atten_stop'], self.cfg[self.expt_cfg_name]['atten_step'])
        freqpts = arange(self.cfg[self.expt_cfg_name]['freq_start'], self.cfg[self.expt_cfg_name]['freq_stop'], self.cfg[self.expt_cfg_name]['freq_step'])
        num_bins = self.cfg[self.expt_cfg_name]['num_bins']

        for xx, atten in enumerate(attenpts):
            self.im.atten.set_attenuator(atten)
            max_contrast_data_ch1 = zeros(len(freqpts))
            max_contrast_data_ch2 = zeros(len(freqpts))
            #self.plotter.clear('max contrast')

            print("atten at: %s" %atten)

            for yy, freq in enumerate(freqpts):
                self.readout.set_frequency(freq)
                #self.readout_shifter.set_phase(self.cfg['readout']['start_phase'] , freq)
                # self.readout_shifter.set_phase((self.cfg['readout']['start_phase'] + self.cfg['readout']['phase_slope'] * (freq - self.cfg['readout']['frequency']))%360, freq)
                tpts, ch1_pts, ch2_pts = adc.acquire_avg_data_by_record(prep_function=self.awg.stop_and_prep, start_function=self.awg.run,excise=self.cfg['readout']['window'])
                # self.plotter.plot_z("current",ch1_pts)
                # with self.datafile() as f:
                #     f.append('time_trace', ch1_pts)
                ss_data = zeros((len(self.expt_pts), num_bins))
                sss_data = zeros((len(self.expt_pts), num_bins))

                ss1, ss2 = adc.acquire_singleshot_data(prep_function=self.awg.stop_and_prep, start_function=self.awg.run,
                                                       excise=self.cfg['readout']['window'])

                #with self.datafile() as f:
                #    f.append_line('ss1', ss1)
                #    f.append_line('ss2', ss2)


                ss1 = reshape(ss1, (int(self.cfg['alazar']['recordsPerAcquisition'] / len(self.expt_pts)), len(self.expt_pts))).T
                histo_range = (ss1.min() / 1.05, ss1.max() * 1.05)
                for jj, ss in enumerate(ss1):
                    sshisto, ssbins = np.histogram(ss, bins=num_bins, range=histo_range)
                    ss_data[jj] += sshisto
                    sss_data[jj] = cumsum(ss_data[[jj]])
                #     self.plotter.plot_xy('histogram %d' % jj, ssbins[:-1], ss_data[jj])
                #     self.plotter.plot_xy('cum histo %d' % jj, ssbins[:-1], sss_data[jj])

                max_contrast_data_ch1[yy] = abs(((sss_data[0] - sss_data[1]) / ss_data[0].sum())).max()

                ss2 = reshape(ss2, (int(self.cfg['alazar']['recordsPerAcquisition'] / len(self.expt_pts)), len(self.expt_pts))).T
                histo_range = (ss2.min() / 1.05, ss2.max() * 1.05)
                for jj, ss in enumerate(ss2):
                    sshisto, ssbins = np.histogram(ss, bins=num_bins, range=histo_range)
                    ss_data[jj] += sshisto
                    sss_data[jj] = cumsum(ss_data[[jj]])
                    #self.plotter.plot_xy('histogram %d' % jj, ssbins[:-1], ss_data[jj])
                    #self.plotter.plot_xy('cum histo %d' % jj, ssbins[:-1], sss_data[jj])

                #self.plotter.plot_xy('contrast', ssbins[:-1], abs(sss_data[0] - sss_data[1]) / ss_data[0].sum())
                max_contrast_data_ch2[yy] = abs(((sss_data[0] - sss_data[1]) / ss_data[0].sum())).max()
                #self.plotter.append_xy('max contrast', freq, max_contrast_data[yy])
            if len(attenpts)>1:
                print("plotting max contrast 2")
                pass
                # self.plotter.append_z('max contrast 2', max_contrast_data, start_step=(
                #  (attenpts[0], attenpts[1] - attenpts[0]),(freqpts[0] / 1.0e9, (freqpts[1] - freqpts[0]) / 1.0e9)))
            with self.datafile() as f:
                f.append_pt('atten', atten)
                f.append_line('freq', freqpts)
                f.append_line('max_contrast_data_ch1', max_contrast_data_ch1)
                f.append_line('max_contrast_data_ch2', max_contrast_data_ch2)
Beispiel #3
0
    def run_normal(self):

        if self.liveplot_enabled:
            self.plotter.clear()

        print("Prep Instruments")
        self.readout.set_frequency(self.cfg['readout']['frequency'])
        self.readout.set_power(self.cfg['readout']['power'])
        self.readout.set_ext_pulse(mod=self.cfg['readout']['mod'])

        self.drive.set_frequency(self.cfg['qubit']['frequency'] - self.cfg['pulse_info'][self.pulse_type]['iq_freq'])
        self.drive.set_power(self.cfg[self.expt_cfg_name]['power'])
        self.drive.set_ext_pulse(mod=self.cfg['drive']['mod'])
        self.drive.set_output(True)

        try:
            self.awg.set_amps_offsets(self.cfg['cal']['iq_amps'], self.cfg['cal']['iq_offsets'])
        except:
            print("self.awg not loaded.")

        print("Prep Card")
        adc = Alazar(self.cfg['alazar'])

        attenpts = arange(self.cfg[self.expt_cfg_name]['atten_start'], self.cfg[self.expt_cfg_name]['atten_stop'], self.cfg[self.expt_cfg_name]['atten_step'])
        freqpts = arange(self.cfg[self.expt_cfg_name]['freq_start'], self.cfg[self.expt_cfg_name]['freq_stop'], self.cfg[self.expt_cfg_name]['freq_step'])
        num_bins = self.cfg[self.expt_cfg_name]['num_bins']

        ss_data_all = zeros((2, len(attenpts), len(freqpts), len(self.expt_pts),
                             self.cfg['alazar']['recordsPerAcquisition'] / len(self.expt_pts))
                            )  # (channel, atten, freq, g/e(/f), average)

        for xx, atten in enumerate(attenpts):
            #self.im.atten.set_attenuator(atten)
            try:
                self.readout_atten.set_attenuator(atten)
            except:
                print("Digital attenuator not loaded.")

            max_contrast_data = zeros((2,len(freqpts))) # (chn, freq)
            max_contrast_data_ef = zeros((2, len(freqpts)))  # (chn, freq)

            if self.liveplot_enabled:
                self.plotter.clear('max contrast')

            for yy, freq in enumerate(freqpts):
                self.readout.set_frequency(freq-self.cfg['readout']['heterodyne_freq'])
                #self.readout_shifter.set_phase(self.cfg['readout']['start_phase'] , freq)
                self.readout_shifter.set_phase((self.cfg['readout']['start_phase'] + self.cfg['readout']['phase_slope'] * (freq - self.cfg['readout']['frequency']))%360, freq)

                ss_data = zeros((len(self.expt_pts), num_bins))
                sss_data = zeros((len(self.expt_pts), num_bins))

                print("runnning atten no.", xx, ", freq no.", yy)

                ss1, ss2 = adc.acquire_singleshot_data(prep_function=self.awg_prep, start_function=self.awg_run,
                                                       excise=self.cfg['readout']['window'])

                for kk, ssthis in enumerate([ss1, ss2]):

                    ssthis = reshape(ssthis, (self.cfg['alazar']['recordsPerAcquisition'] / len(self.expt_pts), len(self.expt_pts))).T
                    ss_data_all[kk, xx, yy, :, :] = ssthis

                    print('ss ch', str(kk+1), 'max/min =', ssthis.max(), ssthis.min())
                    dist = ssthis.max() - ssthis.min()
                    histo_range = (ssthis.min() - 0.01*dist, ssthis.max() + 0.01*dist)

                    for jj, ss in enumerate(ssthis):
                        sshisto, ssbins = np.histogram(ss, bins=num_bins, range=histo_range)
                        ss_data[jj] += sshisto
                        sss_data[jj] = cumsum(ss_data[[jj]])
                        if self.liveplot_enabled:
                            self.plotter.plot_xy('histogram %d' % jj, ssbins[:-1], ss_data[jj])
                            self.plotter.plot_xy('cum histo %d' % jj, ssbins[:-1], sss_data[jj])

                    max_contrast_data[kk, yy] = abs(((sss_data[0] - sss_data[1]) / ss_data[0].sum())).max()

                    if len(self.expt_pts)>2:

                        max_contrast_data_ef[kk, yy] = abs(((sss_data[1] - sss_data[2]) / ss_data[1].sum())).max()

                    if self.liveplot_enabled:
                        self.plotter.plot_xy('contrast_ch' + str(kk+1), ssbins[:-1], abs(sss_data[0] - sss_data[1]) / ss_data[0].sum())
                        self.plotter.append_xy('max contrast_ch' + str(kk+1), freq, max_contrast_data[kk,yy])

            # initialize datafile by kwarg data_file
            # self.slab_file = self.datafile(data_file=self.data_file)

            self.slab_file = self.datafile()

            with self.slab_file as f:
                f.append_pt('atten', atten)
                f.add('attenpts', attenpts)
                f.append_line('freq', freqpts)
                f.append_line('max_contrast_data_ch1', max_contrast_data[0, :])
                f.append_line('max_contrast_data_ch2', max_contrast_data[1, :])

                if len(self.expt_pts) > 2:
                    f.append_line('max_contrast_data_ef_ch1', max_contrast_data_ef[0, :])
                    f.append_line('max_contrast_data_ef_ch2', max_contrast_data_ef[1, :])

                f.add('ss_data_ch1', ss_data_all[0])
                f.add('ss_data_ch2', ss_data_all[1])

                f.close()