示例#1
0
    def from_url(cls, input_url, **kwargs):
        """
        Find compatible EventSource for input_url via the `is_compatible`
        method of the EventSource

        Parameters
        ----------
        input_url : str
            Filename or URL pointing to an event file
        kwargs
            Named arguments for the EventSource

        Returns
        -------
        instance
            Instance of a compatible EventSource subclass
        """
        detect_and_import_io_plugins()
        available_classes = non_abstract_children(cls)

        for subcls in available_classes:
            if subcls.is_compatible(input_url):
                return subcls(input_url=input_url, **kwargs)

        raise ValueError(
            'Cannot find compatible EventSource for \n'
            '\turl:{}\n'
            'in available EventSources:\n'
            '\t{}'.format(input_url, [c.__name__ for c in available_classes])
        )
示例#2
0
    def from_url(cls, input_url, **kwargs):
        """
        Find compatible EventSource for input_url via the `is_compatible`
        method of the EventSource

        Parameters
        ----------
        input_url : str
            Filename or URL pointing to an event file
        kwargs
            Named arguments for the EventSource

        Returns
        -------
        instance
            Instance of a compatible EventSource subclass
        """
        if input_url == "" or input_url is None:
            raise ToolConfigurationError(
                "EventSource: No input_url was specified")

        detect_and_import_io_plugins()
        available_classes = non_abstract_children(cls)

        for subcls in available_classes:
            if subcls.is_compatible(input_url):
                return subcls(input_url=input_url, **kwargs)

        raise ValueError("Cannot find compatible EventSource for \n"
                         "\turl:{}\n"
                         "in available EventSources:\n"
                         "\t{}".format(input_url,
                                       [c.__name__
                                        for c in available_classes]))
示例#3
0
    def from_name(cls, name, config=None, parent=None):
        """
        Obtain an instance of a subclass via its name

        Parameters
        ----------
        name : str
            Name of the subclass to obtain
        config : traitlets.loader.Config
            Configuration specified by config file or cmdline arguments.
            Used to set traitlet values.
            This argument is typically only specified when using this method
            from within a Tool.
        tool : ctapipe.core.Tool
            Tool executable that is calling this component.
            Passes the correct logger to the component.
            This argument is typically only specified when using this method
            from within a Tool.

        Returns
        -------
        instace
            Instance of subclass to this class
        """
        detect_and_import_io_plugins()
        subclasses = {
            base.__name__: base
            for base in non_abstract_children(cls)
        }
        requested_subclass = subclasses[name]

        return requested_subclass(config=config, parent=parent)
示例#4
0
    def from_name(cls, name, config=None, parent=None):
        """
        Obtain an instance of a subclass via its name

        Parameters
        ----------
        name : str
            Name of the subclass to obtain
        config : traitlets.loader.Config
            Configuration specified by config file or cmdline arguments.
            Used to set traitlet values.
            This argument is typically only specified when using this method
            from within a Tool.
        parent : ctapipe.core.Tool
            Tool executable that is calling this component.
            Passes the correct logger and configuration to the component.
            This argument is typically only specified when using this method
            from within a Tool (config need not be passed if parent is used).

        Returns
        -------
        instace
            Instance of subclass to this class
        """
        detect_and_import_io_plugins()
        subclasses = {
            base.__name__: base
            for base in non_abstract_children(cls)
        }
        requested_subclass = subclasses[name]

        return requested_subclass(config=config, parent=parent)
示例#5
0
    def non_abstract_subclasses(cls):
        """
        get dict{name: cls} of non abstract subclasses,
        subclasses can possibly be definded in plugins
        """
        detect_and_import_io_plugins()

        subclasses = {
            base.__name__: base
            for base in non_abstract_children(cls)
        }
        return subclasses
示例#6
0
from .array import get_array_layout
from .eventseeker import EventSeeker
from .eventsource import EventSource, event_source
from .hdf5tableio import HDF5TableReader, HDF5TableWriter
from .tableio import TableWriter, TableReader

# import event sources to make them visible to EventSource.from_url
from .simteleventsource import SimTelEventSource

from ctapipe.core.plugins import detect_and_import_io_plugins

detect_and_import_io_plugins()

__all__ = [
    'get_array_layout',
    'HDF5TableWriter',
    'HDF5TableReader',
    'TableWriter',
    'TableReader',
    'EventSeeker',
    'EventSource',
    'event_source',
    'SimTelEventSource',
]