Skip to content

Commit

Permalink
Current state of repo, after Data meeting
Browse files Browse the repository at this point in the history
  • Loading branch information
msamiotis committed Jun 5, 2024
1 parent 4840cbe commit 3a34e64
Show file tree
Hide file tree
Showing 5 changed files with 1,807 additions and 30 deletions.
43 changes: 33 additions & 10 deletions pycqed/analysis_v2/Two_qubit_gate_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ def __init__(self,
label: str = '',
options_dict: dict = None,
extract_only: bool = False,
auto=True):
auto=True,
flux_lm_qpark = None,
isparked: bool = False):

super().__init__(t_start=t_start,
t_stop=t_stop,
Expand All @@ -277,6 +279,8 @@ def __init__(self,
self.Poly_coefs = Poly_coefs
self.Q_freq = Q_freq
self.interaction_freqs = interaction_freqs
self.flux_lm_qpark = flux_lm_qpark
self.isparked = isparked
if auto:
self.run_analysis()

Expand Down Expand Up @@ -309,10 +313,19 @@ def process_data(self):
Detunings = P_func(Out_voltage)
# Save data
self.proc_data_dict['Out_voltage'] = Out_voltage
self.proc_data_dict['Detunings'] = Detunings
self.proc_data_dict['Detunings'] = np.real(Detunings)
self.proc_data_dict['Times'] = Times
self.proc_data_dict['Pop'] = Pop

self.proc_data_dict['park_detuning'] = None
if self.isparked:
poly = self.flux_lm_qpark.q_polycoeffs_freq_01_det()
ch_amp_park = self.flux_lm_qpark.park_amp()
sq_amp_park = self.flux_lm_qpark.sq_amp()
out_range_park = self.flux_lm_qpark.cfg_awg_channel_range()
out_voltage_park = (sq_amp_park * ch_amp_park * out_range_park) / 2
park_detuning = poly[0] * out_voltage_park ** 2 + poly[1] * out_voltage_park + poly[2]
self.proc_data_dict['park_detuning'] = park_detuning

def prepare_plots(self):
self.axs_dict = {}
fig, ax = plt.subplots(figsize=(10,4), dpi=100)
Expand All @@ -329,6 +342,8 @@ def prepare_plots(self):
'Q_freq' : self.Q_freq,
'interaction_freqs' : self.interaction_freqs,
'ts' : self.timestamp,
'isparked' : self.isparked,
'park_detuning': self.proc_data_dict['park_detuning'],
}

def run_post_extract(self):
Expand All @@ -348,7 +363,9 @@ def TLS_landscape_plotfn(
Times,
Pop,
ts,
interaction_freqs=None,
interaction_freqs = None,
isparked = None,
park_detuning = None,
**kw):
fig = ax.get_figure()
# Chevrons plot
Expand All @@ -362,9 +379,10 @@ def get_plot_axis(vals, rang=None):
Detunings = get_plot_axis(Detunings)
Times = get_plot_axis(Times)
# Frequency qubit population
vmax = min([1, np.max(Pop)])
vmax = 1 #min([1, np.max(Pop)])
vmax = max([vmax, 0.15])
im = ax.pcolormesh(Detunings*1e-6, Times*1e9, Pop, vmax=1)#vmax)
vmin = 0
im = ax.pcolormesh(Detunings*1e-6, Times*1e9, Pop, vmax=vmax, vmin = vmin)
fig.colorbar(im, ax=ax, label='Population')
# plot two-qubit gate frequencies:
if interaction_freqs:
Expand All @@ -374,14 +392,19 @@ def get_plot_axis(vals, rang=None):
ax.text(freq*1e-6, np.mean(Times)*1e9,
f'CZ {gate}', va='center', ha='right',
color='w', rotation=90)
# if isparked:
# ax.axvline(park_detuning*1e-6, color='w', ls='--')
# ax.text(park_detuning*1e-6, np.mean(Times)*1e9,
# f'parking freq', va='center', ha='right',
# color='w', rotation=90)
ax.set_xlabel(f'{Q_name} detuning (MHz)')
ax.set_ylabel('Duration (ns)')
ax.set_title(f'Population {Q_name}')
ax.set_title(f'Population {Q_name}', pad = 35)
axt0 = ax.twiny()
axt0.set_xlim((Q_freq*1e-6-np.array(ax.get_xlim()))*1e-3)
axt0.set_xlabel(f'{Q_name} Frequency (GHz)')
fig.suptitle(f'{ts}\nTLS landscape {Q_name}', y=.95)
axt0.set_xlim((Q_freq*1e-6-np.array(ax.get_xlim()))*1e-3) # removing this for the TLS
axt0.set_xlabel(f'{Q_name} Frequency (GHz)', labelpad = 4)
fig.tight_layout()
fig.suptitle(f'{ts}\nTLS landscape {Q_name}', y=1.07)


class Two_qubit_gate_tomo_Analysis(ba.BaseDataAnalysis):
Expand Down
58 changes: 52 additions & 6 deletions pycqed/analysis_v2/cryoscope_v2_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ def filter_func(t, A, tau, B):
'''
return B*(1+A*np.exp(-t/tau))


def filter_func_high_pass(t, tau, t0):
'''
Filter function implemented
Expand Down Expand Up @@ -868,17 +869,31 @@ def process_data(self):
for i, q in enumerate(self.Qubits):
Times = self.proc_data_dict['time']
Trace = self.proc_data_dict['Traces'][i]
# Look at signal after 50 ns
initial_idx = np.argmin(np.abs(Times-20e-9))
# Look at signal after 30 ns
initial_idx = np.argmin(np.abs(Times-30e-9))
Times = Times[initial_idx:]
Trace = Trace[initial_idx:]
# Fit exponential to trace
from scipy.optimize import curve_fit
p0 = [-.2, 15e-9, 1.02] # third point changed from 1 to 1.02
popt, pcov = curve_fit(filter_func, Times, Trace, p0=p0, maxfev=5000)
filtr = {'amp': popt[0], 'tau': popt[1]}
p0 = [-.2, 1]
device_bounds = ([-483.8e-3, 0], [-0.0, np.inf])
popt, pcov = curve_fit(self.modified_filter_func, Times, Trace, p0=p0, bounds=device_bounds, maxfev=5000)

tau_lb = self.tau_lower_bound(popt[0])
tau_bounds = ([tau_lb, np.inf])
def dummy_exponential(t, tau):
return popt[1]*(1+popt[0]*np.exp(-t/tau))
initial_tau = 15e-9
p0 = [initial_tau]
tau_solution, tau_solution_cov = curve_fit(dummy_exponential, Times, Trace, p0=p0, bounds=tau_bounds, maxfev=5000)

filtr = {'amp': popt[0], 'tau': tau_solution[0]}
new_popt = []
new_popt.append(popt[0])
new_popt.append(tau_solution)
new_popt.append(popt[1])
self.proc_data_dict['exponential_filter'][q] = filtr
self.proc_data_dict['fit_params'][q] = popt
self.proc_data_dict['fit_params'][q] = new_popt

def prepare_plots(self):
for i, qubit in enumerate(self.Qubits):
Expand All @@ -892,6 +907,37 @@ def prepare_plots(self):
if self.update_IIRs:
self.plot_dicts[f'Cryscope_trace_{qubit}']['filter_pars'] = \
self.proc_data_dict['fit_params'][qubit]

def tau_lower_bound(self, amplitude):
A = 2.08896944e-09
B = 2.79228042e+00
C = 4.40035783e-09
return A*np.exp(-B*amplitude) + C

def modified_filter_func(self, t, A, B):
from scipy.optimize import curve_fit
'''
Filter function implemented
in the HDAWG IIR filter model.
'''

for i, q in enumerate(self.Qubits):
Times = self.proc_data_dict['time']
Trace = self.proc_data_dict['Traces'][i]
# Look at signal after 30 ns
initial_idx = np.argmin(np.abs(Times-30e-9))
Times = Times[initial_idx:]
Trace = Trace[initial_idx:]

tau_lb = self.tau_lower_bound(A)
tau_bounds = ([tau_lb, np.inf])
def dummy_exponential(t, tau):
return B*(1+A*np.exp(-t/tau))
initial_tau = 15e-9
p0 = [initial_tau]
tau_solution, tau_solution_cov = curve_fit(dummy_exponential, Times, Trace, p0=p0, bounds=tau_bounds, maxfev=5000)

return B*(1+A*np.exp(-t/tau_solution))

def optimize_fir_software(y, baseline_start=100,
baseline_stop=None, taps=72, start_sample=0,
Expand Down
2 changes: 2 additions & 0 deletions pycqed/instrument_drivers/meta_instrument/HAL_Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -6443,6 +6443,7 @@ def measure_vcz_A_B_landscape(
Q_parks: list = None,
update_flux_params: bool = False,
flux_codeword: str = 'cz',
cz_repetitions = 1,
prepare_for_timedomain: bool = True,
disable_metadata: bool = False):
"""
Expand Down Expand Up @@ -6518,6 +6519,7 @@ def wrapper(Q0, Q1,
prepare_for_timedomain=prepare_for_timedomain,
downsample_swp_points=downsample_swp_points,
extract_only=extract_only,
cz_repetitions = cz_repetitions,
disable_metadata=disable_metadata,
verbose=False)
cp = { f'phi_cond_{i+1}' : a[f'pair_{i+1}_delta_phi_a']\
Expand Down
Loading

0 comments on commit 3a34e64

Please sign in to comment.