Skip to content

Commit

Permalink
Merge pull request #43 from DiCarloLab-Delft/2Q_gates_branch
Browse files Browse the repository at this point in the history
Periodic merge with master
  • Loading branch information
AdriaanRol authored Oct 6, 2016
2 parents 0d1ba53 + 19b35ed commit 828b3ae
Show file tree
Hide file tree
Showing 47 changed files with 704,331 additions and 549 deletions.
4 changes: 2 additions & 2 deletions pycqed/analysis/analysis_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ def smooth(x, window_len=11, window='hanning'):
return y[edge:-edge]


def peak_finder(x, y, percentile=70, num_sigma_threshold=5):
def peak_finder(x, y, percentile=70, num_sigma_threshold=5, window_len=11):

def cut_edges(array, window_len=11):
array = array[(window_len/2):-(window_len/2)]
Expand All @@ -856,7 +856,7 @@ def cut_edges(array, window_len=11):
'''

# Smooth the data
y_smoothed = smooth(y)
y_smoothed = smooth(y, window_len=window_len)

# Finding peaks
# Defining the threshold
Expand Down
5 changes: 5 additions & 0 deletions pycqed/analysis/fitting_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ def gaussian_2D(x, y, amplitude=1,
gaus(y, amplitude, center_y, sigma_y))
return val


def TripleExpDecayFunc(t, tau1, tau2, tau3, amp1, amp2, amp3, offset, n):
return offset+amp1*np.exp(-(t/tau1)**n)+amp2*np.exp(-(t/tau2)**n)+amp3*np.exp(-(t/tau3)**n)

####################
# Guess functions #
####################
Expand Down Expand Up @@ -353,6 +357,7 @@ def double_gauss_guess(model, data, x=None, **kwargs):
CosModel.guess = Cos_guess

ExpDecayModel = lmfit.Model(ExpDecayFunc)
TripleExpDecayModel = lmfit.Model(TripleExpDecayFunc)
ExpDecayModel.guess = exp_dec_guess
ExpDampOscModel = lmfit.Model(ExpDampOscFunc)
GaussExpDampOscModel = lmfit.Model(GaussExpDampOscFunc)
Expand Down
92 changes: 76 additions & 16 deletions pycqed/analysis/measurement_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import imp
import math
from math import erfc
from scipy.signal import argrelextrema
imp.reload(dm_tools)


Expand Down Expand Up @@ -551,7 +552,6 @@ def get_best_fit_results(self, peak=False, weighted=False):
best_fit_results = self.data_file['Analysis'][best_key]
return best_fit_results


class OptimizationAnalysis_v2(MeasurementAnalysis):
def run_default_analysis(self, close_file=True, **kw):
self.get_naming_and_values()
Expand Down Expand Up @@ -723,7 +723,6 @@ def run_default_analysis(self, close_file=True, show=False, **kw):
if close_file:
self.data_file.close()


class TD_Analysis(MeasurementAnalysis):
'''
Parent class for Time Domain (TD) analysis. Contains functions for
Expand Down Expand Up @@ -880,6 +879,60 @@ def fit_data(*kw):
'''
pass

class chevron_optimization_v1(TD_Analysis):
def __init__(self, cost_function=0, NoCalPoints=4, center_point=31, make_fig=True,
zero_coord=None, one_coord=None, cal_points=None,
plot_cal_points=True, **kw):
self.cost_function = cost_function
super(chevron_optimization_v1, self).__init__(**kw)

def run_default_analysis(self,
close_main_fig=True, **kw):
super(chevron_optimization_v1, self).run_default_analysis(**kw)
sweep_points_wocal = self.sweep_points[:-4]
measured_values_wocal = self.measured_values[0][:-4]

output_fft = np.real_if_close(np.fft.rfft(measured_values_wocal))
ax_fft = np.fft.rfftfreq(len(measured_values_wocal),
d=sweep_points_wocal[1]-sweep_points_wocal[0])
order_mask = np.argsort(ax_fft)
y = output_fft[order_mask]
y = y/np.sum(np.abs(y))

u = np.where(np.arange(len(y)) == 0, 0, y)
array_peaks = a_tools.peak_finder(np.arange(len(np.abs(y))),
np.abs(u),
window_len=0)
if array_peaks['peak_idx'] is None:
self.period = 0.
self.cost_value = 100.
else:
self.period = 1./ax_fft[order_mask][array_peaks['peak_idx']]
if self.period == np.inf:
self.period = 0.
if self.cost_function == 0:
self.cost_value = -np.abs(y[array_peaks['peak_idx']])
else:
self.cost_value = self.get_cost_value(sweep_points_wocal,
measured_values_wocal)

def get_cost_value(self, x, y):
num_periods = np.floor(x[-1]/self.period)
if num_periods == np.inf:
num_periods = 0
# sum of mins
sum_min = 0.
for i in range(int(num_periods)):
sum_min += np.interp((i+0.5)*self.period, x, y)
# print(sum_min)

# sum of maxs
sum_max = 0.
for i in range(int(num_periods)):
sum_max += 1.-np.interp(i*self.period, x, y)
# print(sum_max)

return sum_max+sum_min

class Rabi_Analysis(TD_Analysis):
def __init__(self, label='Rabi', **kw):
Expand Down Expand Up @@ -2259,12 +2312,11 @@ def NormCdfdiffDouble(x, mu0_0=mu0_0,
# print "refresh"
V_opt = optimize.brent(NormCdfdiffDouble)
F = -NormCdfdiffDouble(x=V_opt)
# print 'V_opt', V_opt
# print 'F', F
# print 'frac1_1', frac1_1
# print 'frac1_0', frac1_0
# print 'mu0', mu0,mu0_0,mu0_1
# print 'mu1', mu1,mu1_0,mu1_1

#calculating the signal-to-noise ratio
signal= abs(mu0_0-mu1_1)
noise = (sigma0_0 +sigma1_1)/2
SNR = signal/noise

#plotting s-curves
fig, ax = plt.subplots(figsize=(8, 4))
Expand Down Expand Up @@ -2304,13 +2356,12 @@ def NormCdfdiffDouble(x, mu0_0=mu0_0,

#plotting the histograms
fig, axes = plt.subplots(figsize=(8, 4))

n1, bins1, patches = pylab.hist(shots_I_1_rot, bins=int(min_len/50),
label = '1 I',histtype='step',
color='red',normed=1)
color='red', normed=True)
n0, bins0, patches = pylab.hist(shots_I_0_rot, bins=int(min_len/50),
label = '0 I',histtype='step',
color='blue',normed=1)
color='blue', normed=True)
pylab.clf()
# n0, bins0 = np.histogram(shots_I_0_rot, bins=int(min_len/50), normed=1)
# n1, bins1 = np.histogram(shots_I_1_rot, bins=int(min_len/50), normed=1)
Expand Down Expand Up @@ -2344,16 +2395,20 @@ def NormCdfdiffDouble(x, mu0_0=mu0_0,
pylab.semilogy(bins1, y1, 'r',linewidth=1.5)
pylab.semilogy(bins1, y0_1, 'r--', linewidth=3.5)
pylab.semilogy(bins1, y1_1, 'r--', linewidth=3.5)
(pylab.gca()).set_ylim(3*10e-7,10e-3)
#(pylab.gca()).set_ylim(1e-6,1e-3)
pdf_max=(max(max(y0),max(y1)))
(pylab.gca()).set_ylim(pdf_max/1000,2*pdf_max)

axes.set_title('Histograms of shots on rotaded IQ plane optimized for I, %s shots'%min_len)
plt.xlabel('DAQ voltage integrated (V)')#, fontsize=14)
plt.ylabel('Fraction of counts')#, fontsize=14)

plt.axvline(V_opt, ls='--', label=labelstring,
linewidth=2, color='grey')
plt.axvline(V_opt_corrected, ls='--', label=labelstring_corrected,

plt.axvline(V_opt, ls='--',
linewidth=2, color='grey' ,label='SNR={0:.2f}\n Fa={1:.4f}\n Fd={2:.4f}'.format(SNR, 1-(1-self.F_raw)/2, 1-(1-F_corrected)/2))
plt.axvline(V_opt_corrected, ls='--',
linewidth=2, color='black')
plt.legend()
leg2 = ax.legend(loc='best')
leg2.get_frame().set_alpha(0.5)
#plt.hist(SS_Q_data, bins=40,label = '0 Q')
Expand All @@ -2371,6 +2426,8 @@ def NormCdfdiffDouble(x, mu0_0=mu0_0,
else:
fid_grp = self.analysis_group['SSRO_Fidelity']



fid_grp.attrs.create(name='sigma0_0', data=sigma0_0)
fid_grp.attrs.create(name='sigma1_1', data=sigma1_1)
fid_grp.attrs.create(name='mu0_0', data=mu0_0)
Expand All @@ -2380,6 +2437,7 @@ def NormCdfdiffDouble(x, mu0_0=mu0_0,
fid_grp.attrs.create(name='V_opt', data=V_opt)
fid_grp.attrs.create(name='F', data=F)
fid_grp.attrs.create(name='F_corrected', data=F_corrected)
fid_grp.attrs.create(name='SNR', data=SNR)

self.sigma0_0 = sigma0_0
self.sigma1_1 = sigma1_1
Expand All @@ -2390,6 +2448,8 @@ def NormCdfdiffDouble(x, mu0_0=mu0_0,
self.V_opt = V_opt
self.F = F
self.F_corrected = F_corrected
self.SNR = SNR


class SSRO_discrimination_analysis(MeasurementAnalysis):
'''
Expand Down Expand Up @@ -3684,7 +3744,7 @@ def make_figures(self, n_cl, data_0, data_1, data_2,
bbox_transform=f.transFigure,
loc='upper right',
bbox_to_anchor=(.95, .95))
# ax.set_xscale("log", nonposx='clip')
ax.set_xscale("log", nonposx='clip')
plt.subplots_adjust(left=.1, bottom=None, right=.7, top=None)
self.save_fig(f, figname='Two_curve_RB', close_fig=close_main_fig,
fig_tight=False, **kw)
Expand Down
84 changes: 63 additions & 21 deletions pycqed/init/LaMaserati_JrJr.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@
from qcodes.instrument_drivers.tektronix import AWG520 as tk520
from qcodes.instrument_drivers.agilent.E8527D import Agilent_E8527D

