Ejemplo n.º 1
0
    def get_N_ROC(self, P_min1=1, u_P_min1=0, P_0=1, u_P_0=0,
            F0_RO_pulse=1, u_F0_RO_pulse=0,
            F1_RO_pulse=1, u_F1_RO_pulse=0,
            ssro_calib_folder=None):

        if ssro_calib_folder == None:
            ssro_calib_folder = toolbox.latest_data('SSRO')

        self.p0 = np.zeros(self.normalized_ssro.shape)
        self.u_p0 = np.zeros(self.normalized_ssro.shape)

        ro_durations = self.g.attrs['E_RO_durations']
        roc = Nspin_correction.NuclearSpinROC()
        roc.P_min1 = P_min1
        roc.u_P_min1 = u_P_min1
        roc.P_0 = P_0
        roc.u_P_0 = u_P_0

        roc.F0_RO_pulse = F0_RO_pulse
        roc.u_F0_RO_pulse = u_F0_RO_pulse
        roc.F1_RO_pulse = F1_RO_pulse
        roc.u_F1_RO_pulse = u_F1_RO_pulse

        for i in range(len(self.normalized_ssro[0])):
            roc.F0_ssro, roc.u_F0_ssro, roc.F1_ssro, roc.u_F1_ssro = \
                ssro.get_SSRO_calibration(ssro_calib_folder,
                        ro_durations[i])

            p0, u_p0 = roc.num_evaluation(self.normalized_ssro[:,i],
                    self.u_normalized_ssro[:,i])

            self.p0[:,i] = p0
            self.u_p0[:,i] = u_p0

        self.result_corrected = True
Ejemplo n.º 2
0
    def get_electron_ROC(self, **kw):
        ssro_calib_folder = kw.pop('ssro_calib_folder', None)
        if ssro_calib_folder is None:
            ssro_calib_folder = toolbox.latest_data('SSROCalibration')
        # print ssro_calib_folder
        if ssro_calib_folder == '':
            ssro_calib_folder = toolbox.latest_data('SSROCalibration')

        self.p0 = np.zeros(self.normalized_ssro.shape)
        self.u_p0 = np.zeros(self.normalized_ssro.shape)

        ro_duration = self.g.attrs['SSRO_duration']
        roc = error.SingleQubitROC()

        # Decide between ssro calib via MW Initialisation or some other method
        # At the time of writing only MWInit and full las0r SSRO exist ~SK 2016
        if 'MWInit' in ssro_calib_folder:
            el_state = self.adgrp.attrs['electron_transition']
            # print 'MWInit, el_state: ' + str(el_state)

            roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                ssro.get_SSRO_MWInit_calibration(ssro_calib_folder,
                        ro_duration,el_state)

        else:
            roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                ssro.get_SSRO_calibration(ssro_calib_folder,
                        ro_duration)

        p0, u_p0 = roc.num_eval(self.normalized_ssro, self.u_normalized_ssro)

        self.p0 = p0
        self.u_p0 = u_p0

        self.result_corrected = True
Ejemplo n.º 3
0
    def get_N_ROC(self, P_min1=1, u_P_min1=0, P_0=1, u_P_0=0,
            F0_RO_pulse=1, u_F0_RO_pulse=0,
            F1_RO_pulse=1, u_F1_RO_pulse=0,
            ssro_calib_folder=None):

        if ssro_calib_folder == None:
            ssro_calib_folder = toolbox.latest_data('SSRO')

        self.p0 = np.zeros(self.normalized_ssro.shape)
        self.u_p0 = np.zeros(self.normalized_ssro.shape)

        ro_durations = self.g.attrs['E_RO_durations']
        roc = Nspin_correction.NuclearSpinROC()
        roc.P_min1 = P_min1
        roc.u_P_min1 = u_P_min1
        roc.P_0 = P_0
        roc.u_P_0 = u_P_0

        roc.F0_RO_pulse = F0_RO_pulse
        roc.u_F0_RO_pulse = u_F0_RO_pulse
        roc.F1_RO_pulse = F1_RO_pulse
        roc.u_F1_RO_pulse = u_F1_RO_pulse

        for i in range(len(self.normalized_ssro[0])):
            roc.F0_ssro, roc.u_F0_ssro, roc.F1_ssro, roc.u_F1_ssro = \
                ssro.get_SSRO_calibration(ssro_calib_folder,
                        ro_durations[i])

            p0, u_p0 = roc.num_evaluation(self.normalized_ssro[:,i],
                    self.u_normalized_ssro[:,i])

            self.p0[:,i] = p0
            self.u_p0[:,i] = u_p0

        self.result_corrected = True
