Skip to content

Commit

Permalink
Merge with local edits; changed labels and added possibility of chang…
Browse files Browse the repository at this point in the history
…ing which channel is fluxed in qubit_frequency_dac_scan passing a parameter FluxChan. Changed labels for avoidedcrossinganalysis
  • Loading branch information
NielsBultink committed Jul 18, 2018
1 parent 6bc62ca commit c5f4408
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 14 deletions.
19 changes: 14 additions & 5 deletions pycqed/analysis/measurement_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7941,13 +7941,20 @@ def __init__(self, auto=True,
filter_idx_low=[], filter_idx_high=[], filter_threshold=15e6,
force_keep_idx_low=[], force_keep_idx_high=[],
f1_guess=None, f2_guess=None, cross_flux_guess=None,
g_guess=30e6, coupling_label='g',
g_guess=30e6, coupling_label=r'$J_1/2\pi$',
break_before_fitting=False,
add_title=True,
xlabel=None, ylabel='Frequency (GHz)', **kw):
super().__init__(timestamp=timestamp, label=label, **kw)
self.get_naming_and_values_2D()

# measured_magns
# measured_phases = self.measured_values[1]
# rad = [(i * np.pi/180) for i in phases]
# real = [mags[j] * np.cos(i) for j, i in enumerate(rad)]
# imag = [mags[j] * np.sin(i) for j, i in enumerate(rad)]

