replace=False) vb_epos = epos_s[vb_idxs] tof_sing_corr, p_volt, p_bowl = do_voltage_and_bowl(vb_epos, p_volt, p_bowl) tof_vcorr_fac = voltage_and_bowl.mod_full_voltage_correction( p_volt, np.ones_like(epos['tof']), epos['v_dc']) tof_bcorr_fac = voltage_and_bowl.mod_geometric_bowl_correction( p_bowl, np.ones_like(epos['tof']), epos['x_det'], epos['y_det']) # find the voltage and bowl coefficients for the doubles data tof_vcorr_fac_d = tof_vcorr_fac[doub_idxs] tof_bcorr_fac_d = tof_bcorr_fac[doub_idxs] # Find transform to m/z space m2q_corr, p_m2q = m2q_calib.align_m2q_to_ref_m2q(epos_s['m2q'], tof_sing_corr) epos['m2q'] = m2q_calib.mod_physics_m2q_calibration( p_m2q, mod_full_vb_correction(epos, p_volt, p_bowl)) plotting_stuff.plot_histo(epos['m2q'], fig_idx=1, user_xlim=[0, 250], user_bin_width=0.03) import GaN_fun pk_data = GaN_type_peak_assignments.GaN_with_H() bg_rois = [[0.4, 0.9]] pk_params, glob_bg_param, Ga1p_idxs, Ga2p_idxs = GaN_fun.fit_spectrum( epos=epos, pk_data=pk_data, peak_height_fraction=0.05, bg_rois=bg_rois)
# Compute some extra information from epos information wall_time = np.cumsum(epos['pslep']) / 10000.0 pulse_idx = np.arange(0, epos.size) isSingle = np.nonzero(epos['ipp'] == 1) # Voltage and bowl correct ToF data p_volt = np.array([]) p_bowl = np.array([]) t_i = time.time() tof_corr, p_volt, p_bowl = do_voltage_and_bowl(epos, p_volt, p_bowl) print("time to voltage and bowl correct: " + str(time.time() - t_i) + " seconds") # Find c and t0 for ToF data based on aligning to reference spectrum m2q_corr, p_m2q = m2q_calib.align_m2q_to_ref_m2q(ref_epos['m2q'], tof_corr) # import sel_align_m2q_log_xcorr pointwise_scales, piecewise_scales = sel_align_m2q_log_xcorr.get_all_scale_coeffs( m2q_corr, m2q_roi=[0.5, 75], cts_per_slice=2**8, max_scale=1.15) # Compute corrected data m2q_corr_q = m2q_corr / pointwise_scales # Convert back to tof tof_corr_q = np.sqrt(m2q_corr_q / (p_m2q[0] * 1e-4)) + p_m2q[1] # Plot TOF vs event index with voltage overlaid to show if voltage corr went ok ax = plotting_stuff.plot_TOF_vs_time(tof_corr_q, epos, 2) ax.set_title('voltage and bowl corrected') # Plot slices from the detector to show if bowl corr went ok
ax = fig.gca() ax.scatter(epos['x_det'][idxs], epos['y_det'][idxs], alpha=0.1, s=0.1, c=epos['v_dc'][idxs] / epos['v_dc'].max()) ax.axis('equal') ax.axis('square') ax.set_xlabel('x') ax.set_ylabel('y') vc = np.sqrt(5000) / np.sqrt(epos['v_dc']) plotting_stuff.plot_TOF_vs_time(epos['tof'] / vc, epos, 1, user_ylim=[0, 5000]) # Find transform to m/z space epos_R44['m2q'], p_m2q_R44 = m2q_calib.align_m2q_to_ref_m2q( ref_epos['m2q'], mod_full_vb_correction(epos_R44, p_volt_R44, p_bowl_R44)) epos_R20['m2q'], p_m2q_R20 = m2q_calib.align_m2q_to_ref_m2q( ref_epos['m2q'], mod_full_vb_correction(epos_R20, p_volt_R20, p_bowl_R20)) plotting_stuff.plot_histo(epos_R44['m2q'], fig_idx=1, user_label='R44', scale_factor=1 / epos_R44.size) plotting_stuff.plot_histo(epos_R20['m2q'], fig_idx=1, user_label='R20', clearFigure=False, scale_factor=1 / epos_R20.size) # Make a correlation histogram of doubles epos_vb_R44 = epos_R44.copy()
#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\GaN epos files\R20_07250-v01.epos" epos = apt_fileio.read_epos_numpy(fn) #epos = epos[1450000:-1] # Voltage and bowl correct ToF data p_volt = np.array([]) p_bowl = np.array([]) t_i = time.time() tof_corr, p_volt, p_bowl = do_voltage_and_bowl(epos, p_volt, p_bowl) print("time to voltage and bowl correct: " + str(time.time() - t_i) + " seconds") # Find c and t0 for ToF data based on aligning to reference spectrum m2q_corr, p_m2q = m2q_calib.align_m2q_to_ref_m2q(ref_epos['m2q'], tof_corr, nom_voltage=np.mean( epos['v_dc'])) print(p_m2q) plotting_stuff.plot_histo(ref_epos['m2q'], 4, user_label='ref') plotting_stuff.plot_histo(m2q_corr[m2q_corr.size // 2:-1], 4, clearFigure=False, user_label='[c,t0] corr') xs, ys = bin_dat(tof_corr, isDensity=True, bin_width=0.25) bg_lvl = np.mean(ys[(xs > 1000) & (xs < 3500)]) idxs = np.nonzero((xs > 200) & (xs < 1000))
np.ones_like(sub_epos['tof']), sub_epos['v_dc'])\ *voltage_and_bowl.mod_geometric_bowl_correction(p_bowl, np.ones_like(sub_epos['tof']), sub_epos['x_det'], sub_epos['y_det']) # for the moment we are working with doubles only for simplicity idxs = np.where(epos['ipp'] == 2)[0] idxs = sorted(np.concatenate((idxs, idxs + 1))) epos_d = epos[idxs] ref_fn = r"C:\Users\capli\Google Drive\NIST\pos_and_epos_files\GaN_manuscript\R20_07094-v03.epos" ref_epos = apt_fileio.read_epos_numpy(ref_fn) m2q_corr, p_m2q = m2q_calib.align_m2q_to_ref_m2q(ref_epos['m2q'], tof_singles_corr) # Verify the alignment worked m2q_corr = 1e-4*p_m2q[0]*np.square(epos['tof']\ *voltage_and_bowl.mod_full_voltage_correction(p_volt, np.ones_like(epos['tof']), epos['v_dc'])\ *voltage_and_bowl.mod_geometric_bowl_correction(p_bowl, np.ones_like(epos['tof']), epos['x_det'], epos['y_det']) -p_m2q[1]) plotting_stuff.plot_histo(ref_epos['m2q'], 33211233, clearFigure=True) plotting_stuff.plot_histo(m2q_corr, 33211233, clearFigure=False)