EventSeeker#

class ctapipe.io.EventSeeker(**kwargs: Any)[source]#

Bases: Component

Provides the functionality to seek through a EventSource to find a particular event.

By default, this will loop through events from the start of the file (unless the requested event is the same as the previous requested event, or occurs later in the file). However if the ctapipe.io.EventSource has defined a __getitem__ method itself, then it will use that method, thereby taking advantage of the random event access some file formats provide.

To create an instance of an EventSeeker you must provide it a sub-class of EventSource (such as ctapipe.io.SimTelEventSource), which will be used to loop through the file and provide the event container, filled with the event information using the methods defined in the event_source for that file format.

To obtain a particular event in a simtel file:

>>> from ctapipe.io import SimTelEventSource
>>> event_source = SimTelEventSource(input_url="dataset://gamma_test_large.simtel.gz", focal_length_choice="EQUIVALENT")
>>> seeker = EventSeeker(event_source=event_source)
>>> event = seeker.get_event_index(2)
>>> print(event.count)
2

To obtain a particular event in a simtel file from its event_id:

>>> from ctapipe.io import SimTelEventSource
>>> event_source = SimTelEventSource(input_url="dataset://gamma_test_large.simtel.gz", back_seekable=True, focal_length_choice="EQUIVALENT")
>>> seeker = EventSeeker(event_source=event_source)
>>> event = seeker.get_event_id(31007)
>>> print(event.count)
1

NOTE: Event_index refers to the number associated to the event assigned by ctapipe (event.count), based on the order the events are read from the file. Whereas the event_id refers to the ID attached to the event from the external source of the file (software or camera or CTA array).

Methods Summary

get_event_id(event_id)

Obtain the event via its event id

get_event_index(event_index)

Obtain the event via its event index

Methods Documentation

get_event_id(event_id)[source]#

Obtain the event via its event id

Parameters:
event_idint

The event_id to seek.

Returns:
eventctapipe.io.container

The event container filled with the requested event’s information

get_event_index(event_index)[source]#

Obtain the event via its event index

Parameters:
event_indexint

The event_index to seek.

Returns:
eventctapipe.io.container

The event container filled with the requested event’s information