from instrument_drivers.physical_instruments import QuTech_ControlBoxdriver as qcb
import instrument_drivers.meta_instrument.qubit_objects.Tektronix_driven_transmon as qbt
from instrument_drivers.meta_instrument import heterodyne as hd
import instrument_drivers.meta_instrument.CBox_LookuptableManager as lm

from instrument_drivers.meta_instrument.qubit_objects import CBox_driven_transmon as qb
from instrument_drivers.physical_instruments import QuTech_Duplexer as qdux
from pycqed.instrument_drivers.physical_instruments import QuTech_ControlBoxdriver as qcb
import pycqed.instrument_drivers.meta_instrument.qubit_objects.Tektronix_driven_transmon as qbt
from pycqed.instrument_drivers.meta_instrument import heterodyne as hd
import pycqed.instrument_drivers.meta_instrument.CBox_LookuptableManager as lm

from pycqed.instrument_drivers.meta_instrument.qubit_objects import CBox_driven_transmon as qb
from pycqed.instrument_drivers.physical_instruments import QuTech_Duplexer as qdux
from pycqed.instrument_drivers.physical_instruments.ZurichInstruments import UHFQuantumController as ZI_UHFQC
from pycqed.instrument_drivers.physical_instruments import Weinschel_8320_novisa

# Initializing instruments

