예제 #1
0
class WaveformCleanerFactory(Factory):
    """
    Factory to obtain a WaveformCleaner.
    """
    name = "WaveformCleanerFactory"
    description = "Obtain WavefromCleaner based on cleaner traitlet"

    subclasses = Factory.child_subclasses(WaveformCleaner)
    subclass_names = [c.__name__ for c in subclasses]

    cleaner = CaselessStrEnum(subclass_names, 'NullWaveformCleaner',
                              help='Waveform cleaning method to '
                                   'use.').tag(config=True)

    # Product classes traits
    window_width = Int(16, help='Define the width of the pulse '
                                'window').tag(config=True)
    window_shift = Int(8, help='Define the shift of the pulse window from the '
                               'peakpos (peakpos - shift).').tag(config=True)

    def get_factory_name(self):
        return self.name

    def get_product_name(self):
        return self.cleaner
예제 #2
0
class CameraR1CalibratorFactory(Factory):
    name = "CameraR1CalibratorFactory"
    description = "Obtain CameraR1Calibrator based on file origin"

    subclasses = Factory.child_subclasses(CameraR1Calibrator)
    subclass_names = [c.origin for c in subclasses]

    origin = CaselessStrEnum(subclass_names,
                             'hessio',
                             help='Origin of events to be '
                             'calibration.').tag(config=True)

    # Product classes traits
    pedestal_path = Unicode('',
                            allow_none=True,
                            help='Path to a pedestal file').tag(config=True)
    tf_path = Unicode('',
                      allow_none=True,
                      help='Path to a Transfer Function file').tag(config=True)
    adc2pe_path = Unicode('', allow_none=True,
                          help='Path to an adc2pe file').tag(config=True)

    def get_factory_name(self):
        return self.name

    def get_product_name(self):
        return self.origin
예제 #3
0
class ChargeExtractorFactory(Factory):
    """
    Factory to obtain a ChargeExtractor.
    """
    name = "ChargeExtractorFactory"
    description = "Obtain ChargeExtractor based on extractor traitlet"

    subclasses = Factory.child_subclasses(ChargeExtractor)
    subclass_names = [c.__name__ for c in subclasses]

    extractor = CaselessStrEnum(subclass_names,
                                'NeighbourPeakIntegrator',
                                help='Charge extraction scheme to '
                                'use.').tag(config=True)

    # Product classes traits
    # Would be nice to have these automatically set...!
    window_width = Int(7,
                       help='Define the width of the integration '
                       'window. Only applicable to '
                       'WindowIntegrators.').tag(config=True)
    window_shift = Int(3,
                       help='Define the shift of the integration window '
                       'from the peakpos (peakpos - shift). Only '
                       'applicable to '
                       'PeakFindingIntegrators.').tag(config=True)
    t0 = Int(0,
             help='Define the peak position for all pixels. '
             'Only applicable to SimpleIntegrators.').tag(config=True)
    sig_amp_cut_HG = Int(None,
                         allow_none=True,
                         help='Define the cut above which a sample is '
                         'considered as significant for PeakFinding '
                         'in the HG channel. Only applicable to '
                         'PeakFindingIntegrators.').tag(config=True)
    sig_amp_cut_LG = Int(None,
                         allow_none=True,
                         help='Define the cut above which a sample is '
                         'considered as significant for PeakFinding '
                         'in the LG channel. Only applicable to '
                         'PeakFindingIntegrators.').tag(config=True)
    lwt = Int(0,
              help='Weight of the local pixel (0: peak from neighbours '
              'only, 1: local pixel counts as much as any neighbour). '
              'Only applicable to '
              'NeighbourPeakIntegrator').tag(config=True)

    def get_factory_name(self):
        return self.name

    def get_product_name(self):
        return self.extractor
