Page History
...
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 # test whether the last element was found to be a peak, if so ignore it if sample_numbers[-1] >= len(y) - 1: amplitudes = amplitudes[:-1] sample_numbers = sample_numbers[:-1] # 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