Ejemplo n.º 4
0
def get_RO_fidelities(ssro_folder,mw_transition,E_RO_duration):

    if 'MWInit' in ssro_folder:
        F_0,u_F0,F_1,u_F1 = ssro.get_SSRO_MWInit_calibration(ssro_folder,E_RO_duration,mw_transition)
    else:
        F_0,u_F0,F_1,u_F1 = ssro.get_SSRO_calibration(ssro_folder,E_RO_duration)

    return F_0,F_1 ### excludiung uncertainties for now.
Ejemplo n.º 5
0
    def get_correlation_ROC(self, P_min1=1, u_P_min1=0, P_0=0, u_P_0=0,
            F0_RO_pulse=1, u_F0_RO_pulse=0,
            F1_RO_pulse=1, u_F1_RO_pulse=0,
            ssro_calib_folder=None):

        if ssro_calib_folder == None:
            ssro_calib_folder = toolbox.latest_data('SSRO')

        #The shape below is [sweep_pts,4].
        self.p_correlations= np.zeros(self.normalized_correlations.shape)
        self.u_p_correlations = np.zeros(self.normalized_correlations.shape)

        ro_durations = self.g.attrs['E_RO_durations']
        roc = N_and_e_spin_correction.CorrelationsROC()
        roc.P_min1 = P_min1
        roc.u_P_min1 = u_P_min1
        roc.P_0 = P_0
        roc.u_P_0 = u_P_0

        roc.F0_RO_pulse = F0_RO_pulse
        roc.u_F0_RO_pulse = u_F0_RO_pulse
        roc.F1_RO_pulse = F1_RO_pulse
        roc.u_F1_RO_pulse = u_F1_RO_pulse

        #The electron RO correction for the first readout (with ro_durations[0])
        roc.F0_e_ssro, roc.u_F0_e_ssro, roc.F1_e_ssro, roc.u_F1_e_ssro = \
            ssro.get_SSRO_calibration(ssro_calib_folder,
                       ro_durations[0])

        #The electron RO correction for the second readout (with ro_durations[1])
        roc.F0_N_ssro, roc.u_F0_N_ssro, roc.F1_N_ssro, roc.u_F1_N_ssro = \
            ssro.get_SSRO_calibration(ssro_calib_folder,
                   ro_durations[1])

        #Here the correction for the double readout is calculation.
        p_correlations, u_p_correlations = roc.num_evaluation(self.normalized_correlations[:,:],
                self.u_normalized_correlations[:,:])

        #The output p_correlations above is tuple, we transform it to array
        #and Transpose it to retain the right shape.
        self.p_correlations = np.array(p_correlations).T
        self.u_p_correlations = np.array(u_p_correlations).T

        self.result_correlation_corrected = True
Ejemplo n.º 6
0
    def get_correlation_ROC(self, P_min1=1, u_P_min1=0, P_0=0, u_P_0=0,
            F0_RO_pulse=1, u_F0_RO_pulse=0,
            F1_RO_pulse=1, u_F1_RO_pulse=0,
            ssro_calib_folder=None):

        if ssro_calib_folder == None:
            ssro_calib_folder = toolbox.latest_data('SSRO')

        #The shape below is [sweep_pts,4].
        self.p_correlations= np.zeros(self.normalized_correlations.shape)
        self.u_p_correlations = np.zeros(self.normalized_correlations.shape)

        ro_durations = self.g.attrs['E_RO_durations']
        roc = N_and_e_spin_correction.CorrelationsROC()
        roc.P_min1 = P_min1
        roc.u_P_min1 = u_P_min1
        roc.P_0 = P_0
        roc.u_P_0 = u_P_0

        roc.F0_RO_pulse = F0_RO_pulse
        roc.u_F0_RO_pulse = u_F0_RO_pulse
        roc.F1_RO_pulse = F1_RO_pulse
        roc.u_F1_RO_pulse = u_F1_RO_pulse

        #The electron RO correction for the first readout (with ro_durations[0])
        roc.F0_e_ssro, roc.u_F0_e_ssro, roc.F1_e_ssro, roc.u_F1_e_ssro = \
            ssro.get_SSRO_calibration(ssro_calib_folder,
                       ro_durations[0])

        #The electron RO correction for the second readout (with ro_durations[1])
        roc.F0_N_ssro, roc.u_F0_N_ssro, roc.F1_N_ssro, roc.u_F1_N_ssro = \
            ssro.get_SSRO_calibration(ssro_calib_folder,
                   ro_durations[1])

        #Here the correction for the double readout is calculation.
        p_correlations, u_p_correlations = roc.num_evaluation(self.normalized_correlations[:,:],
                self.u_normalized_correlations[:,:])

        #The output p_correlations above is tuple, we transform it to array
        #and Transpose it to retain the right shape.
        self.p_correlations = np.array(p_correlations).T
        self.u_p_correlations = np.array(u_p_correlations).T

        self.result_correlation_corrected = True
