Skip to content

Commit

Permalink
Merge pull request #219 from cta-observatory/fix_arbitrary_filename
Browse files Browse the repository at this point in the history
Fix source not working for arbitrary filename
  • Loading branch information
morcuended authored May 7, 2024
2 parents 068fc1f + 742db28 commit df019a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ctapipe_io_lst/multifiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions src/ctapipe_io_lst/tests/test_lsteventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit df019a7

Please sign in to comment.