コード例 #1
0
#%% Gather the tomo set and its outcomes from the results
tomo_set = results_loaded['Tomoset']
results = results_loaded['Results']
tomo_data = an.tomo.tomography_data(results, circuit_name, tomo_set)

#%% Tomography;
B_chi = tomoself.get_pauli_basis(n)
B_choi = tomoself.get_choi_basis(n, B_chi)

if fit_method == 'wizard':
    # Fitting choi with qiskit functions 'wizard' method and mapping choi to chi
    choi = an.fit_tomodata(tomo_data, method='wizard')
    chi = tomoself.choi_to_chi(choi, B_choi, n)
elif fit_method == 'leastsq':
    # Fitting choi with qiskit functions 'leastsq' method and mapping choi to chi
    choi = an.fit_tomodata(tomo_data, method='leastsq')
    choi = an.make_CP(choi, n)
    chi = tomoself.choi_to_chi(choi, B_choi, n)
elif fit_method == 'own':
    # Fitting choi with own functions and mapping chi
    chi = an.fit_chi_own(tomo_data, tomo_set, n)
    chi = an.make_CP(chi, n)
#%% Calculate B_filter
Bfilter = None
if calcBfilter:
    Bfilter = an.get_measfiltermat(chi, B_chi, n)
#%% Save to file
store.save_chi_meas(chi, timestamp, Bfilter)
store.save_chi_meas_last(chi, Bfilter)
コード例 #2
0
if fit_method == 'wizard':
    # Fitting choi with qiskit functions 'wizard' method and mapping choi to chi
    choi = an.fit_tomodata(
        tomo_data, method='wizard')  # The wizard method makes chi CP itself
    chi = tomoself.choi_to_chi(choi, B_choi,
                               n)  # The chi matrix is needed, not the Choi
elif fit_method == 'leastsq':
    # Fitting choi with qiskit functions 'leastsq' method and mapping choi to chi
    choi = an.fit_tomodata(tomo_data, method='leastsq')
    choi = an.make_CP(
        choi, n
    )  # The leastsq method does not provide CP, so it still has to be done
    chi = tomoself.choi_to_chi(choi, B_choi,
                               n)  # The chi matrix is needed, not the Choi
elif fit_method == 'own':
    # Fitting choi with own functions and mapping chi
    chi = an.fit_chi_own(tomo_data, tomo_set, n)
    chi = an.make_CP(
        chi,
        n)  # My own method does not provide CP, so it still has to be done
#%% Calculate B_filter
Bfilter = None
if calcBfilter:
    Bfilter = an.get_measfiltermat(
        chi, B_chi, n
    )  # This will take quite some time, can be done seperately after reloading the chi_meas
#%% Save to file and save to last used chi file
store.save_chi_meas(chi, timestamp, Bfilter)  # Save to file
store.save_chi_meas_last(chi, Bfilter)  # Save to 'last' file