From 157741aaa5bce094ac6131d108377ecc55f6623f Mon Sep 17 00:00:00 2001 From: Andrew Laing Date: Wed, 25 Nov 2020 14:04:33 +0100 Subject: [PATCH] Add test buffer_calculator with pandas and numpy --- .../detsim/buffer_functions_test.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/invisible_cities/detsim/buffer_functions_test.py b/invisible_cities/detsim/buffer_functions_test.py index c3eb78265c..ee51970b14 100644 --- a/invisible_cities/detsim/buffer_functions_test.py +++ b/invisible_cities/detsim/buffer_functions_test.py @@ -125,3 +125,36 @@ def test_buffer_calculator(mc_waveforms, binned_waveforms, assert evt_pmt .shape[1] == int(buffer_length / pmt_binwid) assert evt_sipm.shape[1] == int(buffer_length / sipm_binwid) assert np.sum(evt_pmt, axis=0)[pre_trg_samp] == pmt_sum[pulses[i]] + + +def test_buffer_calculator_pandas_numpy(mc_waveforms, binned_waveforms): + + _, pmt_binwid, sipm_binwid, _ = mc_waveforms + + pmt_bins, pmt_wfs, sipm_bins, sipm_wfs = binned_waveforms + + buffer_length = 800 * units.mus + bin_width = np.diff(pmt_bins)[0] + stand_off = int(buffer_length / bin_width) + pre_trigger = 100 * units.mus + signal_thresh = 2 + + pulses = find_signal_start(pmt_wfs, signal_thresh, stand_off) + + calculate_buffers = buffer_calculator(buffer_length, + pre_trigger , + pmt_binwid , + sipm_binwid ) + + buffers_pd = calculate_buffers(pulses, *binned_waveforms) + buffers_np = calculate_buffers(pulses , + pmt_bins , + np.asarray( pmt_wfs.tolist()), + sipm_bins , + np.asarray(sipm_wfs.tolist())) + + assert len(buffers_pd) == len(buffers_np) == 1 + evtpd_buffers = buffers_pd[0] + evtnp_buffers = buffers_np[0] + assert np.all([np.all(evtpd_buffers[0] == evtnp_buffers[0]), + np.all(evtpd_buffers[1] == evtnp_buffers[1])])