From bec6be0b38012add0668bb07df8e00806b4e58c4 Mon Sep 17 00:00:00 2001 From: Maximilian Linhoff Date: Tue, 7 May 2024 13:18:49 +0200 Subject: [PATCH 1/2] Add test for using arbitrary input file names --- src/ctapipe_io_lst/tests/test_lsteventsource.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ctapipe_io_lst/tests/test_lsteventsource.py b/src/ctapipe_io_lst/tests/test_lsteventsource.py index 90bea5f1..7112ce99 100644 --- a/src/ctapipe_io_lst/tests/test_lsteventsource.py +++ b/src/ctapipe_io_lst/tests/test_lsteventsource.py @@ -437,3 +437,17 @@ def test_evb_calibrated_data(): assert np.all(e.calibration.tel[1].dl1.time_shift != 0) assert read_events == 200 + + +def test_arbitrary_filename(tmp_path): + from ctapipe_io_lst import LSTEventSource + path = tmp_path / "some_name_not_matching_the_lst_pattern.fits.fz" + path.write_bytes(test_r0_path_all_streams.read_bytes()) + + assert LSTEventSource.is_compatible(path) + + with LSTEventSource(path, pointing_information=False, apply_drs4_corrections=False) as source: + n_read = 0 + for _ in source: + n_read += 1 + assert n_read == n_read From 742db288ff037db72ed615c2bee26a8e9fdb8ea8 Mon Sep 17 00:00:00 2001 From: Maximilian Linhoff Date: Tue, 7 May 2024 13:26:16 +0200 Subject: [PATCH 2/2] Fix source for filenames not matching the LST naming pattern --- src/ctapipe_io_lst/multifiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ctapipe_io_lst/multifiles.py b/src/ctapipe_io_lst/multifiles.py index b8165f01..c92a7134 100644 --- a/src/ctapipe_io_lst/multifiles.py +++ b/src/ctapipe_io_lst/multifiles.py @@ -146,7 +146,7 @@ def _load_next_subrun(self, stream): if stream is None: path = self.path - stream = self.file_info.stream + stream = self.file_info.stream if self.file_info is not None else None else: self.current_subrun[stream] += 1