Example #1
0
def do_main():
    """ Main method to do work
    """
    from pyimgalgos.FiberIndexing import BinPars
    from pyimgalgos.GlobalUtils import create_directory

    # h-k space image parameters
    hmax = 4
    kmax = 6

    # recipical space image parameters, bins for 2-d image
    bpq = BinPars((-0.25, 0.25), 1200, vtype=np.float32, endpoint=True)

    #fname = '/reg/neh/home1/dubrovin/LCLS/rel-mengning/work/peak-idx-cxif5315-r0169-2015-11-13T17:04:37.txt'
    #fname = '/reg/neh/home1/dubrovin/LCLS/rel-mengning/work/peak-idx-cxif5315-r0169-2015-12-01T15:44:49.txt'
    fname = '/reg/neh/home1/dubrovin/LCLS/rel-mengning/work/peak-idx-cxif5315-r0169-2016-05-12T18:17:57.txt'

    rdir = './results-idx'
    create_directory(rdir)

    sp.prefix = '%s/2016-05-13-v01-idx-res-matched' % rdir  # file name prefix for histograms
    #sp.prefix  = '%s/2016-05-13-v01-idx-res-peak-nm' % rdir # file name prefix for histograms

    img_space, img_recip = proc_file(fname, hmax, kmax, bpq)
    print_crystal_in_hk_space(img_space, hmax, kmax)

    print 'img_recip.shape=', img_recip.shape

    if sp.DO_HIST: plot_histograms()

    if sp.DO_PLOT:

        import pyimgalgos.GlobalGraphics as gg

        img = img_space
        img_range = (-kmax - 0.5, kmax + 0.5, -hmax - 0.5, hmax + 0.5)
        axim = gg.plotImageLarge(img, img_range=img_range, amp_range=(0,1), figsize=(8,6),\
                      title='Crystal structure in h-k space', origin='upper', window=(0.1, 0.1, 0.9, 0.86))
        axim.set_xlabel('k index', fontsize=18)
        axim.set_ylabel('h index', fontsize=18)

        gg.savefig('%s-%s-crystal-in-hk-space.png' %
                   (sp.prefix, sp.exp_run))  # sp.tstamp

        img = img_recip
        ave, rms = img.mean(), img.std()
        amin, amax = 0, ave + 5 * rms
        img_range = (bpq.vmin, bpq.vmax, bpq.vmin, bpq.vmax)
        axim = gg.plotImageLarge(img, img_range=img_range, amp_range=(amin, amax), figsize=(10,8),\
                  title='Crystal structure in reciprocal space', origin='upper', window=(0.1, 0.1, 0.86, 0.86))
        axim.set_xlabel('$q_x$ ($1/\AA$)', fontsize=18)
        axim.set_ylabel('$q_y$ ($1/\AA$)', fontsize=18)

        gg.savefig('%s-%s-crystal-in-recip-space.png' %
                   (sp.prefix, sp.exp_run))

        gg.show()