Ejemplo n.º 7
0
    def get_magnetometry_phase_calibration(self, name='',ssro_calib_folder=''):

        self.result_corrected = False
        adwingrp = self.adwingrp(name)        
        self.reps = adwingrp['completed_reps'].value-1
        RO_clicks = adwingrp['RO_data'].value
        phase = adwingrp['set_phase'].value
        times=self.g.attrs['ramsey_time']

        phase_values = np.unique(phase)
        self.ssro_results = np.zeros(len(phase_values))

        
        for j in phase_values:
            self.ssro_results [np.min(np.where(phase==j))] = np.sum(RO_clicks[np.where(phase==j)])
            
        if len(self.ssro_results)==1:
            self.sweep_pts = self.g.attrs['sweep_pts']
            phase=np.array(list(np.arange(len(self.sweep_pts)))*int((self.reps+1)/float(len(self.sweep_pts))))
       
            phase_values = np.unique(phase)
            self.ssro_results = np.zeros(len(phase_values))
            
            for j in phase_values:

                self.ssro_results [np.min(np.where(phase==j))] = np.sum(RO_clicks[np.where(phase==j)])

        #self.sweep_pts = times
        #print 'len phases',len(phases)
        #print phases
        #print phase_values

        self.normalized_ssro = self.ssro_results*len(self.ssro_results)/(float(self.reps))
        self.u_normalized_ssro = (self.normalized_ssro*(1.-self.normalized_ssro)/(float(self.reps)))**0.5  #this is quite ugly, maybe replace?

        
        if ssro_calib_folder == '':
                ssro_calib_folder = toolbox.latest_data('SSROCalibration')
                print ssro_calib_folder
        self.p0 = self.normalized_ssro
        self.u_p0 = self.u_normalized_ssro
        
        ro_duration = self.g.attrs['SSRO_duration']
        roc = error.SingleQubitROC()
        roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
            ssro.get_SSRO_calibration(ssro_calib_folder, 
                    ro_duration)
        p0, u_p0 = roc.num_eval(self.normalized_ssro,
                self.u_normalized_ssro)
            
        self.p0 = p0
        self.u_p0 = u_p0
        
        self.result_corrected = True
        return self.p0,self.u_p0
Ejemplo n.º 8
0
    def find_RO_fidelities(self, timestamp, raw_data, folder=''):

        ssro_folder = tb.data_from_time(timestamp, folder=folder)

        if 'MWInit' in ssro_folder:
            F_0, u_F0, F_1, u_F1 = ssro.get_SSRO_MWInit_calibration(
                ssro_folder, raw_data.g.attrs['E_RO_durations'][0],
                raw_data.g.attrs['electron_transition'])
        else:
            F_0, u_F0, F_1, u_F1 = ssro.get_SSRO_calibration(
                ssro_folder, raw_data.g.attrs['E_RO_durations'][0])

        return F_0, F_1
Ejemplo n.º 9
0
 def get_electron_ROC(self, **kw):
     ssro_calib_folder = kw.pop('ssro_calib_folder', toolbox.latest_data('SSROCalibration'))
             
     self.p0 = np.zeros(self.normalized_ssro.shape)
     self.u_p0 = np.zeros(self.normalized_ssro.shape)
     
     ro_duration = self.g.attrs['SSRO_duration']
     roc = error.SingleQubitROC()
     roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
         ssro.get_SSRO_calibration(ssro_calib_folder, 
                 ro_duration)
     p0, u_p0 = roc.num_eval(self.normalized_ssro,
             self.u_normalized_ssro)
         
     self.p0 = p0
     self.u_p0 = u_p0
     
     self.result_corrected = True
