-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_chi_meas.py
58 lines (46 loc) · 1.58 KB
/
get_chi_meas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 30 14:55:31 2018
@author: Jarnd
"""
#import sys
# sys.path.append('../')
import Functions.Data_storage as store
import Analysis.Analysis as an
import Analysis.tomography_functions as tomoself
fit_method = 'own'
n = 2
calcBfilter = True
#%% Gather the results from file
run_type = 'r'
circuit_name = 'Id'
timestamp = None
results_loaded = store.load_results(circuit_name, run_type, timestamp)
timestamp = results_loaded['Experiment time']
#%% 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)