コード例 #1
0
def get_jobids_from_file(direct,
                         circuit_name=None,
                         run_type=None,
                         timestamp=None):
    '''
    The jobids are loaded from the last saved file if direct=True.
    If not,they are loaded from the file specified by circuit name and run type and timestamp
    returns a 2-length list of the jobids and the data corresponding to the jobid stored in the pickle file.
    See Functions.Data_storage.save_jobdata() for more info of the data
    '''
    if direct == True:
        loaded_jobiddata = store.load_last()
    elif direct == False:
        if circuit_name == None:
            circuit_name = input('Circuit name: ')
        if run_type == None:
            run_type = input('Run Type: ')
        if timestamp == None:
            date = input('Date of experiment (mm_dd):')
            time = input('Time of experiment (hh_mm_ss):')
            loaded_jobiddata = store.load_jobdata(circuit_name, run_type,
                                                  date + '-' + time)
        else:
            loaded_jobiddata = store.load_jobdata(circuit_name, run_type,
                                                  timestamp)
    nr_batches = loaded_jobiddata['Batchnumber']
    jobids = [''] * nr_batches
    for job in loaded_jobiddata['Data']:
        jobids[job['batchno']] = job['Jobid']
    return [jobids, loaded_jobiddata]
コード例 #2
0
def get_tomoset_from_file(direct,
                          circuit_name=None,
                          run_type=None,
                          timestamp=None):
    if direct == True:
        loaded_jobiddata = store.load_last()
    elif direct == False:
        if circuit_name == None:
            circuit_name = input('Circuit name: ')
        if run_type == None:
            run_type = input('Run Type: ')
        if timestamp == None:
            date = input('Date of experiment (mm_dd):')
            time = input('Time of experiment (hh_mm_ss):')
            loaded_jobiddata = store.load_jobdata(circuit_name, run_type,
                                                  date + '-' + time)
        else:
            loaded_jobiddata = store.load_jobdata(circuit_name, run_type,
                                                  timestamp)
    return loaded_jobiddata['tomoset']
コード例 #3
0
def get_jobids_from_file(direct,
                         circuit_name=None,
                         run_type=None,
                         timestamp=None):
    if direct == True:
        loaded_jobiddata = store.load_last()
    elif direct == False:
        if circuit_name == None:
            circuit_name = input('Circuit name: ')
        if run_type == None:
            run_type = input('Run Type: ')
        if timestamp == None:
            date = input('Date of experiment (mm_dd):')
            time = input('Time of experiment (hh_mm_ss):')
            loaded_jobiddata = store.load_jobdata(circuit_name, run_type,
                                                  date + '-' + time)
        else:
            loaded_jobiddata = store.load_jobdata(circuit_name, run_type,
                                                  timestamp)
    nr_batches = loaded_jobiddata['Batchnumber']
    jobids = [''] * nr_batches
    for job in loaded_jobiddata['Data']:
        jobids[job['batchno']] = job['Jobid']
    return [jobids, loaded_jobiddata]
コード例 #4
0
batch_size = int(len(tomo_circuits)/nr_batches)
if len(tomo_circuits) % nr_batches != 0:
    nr_batches += 1

for i in range(nr_batches):
    run_circuits = tomo_circuits[i*batch_size:(i+1)*batch_size]
    circuit_list = []
    for cir in run_circuits:
        Q_program.get_circuit(cir).name = cir
        circuit_list.append(Q_program.get_circuit(cir))
    print('Batch %d/%d: %s' % (i+1, nr_batches, 'INITIALIZING'))
    if i == 0:
        job = execute(circuit_list, backend=backendname, shots=shots)
        jobs.append(job)
        job_data.append({'Date': job.creation_date,
                         'Jobid': job.id, 'runtype': run_type, 'batchno': i})
        print('Batch %d/%d: %s' % (i+1, nr_batches, 'SENT'))
    else:
        job = execute(circuit_list, backend=backendname, shots=shots)
        jobs.append(job)
        job_data.append({'Date': job.creation_date,
                         'Jobid': job.id, 'runtype': run_type, 'batchno': i})
        print('Batch %d/%d: %s' % (i+1, nr_batches, 'SENT'))

