#ref_epos = ref_epos[130000:]

# Read in data
#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07263-v02.epos" # 25 K
#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07080-v01.epos" # 50 K
#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07086-v01.epos" # 125 K
#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07276-v03.epos" # 150 K
fn = r'C:\Users\capli\Google Drive\NIST\pos_and_epos_files\SiO2_Nov092020\R44_03376-v01.epos'

epos = apt_fileio.read_epos_numpy(fn)
#epos = epos[epos.size//2:-1]

# Plot TOF vs event index and show the current ROI selection
#roi_event_idxs = np.arange(1000,epos.size-1000)
roi_event_idxs = np.arange(epos.size)
ax = plotting_stuff.plot_TOF_vs_time(epos['tof'], epos, 1)
ax.plot(roi_event_idxs[0] * np.ones(2), [0, 1200], '--k')
ax.plot(roi_event_idxs[-1] * np.ones(2), [0, 1200], '--k')
ax.set_title('roi selected to start analysis')
epos = epos[roi_event_idxs]

# 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)
def __main__():
    
    
    plt.close('all')
    #
    # Load data
    fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_00504-v56.epos"
    fn = r"\\cfs2w.campus.nist.gov\647\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_04472-v02_allVfromAnn.epos"

    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\GaN epos files\R20_07148-v01_vbm_corr.epos"
    #fn = r"D:\Users\clifford\Documents\Python Scripts\NIST_DATA\R20_07094-v03.epos"
    #fn = r"D:\Users\clifford\Documents\Python Scripts\NIST_DATA\R45_04472-v03.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07263-v02.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07080-v01.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07086-v01.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07276-v03.epos"
#    fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_04472-v03.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_04472-v02.epos"
#    fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\GaN epos files\R20_07148-v01.epos" # Mg doped
#    fn = fn[:-5]+'_vbm_corr.epos'
    
    
    epos = apt_fileio.read_epos_numpy(fn)
        
#    plotting_stuff.plot_TOF_vs_time(epos['m2q'],epos,1,clearFigure=True,user_ylim=[0,150])
#    epos = epos[0:2**20]
    
    cts_per_slice=2**10
    m2q_roi = [0.8,75]
    
    import time
    t_start = time.time()
    pointwise_scales,piecewise_scales = get_all_scale_coeffs(epos['m2q'],
                                                             m2q_roi=m2q_roi,
                                                             cts_per_slice=cts_per_slice,
                                                             max_scale=1.15)
    t_end = time.time()
    print('Total Time = ',t_end-t_start)
    
    
    
    
    
    # Plot histogram in log space
    lys_corr = np.log(epos['m2q'])-np.log(pointwise_scales)
    N,x_edges,ly_edges = create_histogram(lys_corr,y_roi=m2q_roi,cts_per_slice=cts_per_slice)
    
#    fig = plt.figure(figsize=(8,8))
#    plt.imshow(np.log1p(np.transpose(N)), aspect='auto', interpolation='none',
#               extent=extents(x_edges) + extents(ly_edges), origin='lower')
#    
    # Compute corrected data
    m2q_corr = epos['m2q']/pointwise_scales
    
    # Plot data uncorrected and corrected
    TEST_PEAK = 32
    ax = plotting_stuff.plot_TOF_vs_time(epos['m2q'],epos,111,clearFigure=True,user_ylim=[0,75])
    ax.plot(pointwise_scales*TEST_PEAK)
    plotting_stuff.plot_TOF_vs_time(m2q_corr,epos,222,clearFigure=True,user_ylim=[0,75])
    
    # Plot histograms uncorrected and corrected
    plotting_stuff.plot_histo(m2q_corr,333,user_xlim=[0, 75],user_bin_width=0.01)
    plotting_stuff.plot_histo(epos['m2q'],333,user_xlim=[0, 75],clearFigure=False,user_bin_width=0.01)
    
#    epos['m2q'] = m2q_corr
#    apt_fileio.write_epos_numpy(epos,'Q:\\NIST_Projects\\EUV_APT_IMS\\BWC\\GaN epos files\\R20_07148-v01_vbmq_corr.epos')
    
    
    _, ys = bin_dat(m2q_corr,isBinAligned=True,bin_width=0.01,user_roi=[0,75])

    print(np.sum(np.square(ys)))
    

    
    return 0
Ejemplo n.º 3
0
from histogram_functions import bin_dat
from voltage_and_bowl import do_voltage_and_bowl

