diff --git a/packs/proc/processing_utils.py b/packs/proc/processing_utils.py index c7ec2ed..75698ae 100644 --- a/packs/proc/processing_utils.py +++ b/packs/proc/processing_utils.py @@ -445,7 +445,7 @@ def process_event_lazy_WD1(file_object : BinaryIO): def process_bin_WD1(file_path : str, save_path : str, - sample_size : int, + sample_size : float, overwrite : Optional[bool] = False, print_mod : Optional[int] = -1): @@ -467,7 +467,7 @@ def process_bin_WD1(file_path : str, ---------- file_path (str) : Path to binary file save_path (str) : Path to saved file - sample_size (int) : Size of each sample in an event (default 2 ns in the case of V1730B digitiser) + sample_size (float) : Size of each sample in an event (default 2 ns in the case of V1730B digitiser) overwrite (bool) : Boolean for overwriting pre-existing files print_mod (int) : Readout frequency for number of events, -1 implies no readout Returns @@ -478,6 +478,7 @@ def process_bin_WD1(file_path : str, # lets build it here first and break it up later # destroy the group within the file if you're overwriting + save_path = os.path.abspath(save_path) save_path = check_save_path(save_path, overwrite) print(save_path) diff --git a/packs/tests/data/one_channel_LECROYWS4054HD.h5 b/packs/tests/data/one_channel_LECROYWS4054HD.h5 index e200c9e..2f1803e 100644 Binary files a/packs/tests/data/one_channel_LECROYWS4054HD.h5 and b/packs/tests/data/one_channel_LECROYWS4054HD.h5 differ diff --git a/packs/tests/data/one_channel_WD1.h5 b/packs/tests/data/one_channel_WD1.h5 index 19f4b5a..b4040d4 100644 Binary files a/packs/tests/data/one_channel_WD1.h5 and b/packs/tests/data/one_channel_WD1.h5 differ diff --git a/packs/tests/data/one_channel_WD2.h5 b/packs/tests/data/one_channel_WD2.h5 index bd35f1f..d03404b 100644 Binary files a/packs/tests/data/one_channel_WD2.h5 and b/packs/tests/data/one_channel_WD2.h5 differ diff --git a/packs/tests/data/three_channels_WD2.h5 b/packs/tests/data/three_channels_WD2.h5 index 286c67e..3e8ec2f 100644 Binary files a/packs/tests/data/three_channels_WD2.h5 and b/packs/tests/data/three_channels_WD2.h5 differ diff --git a/packs/tests/processing_test.py b/packs/tests/processing_test.py index 11912ae..1dc1dc1 100644 --- a/packs/tests/processing_test.py +++ b/packs/tests/processing_test.py @@ -241,8 +241,19 @@ def test_WD1_Lecroy_decode_produces_expected_output(config, inpt, output, compar run_pack = [sys.executable, MULE_dir + "/bin/mule", "proc", temp_config] subprocess.run(run_pack) - # the event info can be read out like a normal h5, the RWF cannot due to how they're structured - assert pd.read_hdf(save_path, 'RAW/event_info').equals(pd.read_hdf(comparison_path, 'RAW/event_info')) + # load event info from both files for comparison + saved_event_info = pd.read_hdf(save_path, 'RAW/event_info') + comparison_event_info = pd.read_hdf(comparison_path, 'RAW/event_info') + + # compare integer columns exactly + exact_cols = ['event_number', 'timestamp', 'samples', 'channels'] + assert saved_event_info[exact_cols].equals(comparison_event_info[exact_cols]) + + # compare float columns with tolerance to account for floating point precision differences + np.testing.assert_allclose(saved_event_info['sampling_period'].values, + comparison_event_info['sampling_period'].values, + rtol=1e-10) + assert [x for x in reader(save_path, 'RAW', 'rwf')] == [x for x in reader(comparison_path, 'RAW', 'rwf')] diff --git a/packs/types/types.py b/packs/types/types.py index a5052ee..6e589c2 100644 --- a/packs/types/types.py +++ b/packs/types/types.py @@ -5,7 +5,7 @@ ('event_number', np.uint32), ('timestamp', np.uint64), ('samples', np.uint32), - ('sampling_period', np.uint64), + ('sampling_period', np.float64), ('channels', np.int32), ])