def analysis(path): def plot_pol(): fpol, axpol = pol.plot(1, 'sec') axpol.grid(axis='y') plt.savefig(path+'polarization.png', dpi=450, bbox_inches='tight', pad_inches=.1) plt.close() def plot_td(): fig, ax = plot_TD(ps[3000:],num_seg=4) plt.savefig(path+'PS_TD.png', dpi=450, bbox_inches='tight', pad_inches=.1) plt.close() def plot_tss(): print("plotting TSS") ftss, axtss = tss.plot() # axtss[0].set_title(name.split(":")[1].strip()) plt.savefig(path+'tss.png', dpi=450, bbox_inches='tight', pad_inches=.1) plt.close() tss = TSS(path, 'MU.dat') sp = Data(path, 'TRPSPI:MAIN.dat') axis = sp[0,0][['S_X','S_Y','S_Z']] ps = Data(path, 'TRPRAY:MAIN.dat') pol = Polarization.on_axis(sp, axis) plot_pol() plot_td() plot_tss() t = pol['iteration']*TAU par, err = fit_line(t, pol['Value']) return par[1], err[1]
def plot_spd(): t = pol['iteration']*TAU spd = pol.spin_proj.std(axis=1) fit = lowess(spd[0:None:100], t[0:None:100]) par, err = fit_line(t, spd) fig, ax = plt.subplots(1,1) ax.plot(t, spd, '.') ax.plot(fit[:,0], fit[:, 1], '-k') ax.plot(t, par[0]+par[1]*t, '-r', label=r'slp = {:4.2e} $\pm$ {:4.2e} [u/sec]'.format(par[1], err[1])) ax.set_xlabel('sec') ax.set_ylabel(r'$\sigma(\vec s_i, \bar n_{})$'.format(eid)) ax.grid() ax.legend() ax.ticklabel_format(axis='y', style='sci', scilimits=(0,0), useMathText=True) return fig, ax
def spin_offset_analysis(spdata, psdata, eid): try: jj = spdata['EID'][:,0]==eid # SPD eid now is 1, b/c I didn't split the lattice map anywhere else except: jj = slice(0, None) dm = psdata[jj]['D'].mean(0) sm = {lbl: spdata[jj][lbl].mean(0) for lbl in ['S_X','S_Y','S_Z']} fig, ax = plt.subplots(3,1, sharex=True) ax[2].set_xlabel(r'$\langle\delta\rangle$') for i, it in enumerate(sm.items()): name, data = it par, err = fit_line(dm, data) ax[i].plot(dm, data, '.') ax[i].plot(dm, par[0] + par[1]*dm, '--r') ax[i].grid() ax[i].set_ylabel(r'$\langle$'+r'${}$'.format(name) + r'$\rangle$') ax[i].ticklabel_format(axis='both', style='sci', scilimits=(0,0)) return fig, ax
def analyze_spin(spdata): t = spdata['iteration'][:,0]*TAU fig, ax = plt.subplots(3,1,sharex=True) ax[2].set_xlabel('sec') for i, lab in enumerate(['S_X','S_Y','S_Z']): ax[i].set_ylabel(lab) ax[i].ticklabel_format(axis='y',style='sci', scilimits=(0,0),useMathText=True) ax[i].grid() for s in spdata.T: for i, v in enumerate(['S_X','S_Y','S_Z']): sc = s[v] fit = lowess(sc, t) par, err = fit_line(t, sc) ax[i].plot(t, sc, '.', label='({:4.2e} $\pm$ {:4.2e}, {:4.2e} $\pm$ {:4.2e})'.format(par[0], err[0], par[1], err[1])) ax[i].plot(t, par[0] + t*par[1], '-r') ax[i].plot(fit[:,0], fit[:,1], '-k') ax[i].legend() return fig, ax
# sweep.fit = np.array(sweep.fit) sweep.rabi_freq = sweep.fit.T[0] sweep.rabi_gamma = sweep.fit.T[1] # plt.figure() plt.plot(sweep.vals, sweep.rabi_freq) plt.ylabel("Rabi freq (MHz)") # plt.figure() plt.plot(sweep.vals, sweep.rabi_gamma) plt.ylabel("Rabi decay, 1/T_Rabi (1/us)") # popt, perr, _, _ = analysis.fit_line(sweep.vals, sweep.rabi_freq) # plt.show() # times = np.linspace(0., seq.sweep_time, seq.num_patterns)*1e-3 # plt.plot(times, p_readout[0]) # popt, perr, _, _ = analysis.fit_sine_decay(times, p_readout[0]) # # # print("pi_time from fit (ns): {}".format(1e3*0.5/popt[0])) # expt_cal = seq_programs.get_expt_cal() # print("pi_time is expt_cal (ns): {}".format(expt_cal.pi_time.ge)) wx_programs.wx_set_and_amplitude_and_offset() save_by_pickle((seq, daq, sweep))