Ejemplo n.º 1
0
    def __init__(self, config=None, parent=None,
                 extractor_name='NeighborPeakWindowSum',
                 **kwargs):
        """
        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.
        extractor_name : str
            The name of the ImageExtractor to use.
        kwargs
        """
        super().__init__(config=config, parent=parent, **kwargs)

        extractor = ImageExtractor.from_name(
            extractor_name,
            parent=self,
        )

        self.dl0 = CameraDL0Reducer(parent=parent)
        self.dl1 = CameraDL1Calibrator(
            parent=self,
            extractor=extractor,
        )
Ejemplo n.º 2
0
    def __init__(self,
                 config=None,
                 parent=None,
                 extractor_name='NeighborPeakWindowSum',
                 **kwargs):
        """
        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.
        extractor_name : str
            The name of the ImageExtractor to use.
        kwargs
        """
        super().__init__(config=config, parent=parent, **kwargs)

        extractor = ImageExtractor.from_name(
            extractor_name,
            parent=self,
        )

        self.dl0 = CameraDL0Reducer(parent=parent)
        self.dl1 = CameraDL1Calibrator(
            parent=self,
            extractor=extractor,
        )
Ejemplo n.º 3
0
    def __init__(self,
                 config=None,
                 parent=None,
                 r1_product=None,
                 extractor_name='NeighborPeakWindowSum',
                 eventsource=None,
                 **kwargs):
        """
        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.
        r1_product : str
            The R1 calibrator to use. Manually overrides the Factory.
        extractor_name : str
            The name of the ImageExtractor to use.
        eventsource : ctapipe.io.eventsource.EventSource
            EventSource that is being used to read the events. The EventSource
            contains information (such as metadata or inst) which indicates
            the appropriate R1Calibrator to use.
        kwargs
        """
        super().__init__(config=config, parent=parent, **kwargs)

        extractor = ImageExtractor.from_name(
            extractor_name,
            parent=self,
        )

        if r1_product:
            self.r1 = CameraR1Calibrator.from_name(
                r1_product,
                parent=self,
            )
        else:
            self.r1 = CameraR1Calibrator.from_eventsource(
                eventsource,
                parent=self,
            )

        self.dl0 = CameraDL0Reducer(parent=parent)
        self.dl1 = CameraDL1Calibrator(
            parent=self,
            extractor=extractor,
        )
Ejemplo n.º 4
0
    def setup(self):
        if self.output is None:
            raise ToolConfigurationError(
                'You need to provide an --output file')

        if self.output.exists() and not self.overwrite:
            raise ToolConfigurationError(
                'Outputfile {self.output} already exists, use `--overwrite` to overwrite'
            )

        self.source = self.add_component(EventSource.from_config(parent=self))
        self.extractor = self.add_component(
            ImageExtractor.from_name(self.extractor_name,
                                     parent=self,
                                     subarray=self.source.subarray))
        self.calib = self.add_component(
            CameraCalibrator(
                subarray=self.source.subarray,
                parent=self,
                image_extractor=self.extractor,
            ))
        self.ring_fitter = self.add_component(MuonRingFitter(parent=self, ))
        self.intensity_fitter = self.add_component(
            MuonIntensityFitter(
                subarray=self.source.subarray,
                parent=self,
            ))
        self.cleaning = self.add_component(
            TailcutsImageCleaner(
                parent=self,
                subarray=self.source.subarray,
            ))
        self.writer = self.add_component(
            HDF5TableWriter(
                self.output,
                "",
                add_prefix=True,
                parent=self,
                mode='w',
            ))
        self.pixels_in_tel_frame = {}
        self.field_of_view = {}
        self.pixel_widths = {}

        for p in [
                'min_pixels', 'pedestal', 'ratio_width',
                'completeness_threshold'
        ]:
            getattr(self, p).attach_subarray(self.source.subarray)
Ejemplo n.º 5
0
    def __init__(self, config=None, parent=None,
                 r1_product=None,
                 extractor_name='NeighborPeakWindowSum',
                 eventsource=None,
                 **kwargs):
        """
        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.
        r1_product : str
            The R1 calibrator to use. Manually overrides the Factory.
        extractor_name : str
            The name of the ImageExtractor to use.
        eventsource : ctapipe.io.eventsource.EventSource
            EventSource that is being used to read the events. The EventSource
            contains information (such as metadata or inst) which indicates
            the appropriate R1Calibrator to use.
        kwargs
        """
        super().__init__(config=config, parent=parent, **kwargs)

        extractor = ImageExtractor.from_name(
            extractor_name,
            parent=self,
        )

        if r1_product:
            self.r1 = CameraR1Calibrator.from_name(
                r1_product,
                parent=self,
            )
        else:
            self.r1 = CameraR1Calibrator.from_eventsource(
                eventsource,
                parent=self,
            )

        self.dl0 = CameraDL0Reducer(parent=parent)
        self.dl1 = CameraDL1Calibrator(
            parent=self,
            extractor=extractor,
        )
Ejemplo n.º 6
0
def load_image_extractor_from_config(custom_config, subarray):
    """
    Return an image extractor from a custom config.
    The passed custom_config superseeds the standard config.
    Parameters
    ----------
    config: dictionnary. Should contains:
        - image_extractor
        - image_extractor_config

    Returns
    -------

    """
    config = replace_config(get_standard_config(), custom_config)
    conf = Config(config)
    return ImageExtractor.from_name(config['image_extractor'],
                                    subarray=subarray,
                                    config=conf)