Exemple #1
0
def succesprob_analysis(folders, folderstwo, RO_times, date, date2):
    s_heralded = []
    s_feedback = []
    us_heralded = []
    us_feedback = []
    for fn in folders:
        zdata_norm, zdata_corr = sc.plot_feedback(fn,
                                                  filename='Spin_RO',
                                                  d=date)
        s_heralded.append(zdata_norm['SN'][2])
        us_heralded.append(zdata_norm['uSN'][2])
        s_feedback.append(zdata_norm['SN'][2] +
                          (1 - zdata_norm['SN'][2]) * zdata_norm['FS'][2])
        us_feedback.append(
            np.sqrt(((1 - zdata_norm['FS'][2]) * zdata_norm['uSN'][2])**2 +
                    ((1 - zdata_norm['SN'][2]) * zdata_norm['uFS'][2])**2))
    for fn in folderstwo:
        zdata_norm, zdata_corr = sc.plot_feedback(fn,
                                                  filename='Spin_RO',
                                                  d=date2)
        s_heralded.append(zdata_norm['SN'][1])
        us_heralded.append(zdata_norm['uSN'][1])
        s_feedback.append(zdata_norm['SN'][1] +
                          (1 - zdata_norm['SN'][1]) * zdata_norm['FS'][1])
        us_feedback.append(
            np.sqrt(((1 - zdata_norm['FS'][2]) * zdata_norm['uSN'][2])**2 +
                    ((1 - zdata_norm['SN'][2]) * zdata_norm['uFS'][2])**2))
    sdata = {}
    sdata['s_heralded'] = s_heralded
    sdata['us_heralded'] = us_heralded
    sdata['s_feedback'] = s_feedback
    sdata['us_feedback'] = us_feedback
    sdata['RO_times'] = RO_times
    np.savez(os.path.join(basepath, 'Psucces'), **sdata)
Exemple #2
0
def targetstate_analysis(foldernamez,foldernamex, filename='Spin_RO',date='',RO_time=''):
    zdata_norm,zdata_corr=sc.plot_feedback(foldernamez, filename='Spin_RO',d=date)
    print RO_time
    if ((RO_time=='2us') or (RO_time=='4us') or (RO_time=='6us')): 
        xdata_norm,xdata_corr=sc.plot_feedback(foldernamex, filename='Spin_RO',d=date)
        SNfit=sc.fit_sin(xdata_norm['sweep_par'],xdata_corr['FinalRO_SN'],xdata_corr['uFinalRO_SN'])
        FSfit=sc.fit_sin(xdata_norm['sweep_par'],xdata_corr['FinalRO_FS'],xdata_corr['uFinalRO_FS'])
        allfit=sc.fit_sin(xdata_norm['sweep_par'],xdata_corr['FinalRO_All'],xdata_corr['uFinalRO_All'])
        N=(xdata_norm['SN'][2]+xdata_norm['FS'][2])
        xsucces= (xdata_norm['SN'][2]*(abs(SNfit['params'][1])*2)+
			xdata_norm['FS'][2]*(abs(FSfit['params'][1])*2))/N
	uxsucces=np.sqrt(((xdata_norm['SN'][2]*abs(SNfit['error_dict']['a'])*2)/N)**2+
	                 ((xdata_norm['FS'][2]*abs(FSfit['error_dict']['a'])*2)/N)**2)
        Sx=[abs(FSfit['params'][1])*2,abs(SNfit['params'][1])*2,xsucces]
        uSx=[FSfit['error_dict']['a']*2,SNfit['error_dict']['a']*2,uxsucces,0]
	i=2
	Sz=[zdata_corr['FinalRO_FS'][i],zdata_corr['FinalRO_SN'][i],zdata_corr['FinalRO_Succes'][i]]
    else:
	Sx=[0,0,0]
	uSx=[0,0,0]
	i=1
	Sz=[1-zdata_corr['FinalRO_FS'][i],1-zdata_corr['FinalRO_SN'][i],1-zdata_corr['FinalRO_Succes'][i]]
    if (RO_time=='15us'):	
	i=2
	Sz=[zdata_corr['FinalRO_FS'][i],zdata_corr['FinalRO_SN'][i],zdata_corr['FinalRO_Succes'][i]]


    

    Sy=[0,0,0,0]
    fdata={}
    fdata['zdata_norm']=zdata_norm
    fdata['zdata_corr']=zdata_corr
    fdata['res_FS']=[2*(1-Sz[0])-1,Sx[0],Sy[0],0]
    fdata['res_SN']=[2*(1-Sz[1])-1,Sx[1],Sy[1],0]
    fdata['res_Succes']=[2*(1-Sz[2])-1,Sx[2],Sy[2],0]
    fdata['ures_FS']=[zdata_corr['uFinalRO_FS'][i]*2,uSx[0],0,0]
    fdata['ures_SN']=[zdata_corr['uFinalRO_SN'][i]*2,uSx[1],0,0]
    fdata['ures_Succes']=[zdata_corr['uFinalRO_Succes'][i]*2,uSx[2],0,0]
    #fdata['SNfit']=SNfit
    #fdata['FSfit']=FSfit
    #fdata['allfit']=allfit
    meas_strength = calc_meas_strength(50,12,1400)
    fdata['meas_strength'] = meas_strength
    fdata['res_ideal']=[np.sin(meas_strength*np.pi/2.),np.cos(meas_strength*np.pi/2.),0,0]
    fdata['dm'],fdata['f'],fdata['uf'],fdata['ideal']=tls.calc_fidelity_psi(tau,(fdata['res_Succes'][0]+1)/2.,fdata['res_Succes'][1]/2.+0.5,utau,fdata['ures_Succes'][0]/2.,fdata['ures_Succes'][1],th=th,dir=dir)
    tls.make_hist(fdata['dm'][0],np.array([[0,0],[0,0]]))

    #print 'Fidelity',f,'  +-',uf
    #print 'Ideal state:', ideal
    #print 'uz: ',uzcor,'  ux: ',uxcor
    np.savez(os.path.join(basepath,name+RO_time),**fdata)