예제 #4
0
class DataVolumeReductorFactory(Factory):
    name = "DataVolumeReductorFactory"
    description = "Obtain DataVolumeReductor based on reductor traitlet"

    subclasses = Factory.child_subclasses(DataVolumeReductor)
    subclass_names = [c.__name__ for c in subclasses]

    reductor = CaselessStrEnum(subclass_names, 'NeighbourPeakIntegrator',
                               help='Data volume reduction scheme to use for '
                                    'the conversion to dl0.').tag(config=True)

    # Product classes traits

    def get_factory_name(self):
        return self.name

    def get_product_name(self):
        return self.reductor
예제 #5
0
파일: chec.py 프로젝트: watsonjj/targetpipe
class SPEFitterFactory(Factory):
    """
    Factory to obtain a ChargeFitter of type 'spe'.
    """
    name = "SPEFitterFactory"
    description = "Obtain ChargeFitter based on fitter traitlet"

    subclasses = Factory.child_subclasses(ChargeFitter)
    subclass_names = [c.__name__ for c in subclasses if c.fitter_type == 'spe']

    fitter = CaselessStrEnum(subclass_names,
                             'CHECMSPEFitter',
                             help='Charge fitter to use.').tag(config=True)

    def get_factory_name(self):
        return self.name

    def get_product_name(self):
        return self.fitter
예제 #6
0
class EventFileReaderFactory(Factory):
    name = "EventFileReaderFactory"
    description = "Obtain EventFileReader based on file type"

    subclasses = Factory.child_subclasses(EventFileReader)
    subclass_names = [c.__name__ for c in subclasses]

    reader = CaselessStrEnum(subclass_names,
                             None,
                             allow_none=True,
                             help='Event file reader to use. If None then '
                             'a reader will be chosen based on file '
                             'extension').tag(config=True)

    # Product classes traits
    # Would be nice to have these automatically set...!
    input_path = Unicode(get_path('gamma_test.simtel.gz'),
                         allow_none=True,
                         help='Path to the input file containing '
                         'events.').tag(config=True)
    max_events = Int(None,
                     allow_none=True,
                     help='Maximum number of events that will be read from'
                     'the file').tag(config=True)

    def get_factory_name(self):
        return self.name

    def get_product_name(self):
        if self.reader is not None:
            return self.reader
        else:
            if self.input_path is None:
                raise ValueError("Please specify an input_path for event file")
            try:
                for subclass in self.subclasses:
                    if subclass.check_file_compatibility(self.input_path):
                        return subclass.__name__
                raise ValueError
            except ValueError:
                self.log.exception("Cannot find compatible EventFileReader "
                                   "for: {}".format(self.input_path))
                raise
예제 #7
0
class EventFileReaderFactory(Factory):
    """
    The `EventFileReader` `ctapipe.core.factory.Factory`. This
    `ctapipe.core.factory.Factory` allows the correct
    `EventFileReader` to be obtained for the event file being read. This
    factory tests each EventFileReader by calling
    `EventFileReader.check_file_compatibility` to see which `EventFileReader`
    is compatible with the file.

    Parameters
    ----------
    config : traitlets.loader.Config
        Configuration specified by config file or cmdline arguments.
        Used to set traitlet values.
        Set to None if no configuration to pass.
    tool : ctapipe.core.Tool or None
        Tool executable that is calling this component.
        Passes the correct logger to the component.
        Set to None if no Tool to pass.
    kwargs

    Attributes
    ----------
    reader : traitlets.CaselessStrEnum
        A string with the `EventFileReader.name` of the reader you want to
        use. If left blank, `EventFileReader.check_file_compatibility` will be
        used to find a compatible reader.
    """

    name = "EventFileReaderFactory"
    description = "Obtain EventFileReader based on file type"

    subclasses = Factory.child_subclasses(EventFileReader)
    subclass_names = [c.__name__ for c in subclasses]

    reader = CaselessStrEnum(subclass_names,
                             None,
                             allow_none=True,
                             help='Event file reader to use. If None then '
                             'a reader will be chosen based on file '
                             'extension').tag(config=True)

    # Product classes traits
    # Would be nice to have these automatically set...!
    input_path = Unicode(get_dataset('gamma_test.simtel.gz'),
                         allow_none=True,
                         help='Path to the input file containing '
                         'events.').tag(config=True)
    max_events = Int(None,
                     allow_none=True,
                     help='Maximum number of events that will be read from'
                     'the file').tag(config=True)

    def get_factory_name(self):
        return self.name

    def get_product_name(self):
        if self.reader is not None:
            return self.reader
        else:
            if self.input_path is None:
                raise ValueError("Please specify an input_path for event file")
            try:
                for subclass in self.subclasses:
                    if subclass.check_file_compatibility(self.input_path):
                        return subclass.__name__
                raise ValueError
            except ValueError:
                self.log.exception("Cannot find compatible EventFileReader "
                                   "for: {}".format(self.input_path))
                raise
