ctapipe is not stable yet, so expect large and rapid changes to structure and functionality as we explore various design choices before the 1.0 release.

Component#

class ctapipe.core.component.Component(**kwargs: Any)[source]#

Bases: Configurable

Base class of all Components.

Components are classes that are configurable via traitlets and setup a logger in the ctapipe logging hierarchy.

traitlets can validate values and provide defaults and descriptions. These will be automatically translated into configuration parameters (command-line, config file, etc). Note that any parameter that should be externally configurable must have its config attribute set to True, e.g. defined like myparam = Integer(0, help='the parameter').tag(config=True).

All components also contain a Logger instance in their log attribute, that you must use to output info, debugging data, warnings, etc (do not use print() statements, instead use self.log.info(), self.log.warning(), self.log.debug(), etc).

Components are generally used within ctapipe.core.Tool subclasses, which provide configuration handling and command-line tool generation.

For example:

from ctapipe.core import Component
from traitlets import (Integer, Float)

class MyComponent(Component):
    """ Does something """
    some_option = Integer(default_value=6,
                          help='a value to set').tag(config=True)

comp = MyComponent()
comp.some_option = 6      # ok
comp.some_option = 'test' # will fail validation

Methods Summary

from_name(name[, config, parent])

Obtain an instance of a subclass via its name

get_current_config()

return the current configuration as a dict (e.g. the values of all traits, even if they were not set during configuration).

non_abstract_subclasses()

Get a dict of all non-abstract subclasses of this class.

Methods Documentation

classmethod from_name(name, config=None, parent=None, **kwargs)[source]#

Obtain an instance of a subclass via its name

Parameters:
namestr

Name of the subclass to obtain

configtraitlets.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.

parentctapipe.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).

kwargs
Returns:
instance

Instance of subclass to this class

get_current_config()[source]#

return the current configuration as a dict (e.g. the values of all traits, even if they were not set during configuration)

classmethod non_abstract_subclasses()[source]#

Get a dict of all non-abstract subclasses of this class.

This method is using the entry-point plugin system to also check for registered plugin implementations.

Returns:
subclassesdict[str, type]

A dict mapping the name to the class of all found, non-abstract subclasses of this class.