コード例 #1
0
ファイル: GlobalUtils.py プロジェクト: slactjohnson/lcls2
def test_mask_neighbors_3d(allnbrs=True):
    from pyimgalgos.NDArrGenerators import random_exponential
    import pyimgalgos.Graphics as gr

    #randexp = random_exponential(shape=(2,2,30,80), a0=1)
    randexp = random_exponential(shape=(2, 30, 80), a0=1)

    fig = gr.figure(figsize=(16, 6), title='Random > 2-d mask')
    axim1 = gr.add_axes(fig, axwin=(0.05, 0.05, 0.40, 0.91))
    axcb1 = gr.add_axes(fig, axwin=(0.452, 0.05, 0.01, 0.91))

    axim2 = gr.add_axes(fig, axwin=(0.55, 0.05, 0.40, 0.91))
    axcb2 = gr.add_axes(fig, axwin=(0.952, 0.05, 0.01, 0.91))

    mask = np.select((randexp > 6, ), (0, ), default=1)
    mask_nbrs = mask_neighbors(mask, allnbrs)

    img1 = reshape_nda_to_2d(mask)
    img2 = reshape_nda_to_2d(mask_nbrs)

    imsh1, cbar1 = gr.imshow_cbar(fig,
                                  axim1,
                                  axcb1,
                                  img1,
                                  amin=0,
                                  amax=10,
                                  orientation='vertical')
    imsh2, cbar2 = gr.imshow_cbar(fig,
                                  axim2,
                                  axcb2,
                                  img2,
                                  amin=0,
                                  amax=10,
                                  orientation='vertical')
    gr.show(mode=None)
コード例 #2
0
ファイル: GlobalUtils.py プロジェクト: slactjohnson/lcls2
def test_mask_edges_2d(mrows=1, mcols=1):
    from pyimgalgos.NDArrGenerators import random_exponential
    import pyimgalgos.Graphics as gr

    fig = gr.figure(figsize=(8, 6), title='Mask edges 2-d')
    axim1 = gr.add_axes(fig, axwin=(0.05, 0.05, 0.87, 0.91))
    axcb1 = gr.add_axes(fig, axwin=(0.922, 0.05, 0.01, 0.91))

    mask = np.ones((20, 30))
    mask_out = mask_edges(mask, mrows, mcols)

    img1 = mask_out
    imsh1, cbar1 = gr.imshow_cbar(fig,
                                  axim1,
                                  axcb1,
                                  img1,
                                  amin=0,
                                  amax=10,
                                  orientation='vertical')
    gr.show(mode=None)
コード例 #3
0
        #ax[i].plot(wtsel, grad2, gfmt[0], linewidth=lw)

        gg.drawLine(ax[i],
                    ax[i].get_xlim(), (THR, THR),
                    s=10,
                    linewidth=1,
                    color='k')

    #wf2sel = wf2[ch[i],BBEG:BEND]
    #wt2sel = wt2[ch[i],BBEG:BEND]

    #ax[i].plot(wt2sel, wf2sel, gfmt[i], linewidth=lw)
    #edges = draw_times(ax[i], wf2sel, wt2sel)

    gr.draw_fig(fig)
    gr.show(mode='non-hold')

for i in range(NAXES):
    ax[i].clear()
    ax[i].plot(wttot[:NBINSWL], sp.w[i, :], gfmt[0], linewidth=lw)
    gg.drawLine(ax[i], ax[i].get_xlim(), (0, 0), s=10, linewidth=1, color='k')

gr.show()

np.save(ofname, sp.w)
print 'Wavelets saved in file %s' % ofname

#ch=0
#fig, ax = gg.plotGraph(wt[ch,:-1], wf[ch,:-1], figsize=(15,5))
#gg.show()
コード例 #4
0
    'Y1',
    'Y2',
    'MCP',
    'XX',
    'YY',
)
ax = [gr.add_axes(fig, axwin=(x0, y0 + i * dy, w, h)) for i in range(NAXES)]

#----------

w = np.load(IFNAME)
print 'Wavelets liaded from file %s' % IFNAME

#----------
zerocr = [382, 344, 388, 336, 500]

for i in range(NAXES):
    ax[i].clear()
    wl = w[i, :]
    ax[i].plot(w[i, :], gfmt[0], linewidth=1)
    gg.drawLine(ax[i], ax[i].get_xlim(), (0, 0), s=10, linewidth=1, color='k')
    z = zerocr[i]
    print 'ch:%d sum-signal: %.1f sum-tail: %.1f' % (i, np.sum(
        wl[:z]), np.sum(wl[z:]))

gr.show()

sys.exit(0)

#----------