Example #2
0
def test_plot_beta_l0() :
    print """Test plot for beta angle"""

    import pyimgalgos.GlobalGraphics as gg

    xarr = np.linspace(-2,2,50)
    phi = 0
    cmt = 'l0'


    
    y_000 = [funcy_l0(x, phi,   0) for x in xarr]
    y_p10 = [funcy_l0(x, phi,  10) for x in xarr]
    y_p20 = [funcy_l0(x, phi,  20) for x in xarr]
    y_p30 = [funcy_l0(x, phi,  30) for x in xarr]
    y_p40 = [funcy_l0(x, phi,  40) for x in xarr]
    y_p50 = [funcy_l0(x, phi,  50) for x in xarr] # 48
    y_m10 = [funcy_l0(x, phi, -10) for x in xarr]
    y_m20 = [funcy_l0(x, phi, -20) for x in xarr]
    y_m30 = [funcy_l0(x, phi, -30) for x in xarr]    
    y_m40 = [funcy_l0(x, phi, -40) for x in xarr]    
    y_m50 = [funcy_l0(x, phi, -50) for x in xarr] # -48

    #fig2, ax2 = gg.plotGraph(xarr, y_m01, pfmt='k.', figsize=(10,5), window=(0.15, 0.10, 0.78, 0.80)) 
    fig2, ax2 = gg.plotGraph(xarr, y_000, pfmt='k-', figsize=(10,5), window=(0.15, 0.10, 0.78, 0.80), lw=2) 

    #b: blue
    #g: green
    #r: red
    #c: cyan
    #m: magenta
    #y: yellow
    #k: black
    #w: white


    ax2.plot(xarr, y_p50,'g-x', label=' 50')
    ax2.plot(xarr, y_p40,'m-',  label=' 40')
    ax2.plot(xarr, y_p30,'b-',  label=' 30')
    ax2.plot(xarr, y_p20,'y-',  label=' 20')
    ax2.plot(xarr, y_p10,'r-',  label=' 10')
    ax2.plot(xarr, y_000,'k-',  label='  0')
    ax2.plot(xarr, y_m10,'r.',  label='-10')
    ax2.plot(xarr, y_m20,'y.',  label='-20')
    ax2.plot(xarr, y_m30,'b.',  label='-30')
    ax2.plot(xarr, y_m40,'m.',  label='-40')
    ax2.plot(xarr, y_m50,'g+',  label='-50')
                                        
    ax2.legend(loc='upper right')

    ax2.set_xlabel('x', fontsize=14)
    ax2.set_ylabel('y', fontsize=14)
    ax2.set_title('%s: phi=%.1f, beta=[-50,50]' % (cmt,phi), color='k', fontsize=20)

    gg.savefig('test-plot-beta-l0.png')
    gg.show()
Example #3
0
def test_plot_beta_l1(DoR=0.4292, sgnrt=1.) :
    print """Test plot for beta angle"""

    import pyimgalgos.GlobalGraphics as gg

    xarr = np.linspace(-2,2,50)
    phi = 0

    fancy_plt = funcy_l1_v1
    #fancy_plt = funcy_l1_v0

    cmt = 'POS' if sgnrt > 0 else 'NEG' #'-B -/+ sqrt(B*B-C)'
    cmt = '%s-DoR-%.3f' % (cmt, DoR)
    
    y_p10 = [fancy_plt(x, phi,  10,   DoR, sgnrt) for x in xarr]
    y_000 = [fancy_plt(x, phi,   0,   DoR, sgnrt) for x in xarr]
    y_m10 = [fancy_plt(x, phi, -10,   DoR, sgnrt) for x in xarr]
    y_m13 = [fancy_plt(x, phi, -13,   DoR, sgnrt) for x in xarr]    
    y_m15 = [fancy_plt(x, phi, -15,   DoR, sgnrt) for x in xarr]    
    y_m20 = [fancy_plt(x, phi, -20,   DoR, sgnrt) for x in xarr]
    y_m30 = [fancy_plt(x, phi, -30,   DoR, sgnrt) for x in xarr]
    y_m35 = [fancy_plt(x, phi, -35,   DoR, sgnrt) for x in xarr]    
    y_m40 = [fancy_plt(x, phi, -40,   DoR, sgnrt) for x in xarr]
    
    fig2, ax2 = gg.plotGraph(xarr, y_000, pfmt='k-', figsize=(10,5), window=(0.15, 0.10, 0.78, 0.80), lw=2) 
    ax2.plot(xarr, y_p10,'g-',  label=' 10')
    ax2.plot(xarr, y_000,'k-',  label='  0')
    ax2.plot(xarr, y_m10,'g.',  label='-10')
    ax2.plot(xarr, y_m13,'r-.', label='-13')
    ax2.plot(xarr, y_m15,'y.',  label='-14')
    ax2.plot(xarr, y_m20,'r.',  label='-20')
    ax2.plot(xarr, y_m30,'c.',  label='-30')
    ax2.plot(xarr, y_m35,'m.',  label='-35')
    ax2.plot(xarr, y_m40,'b+',  label='-40')

    ax2.legend(loc='upper right')
    
    ax2.set_title('%s: phi=%.1f, beta=[-40,10]' % (cmt,phi), color='k', fontsize=20)

    ax2.set_xlabel('x', fontsize=14)
    ax2.set_ylabel('y', fontsize=14)

    gg.savefig('test-plot-beta-l1-%s.png' % cmt)
    gg.show()