Exemple #3
0
def succesprob_analysis(folders,folderstwo,RO_times,date,date2):
    s_heralded=[]
    s_feedback=[]
    us_heralded=[]
    us_feedback=[]
    for fn in folders:
        zdata_norm,zdata_corr=sc.plot_feedback(fn, filename='Spin_RO',d=date)
        s_heralded.append(zdata_norm['SN'][2])
	us_heralded.append(zdata_norm['uSN'][2])
        s_feedback.append(zdata_norm['SN'][2]+(1-zdata_norm['SN'][2])*zdata_norm['FS'][2])
	us_feedback.append(np.sqrt(((1-zdata_norm['FS'][2])*zdata_norm['uSN'][2])**2+((1-zdata_norm['SN'][2])*zdata_norm['uFS'][2])**2))
    for fn in folderstwo:
        zdata_norm,zdata_corr=sc.plot_feedback(fn, filename='Spin_RO',d=date2)
        s_heralded.append(zdata_norm['SN'][1])
	us_heralded.append(zdata_norm['uSN'][1])
        s_feedback.append(zdata_norm['SN'][1]+(1-zdata_norm['SN'][1])*zdata_norm['FS'][1])
        us_feedback.append(np.sqrt(((1-zdata_norm['FS'][2])*zdata_norm['uSN'][2])**2+((1-zdata_norm['SN'][2])*zdata_norm['uFS'][2])**2))
    sdata={}
    sdata['s_heralded']=s_heralded
    sdata['us_heralded']=us_heralded
    sdata['s_feedback']=s_feedback
    sdata['us_feedback']=us_feedback
    sdata['RO_times']=RO_times
    np.savez(os.path.join(basepath,'Psucces'),**sdata)
def calc_meas_strength(x, t_zero, t_star):
    measstren = theta(x, t_zero, t_star) / 90.
    return measstren


def theta(tau, t_zero, t_star):
    return 90 - 2 * np.arccos(sqrt(S(tau, t_zero, t_star))) * 180. / np.pi


def S(tau, t_zero, t_star):
    return np.exp(-(tau / t_star)**2) * np.cos(np.pi / 4 - (tau + t_zero) *
                                               np.pi * .002185 / 2.)**2


data_norm, data_corr = sc.plot_feedback('172738')
y_once = data_corr['FinalRO_SN']
uy_once = data_corr['uFinalRO_SN']

y_twice = data_corr['FinalRO_FS']
uy_twice = data_corr['uFinalRO_FF']

tau = data_corr['sweep_par']

x = calc_meas_strength(tau, 12, 2400)
x_name = data_corr['sweep_par_name']