예제 #8
0
class CameraR1CalibratorFactory(Factory):
    """
    The R1 calibrator `ctapipe.core.factory.Factory`. This
    `ctapipe.core.factory.Factory` allows the correct
    `CameraR1Calibrator` to be obtained for the data investigated. The
    discriminator used by this factory is the "origin" of the file, a string
    obtainable from `ctapipe.io.eventfilereader.EventFileReader.origin`.

    Additional filepaths are required by some cameras for R1 calibration. Due
    to the current inplementation of `ctapipe.core.factory.Factory`, every
    trait that could
    possibly be required for a child `ctapipe.core.component.Component` of
    `CameraR1Calibrator` must
    be included in this `ctapipe.core.factory.Factory`. The
    `CameraR1Calibrator` specific to a
    camera type should then define how/if that filepath should be used. The
    format of the file is not restricted, and the file can be read from inside
    ctapipe, or can call a different library created by the camera teams for
    the calibration of their camera.

    Parameters
    ----------
    config : traitlets.loader.Config
        Configuration specified by config file or cmdline arguments.
        Used to set traitlet values.
        Set to None if no configuration to pass.
    tool : ctapipe.core.Tool or None
        Tool executable that is calling this component.
        Passes the correct logger to the component.
        Set to None if no Tool to pass.
    kwargs

    Attributes
    ----------
    origin : traitlets.CaselessStrEnum
        A string describing the origin of the event file being calibrated.
        Should be obtained from the
        `ctapipe.io.eventfilereader.EventFileReader.origin` attribute of the
        correct `ctapipe.io.eventfilereader.EventFileReader` for the file.
    pedestal_path : traitlets.Unicode
        A string containing the path to a file containing the electronic
        pedestal to be subtracted from the waveforms. How/if this file is used
        is defined by the `CameraR1Calibrator` specific to the camera.
    tf_path : traitlets.Unicode
        A string containing the path to a file containing the transfer
        function to be applied to the waveforms to fix the non-linearity of
        the digitiser. How/if this file is used is defined by the
        `CameraR1Calibrator` specific to the camera.
    pe_path : traitlets.Unicode
        A string containing the path to a file containing the conversion
        coefficients into photoelectrons. How/if this file is used is defined
        by the `CameraR1Calibrator` specific to the camera.
    ff_path : traitlets.Unicode
        A string containing the path to a file containing the flat-field
        conversion coefficients. How/if this file is used is defined by the
        `CameraR1Calibrator` specific to the camera.
    """

    name = "CameraR1CalibratorFactory"
    description = "Obtain CameraR1Calibrator based on file origin"

    subclasses = Factory.child_subclasses(CameraR1Calibrator)
    subclass_names = [c.origin for c in subclasses]

    origin = CaselessStrEnum(subclass_names, 'hessio',
                             help='Origin of events to be '
                                  'calibration.').tag(config=True)

    # Product classes traits
    pedestal_path = Unicode('', allow_none=True,
                            help='Path to a pedestal file').tag(config=True)
    tf_path = Unicode('', allow_none=True,
                      help='Path to a Transfer Function file').tag(config=True)
    pe_path = Unicode('', allow_none=True,
                          help='Path to an pe conversion file').tag(config=True)
    ff_path = Unicode('', allow_none=True,
                      help='Path to a flat field file').tag(config=True)

    def get_factory_name(self):
        return self.name

    def get_product_name(self):
        return self.origin