You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Centroid correction can be done to smooth the centroid position of single photon peaks. In the following example code, the V1 peak finder which can be found here is used to obtain a large number of peaks. The row and column "center of gravity" for each peak is saved in the array centroids. The object, CentroidSmootherCalib, saves the data needed to smooth the centroids. Then the object, CentroidSmoother, will obtain this data and by passing getSmoothedCentroids the array of the row and column of centroids, an array of the row and column of the smoothed centroids is returned. 

from ImgAlgos.PyAlgos import PyAlgos
from psana import *

ds = DataSource('exp=xcs06016:run=37:smd')
det = Detector('epix_2')

alg = PyAlgos()
alg.set_peak_selection_pars(npix_min=1, npix_max=9, amax_thr=0, atot_thr=35, son_min=0)

centroids = []
for nevent, evt in enumerate(ds.events()):
    if nevent == 25:
        break

    nda = det.calib(evt)
    peaks = alg.peak_finder_v1(nda, thr_low=10, thr_high=30, radius=1, dr=0)
    for p in peaks:
        centroids.append([p[6], p[7]])
centroids = np.array(centroids)

calib = CentroidSmootherCalib()
calib.add(centroids)
calib.save(ds, det, 0)

cs = CentroidSmoother(ds, det, evt.run())
 
smoothCents = cs.getSmoothedCentroids(centroids)
  • No labels