Expand All @@ -94,6 +95,12 @@
station.add_component(AWG520)
IVVI = iv.IVVI('IVVI', address='COM4', numdacs=16, server_name=None)
station.add_component(IVVI)

#Initializing UHFQC
UHFQC_1 = ZI_UHFQC.UHFQC('UHFQC_1', device='dev2178', server_name=None)
station.add_component(UHFQC_1)

ATT = Weinschel_8320_novisa.Weinschel_8320(name='ATT',address='192.168.0.54', server_name=None)
# Dux = qdux.QuTech_Duplexer('Dux', address='TCPIP0::192.168.0.101',
# server_name=None)
# SH = sh.SignalHound_USB_SA124B('Signal hound', server_name=None) #commented because of 8s load time
Expand All @@ -113,39 +120,39 @@
td_source=Qubit_LO,
IVVI=IVVI, rf_RO_source=RF,
AWG=AWG,
CBox=CBox, heterodyne_instr=HS,
heterodyne_instr=HS,
MC=MC,
server_name=None)
station.add_component(AncB)
AncT = qbt.Tektronix_driven_transmon('AncT', LO=LO, cw_source=Spec_source,
td_source=Qubit_LO,
IVVI=IVVI, rf_RO_source=RF,
AWG=AWG,
CBox=CBox, heterodyne_instr=HS,
heterodyne_instr=HS,
MC=MC,
server_name=None)
station.add_component(AncT)
DataB = qbt.Tektronix_driven_transmon('DataB', LO=LO, cw_source=Spec_source,
td_source=Qubit_LO,
IVVI=IVVI, rf_RO_source=RF,
AWG=AWG,
CBox=CBox, heterodyne_instr=HS,
heterodyne_instr=HS,
MC=MC,
server_name=None)
station.add_component(DataB)
DataM = qbt.Tektronix_driven_transmon('DataM', LO=LO, cw_source=Spec_source,
td_source=Qubit_LO,
IVVI=IVVI, rf_RO_source=RF,
AWG=AWG,
CBox=CBox, heterodyne_instr=HS,
heterodyne_instr=HS,
MC=MC,
server_name=None)
station.add_component(DataM)
DataT = qbt.Tektronix_driven_transmon('DataT', LO=LO, cw_source=Spec_source,
td_source=Qubit_LO,
IVVI=IVVI, rf_RO_source=RF,
AWG=AWG,
CBox=CBox, heterodyne_instr=HS,
heterodyne_instr=HS,
MC=MC,
server_name=None)
station.add_component(DataT)
Expand All @@ -167,6 +174,7 @@
# The AWG sequencer
station.pulsar = ps.Pulsar()
station.pulsar.AWG = station.components['AWG']
marker1highs=[2,2,2.7,2]
for i in range(4):
# Note that these are default parameters and should be kept so.
# the channel offset is set in the AWG itself. For now the amplitude is
Expand All @@ -180,7 +188,7 @@
station.pulsar.define_channel(id='ch{}_marker1'.format(i+1),
name='ch{}_marker1'.format(i+1),
type='marker',
high=2.0, low=0, offset=0.,
high=marker1highs[i], low=0, offset=0.,
delay=0, active=True)
station.pulsar.define_channel(id='ch{}_marker2'.format(i+1),
name='ch{}_marker2'.format(i+1),
Expand All @@ -194,6 +202,8 @@

t1 = time.time()

#manually setting the clock, to be done automatically
AWG.clock_freq(1e9)


print('Ran initialization in %.2fs' % (t1-t0))
Expand All @@ -208,17 +218,49 @@ def all_sources_off():

def print_instr_params(instr):
snapshot = instr.snapshot()
for par in snapshot['parameters']:
for par in sorted(snapshot['parameters']):
print('{}: {} {}'.format(snapshot['parameters'][par]['name'],
snapshot['parameters'][par]['value'],
snapshot['parameters'][par]['units']))

def set_integration_weights():
trace_length = 512
tbase = np.arange(0, 5*trace_length, 5)*1e-9
cosI = np.floor(127.*np.cos(2*np.pi*AncB.get('f_RO_mod')*tbase))
sinI = np.floor(127.*np.sin(2*np.pi*AncB.get('f_RO_mod')*tbase))
CBox.sig0_integration_weights(cosI)
CBox.sig1_integration_weights(sinI)

from scripts.Experiments.FiveQubits import common_functions as cfct
cfct.set_AWG_limits(station,1.7)

q0=AncT
q1=DataT

def switch_to_pulsed_RO_CBox(qubit):
UHFQC_1.AWG_file('traditional.seqc')
qubit.RO_pulse_type('Gated_MW_RO_pulse')
qubit.RO_acq_marker_delay(175e-9)
qubit.acquisition_instr(CBox)
qubit.RO_acq_marker_channel('ch3_marker1')
qubit.RO_acq_weight_function_I(0)
qubit.RO_acq_weight_function_Q(1)

def switch_to_pulsed_RO_UHFQC(qubit):
UHFQC_1.AWG_file('traditional.seqc')
qubit.RO_pulse_type('Gated_MW_RO_pulse')
qubit.RO_acq_marker_delay(175e-9)
qubit.acquisition_instr(UHFQC_1)
qubit.RO_acq_marker_channel('ch3_marker2')
qubit.RO_acq_weight_function_I(0)
qubit.RO_acq_weight_function_Q(1)


def switch_to_IQ_mod_RO_UHFQC(qubit):
UHFQC_1.AWG_file('traditional_IQ_mod_readout.seqc')
qubit.RO_pulse_type('MW_IQmod_pulse_nontek')
qubit.RO_acq_marker_delay(-100e-9)
qubit.acquisition_instr(UHFQC_1)
qubit.RO_acq_marker_channel('ch3_marker2')
qubit.RO_I_channel('0')
qubit.RO_Q_channel('1')
qubit.RO_acq_weight_function_I(0)
qubit.RO_acq_weight_function_Q(1)

#preparing UHFQC readout with IQ mod pulses

switch_to_pulsed_RO_CBox(q0)
switch_to_pulsed_RO_CBox(q1)
5 changes: 0 additions & 5 deletions pycqed/init/LaMaserati_JrJr_Cbox3_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@
CBox.set('lin_trans_coeffs', [1, 0, 0, 1])
CBox.trigger_source('external')






LO = rs.RohdeSchwarz_SGS100A(name='LO', address='TCPIP0::192.168.0.73', server_name=None) #
station.add_component(LO)
RF = rs.RohdeSchwarz_SGS100A(name='RF', address='TCPIP0::192.168.0.74', server_name=None) #
Expand Down
Loading

0 comments on commit 828b3ae

Please sign in to comment.