figure42 = plt.figure(42)
plt.clf()
plt.errorbar(x,
             .9 - y_once,
from analysis.lib.tools import plot
from analysis.lib.spin import spin_control as sc
from matplotlib import rc
from mpl_toolkits.mplot3d import Axes3D

def calc_meas_strength(x,t_zero,t_star):
    measstren=theta(x,t_zero,t_star)/90.
    return measstren

def theta(tau,t_zero,t_star):
    return 90-2*np.arccos(sqrt(S(tau,t_zero,t_star)))*180./np.pi

def S(tau,t_zero,t_star):
    return np.exp(-(tau/t_star)**2)*np.cos(np.pi/4-(tau+t_zero)*np.pi*.002185/2.)**2

data_norm,data_corr = sc.plot_feedback('172738')
y_once=data_corr['FinalRO_SN']
uy_once=data_corr['uFinalRO_SN']

y_twice=data_corr['FinalRO_FS']
uy_twice=data_corr['uFinalRO_FF']

tau=data_corr['sweep_par']

x=calc_meas_strength(tau,12,2400)
x_name=data_corr['sweep_par_name']

figure42=plt.figure(42)
plt.clf()
plt.errorbar(x,.9-y_once,fmt='o', yerr=uy_once,label='Collapse once',color='RoyalBlue')
plt.errorbar(x,y_twice,fmt='o', yerr=uy_twice,label='Collapse twice',color='Crimson')
Exemple #6
0
def targetstate_analysis(foldernamez,
                         foldernamex,
                         filename='Spin_RO',
                         date='',
                         RO_time=''):
    zdata_norm, zdata_corr = sc.plot_feedback(foldernamez,
                                              filename='Spin_RO',
                                              d=date)
    print RO_time
    if ((RO_time == '2us') or (RO_time == '4us') or (RO_time == '6us')):
        xdata_norm, xdata_corr = sc.plot_feedback(foldernamex,
                                                  filename='Spin_RO',
                                                  d=date)
        SNfit = sc.fit_sin(xdata_norm['sweep_par'], xdata_corr['FinalRO_SN'],
                           xdata_corr['uFinalRO_SN'])
        FSfit = sc.fit_sin(xdata_norm['sweep_par'], xdata_corr['FinalRO_FS'],
                           xdata_corr['uFinalRO_FS'])
        allfit = sc.fit_sin(xdata_norm['sweep_par'], xdata_corr['FinalRO_All'],
                            xdata_corr['uFinalRO_All'])
        N = (xdata_norm['SN'][2] + xdata_norm['FS'][2])
        xsucces = (xdata_norm['SN'][2] *
                   (abs(SNfit['params'][1]) * 2) + xdata_norm['FS'][2] *
                   (abs(FSfit['params'][1]) * 2)) / N
        uxsucces = np.sqrt(
            ((xdata_norm['SN'][2] * abs(SNfit['error_dict']['a']) * 2) /
             N)**2 +
            ((xdata_norm['FS'][2] * abs(FSfit['error_dict']['a']) * 2) / N)**2)
        Sx = [
            abs(FSfit['params'][1]) * 2,
            abs(SNfit['params'][1]) * 2, xsucces
        ]
        uSx = [
            FSfit['error_dict']['a'] * 2, SNfit['error_dict']['a'] * 2,
            uxsucces, 0
        ]
        i = 2
        Sz = [
            zdata_corr['FinalRO_FS'][i], zdata_corr['FinalRO_SN'][i],
            zdata_corr['FinalRO_Succes'][i]
        ]
    else:
        Sx = [0, 0, 0]
        uSx = [0, 0, 0]
        i = 1
        Sz = [
            1 - zdata_corr['FinalRO_FS'][i], 1 - zdata_corr['FinalRO_SN'][i],
            1 - zdata_corr['FinalRO_Succes'][i]
        ]
    if (RO_time == '15us'):
        i = 2
        Sz = [
            zdata_corr['FinalRO_FS'][i], zdata_corr['FinalRO_SN'][i],
            zdata_corr['FinalRO_Succes'][i]
        ]

    Sy = [0, 0, 0, 0]
    fdata = {}
    fdata['zdata_norm'] = zdata_norm
    fdata['zdata_corr'] = zdata_corr
    fdata['res_FS'] = [2 * (1 - Sz[0]) - 1, Sx[0], Sy[0], 0]
    fdata['res_SN'] = [2 * (1 - Sz[1]) - 1, Sx[1], Sy[1], 0]
    fdata['res_Succes'] = [2 * (1 - Sz[2]) - 1, Sx[2], Sy[2], 0]
    fdata['ures_FS'] = [zdata_corr['uFinalRO_FS'][i] * 2, uSx[0], 0, 0]
    fdata['ures_SN'] = [zdata_corr['uFinalRO_SN'][i] * 2, uSx[1], 0, 0]
    fdata['ures_Succes'] = [zdata_corr['uFinalRO_Succes'][i] * 2, uSx[2], 0, 0]
    #fdata['SNfit']=SNfit
    #fdata['FSfit']=FSfit
    #fdata['allfit']=allfit
    meas_strength = calc_meas_strength(50, 12, 1400)
    fdata['meas_strength'] = meas_strength
    fdata['res_ideal'] = [
        np.sin(meas_strength * np.pi / 2.),
        np.cos(meas_strength * np.pi / 2.), 0, 0
    ]
    fdata['dm'], fdata['f'], fdata['uf'], fdata[
        'ideal'] = tls.calc_fidelity_psi(tau,
                                         (fdata['res_Succes'][0] + 1) / 2.,
                                         fdata['res_Succes'][1] / 2. + 0.5,
                                         utau,
                                         fdata['ures_Succes'][0] / 2.,
                                         fdata['ures_Succes'][1],
                                         th=th,
                                         dir=dir)
    tls.make_hist(fdata['dm'][0], np.array([[0, 0], [0, 0]]))

    #print 'Fidelity',f,'  +-',uf
    #print 'Ideal state:', ideal
    #print 'uz: ',uzcor,'  ux: ',uxcor
    np.savez(os.path.join(basepath, name + RO_time), **fdata)