Skip to content

Commit df019a7

Browse files
authored
Merge pull request #219 from cta-observatory/fix_arbitrary_filename
Fix source not working for arbitrary filename
2 parents 068fc1f + 742db28 commit df019a7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/ctapipe_io_lst/multifiles.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _load_next_subrun(self, stream):
146146

147147
if stream is None:
148148
path = self.path
149-
stream = self.file_info.stream
149+
stream = self.file_info.stream if self.file_info is not None else None
150150
else:
151151
self.current_subrun[stream] += 1
152152

src/ctapipe_io_lst/tests/test_lsteventsource.py

+14
Original file line numberDiff line numberDiff line change
@@ -437,3 +437,17 @@ def test_evb_calibrated_data():
437437
assert np.all(e.calibration.tel[1].dl1.time_shift != 0)
438438

439439
assert read_events == 200
440+
441+
442+
def test_arbitrary_filename(tmp_path):
443+
from ctapipe_io_lst import LSTEventSource
444+
path = tmp_path / "some_name_not_matching_the_lst_pattern.fits.fz"
445+
path.write_bytes(test_r0_path_all_streams.read_bytes())
446+
447+
assert LSTEventSource.is_compatible(path)
448+
449+
with LSTEventSource(path, pointing_information=False, apply_drs4_corrections=False) as source:
450+
n_read = 0
451+
for _ in source:
452+
n_read += 1
453+
assert n_read == n_read

0 commit comments

Comments
 (0)