Ejemplo n.º 10
0
    def get_electron_ROC(self, ssro_calib_folder=''):
        if ssro_calib_folder == '':
            ssro_calib_folder = toolbox.latest_data('SSRO')

        self.p0 = np.zeros(self.normalized_ssro.shape)
        self.u_p0 = np.zeros(self.normalized_ssro.shape)

        ro_durations = self.g.attrs['E_RO_durations']
        roc = error.SingleQubitROC()

        # Decide between ssro calib via MW Initialisation or some other method
        # At the time of writing only MWInit and full las0r SSRO exist ~SK 2016
        if 'MWInit' in ssro_calib_folder:
            el_state = self.adgrp.attrs['electron_transition']
            # print 'MWInit, el_state: ' + str(el_state)

            for i in range(len(self.normalized_ssro[0])):
                roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                    ssro.get_SSRO_MWInit_calibration(ssro_calib_folder,
                            ro_durations[i],el_state)

                p0, u_p0 = roc.num_eval(self.normalized_ssro[:,i],
                        self.u_normalized_ssro[:,i])

                self.p0[:,i] = p0
                self.u_p0[:,i] = u_p0


        else:
            for i in range(len(self.normalized_ssro[0])):
                roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                    ssro.get_SSRO_calibration(ssro_calib_folder,
                            ro_durations[i])

                p0, u_p0 = roc.num_eval(self.normalized_ssro[:,i],
                        self.u_normalized_ssro[:,i])

                self.p0[:,i] = p0
                self.u_p0[:,i] = u_p0



        self.result_corrected = True
Ejemplo n.º 11
0
    def get_electron_ROC(self, ssro_calib_folder='',**kw):
        if ssro_calib_folder == '':
            ssro_calib_folder = toolbox.latest_data('SSROCalibration', **kw)

        self.p0 = np.zeros(self.normalized_ssro.shape)
        self.u_p0 = np.zeros(self.normalized_ssro.shape)

        ro_durations = self.g.attrs['E_RO_durations']
        roc = error.SingleQubitROC()

        # Decide between ssro calib via MW Initialisation or some other method
        # At the time of writing only MWInit and full las0r SSRO exist ~SK 2016
        if 'MWInit' in ssro_calib_folder:
            el_state = self.adgrp.attrs['electron_transition']
            # print 'MWInit, el_state: ' + str(el_state)

            for i in range(len(self.normalized_ssro[0])):
                roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                    ssro.get_SSRO_MWInit_calibration(ssro_calib_folder,
                            ro_durations[i],el_state)

                p0, u_p0 = roc.num_eval(self.normalized_ssro[:,i],
                        self.u_normalized_ssro[:,i])

                self.p0[:,i] = p0
                self.u_p0[:,i] = u_p0


        else:
            for i in range(len(self.normalized_ssro[0])):
                roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                    ssro.get_SSRO_calibration(ssro_calib_folder,
                            ro_durations[i])

                p0, u_p0 = roc.num_eval(self.normalized_ssro[:,i],
                        self.u_normalized_ssro[:,i])

                self.p0[:,i] = p0
                self.u_p0[:,i] = u_p0


        self.result_corrected = True
Ejemplo n.º 12
0
    def get_electron_ROC(self, ssro_calib_folder=''):
        if ssro_calib_folder == '':
            ssro_calib_folder = toolbox.latest_data('SSRO')

        self.p0 = np.zeros(self.normalized_ssro.shape)
        self.u_p0 = np.zeros(self.normalized_ssro.shape)
        
        ro_durations = self.g.attrs['E_RO_durations']
        roc = error.SingleQubitROC()

        for i in range(len(self.normalized_ssro[0])):
            roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                ssro.get_SSRO_calibration(ssro_calib_folder, 
                        ro_durations[i])
            p0, u_p0 = roc.num_eval(self.normalized_ssro[:,i],
                    self.u_normalized_ssro[:,i])
            
            self.p0[:,i] = p0
            self.u_p0[:,i] = u_p0
        
        self.result_corrected = True
Ejemplo n.º 13
0
    def get_electron_ROC(self, **kw):
        ssro_calib_folder = kw.pop('ssro_calib_folder', toolbox.latest_data('SSRO'))
        # print ssro_calib_folder
        if ssro_calib_folder == '':
                ssro_calib_folder = toolbox.latest_data('SSRO')


        self.p0 = np.zeros(self.normalized_ssro.shape)
        self.u_p0 = np.zeros(self.normalized_ssro.shape)

        ro_duration = self.g.attrs['SSRO_duration']
        roc = error.SingleQubitROC()

        # Decide between ssro calib via MW Initialisation or some other method
        # At the time of writing only MWInit and full las0r SSRO exist ~SK 2016
        if 'MWInit' in ssro_calib_folder:
            el_state = self.adgrp.attrs['electron_transition']
            # print 'MWInit, el_state: ' + str(el_state)
       
            roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                ssro.get_SSRO_MWInit_calibration(ssro_calib_folder,
                        ro_duration,el_state)

        else:
            roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                ssro.get_SSRO_calibration(ssro_calib_folder,
                        ro_duration)

        p0, u_p0 = roc.num_eval(self.normalized_ssro,
                self.u_normalized_ssro)

        self.p0 = p0
        self.u_p0 = u_p0



        self.result_corrected = True
