diff --git a/src/toolbox_scs/detectors/digitizers.py b/src/toolbox_scs/detectors/digitizers.py index e6101710d239eb3f51fa211f6593504408c3f7fb..f61b5e897bb51e5392d0c2bb762910e47c30ea4d 100644 --- a/src/toolbox_scs/detectors/digitizers.py +++ b/src/toolbox_scs/detectors/digitizers.py @@ -56,9 +56,9 @@ def peaks_from_raw_trace(traces, pulseStart, pulseStop, baseStart, baseStop, number of pulses. Ignored if intstart is a 1D-array. extra_dim: str Name given to the dimension along the peaks. Defaults to 'pulseId'. - mode: str in ['trapz', 'sum', 'mean', 'ampl'] - The operation performed over the integration region. `ampl` is the - amplitude between the baseline and the peak height. + mode: str in ['trapz', 'sum', 'mean', 'amplitude'] + The operation performed over the integration region. `amplitude` is + the difference between the baseline and the peak height. Returns ------- @@ -91,14 +91,10 @@ def peaks_from_raw_trace(traces, pulseStart, pulseStop, baseStart, baseStop, coords=coords, dims=['trainId', extra_dim]) func = {'trapz': np.trapz, 'sum': np.sum, - 'mean': np.mean}.get(mode) - if mode == 'ampl': - def func(val, axis): - return np.max(val, axis=axis) - np.min(val, axis=axis) - + 'mean': np.mean, 'amplitude': 'amplitude'}.get(mode) if func is None: raise ValueError('mode must be a string in ["trapz", "sum",' - '"mean", "ampl"]') + '"mean", "amplitude"]') for i, p in enumerate(pulses): a = pulseStart + p b = pulseStop + p @@ -108,7 +104,11 @@ def peaks_from_raw_trace(traces, pulseStart, pulseStop, baseStart, baseStop, break bg = np.outer(np.median(traces[:, bkga:bkgb], axis=1), np.ones(b-a)) - results[:, i] = func(traces[:, a:b] - bg, axis=1) + if mode == 'amplitude': + results[:, i] = np.max(traces[:, bkga:b], axis=1) - \ + np.min(traces[:, bkga:b], axis=1) + else: + results[:, i] = func(traces[:, a:b] - bg, axis=1) return results @@ -765,7 +765,7 @@ def get_digitizer_peaks(proposal, runNB, mnemonic, merge_with=None, {'pulseStart':100, 'pulsestop':200, 'baseStart':50, 'baseStop':99, 'period':24, 'npulses':500}. If None, integration parameters are computed automatically. - mode: str in ['trapz', 'sum', 'mean', 'ampl'] + mode: str in ['trapz', 'sum', 'mean', 'amplitude'] The operation performed over the integration region. `ampl` is the amplitude between the baseline and the peak height. save: bool