Пример #1
0
def get_shots_zero_one(data,
                       post_select: bool = False,
                       nr_samples: int = 2,
                       sample_0: int = 0,
                       sample_1: int = 1,
                       post_select_threshold: float = None):
    if not post_select:
        shots_0, shots_1 = a_tools.zigzag(data, sample_0, sample_1, nr_samples)
    else:
        presel_0, presel_1 = a_tools.zigzag(data, sample_0, sample_1,
                                            nr_samples)

        shots_0, shots_1 = a_tools.zigzag(data, sample_0 + 1, sample_1 + 1,
                                          nr_samples)

    if post_select:
        post_select_shots_0 = data[0::nr_samples]
        shots_0 = data[1::nr_samples]

        post_select_shots_1 = data[nr_samples // 2::nr_samples]
        shots_1 = data[nr_samples // 2 + 1::nr_samples]

        # Determine shots to remove
        post_select_indices_0 = dm_tools.get_post_select_indices(
            thresholds=[post_select_threshold],
            init_measurements=[post_select_shots_0])

        post_select_indices_1 = dm_tools.get_post_select_indices(
            thresholds=[post_select_threshold],
            init_measurements=[post_select_shots_1])

        shots_0[post_select_indices_0] = np.nan
        shots_0 = shots_0[~np.isnan(shots_0)]

        shots_1[post_select_indices_1] = np.nan
        shots_1 = shots_1[~np.isnan(shots_1)]

    return shots_0, shots_1
Пример #2
0
    def process_data(self):

        # Shorthand reference to proc_data_dict to keep code more readable
        dat_dict = self.proc_data_dict

        ch_idx_anc = self.options_dict.get('ch_idx_anc', 0)
        ch_idx_data = self.options_dict.get('ch_idx_data', 1)
        nr_of_meas = self.options_dict.get('nr_of_meas', 5)
        post_sel_th_anc = self.options_dict.get('post_sel_th_anc', 0)
        post_sel_th_data = self.options_dict.get('post_sel_th_data', 0)

        dig_th_anc = self.options_dict.get('dig_th_anc', post_sel_th_anc)
        dig_th_data = self.options_dict.get('dig_th_anc', post_sel_th_data)

        post_select = self.options_dict.get('post_select', True)

        nr_bins = self.options_dict.get('nr_bins', 100)

        shots_anc = list(self.raw_data_dict['measured_values_ord_dict'].values())\
            [ch_idx_anc][0]
        shots_data = list(self.raw_data_dict['measured_values_ord_dict'].values())\
            [ch_idx_data][0]

        dat_dict['shots_anc'] = shots_anc
        dat_dict['shots_data'] = shots_data

        # Data binning
        (prep_0_anc, meas_0_anc, trace_0_anc, prep_1_anc, meas_1_anc,
         trace_1_anc) = repeated_parity_data_binning(dat_dict['shots_anc'],
                                                     nr_of_meas)
        (prep_0_data, meas_0_data, trace_0_data, prep_1_data, meas_1_data,
         trace_1_data) = repeated_parity_data_binning(dat_dict['shots_data'],
                                                      nr_of_meas)

        dat_dict['trace_0_anc'] = trace_0_anc
        # Digitizing traces
        dat_dict['trace_0_anc_dig'] = dm_tools.digitize(trace_0_anc,
                                                        dig_th_anc,
                                                        zero_state=0)
        dat_dict['trace_0_data_dig'] = dm_tools.digitize(trace_0_data,
                                                         dig_th_data,
                                                         zero_state=0)
        dat_dict['trace_1_anc_dig'] = dm_tools.digitize(trace_1_anc,
                                                        dig_th_anc,
                                                        zero_state=0)
        dat_dict['trace_1_data_dig'] = dm_tools.digitize(trace_1_data,
                                                         dig_th_data,
                                                         zero_state=0)

        # post selection
        if post_select:
            dat_dict['post_sel_idx_0'] = dm_tools.get_post_select_indices(
                (post_sel_th_anc, post_sel_th_data), (prep_0_anc, prep_0_data))
            dat_dict['post_sel_idx_1'] = dm_tools.get_post_select_indices(
                (post_sel_th_anc, post_sel_th_data), (prep_1_anc, prep_1_data))

            for arr in [meas_0_anc, meas_0_data, trace_0_anc, trace_0_data]:
                arr[dat_dict['post_sel_idx_0']] = np.nan
            for arr in [meas_1_anc, meas_1_data, trace_1_anc, trace_1_data]:
                arr[dat_dict['post_sel_idx_1']] = np.nan

        # Counting the rounds to event
        dat_dict['RTE_0'] = count_RTE(dat_dict['trace_0_anc_dig'],
                                      exp_pattern='alternating',
                                      init_state=0)
        dat_dict['RTE_1'] = count_RTE(dat_dict['trace_1_anc_dig'],
                                      exp_pattern='constant',
                                      init_state=0)

        dat_dict['RTE_0_ps'] = copy(dat_dict['RTE_0'])
        dat_dict['RTE_0_ps'][dat_dict['post_sel_idx_0']] = np.nan
        dat_dict['RTE_1_ps'] = copy(dat_dict['RTE_1'])
        dat_dict['RTE_1_ps'][dat_dict['post_sel_idx_1']] = np.nan

        dat_dict['mRTE_0_ps'] = np.nanmean(dat_dict['RTE_0_ps'])
        dat_dict['mRTE_1_ps'] = np.nanmean(dat_dict['RTE_1_ps'])

        # Histogramming
        dat_dict['prep_0_anc_hist'] = np.histogram(prep_0_anc,
                                                   bins=nr_bins,
                                                   range=(np.min(shots_anc),
                                                          np.max(shots_anc)))
        dat_dict['prep_1_anc_hist'] = np.histogram(prep_1_anc,
                                                   bins=nr_bins,
                                                   range=(np.min(shots_anc),
                                                          np.max(shots_anc)))

        dat_dict['meas_0_anc_hist'] = np.histogram(meas_0_anc,
                                                   bins=nr_bins,
                                                   range=(np.min(shots_anc),
                                                          np.max(shots_anc)))
        dat_dict['meas_1_anc_hist'] = np.histogram(meas_1_anc,
                                                   bins=nr_bins,
                                                   range=(np.min(shots_anc),
                                                          np.max(shots_anc)))

        dat_dict['prep_0_data_hist'] = np.histogram(prep_0_data,
                                                    bins=nr_bins,
                                                    range=(np.min(shots_data),
                                                           np.max(shots_data)))
        dat_dict['prep_1_data_hist'] = np.histogram(prep_1_data,
                                                    bins=nr_bins,
                                                    range=(np.min(shots_data),
                                                           np.max(shots_data)))
        dat_dict['meas_0_data_hist'] = np.histogram(meas_0_data,
                                                    bins=nr_bins,
                                                    range=(np.min(shots_data),
                                                           np.max(shots_data)))
        dat_dict['meas_1_data_hist'] = np.histogram(meas_1_data,
                                                    bins=nr_bins,
                                                    range=(np.min(shots_data),
                                                           np.max(shots_data)))

        # Histogramming RTE

        dat_dict['prep_0_RTE_hist'] = np.histogram(dat_dict['RTE_0_ps'],
                                                   bins=nr_of_meas + 1,
                                                   range=(-0.5,
                                                          nr_of_meas + 0.5))
        dat_dict['prep_1_RTE_hist'] = np.histogram(dat_dict['RTE_1_ps'],
                                                   bins=nr_of_meas + 1,
                                                   range=(-0.5,
                                                          nr_of_meas + 0.5))

        F_ass_1 = np.sum(meas_1_anc < dig_th_anc) / (
            np.sum(meas_1_anc > dig_th_anc) + np.sum(meas_1_anc < dig_th_anc))
        F_ass_0 = np.sum(meas_0_anc > dig_th_anc) / (
            np.sum(meas_0_anc > dig_th_anc) + np.sum(meas_0_anc < dig_th_anc))

        F_ass_avg = 1 - (1 - F_ass_0 + 1 - F_ass_1) / 2
        self.proc_data_dict['F_ass'] = F_ass_avg