Versions Compared

Key

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

The Centroid correction can be done to smooth the centroid position of single photon peaks. In the following example code uses , the V1 peak finder which can be found here is used to obtain an array of peaks.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. 

Code Block
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=49, 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]])

print '%d total peaks.' % len(centroids)
centroids = np.array(centroids)

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

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