Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can find more advanced examples here and some overview documentation here.  More detailed documentation (including description of parameters) is here.  You can look at an image and interactively tune the peak-finding parameters using the "psocake" software shown here (see the peak-finding section).

This script lives in in /reg/g/psdm/tutorials/examplePythonexamplePython3/peakFinder.py.  A peak finder runs on an area detector and tries to locate regions of charge (e.g. photons).

Code Block
import psana
ds = psana.DataSource('exp=xpptut15:run=54:smd')
det = psana.Detector('cspad')
from ImgAlgos.PyAlgos import PyAlgos
alg = PyAlgos()
alg.set_peak_selection_pars(npix_min=2, npix_max=50, amax_thr=10, atot_thr=20, son_min=5)
hdr = '\nSeg  Row  Col  Npix    Amptot'
fmt = '%3d %4d %4d  %4d  %8.1f'
for nevent,evt in enumerate(ds.events()):
    if nevent>=2 : 
        break
    nda = det.calib(evt)
    if nda is None: 
        continue
    peaks = alg.peak_finder_v4r2(nda, thr_low=5, thr_high=21, rank=4, r0=5, dr=0.05)
    print (hdr)
    for peak in peaks :
        seg,row,col,npix,amax,atot = peak[0:6]
        print (fmt % (seg, row, col, npix, atot))

Hit Finding

This script lives in in /reg/g/psdm/tutorials/examplePythonexamplePython3/hitFinder.py.  These hit finding algorithms try to determine if a particular LCLS shot was good or not, by looking for significant charge distributed over an area detector.

Code Block
import psana
ds = psana.DataSource('exp=xpptut15:run=54:smd')
det = psana.Detector('cspad')
from ImgAlgos.PyAlgos import PyAlgos
alg = PyAlgos()
for nevent,evt in enumerate(ds.events()):
    if nevent>=2 : break
    nda = det.calib(evt)
    if nda is None: continue
    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 total intensity %5{totint:5.1f} above threshold %5{thr:5.1f}') %# (numpix, totint, thr)

References