Example #4
0
def test_plot_beta_l1_zoom(DoR=0.4292, sgnrt=1.) :
    print """Test plot for beta angle"""

    import pyimgalgos.GlobalGraphics as gg

    phi = 0

    fancy_plt = funcy_l1_v1
    #fancy_plt = funcy_l1_v0

    if sgnrt > 0 : 

        cmt = 'POS' #'-B -/+ sqrt(B*B-C)'
        cmt = '%s-DoR-%.3f' % (cmt, DoR)
        
        xarr = np.linspace(-0.29,0.29,60)

        y_000 = [fancy_plt(x, phi,   0,   DoR, sgnrt) for x in xarr]
        y_m05 = [fancy_plt(x, phi,  -5,   DoR, sgnrt) for x in xarr]
        y_m09 = [fancy_plt(x, phi,  -9,   DoR, sgnrt) for x in xarr]
        y_m13 = [fancy_plt(x, phi, -13.3, DoR, sgnrt) for x in xarr]    
        y_m18 = [fancy_plt(x, phi, -18,   DoR, sgnrt) for x in xarr]
        y_m20 = [fancy_plt(x, phi, -20,   DoR, sgnrt) for x in xarr]
        
        fig2, ax2 = gg.plotGraph(xarr, y_000, pfmt='k-', figsize=(10,5), window=(0.15, 0.10, 0.78, 0.80), lw=2) 
        ax2.plot(xarr, y_000,'k-',  label='  0')
        ax2.plot(xarr, y_m05,'g.',  label=' -5')
        ax2.plot(xarr, y_m09,'y.',  label=' -9')
        ax2.plot(xarr, y_m13,'r-.', label='-13')
        ax2.plot(xarr, y_m18,'c.',  label='-18')
        ax2.plot(xarr, y_m20,'b.',  label='-20')
        
        ax2.set_title('%s: phi=%.1f, beta=[-20,0]' % (cmt,phi), color='k', fontsize=20)
        ax2.legend(loc='upper center')

    if sgnrt < 0 : 

        cmt = 'NEG' #'-B -/+ sqrt(B*B-C)'
        cmt = '%s-DoR-%.3f' % (cmt, DoR)
        
        xarr = np.linspace(-1,1,50)

        y_m20 = [fancy_plt(x, phi, -20,   DoR, sgnrt) for x in xarr]
        y_m23 = [fancy_plt(x, phi, -23,   DoR, sgnrt) for x in xarr]
        y_m25 = [fancy_plt(x, phi, -25,   DoR, sgnrt) for x in xarr]
        y_m27 = [fancy_plt(x, phi, -27,   DoR, sgnrt) for x in xarr]
        y_m30 = [fancy_plt(x, phi, -30,   DoR, sgnrt) for x in xarr]
        y_m35 = [fancy_plt(x, phi, -35,   DoR, sgnrt) for x in xarr]
        y_m40 = [fancy_plt(x, phi, -40,   DoR, sgnrt) for x in xarr]
        y_m60 = [fancy_plt(x, phi, -60,   DoR, sgnrt) for x in xarr]
        
        fig2, ax2 = gg.plotGraph(xarr, y_m25, pfmt='k-', figsize=(10,5), window=(0.15, 0.10, 0.78, 0.80), lw=2) 
        ax2.plot(xarr, y_m20,'g+-', label='-20')
        ax2.plot(xarr, y_m23,'m-',  label='-23')
        ax2.plot(xarr, y_m25,'k-',  label='-25')
        ax2.plot(xarr, y_m27,'b.',  label='-27')
        ax2.plot(xarr, y_m30,'y.',  label='-30')
        ax2.plot(xarr, y_m35,'r.',  label='-35')
        ax2.plot(xarr, y_m40,'c.',  label='-40')
        ax2.plot(xarr, y_m60,'+',   label='-60')
        
        ax2.set_title('%s: phi=%.1f, beta=[-60,-20]' % (cmt,phi), color='k', fontsize=20)
        ax2.legend(loc='lower right')

    ax2.set_xlabel('x', fontsize=14)
    ax2.set_ylabel('y', fontsize=14)

    gg.savefig('test-plot-beta-l1-%s-zoomed.png' % cmt)
    gg.show()