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 centroids for each peak are 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) # This should only be run once to save run-dependent calibration constants calib = CentroidSmootherCalib() calib.add(centroids) runNumBegin = 0 # There is also an optional runNumEnd parameter calib.save(ds, det, runNumBegin) # This loads the run-dependent calibration constants for run number evt.run() cs = CentroidSmoother(ds, det, evt.run()) smoothCents = cs.getSmoothedCentroids(centroids)
Overview
Content Tools