# Read in template spectrum
fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\180821_GaN_A71\R20_07094-v03.epos"
ref_epos = apt_fileio.read_epos_numpy(fn)
ref_epos = ref_epos[0:ref_epos.size // 2]

# Read in data
fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\180821_GaN_A71\R20_07094-v03.epos"
epos = apt_fileio.read_epos_numpy(fn)
epos = epos[epos.size // 2:-1]

# Plot TOF vs wall_time and show the current ROI selection
roi_event_idxs = np.arange(1000, epos.size - 1000)
ax = plotting_stuff.plot_TOF_vs_time(epos['tof'], epos, 1)
ax.plot(roi_event_idxs[0] * np.ones(2), [0, 1200], '--k')
ax.plot(roi_event_idxs[-1] * np.ones(2), [0, 1200], '--k')
ax.set_title('ROI selected to start analysis')
epos = epos[roi_event_idxs]

# 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)
def __main__():

    plt.close('all')
    #
    # Load data
    fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_00504-v56.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\GaN epos files\R20_07148-v01_vbm_corr.epos"
    #fn = r"D:\Users\clifford\Documents\Python Scripts\NIST_DATA\R20_07094-v03.epos"
    #fn = r"D:\Users\clifford\Documents\Python Scripts\NIST_DATA\R45_04472-v03.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07263-v02.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07080-v01.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07086-v01.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07276-v03.epos"
    #    fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_04472-v03.epos"
    #fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_04472-v02.epos"
    #    fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\GaN epos files\R20_07148-v01.epos" # Mg doped
    #    fn = fn[:-5]+'_vbm_corr.epos'

    epos = apt_fileio.read_epos_numpy(fn)

    #    plotting_stuff.plot_TOF_vs_time(epos['m2q'],epos,1,clearFigure=True,user_ylim=[0,150])

    epos = epos[0:2**20]

    cts_per_slice = 2**10
    #m2q_roi = [0.9,190]
    m2q_roi = [0.8, 80]
    #    m2q_roi = [60,100]
    import time
    t_start = time.time()
    pointwise_scales, piecewise_scales = get_all_scale_coeffs(
        epos['m2q'],
        m2q_roi=m2q_roi,
        cts_per_slice=cts_per_slice,
        max_scale=1.15)
    t_end = time.time()
    print('Total Time = ', t_end - t_start)

    # Plot histogram in log space
    lys_corr = np.log(epos['m2q']) - np.log(pointwise_scales)
    N, x_edges, ly_edges = create_histogram(lys_corr,
                                            y_roi=m2q_roi,
                                            cts_per_slice=cts_per_slice)

    fig = plt.figure(figsize=(8, 8))
    plt.imshow(np.log1p(np.transpose(N)),
               aspect='auto',
               interpolation='none',
               extent=extents(x_edges) + extents(ly_edges),
               origin='lower')

    # Compute corrected data
    m2q_corr = epos['m2q'] / pointwise_scales

    # Plot data uncorrected and corrected
    TEST_PEAK = 32
    ax = plotting_stuff.plot_TOF_vs_time(epos['m2q'],
                                         epos,
                                         111,
                                         clearFigure=True,
                                         user_ylim=[0, 150])
    ax.plot(pointwise_scales * TEST_PEAK)

    plotting_stuff.plot_TOF_vs_time(m2q_corr,
                                    epos,
                                    222,
                                    clearFigure=True,
                                    user_ylim=[0, 150])

    # Plot histograms uncorrected and corrected
    plotting_stuff.plot_histo(m2q_corr, 333, user_xlim=[0, 150])
    plotting_stuff.plot_histo(epos['m2q'],
                              333,
                              user_xlim=[0, 150],
                              clearFigure=False)

    #import pandas as pd
    #
    #
    #fig = plt.figure(figsize=(8,8))
    #ax = fig.gca()
    #
    #df = pd.read_csv(r"Q:\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_04472_LaserPositionHist.csv")
    #ax.plot(df['Ion Sequence Number'],df['Laser X Position (mic)'])
    #ax.plot(df['Ion Sequence Number'],df['Laser Y Position (mic)'])
    #ax.plot(df['Ion Sequence Number'],df['Laser Z Position (mic)'])
    #
    #ax.clear()
    #ax.plot(pointwise_scales)
    #ax.grid()
    #ax.plot(np.convolve(np.diff(epos['v_dc']),np.ones(101)/101,mode='same')+1)
    ##ax.plot(np.convolve(np.diff(epos['v_dc']),np.ones(1)/1,mode='same')+1)

    #
    #
    #wall_time = np.cumsum(epos['pslep'])/500000.0
    #
    #dt = ppd.moving_average(np.diff(wall_time),n=512)
    #ra = 1/dt
    #
    #fig = plt.figure(figsize=(8,8))
    #ax = fig.gca()
    #ax.plot(ra)
    #
    #dsc_pointwise = np.r_[np.diff(pointwise_scales),0]
    #
    ##ax.plot(dsc_pointwise*10000000)
    #
    #ax.plot((pointwise_scales-1)*100000/3)
    #
    #ax.plot((pointwise_scales-1)*100/3)
    #
    #
    #fig = plt.gcf()
    #ax = fig.gca()

    #

    dsc = np.r_[np.diff(piecewise_scales), 0]
    #fig = plt.figure(figsize=(8,8))
    #ax = fig.gca()
    #ax.plot(dsc)

    #fig = plt.figure(figsize=(8,8))
    #ax = fig.gca()

    ax.hist(dsc, bins=64, range=[-0.01, 0.01])
    dsc_cut = scipy.stats.trimboth(dsc, 0.025)

    outlier_lims = [
        np.mean(dsc_cut) - 7 * np.std(dsc_cut),
        np.mean(dsc_cut) + 7 * np.std(dsc_cut)
    ]

    epos['m2q'] = m2q_corr

    #apt_fileio.write_epos_numpy(epos,'Q:\\NIST_Projects\\EUV_APT_IMS\\BWC\\GaN epos files\\R20_07148-v01_vbmq_corr.epos')

    return 0
Ejemplo n.º 5
0
#N,x_edges,ly_edges = create_histogram(lys_corr,y_roi=m2q_roi,cts_per_slice=cts_per_slice)

## Plot histogram
#fig = plt.figure(figsize=(7,4.5))
#plt.imshow(np.log1p(np.transpose(N)), aspect='auto', interpolation='none',
#           extent=extents(x_edges) + extents(ly_edges), origin='lower')


   
    
fig = plt.figure(figsize=(7,4.5))
ax = fig.gca()
#ax.plot(piecewise_scales,'-')

m2q_corr = epos['m2q']/pointwise_scales
ax = plotting_stuff.plot_TOF_vs_time(epos['m2q'],epos,111,clearFigure=True,user_ylim=[0,75])

ax.set_ylabel('m/z (Da)')


import pandas as pd


fig = plt.figure(figsize=(7,4.5))
ax = fig.gca()

df = pd.read_csv(r"Q:\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_04472_LaserPositionHist.csv")
ax.plot(df['Ion Sequence Number'],df['Laser X Position (mic)'])
ax.plot(df['Ion Sequence Number'],df['Laser Y Position (mic)'])
ax.plot(df['Ion Sequence Number'],df['Laser Z Position (mic)'])
Ejemplo n.º 6
0
fn = r"C:\Users\bwc\Documents\NetBeansProjects\R44_03200\recons\recon-v02\default\R44_03200-v02.epos"
epos = apt_fileio.read_epos_numpy(fn)
#epos = epos[:]



# 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")

# Only apply bowl correction
tof_bcorr = voltage_and_bowl.mod_geometric_bowl_correction(p_bowl,epos['tof'],epos['x_det'],epos['y_det'])
ax = plotting_stuff.plot_TOF_vs_time(tof_bcorr,epos,2)


# Plot histogram for sio2
fig = plt.figure(figsize=(2*3.14961,2*3.14961),num=45321,dpi=100)
plt.clf()
ax1, ax2 = fig.subplots(2,1,sharex=True)

roi = [1400000,1800000]

N,x_edges,y_edges = create_histogram(tof_bcorr[roi[0]:roi[1]],y_roi=[300,310],cts_per_slice=2**7,delta_y=.2)
ax1.imshow(np.log10(1+1*np.transpose(N)), aspect='auto', 
           extent=extents(x_edges) + extents(y_edges), origin='lower', cmap=cc.cm.CET_L8,
           interpolation='bilinear')

ax1.set(ylabel='flight time (ns)')
Ejemplo n.º 7
0
plt.close('all')

# Load data
#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_00504-v56.epos"
#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\GaN epos files\R20_07148-v01_vbm_corr.epos"
fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\R45_data\R45_04472-v03.epos"

#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07263-v02.epos"
#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07080-v01.epos"
#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07086-v01.epos"
#fn = r"Q:\NIST_Projects\EUV_APT_IMS\BWC\Final EPOS for APL Mat Paper\R20_07276-v03.epos"

epos = apt_fileio.read_epos_numpy(fn)
plotting_stuff.plot_TOF_vs_time(epos['m2q'],
                                epos,
                                1,
                                clearFigure=True,
                                user_ylim=[0, 150])

# Create histogram

cts_per_histo = 2**10
nx = int(epos.size / cts_per_histo)
xs = np.arange(epos.size)

y_roi = np.log10(np.array([0.5, 200]))
ny = 2**12
ys = np.log10(epos['m2q'])

N, x_edges, y_edges = np.histogram2d(xs,
                                     ys,
Ejemplo n.º 8
0
epos = apt_fileio.read_epos_numpy(fn)
epos = epos[100000::10]

# 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")

# Only apply bowl correction
tof_bcorr = voltage_and_bowl.mod_geometric_bowl_correction(
    p_bowl, epos['tof'], epos['x_det'], epos['y_det'])
ax = plotting_stuff.plot_TOF_vs_time(tof_bcorr, epos, 2)

# Plot histogram for steel
fig = plt.figure(figsize=(2 * 3.14961, 2 * 3.14961), num=321, dpi=100)
plt.clf()
ax1, ax2 = fig.subplots(2, 1, sharex=True)

N, x_edges, y_edges = create_histogram(tof_bcorr,
                                       y_roi=[400, 600],
                                       cts_per_slice=2**10,
                                       delta_y=0.5)
ax1.imshow(np.log10(1 + 1 * np.transpose(N)),
           aspect='auto',
           extent=extents(x_edges) + extents(y_edges),
           origin='lower',
           cmap=cc.cm.CET_L8,
Ejemplo n.º 9
0
idxs = np.where((epos['tof'] > roi[0]) & (epos['tof'] < roi[1]))[0]
fig = plt.figure(num=10)
fig.clf()
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,