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 '%s(f"{80*'_':s}\nEvent %d' %{nevent:d}" # (80*'_', nevent) nda = det.calib(evt) print (f'Calibrated data shape:%s {nda.shape:s} {nda.dtype:%ss}') %# (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 '%d(f'{numpix:d} pixels have intensity above threshold =%5 {thr:5.1f}') %# (numpix, thr) print '%(f'{totint:.1f} is a total intensity in pixels above threshold =%5{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)) |
includes examples for two hit-finders
...
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)
...
When run, it does necessary initialization, loops over events, finds peaks and prints them like:
Code Block |
---|
Event 5 Calibrated data shape:(32, 185, 388) dtype:float32 31 pixels have intensity above threshold = 20.0 816.9 is a total intensity in pixels above threshold = 20.0 Array of peak parameters shape:(7, 17) dtype:float32 Seg Row Col Npix Amax Atot rcent ccent rsigma csigma rmin rmax cmin cmax bkgd rms son 7 184 5 8 45.0 107.5 183.4 5.0 1.06 2.70 179 185 0 11 -1.38 3.60 12.88 8 44 10 19 40.2 177.1 43.9 10.0 2.80 2.87 39 50 5 16 1.23 4.89 7.97 9 184 240 12 46.1 126.2 181.9 239.6 1.99 2.43 179 185 235 246 3.05 3.82 11.28 17 184 35 3 32.1 44.5 183.4 35.7 1.66 1.42 179 185 30 41 0.27 4.15 7.66 23 183 57 7 35.9 78.0 181.5 56.6 1.98 2.40 178 185 52 63 -1.89 4.02 9.39 25 172 198 22 30.8 181.9 171.5 198.4 2.55 3.07 167 178 193 204 0.11 3.62 8.48 31 117 106 11 38.8 120.8 116.4 106.4 2.29 2.68 112 123 101 112 -0.27 4.55 8.57 |
...
Overview
Content Tools