# dists = [a_tools.calculate_distance_ground_state(real[i],imag[i], normalize=True) for i in range(len(real))]
# self.S21dist = a_tools.calculate_distance_ground_state()
flux = self.Y[:, 0]
self.peaks_low, self.peaks_high = self.find_peaks()
self.f, self.ax = self.make_unfiltered_figure(self.peaks_low, self.peaks_high,
Expand Down Expand Up @@ -8112,11 +8119,13 @@ def make_filtered_figure(self,
def make_fit_figure(self,
filt_flux_low, filt_flux_high,
filt_peaks_low, filt_peaks_high, fit_res,
transpose, cmap, coupling_label='g',
transpose, cmap, coupling_label=r'$J_1/2\pi$',
xlabel=None, ylabel='Frequency (GHz)',
add_title=True):
flux = self.Y[:, 0]
title = ' avoided crossing fit'
title_name = ' avoided crossing fit'
extratitle = '\n%s'%(self.folder.split('\\')[-1][7:])
title = title_name + extratitle
f, ax = plt.subplots()
if add_title:
ax.set_title(self.timestamp_string + title)
Expand Down Expand Up @@ -8150,7 +8159,7 @@ def make_fit_figure(self,
fit_res.params['g'] * 1e-6, fit_res.params['g'].stderr * 1e-6)
ax.text(.6, .8, g_legend, transform=ax.transAxes, color='white')
# ax.legend() # looks ugly, better after matplotlib update?
f.savefig(os.path.join(self.folder, title + '.png'), format='png',
f.savefig(os.path.join(self.folder, title_name + '.png'), format='png',
dpi=600)
return f, ax

Expand Down
18 changes: 14 additions & 4 deletions pycqed/analysis_v2/dac_scan_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Resonator_dac_arch_guess
import lmfit
from collections import OrderedDict
from copy import deepcopy, copy


class FluxFrequency(ba.BaseDataAnalysis):
Expand Down Expand Up @@ -152,8 +153,11 @@ def process_data(self):
# Smooth data and find peeks
smooth = self.options_dict.get('smoothing', False)
freqs = self.proc_data_dict['frequency_values']
# self.proc_data_dict['peaks'] = {}
for k in ['amplitude_values', 'phase_values', 'distance_values']:
self.proc_data_dict[k + '_smooth'] = {}
# peaklist_x = []
# peaklist_z = []
for i, dac_value in enumerate(self.proc_data_dict['dac_values']):
peaks_x, peaks_z, smoothed_z = a_tools.peak_finder_v3(freqs[i],
self.proc_data_dict[k][i],
Expand All @@ -163,15 +167,20 @@ def process_data(self):
'smoothing_win_len',
False),
factor=self.options_dict.get('data_factor', 1))
# print(dac_value, peaks_x, peaks_z)
# peaklist_x.append(list(peaks_x))
# peaklist_z.append(peaks_z)
self.proc_data_dict[k + '_smooth'][i] = smoothed_z

# self.proc_data_dict['peaks'][k[:-7]] = np.array([peaklist_x, peaklist_z])
# Fixme: save peaks

def prepare_fitting(self):
self.fit_dicts = OrderedDict()

dac_vals = self.proc_data_dict['dac_values']
freq_vals = self.proc_data_dict['fit_frequencies']
if max(freq_vals) < 1e9:
freq_vals *= 1e9

guess = self.options_dict.get('fit_guess', {})
f_q = guess.get('f_max_qubit', self.options_dict.get('f_max_qubit', None))
Expand Down Expand Up @@ -249,7 +258,7 @@ def prepare_plots(self):
else:
cm = custom_multiplier

current_label = 'Flux bias current, I'
current_label = self.params_dict['dac'].split('.')[-1]
current_unit = 'A'
if plot_vs_flux:
current_label = 'Flux'
Expand All @@ -263,6 +272,7 @@ def prepare_plots(self):
else:
s = 'Resonator'

self.qubit_name = self.raw_data_dict['measurementstring'][0].split("_")[2]
ext = self.options_dict.get('qubit_freq', None) is not None
for ax in ['amplitude', 'phase', 'distance']:
z = self.proc_data_dict['%s_values' % ax]
Expand All @@ -272,7 +282,7 @@ def prepare_plots(self):
'xvals': x,
'yvals': y,
'zvals': z,
'title': 'Flux Current ' + s + ' Sweep',
'title': 'Flux Current ' + s + ' Sweep\nqubit %s\nTimestamp %s -> %s'%(self.qubit_name,self.t_start, self.t_stop),
'xlabel': current_label,
'xunit': current_unit,
'ylabel': r'Frequency',
Expand All @@ -296,7 +306,7 @@ def prepare_plots(self):
unit = ' (norm.)'
td['zlabel'] = ax + unit
td['ax_id'] = ax
self.plot_dicts[ax] = td
self.plot_dicts[ax+'_2D'] = td

if self.options_dict.get('show_fitted_peaks', True):
sc = {
Expand Down
4 changes: 2 additions & 2 deletions pycqed/analysis_v2/quantum_efficiency_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ def prepare_plots(self):
for d in self.ssro.plot_dicts:
dicts[d] = self.ssro.plot_dicts[d]


if self.options_dict.get('subplots', True):
self.plot_dicts = deepcopy(dicts)

Expand Down Expand Up @@ -570,7 +569,7 @@ def fit_phase(amps, phase):
dpo = self.options_dict.get('default_phase_offset', 180)
phase_guess = np.mean(phase[0:i]) if fit_offset else dpo

params.add('b', value=phase_guess, vary=False)
params.add('b', value=phase_guess, min=0, max=360, vary=True)
params.add('c', expr=cexp)
mini = lmfit.Minimizer(minimizer_function, params=params, fcn_args=(amps, phase))
res = mini.minimize(method='differential_evolution')
Expand Down Expand Up @@ -610,6 +609,7 @@ def prepare_plots(self):
self.fit_res['coherence_fit'].params['sigma'].value,
self.fit_res['coherence_fit'].params['sigma'].stderr)
fit_text += '\n$c=%.5f$'%(phase_fit_params['c'].value)

self.plot_dicts['text_msg_amp_vs_dephasing'] = {
'ax_id': 'amp_vs_dephasing',
# 'ypos': 0.15,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ def measure_resonator_frequency_dac_scan(self, freqs, dac_values, MC=None,

def measure_qubit_frequency_dac_scan(self, freqs, dac_values,
pulsed=True, MC=None,
analyze=True, close_fig=True):
analyze=True, fluxChan=None, close_fig=True):
if not pulsed:
logging.warning('CCL transmon can only perform '
'pulsed spectrocsopy')
Expand All @@ -1472,7 +1472,10 @@ def measure_qubit_frequency_dac_scan(self, freqs, dac_values,
else:
# Assume the flux is controlled using an SPI rack
fluxcontrol = self.instr_FluxCtrl.get_instr()
dac_par = fluxcontrol.parameters[(self.cfg_dc_flux_ch())]
if fluxChan==None:
dac_par = fluxcontrol.parameters[(self.cfg_dc_flux_ch())]
else:
dac_par = fluxcontrol.parameters[(fluxChan)]

spec_source = self.instr_spec_source.get_instr()
spec_source.on()
Expand All @@ -1491,9 +1494,14 @@ def measure_spectroscopy(self, freqs, pulsed=True, MC=None,
if not pulsed:
logging.warning('CCL transmon can only perform '
'pulsed spectrocsopy')
UHFQC = self.instr_acquisition.get_instr()
self.prepare_for_continuous_wave()
if MC is None:
MC = self.instr_MC.get_instr()
# Starting specmode if set in config
if self.cfg_spec_mode():
UHFQC.spec_mode_on(IF=self.ro_freq_mod(),
ro_amp=self.ro_pulse_amp())

# Snippet here to create and upload the CCL instructions
CCL = self.instr_CC.get_instr()
Expand All @@ -1513,6 +1521,10 @@ def measure_spectroscopy(self, freqs, pulsed=True, MC=None,
self.int_avg_det_single._set_real_imag(False)
MC.set_detector_function(self.int_avg_det_single)
MC.run(name='spectroscopy_'+self.msmt_suffix)
# Stopping specmode
if self.cfg_spec_mode():
UHFQC.spec_mode_off()
self._prep_ro_pulse(upload=True)
if analyze:
ma.Homodyne_Analysis(label=self.msmt_suffix, close_fig=close_fig)

Expand Down Expand Up @@ -1633,6 +1645,8 @@ def measure_transients(self, MC=None, analyze: bool=True,
self.instr_LO_mw.get_instr().off()
elif 'on' in pulse_comb.lower():
self.instr_LO_mw.get_instr().on()
else:
raise ValueError("pulse_comb {} not understood: Only 'on' and 'off' allowed.".format(pulse_comb))

s = swf.OpenQL_Sweep(openql_program=p,
CCL=self.instr_CC.get_instr(),
Expand Down Expand Up @@ -3148,7 +3162,7 @@ def measure_quantum_efficiency(self, amps_rel=None, nr_shots=2*4094,
label_dephasing='_ro_amp_sweep_dephasing'+self.msmt_suffix,
label_ssro='_ro_amp_sweep_SNR'+self.msmt_suffix)

qea.run_analysis()
# qea.run_analysis()
eta = qea.fit_dicts['eta']
u_eta = qea.fit_dicts['u_eta']

Expand Down

0 comments on commit c5f4408

Please sign in to comment.