###############################################################################
store.save_jobids(circuit_name, job_data, tomo_set,
                  backendname, shots, nr_batches, run_type)
store.save_last(circuit_name, job_data, tomo_set,
                backendname, shots, nr_batches, run_type)
# store.save_jobs(circuit_name,run_type,backendname,jobs,tomo_set,shots)
コード例 #5
0
    job_data.append({
        'Date': job.
        creation_date,  # Put a dictionary of info of the current job in job_data
        'Jobid': job.id,
        'runtype': run_type,
        'batchno': i
    })
    print('Batch %d/%d: %s' % (i + 1, nr_batches, 'SENT')
          )  # This batch is done and the jobs are saved to job_data and jobs

###############################################################################
store.save_jobdata(
    circuit_name,
    job_data,
    tomo_set,  # Save the data of all jobs (in job_data) to file
    backendname,
    shots,
    nr_batches,
    run_type,
    Unitary)
store.save_last(
    circuit_name,
    job_data,
    tomo_set,
    backendname,  # Save also to 'last' file
    shots,
    nr_batches,
    run_type,
    Unitary)

unregister(
コード例 #6
0
import Functions.Plotting as pt
import numpy as np

#%% Specify the fitting method and loading method
fit_method = 'own'


jobs = ['11_17-17_30_34']#,'11_17-17_31_06','11_17-17_31_30','11_17-17_32_20']#,'11_17-17_32_53']
circuit_name = 'FTSWAP'

#%% Load the results from file
meas_data_all = [];
for jobc,job in enumerate(jobs):
    run_type = 's'
    timestamp = job
    results_loaded = store.load_results(circuit_name, run_type, timestamp)


    #%% Gather the tomo set from the loaded results and its outcomes from the results
    tomo_set = results_loaded['Tomoset']
    results = results_loaded['Results']
    timestamp = results_loaded['Experiment time']
    Unitary = results_loaded['Unitary']
    tomo_data = an.tomo.tomography_data(results, circuit_name, tomo_set)
    meas_data_all.append(tomo_data['data'])
    n = int(np.log2(np.shape(Unitary)[0]))

#%% Tomography; obtaining chi and choi matrices, check CP and TP
B_chi = tomoself.get_pauli_basis(n, normalise = False)
B_choi = tomoself.get_choi_basis(n, B_chi)
コード例 #7
0
@author: Jarnd
"""

#import Functions.Plotting as pt
#from Analysis.tomography_functions import get_pauli_names as paulilist
import numpy as np
import Functions.Simpleerrorfunc as sef
import Functions.Data_storage as store
import Analysis.tomography_functions as tomoself
import Analysis.Analysefunc as an
import Functions.Plotting as pt
import time
import datetime
#%%
chidict_FTSWAP = store.load_chi_last('FTSWAP')
chidict_NFTSWAP = store.load_chi_last('NFTSWAP')

chiFT = chidict_FTSWAP['chi_filtered']
chiNFT = chidict_NFTSWAP['chi_filtered']

B_chi = tomoself.get_pauli_basis(2)
B_choi = tomoself.get_choi_basis(2, B_chi)
choi_FT = tomoself.chi_to_choi(chiFT, B_choi, 2)
choi_NFT = tomoself.chi_to_choi(chiNFT, B_choi, 2)

chi_tot_meas = np.kron(chiNFT, chiFT)

Fidft_meas = an.get_chi_error(chiFT, B_chi, sef.SWAP)[0, 0] / 4
Fidnft_meas = an.get_chi_error(chiNFT, B_chi, sef.SWAP)[0, 0] / 4
Fidtot_meas = an.get_chi_error(chi_tot_meas,
コード例 #8
0
        circuit_list.append(Q_program.get_circuit(cir))
    print('Batch %d/%d: %s' % (i + 1, nr_batches, 'INITIALIZING'))
    if i == 0:
        job = execute(circuit_list, backend=backendname, shots=shots)
        jobs.append(job)
        job_data.append({
            'Date': job.creation_date,
            'Jobid': job.id,
            'runtype': run_type,
            'batchno': i
        })
        print('Batch %d/%d: %s' % (i + 1, nr_batches, 'SENT'))
    else:
        job = execute(circuit_list, backend=backendname, shots=shots)
        jobs.append(job)
        job_data.append({
            'Date': job.creation_date,
            'Jobid': job.id,
            'runtype': run_type,
            'batchno': i
        })
        print('Batch %d/%d: %s' % (i + 1, nr_batches, 'SENT'))

###############################################################################
store.save_jobdata(circuit_name, job_data, tomo_set, backendname, shots,
                   nr_batches, run_type, Unitary)
store.save_last(circuit_name, job_data, tomo_set, backendname, shots,
                nr_batches, run_type, Unitary)

unregister(provider)
コード例 #9
0
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)
コード例 #10
0
import Functions.Data_storage as store
import Analysis.Analysefunc as an
import Analysis.tomography_functions as tomoself
import Functions.Plotting as pt
import numpy as np


fit_method = 'own'
n = 2


direct = False

#%% Gather the results from file
if direct == True:
    timestamp = store.load_last()['Experiment time']
    run_type = store.load_last()['Type']
    circuit_name = store.load_last()['Circuit name']
else:
    run_type = input('Run Type is (enter as string): ')
    circuit_name = input('Circuit name is(enter as string): ')
    timestamp = None
results_loaded = store.load_results(circuit_name, run_type, timestamp)


#%% 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;
コード例 #11
0
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 22 10:59:52 2018

@author: Jarnd
"""

import Functions.Data_storage as store
import Analysis.Analysefunc as an
import Analysis.tomography_functions as tomoself
import Functions.Plotting as pt
import numpy as np

FT_chi_dict = store.load_chi_last('FTSWAP')
NFT_chi_dict = store.load_chi_last('NFTSWAP')

FT_chi_perror = FT_chi_dict['chi_perror']
NFT_chi_perror = NFT_chi_dict['chi_perror']

FT_chi_perror_stddv = FT_chi_dict['chistddv_error']
NFT_chi_perror_stddv = NFT_chi_dict['chistddv_error']

#
#FT_single_weight, FT_single_weight_stddv = an.get_single_weight(FT_chi_perror,FT_chi_perror_stddv)
#FT_multi_weight, FT_multi_weight_stddv = an.get_single_weight(FT_chi_perror,FT_chi_perror_stddv)
#NFT_single_weight, NFT_single_weight_stddv = an.get_multi_weight(NFT_chi_perror,NFT_chi_perror_stddv)
#NFT_multi_weight, NFT_multi_weight_stddv = an.get_multi_weight(NFT_chi_perror,NFT_chi_perror_stddv)

FT_ratio, FT_ratio_stddv = an.get_multi_single_ratio(FT_chi_perror,FT_chi_perror_stddv)
NFT_ratio, NFT_ratio_stddv = an.get_multi_single_ratio(NFT_chi_perror,NFT_chi_perror_stddv)
コード例 #12
0
import Functions.Data_storage as store
import Analysis.Analysis as an
import Analysis.tomography_functions as tomoself

fit_method = 'own'  # Specify the fithmethod: 'own', 'leastsq' and 'wizard'
n = 2

calcBfilter = True  # True to calculate the B_filter

#%% Gather the results from file

run_type = 'r'
circuit_name = 'Id'
timestamp = None
results_loaded = store.load_results(
    circuit_name, run_type,
    timestamp)  # Load results from Id experiment after providing date and time
timestamp = results_loaded[
    'Experiment time']  # Reload the timestamp from the results for saving the chi matrix dicitonary

#%% 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