def calibrate(self):
# generate sequence
self.set()
# run and load normalized data
data, _ = self.run(norm_pts = {self.qubit_names[0]: (0, 1), self.qubit_names[1]: (0, 2)})
# select target qubit
data_t = data[self.qubit_names[1]]
# fit
self.opt_par, all_params_0, all_params_1 = fit_CR([self.lengths, self.phases, self.amps], data_t, self.cal_type)
# plot the result
xaxis = self.lengths if self.cal_type==CR_cal_type.LENGTH else self.phases if self.cal_type==CR_cal_type.PHASE else self.amps
finer_xaxis = np.linspace(np.min(xaxis), np.max(xaxis), 4*len(xaxis))
self.plot["Data 0"] = (xaxis, data_t[:len(data_t)//2])
self.plot["Fit 0"] = (finer_xaxis, np.polyval(all_params_0, finer_xaxis) if self.cal_type == CR_cal_type.AMP else sinf(finer_xaxis, *all_params_0))
self.plot["Data 1"] = (xaxis, data_t[len(data_t)//2:])
self.plot["Fit 1"] = (finer_xaxis, np.polyval(all_params_1, finer_xaxis) if self.cal_type == CR_cal_type.AMP else sinf(finer_xaxis, *all_params_1))
return (str.lower(self.cal_type.name), self.opt_par)
评论列表
文章目录