Ejemplo n.º 14
0
    def get_electron_ROC(self, ssro_calib_folder='',post_select_QEC = False, post_select_multiple_rounds = False, post_select_GHZ = False,post_select = True):
        '''
        Performs Readout Correction, needs to be updated to correct for post selected results and apply error-bars correctly.
        '''
        
        if post_select_QEC == True and self.post_select == True:
            if ssro_calib_folder == '':
                ssro_calib_folder = toolbox.latest_data('SSRO')

            self.p0_00 = np.zeros(self.normalized_ssro_00.shape)
            self.u_p0_00 = np.zeros(self.normalized_ssro_00.shape)
            self.p0_01 = np.zeros(self.normalized_ssro_01.shape)
            self.u_p0_01 = np.zeros(self.normalized_ssro_01.shape)
            self.p0_10 = np.zeros(self.normalized_ssro_10.shape)
            self.u_p0_10 = np.zeros(self.normalized_ssro_10.shape)
            self.p0_11 = np.zeros(self.normalized_ssro_11.shape)
            self.u_p0_11 = np.zeros(self.normalized_ssro_11.shape)
            
            ro_durations = self.g.attrs['E_RO_durations']

            roc = error.SingleQubitROC()

            for i in range(len(self.normalized_ssro_00[0])):
                roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                    ssro.get_SSRO_calibration(ssro_calib_folder,
                            ro_durations[i])
                p0_00, u_p0_00 = roc.num_eval(self.normalized_ssro_00[:,i],
                        self.u_normalized_ssro_00[:,i])
                p0_01, u_p0_01 = roc.num_eval(self.normalized_ssro_01[:,i],
                        self.u_normalized_ssro_01[:,i])
                p0_10, u_p0_10 = roc.num_eval(self.normalized_ssro_10[:,i],
                        self.u_normalized_ssro_10[:,i])
                p0_11, u_p0_11 = roc.num_eval(self.normalized_ssro_11[:,i],
                        self.u_normalized_ssro_11[:,i])

                self.p0_00[:,i] = p0_00
                self.u_p0_00[:,i] = u_p0_00
                self.p0_01[:,i] = p0_01
                self.u_p0_01[:,i] = u_p0_01
                self.p0_10[:,i] = p0_10
                self.u_p0_10[:,i] = u_p0_10
                self.p0_11[:,i] = p0_11
                self.u_p0_11[:,i] = u_p0_11

        elif post_select_multiple_rounds == True and self.post_select == True:
              
            if ssro_calib_folder == '':
                ssro_calib_folder = toolbox.latest_data('SSRO')

            self.p0_0000   = np.zeros(self.normalized_ssro_0000.shape)
            self.u_p0_0000 =  np.zeros(self.normalized_ssro_0000.shape)
            self.p0_0100   = np.zeros(self.normalized_ssro_0100.shape)
            self.u_p0_0100 =  np.zeros(self.normalized_ssro_0100.shape)
            self.p0_1000   = np.zeros(self.normalized_ssro_1000.shape)
            self.u_p0_1000 =  np.zeros(self.normalized_ssro_1000.shape)
            self.p0_1100   = np.zeros(self.normalized_ssro_1100.shape)
            self.u_p0_1100 =  np.zeros(self.normalized_ssro_1100.shape)

            self.p0_0010   = np.zeros(self.normalized_ssro_0010.shape)
            self.u_p0_0010 =  np.zeros(self.normalized_ssro_0010.shape)
            self.p0_0110   = np.zeros(self.normalized_ssro_0110.shape)
            self.u_p0_0110 =  np.zeros(self.normalized_ssro_0110.shape)
            self.p0_1010   = np.zeros(self.normalized_ssro_1010.shape)
            self.u_p0_1010 =  np.zeros(self.normalized_ssro_1010.shape)
            self.p0_1110   = np.zeros(self.normalized_ssro_1110.shape)
            self.u_p0_1110 =  np.zeros(self.normalized_ssro_1110.shape)

            self.p0_0001   = np.zeros(self.normalized_ssro_0001.shape)
            self.u_p0_0001 =  np.zeros(self.normalized_ssro_0001.shape)
            self.p0_0101   = np.zeros(self.normalized_ssro_0101.shape)
            self.u_p0_0101 =  np.zeros(self.normalized_ssro_0101.shape)
            self.p0_1001   = np.zeros(self.normalized_ssro_1001.shape)
            self.u_p0_1001 =  np.zeros(self.normalized_ssro_1001.shape)
            self.p0_1101   = np.zeros(self.normalized_ssro_1101.shape)
            self.u_p0_1101 =  np.zeros(self.normalized_ssro_1101.shape)

            self.p0_0011   = np.zeros(self.normalized_ssro_0011.shape)
            self.u_p0_0011 =  np.zeros(self.normalized_ssro_0011.shape)
            self.p0_0111   = np.zeros(self.normalized_ssro_0111.shape)
            self.u_p0_0111 =  np.zeros(self.normalized_ssro_0111.shape)
            self.p0_1011   = np.zeros(self.normalized_ssro_1011.shape)
            self.u_p0_1011 =  np.zeros(self.normalized_ssro_1011.shape)
            self.p0_1111   = np.zeros(self.normalized_ssro_1111.shape)
            self.u_p0_1111 =  np.zeros(self.normalized_ssro_1111.shape)
            
            ro_durations = self.g.attrs['E_RO_durations']

            roc = error.SingleQubitROC()

            for i in range(len(self.normalized_ssro_0000[0])):
                roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                    ssro.get_SSRO_calibration(ssro_calib_folder,
                            ro_durations[i])
                p0_0000, u_p0_0000 = roc.num_eval(self.normalized_ssro_0000[:,i],
                        self.u_normalized_ssro_0000[:,i])
                p0_0100, u_p0_0100 = roc.num_eval(self.normalized_ssro_0100[:,i],
                        self.u_normalized_ssro_0100[:,i])
                p0_1000, u_p0_1000 = roc.num_eval(self.normalized_ssro_1000[:,i],
                        self.u_normalized_ssro_1000[:,i])
                p0_1100, u_p0_1100 = roc.num_eval(self.normalized_ssro_1100[:,i],
                        self.u_normalized_ssro_1100[:,i])

                p0_0010, u_p0_0010 = roc.num_eval(self.normalized_ssro_0010[:,i],
                        self.u_normalized_ssro_0010[:,i])
                p0_0110, u_p0_0110 = roc.num_eval(self.normalized_ssro_0110[:,i],
                        self.u_normalized_ssro_0110[:,i])
                p0_1010, u_p0_1010 = roc.num_eval(self.normalized_ssro_1010[:,i],
                        self.u_normalized_ssro_1010[:,i])
                p0_1110, u_p0_1110 = roc.num_eval(self.normalized_ssro_1110[:,i],
                        self.u_normalized_ssro_1110[:,i])

                p0_0001, u_p0_0001 = roc.num_eval(self.normalized_ssro_0001[:,i],
                        self.u_normalized_ssro_0001[:,i])
                p0_0101, u_p0_0101 = roc.num_eval(self.normalized_ssro_0101[:,i],
                        self.u_normalized_ssro_0101[:,i])
                p0_1001, u_p0_1001 = roc.num_eval(self.normalized_ssro_1001[:,i],
                        self.u_normalized_ssro_1001[:,i])
                p0_1101, u_p0_1101 = roc.num_eval(self.normalized_ssro_1101[:,i],
                        self.u_normalized_ssro_1101[:,i])

                p0_0011, u_p0_0011 = roc.num_eval(self.normalized_ssro_0011[:,i],
                        self.u_normalized_ssro_0011[:,i])
                p0_0111, u_p0_0111 = roc.num_eval(self.normalized_ssro_0111[:,i],
                        self.u_normalized_ssro_0111[:,i])
                p0_1011, u_p0_1011 = roc.num_eval(self.normalized_ssro_1011[:,i],
                        self.u_normalized_ssro_1011[:,i])
                p0_1111, u_p0_1111 = roc.num_eval(self.normalized_ssro_1111[:,i],
                        self.u_normalized_ssro_1111[:,i])

                self.p0_0000[:,i]   = p0_0000
                self.u_p0_0000[:,i] = u_p0_0000
                self.p0_0100[:,i]   = p0_0100
                self.u_p0_0100[:,i] = u_p0_0100
                self.p0_1000[:,i]   = p0_1000
                self.u_p0_1000[:,i] = u_p0_1000
                self.p0_1100[:,i]   = p0_1100
                self.u_p0_1100[:,i] = u_p0_1100

                self.p0_0010[:,i]   = p0_0010
                self.u_p0_0010[:,i] = u_p0_0010
                self.p0_0110[:,i]   = p0_0110
                self.u_p0_0110[:,i] = u_p0_0110
                self.p0_1010[:,i]   = p0_1010
                self.u_p0_1010[:,i] = u_p0_1010
                self.p0_1110[:,i]   = p0_1110
                self.u_p0_1110[:,i] = u_p0_1110

                self.p0_0001[:,i]   = p0_0001
                self.u_p0_0001[:,i] = u_p0_0001
                self.p0_0101[:,i]   = p0_0101
                self.u_p0_0101[:,i] = u_p0_0101
                self.p0_1001[:,i]   = p0_1001
                self.u_p0_1001[:,i] = u_p0_1001
                self.p0_1101[:,i]   = p0_1101
                self.u_p0_1101[:,i] = u_p0_1101

                self.p0_0011[:,i]   = p0_0011
                self.u_p0_0011[:,i] = u_p0_0011
                self.p0_0111[:,i]   = p0_0111
                self.u_p0_0111[:,i] = u_p0_0111
                self.p0_1011[:,i]   = p0_1011
                self.u_p0_1011[:,i] = u_p0_1011
                self.p0_1111[:,i]   = p0_1111
                self.u_p0_1111[:,i] = u_p0_1111

        elif post_select_GHZ == True and self.post_select==True:
            if ssro_calib_folder == '':
                ssro_calib_folder = toolbox.latest_data('SSRO')
            
            self.p0_000 = np.zeros(self.normalized_ssro_000.shape)
            self.u_p0_000 = np.zeros(self.normalized_ssro_000.shape)
            self.p0_001 = np.zeros(self.normalized_ssro_001.shape)
            self.u_p0_001 = np.zeros(self.normalized_ssro_001.shape)
            self.p0_010 = np.zeros(self.normalized_ssro_010.shape)
            self.u_p0_010 = np.zeros(self.normalized_ssro_010.shape)
            self.p0_011 = np.zeros(self.normalized_ssro_011.shape)
            self.u_p0_011 = np.zeros(self.normalized_ssro_011.shape)
            self.p0_100 = np.zeros(self.normalized_ssro_100.shape)
            self.u_p0_100 = np.zeros(self.normalized_ssro_100.shape)
            self.p0_101 = np.zeros(self.normalized_ssro_101.shape)
            self.u_p0_101 = np.zeros(self.normalized_ssro_101.shape)
            self.p0_110 = np.zeros(self.normalized_ssro_110.shape)
            self.u_p0_110 = np.zeros(self.normalized_ssro_110.shape)
            self.p0_111 = np.zeros(self.normalized_ssro_111.shape)
            self.u_p0_111 = np.zeros(self.normalized_ssro_111.shape)
            
            ro_durations = self.g.attrs['E_RO_durations']

            roc = error.SingleQubitROC()

            for i in range(len(self.normalized_ssro_000[0])):
                roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                    ssro.get_SSRO_calibration(ssro_calib_folder,
                            ro_durations[i])
                p0_000, u_p0_000 = roc.num_eval(self.normalized_ssro_000[:,i],
                        self.u_normalized_ssro_000[:,i])
                p0_001, u_p0_001 = roc.num_eval(self.normalized_ssro_001[:,i],
                        self.u_normalized_ssro_001[:,i])
                p0_010, u_p0_010 = roc.num_eval(self.normalized_ssro_010[:,i],
                        self.u_normalized_ssro_010[:,i])
                p0_011, u_p0_011 = roc.num_eval(self.normalized_ssro_011[:,i],
                        self.u_normalized_ssro_011[:,i])
                p0_100, u_p0_100 = roc.num_eval(self.normalized_ssro_100[:,i],
                        self.u_normalized_ssro_100[:,i])
                p0_101, u_p0_101 = roc.num_eval(self.normalized_ssro_101[:,i],
                        self.u_normalized_ssro_101[:,i])
                p0_110, u_p0_110 = roc.num_eval(self.normalized_ssro_110[:,i],
                        self.u_normalized_ssro_110[:,i])
                p0_111, u_p0_111 = roc.num_eval(self.normalized_ssro_111[:,i],
                        self.u_normalized_ssro_111[:,i])

                self.p0_000[:,i]   = p0_000
                self.u_p0_000[:,i]   = u_p0_000
                self.p0_001[:,i]   = p0_001
                self.u_p0_001[:,i]   = u_p0_001
                self.p0_010[:,i]   = p0_010
                self.u_p0_010[:,i]   = u_p0_010
                self.p0_011[:,i]   = p0_011
                self.u_p0_011[:,i]   = u_p0_011
                self.p0_100[:,i]   = p0_100
                self.u_p0_100[:,i]   = u_p0_100
                self.p0_101[:,i]   = p0_101
                self.u_p0_101[:,i]   = u_p0_101
                self.p0_110[:,i]   = p0_110
                self.u_p0_110[:,i]   = u_p0_110
                self.p0_111[:,i]   = p0_111
                self.u_p0_111[:,i]   = u_p0_111

            self.result_corrected = True

        elif self.post_select == True:
            if ssro_calib_folder == '':
                ssro_calib_folder = toolbox.latest_data('SSRO')

            self.p0_0 = np.zeros(self.normalized_ssro_0.shape)
            self.u_p0_0 = np.zeros(self.normalized_ssro_0.shape)
            self.p0_1 = np.zeros(self.normalized_ssro_1.shape)
            self.u_p0_1 = np.zeros(self.normalized_ssro_1.shape)
            ro_durations = self.g.attrs['E_RO_durations']

            roc = error.SingleQubitROC()

            for i in range(len(self.normalized_ssro_0[0])):
                roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
                    ssro.get_SSRO_calibration(ssro_calib_folder,
                            ro_durations[i])
                p0_0, u_p0_0 = roc.num_eval(self.normalized_ssro_0[:,i],
                        self.u_normalized_ssro_0[:,i])
                p0_1, u_p0_1 = roc.num_eval(self.normalized_ssro_1[:,i],
                        self.u_normalized_ssro_1[:,i])

                self.p0_0[:,i] = p0_0
                self.u_p0_0[:,i] = u_p0_0
                self.p0_1[:,i] = p0_1
                self.u_p0_1[:,i] = u_p0_1

            self.result_corrected = True
        


            self.result_corrected = True
        else:
            mbi.MBIAnalysis.get_electron_ROC(self,ssro_calib_folder)  #NOTE: super cannot be used as this is an "old style class"
