Page History
...
Code Block |
---|
import psana ds = psana.DataSource('exp=xpptut15:run=54:smd') det = psana.Detector('cspad', ds.env()) ##----------------------------- # peak-finder initialization from ImgAlgos.PyAlgos import PyAlgos import numpy as np winds = [(s, 0, 185, 0, 388) for s in (0,1,7,8,9,15,16,17,23,24,25,31)] mask = np.ones((32,185,388)) alg = PyAlgos(windows=winds, mask=mask, pbits=0) alg.set_peak_selection_pars(npix_min=2, npix_max=50, amax_thr=10, atot_thr=20, son_min=5) ##----------------------------- hdr = 'Seg Row Col Npix Amax Atot rcent ccent rsigma csigma '+\ 'rmin rmax cmin cmax bkgd rms son' fmt = '%3d %4d %4d %4d %8.1f %8.1f %6.1f %6.1f %6.2f %6.2f %4d %4d %4d %4d %6.2f %6.2f %6.2f' ##----------------------------- for nevent,evt in enumerate(ds.events()): if nevent>5 : break print(f"{80*'_':s}\nEvent {nevent:d}") # (80*'_', nevent) nda = det.calib(evt) print(f'Calibrated data shape:{nda.shape:s} {nda.dtype:s}') # (nda.shape, nda.dtype) # hit-finders thr = 20 numpix = alg.number_of_pix_above_thr(nda, thr) totint = alg.intensity_of_pix_above_thr(nda, thr) print(f'{numpix:d} pixels have intensity above threshold = {thr:5.1f}') # (numpix, thr) print(f'{totint:.1f} is a total intensity in pixels above threshold ={thr:5.1f})' # (totint, thr) # get 2-d array of peak parameters peaks = alg.peak_finder_v1(nda, thr_low=5, thr_high=30, radius=5, dr=0.05) #peaks = alg.peak_finder_v2(nda, thr=12, r0=5.0, dr=0.05) #peaks = alg.peak_finder_v3(nda, rank=3, r0=5.0, dr=0.05) print ('Array of peak parameters shape:%s dtype:%s' % (peaks.shape, nda.dtype)) print (hdr) for peak in peaks : seg,row,col,npix,amax,atot,rcent,ccent,rsigma,csigma,\ rmin,rmax,cmin,cmax,bkgd,rms,son = peak[0:17] print(fmt % (seg, row, col, npix, amax, atot, rcent, ccent, rsigma, csigma,\ rmin, rmax, cmin, cmax, bkgd, rms, son)) |
...
Overview
Content Tools