コード例 #1
0
ファイル: allPeakFinding.py プロジェクト: zhenwork/psocake
def getPeaks(d, alg, hdr, fmt, mask, times, env, run, j):
    """Finds peaks within an event, and returns the event information, peaks found, and hits found
    
    Arguments:
    d -- psana.Detector() of this experiment's detector
    alg -- the algorithm used to find peaks
    hdr -- Title row for printed chart of peaks found
    fmt -- Locations of peaks found for printed chart
    mask -- the detector mask
    times -- all the events for this run
    env -- ds.env()
    run -- ds.runs().next(), the run information
    j -- this event's number
    
    """
    evt = run.event(times[j])
    try:
        nda = d.calib(evt) * mask
    except TypeError:
        nda = d.calib(evt)
    if (nda is not None):
        peaks = alg.peak_finder_v3r3(nda, rank=3, r0=3, dr=2, nsigm=5)
        numPeaksFound = len(peaks)
        alg = PA()
        thr = 20
        numpix = alg.number_of_pix_above_thr(nda, thr)
        #totint = alg.intensity_of_pix_above_thr(nda, thr)
        return [evt, nda, peaks, numPeaksFound, numpix]
    else:
        return [None, None, None, None, None]
コード例 #2
0
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 pixels have total intensity %5.1f above threshold %5.1f' % (
        numpix, totint, thr)