Ejemplo n.º 15
0
    def get_magnetometry_phase_calibration(self,
                                           name='',
                                           ssro_calib_folder=''):

        self.result_corrected = False
        adwingrp = self.adwingrp(name)
        self.reps = adwingrp['completed_reps'].value - 1
        RO_clicks = adwingrp['RO_data'].value
        phase = adwingrp['set_phase'].value
        times = self.g.attrs['ramsey_time']

        phase_values = np.unique(phase)
        self.ssro_results = np.zeros(len(phase_values))

        for j in phase_values:
            self.ssro_results[np.min(np.where(phase == j))] = np.sum(
                RO_clicks[np.where(phase == j)])

        if len(self.ssro_results) == 1:
            self.sweep_pts = self.g.attrs['sweep_pts']
            phase = np.array(
                list(np.arange(len(self.sweep_pts))) * int(
                    (self.reps + 1) / float(len(self.sweep_pts))))

            phase_values = np.unique(phase)
            self.ssro_results = np.zeros(len(phase_values))

            for j in phase_values:

                self.ssro_results[np.min(np.where(phase == j))] = np.sum(
                    RO_clicks[np.where(phase == j)])

        #self.sweep_pts = times
        #print 'len phases',len(phases)
        #print phases
        #print phase_values

        self.normalized_ssro = self.ssro_results * len(
            self.ssro_results) / (float(self.reps))
        self.u_normalized_ssro = (
            self.normalized_ssro * (1. - self.normalized_ssro) /
            (float(self.reps)))**0.5  #this is quite ugly, maybe replace?

        if ssro_calib_folder == '':
            ssro_calib_folder = toolbox.latest_data('SSROCalibration')
            print ssro_calib_folder
        self.p0 = self.normalized_ssro
        self.u_p0 = self.u_normalized_ssro

        ro_duration = self.g.attrs['SSRO_duration']
        roc = error.SingleQubitROC()
        roc.F0, roc.u_F0, roc.F1, roc.u_F1 = \
            ssro.get_SSRO_calibration(ssro_calib_folder,
                    ro_duration)
        p0, u_p0 = roc.num_eval(self.normalized_ssro, self.u_normalized_ssro)

        self.p0 = p0
        self.u_p0 = u_p0

        self.result_corrected = True
        return self.p0, self.u_p0