Page History
...
Code Block |
---|
from psana import * from pypsalg import find_edges ds = DataSource('exp=amotut13:run=206') det = Detector('AmoETOF.0:Acqiris.0') import matplotlib.pyplot as plt for nevent,evt in enumerate(ds.events()): waveforms,times = det.raw(evt) # find edges for channel 0 # parameters: baseline, threshold, fraction, deadtime, leading_edges edges = find_edges(waveforms[0],0.0,-0.05,1.0,5.0,True) # pairs of (amplitude,sampleNumber) print edges break |
Sven Augustin suggested this code to get actual times instead of sample numbers for the edges:
Code Block |
---|
import pypsalg
def CFD(x, y, baseline=0.0, threshold=0.1, fraction=1.0, deadtime=5.0, leading_edges=True):
if x is None or y is None:
return None
edges = pypsalg.find_edges(y, baseline, threshold, fraction, deadtime, leading_edges)
if not edges.size:
return None
amplitudes, sample_numbers = edges.T
# separate integer index and linearly interpolated fraction in between
indices = sample_numbers.astype(int)
linterp = sample_numbers % 1
# get x step size for each index and calculate interpolated x axis
steps = x[1:][indices] - x[:-1][indices]
times = x[indices] + steps * linterp
return times, amplitudes
|
Overview
Content Tools