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)
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)
#------------------------------ ds = psana.DataSource(dsname) env = ds.env() #nrun = evt.run() #myrun = next(ds.runs()) #evt = next(myrun.events()) #for key in evt.keys() : print key det2 = WFDetector(src2, env) #, pbits=1022) det1 = WFDetector(src1, env) #, pbits=1022) #det1.print_attributes() #------------------------------ fig = gr.figure(figsize=(15, 15), title='Image') fig.clear() #gr.move_fig(fig, 200, 100) #fig.canvas.manager.window.geometry('+200+100') NAXES = 5 dy = 1. / NAXES lw = 1 w = 0.87 h = dy - 0.04 x0, y0 = 0.07, 0.03 ch = (2, 3, 4, 5, 6) gfmt = ( 'b-',
addhdr = ' Evnum Reg Seg Row Col Npix Amax Atot rcent ccent '+\ 'rsigma csigma bkgd rms son imrow imcol x[um] y[um] r[um] phi[deg]' fmt = '%7d %3s %3d %4d %4d %4d %8.1f %8.1f %6.1f %6.1f %6.2f %6.2f'+\ ' %6.2f %6.2f %6.2f'+\ ' %6d %6d %8.0f %8.0f %8.0f %8.2f' pstore = PeakStore(env, runnum, prefix='peaks', add_header=addhdr, pbits=1) pstore.print_attrs() ##----------------------------- fig, axim, axcb = gg.fig_axes() if DO_PLOT else (None, None, None) fighi, axhi = None, None if DO_SPEC : fighi = gr.figure(figsize=(6,5), title='Spectrum of pixel intensities', move=(800,0)) axhi = gr.add_axes(fighi, (0.17, 0.12, 0.78, 0.78)) ##----------------------------- def geo_pars(s,r,c) : inds = (s,r,c) return imRow[inds], imCol[inds], Xum[inds], Yum[inds], Rum[inds], Phi[inds] ##----------------------------- t0_sec_evloop = time() npeaks_tot = 0 nda = None peaks = None
import sys from time import time import psana import numpy as np from Detector.WFDetector import WFDetector import pyimgalgos.Graphics as gr import pyimgalgos.GlobalGraphics as gg #import pyimgalgos.GlobalUtils as gu #---------- IFNAME = '/reg/g/psdm/detector/data_test/npy/wavelets-amox27716-r0091.npy' fig = gr.figure(figsize=(15, 15), title='Wavelets') fig.clear() #gr.move_fig(fig, 200, 100) #fig.canvas.manager.window.geometry('+200+100') NAXES = 5 dy = 1. / NAXES w, h = 0.87, (dy - 0.04) x0, y0 = 0.07, 0.03 gfmt = ( 'b-', 'r-', 'g-', 'k-',