How to use the ctapipe.calib.CameraCalibrator function in ctapipe

To help you get started, we’ve selected a few ctapipe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cta-observatory / ctapipe / ctapipe / tools / muon_reconstruction.py View on Github external
"Minimum number of pixels after cleaning and ring finding"
            "required to process an event"
        ),
        default_value=100,
    ).tag(config=True)

    pedestal = traits.FloatTelescopeParameter(
        help="Pedestal noise rms", default_value=1.1,
    ).tag(config=True)

    extractor_name = traits.create_class_enum_trait(
        ImageExtractor, default_value="GlobalPeakWindowSum",
    ).tag(config=True)

    classes = [
        CameraCalibrator,
        TailcutsImageCleaner,
        EventSource,
        MuonRingFitter,
        MuonIntensityFitter,
    ] + traits.classes_with_traits(ImageExtractor)

    aliases = {
        "i": "EventSource.input_url",
        "input": "EventSource.input_url",
        "o": "MuonAnalysis.output",
        "output": "MuonAnalysis.output",
        "max-events": "EventSource.max_events",
        "allowed-tels": "EventSource.allowed_tels",
    }

    flags = {
github cta-observatory / ctapipe / ctapipe / tools / extract_charge_resolution.py View on Github external
def setup(self):
        self.log_format = "%(levelname)s: %(message)s [%(name)s.%(funcName)s]"

        self.eventsource = self.add_component(SimTelEventSource(parent=self))

        extractor = self.add_component(
            ImageExtractor.from_name(
                self.extractor_product, parent=self, subarray=self.eventsource.subarray,
            )
        )

        self.calibrator = self.add_component(
            CameraCalibrator(
                parent=self,
                image_extractor=extractor,
                subarray=self.eventsource.subarray,
            )
        )
        self.calculator = ChargeResolutionCalculator()
github cta-observatory / ctapipe / ctapipe / tools / display_dl1.py View on Github external
def setup(self):
        self.eventsource = self.add_component(EventSource.from_config(parent=self))

        self.calibrator = self.add_component(
            CameraCalibrator(parent=self, subarray=self.eventsource.subarray)
        )
        self.plotter = self.add_component(
            ImagePlotter(subarray=self.eventsource.subarray, parent=self)
        )
github cta-observatory / ctapipe / examples / plot_array_hillas.py View on Github external
# importing data from avaiable datasets in ctapipe
    filename = datasets.get_dataset_path("gamma_test_large.simtel.gz")

    if len(sys.argv) > 1:
        filename = sys.argv[1]

    # reading the Monte Carlo file for LST
    source = event_source(filename)

    # pointing direction of the telescopes
    point_azimuth = {}
    point_altitude = {}

    subarray = source.subarray
    calib = CameraCalibrator(subarray=subarray)
    off_angles = []
    first_event = True
    markers = None

    for event in source:
        if first_event:
            fig, ax = plt.subplots(1, 1, figsize=(10, 8))
            array_disp = ArrayDisplay(subarray, axes=ax, tel_scale=1.0)
            array_disp.telescopes.set_linewidth(3)
            array_disp.add_labels()
            first_event = False
            hit_pattern = np.zeros(subarray.num_tels)

        if len(event.r0.tels_with_data) < 3:
            continue
github cta-observatory / ctapipe / ctapipe / tools / display_integrator.py View on Github external
def setup(self):
        self.log_format = "%(levelname)s: %(message)s [%(name)s.%(funcName)s]"

        event_source = self.add_component(EventSource.from_config(parent=self))
        self.subarray = event_source.subarray
        self.eventseeker = self.add_component(EventSeeker(event_source, parent=self))
        self.extractor = self.add_component(
            ImageExtractor.from_name(
                self.extractor_product, parent=self, subarray=self.subarray
            )
        )
        self.calibrate = self.add_component(
            CameraCalibrator(
                parent=self, image_extractor=self.extractor, subarray=self.subarray
            )
github cta-observatory / ctapipe / ctapipe / tools / bokeh / file_viewer.py View on Github external
def setup(self):
        self.log_format = "%(levelname)s: %(message)s [%(name)s.%(funcName)s]"

        self.reader = EventSource.from_config(parent=self)
        self.seeker = EventSeeker(self.reader, parent=self)

        self.extractor = ImageExtractor.from_name(
            self.extractor_product, parent=self, subarray=self.reader.subarray,
        )
        self.calibrator = CameraCalibrator(
            subarray=self.reader.subarray, parent=self, image_extractor=self.extractor,
        )

        self.viewer = BokehEventViewer(parent=self, subarray=self.reader.subarray)

        # Setup widgets
        self.viewer.create()
        self.viewer.enable_automatic_index_increment()
        self.create_previous_event_widget()
        self.create_next_event_widget()
        self.create_event_index_widget()
        self.create_goto_event_index_widget()
        self.create_event_id_widget()
        self.create_goto_event_id_widget()
        self.create_telid_widget()
        self.create_channel_widget()
github cta-observatory / ctapipe / examples / simple_event_writer.py View on Github external
exists=True,
    ).tag(config=True)
    outfile = Path(
        help="output file name", directory_ok=False, default_value="output.h5"
    ).tag(config=True)
    progress = Bool(help="display progress bar", default_value=True).tag(config=True)

    aliases = Dict(
        {
            "infile": "EventSource.input_url",
            "outfile": "SimpleEventWriter.outfile",
            "max-events": "EventSource.max_events",
            "progress": "SimpleEventWriter.progress",
        }
    )
    classes = List([EventSource, CameraCalibrator])

    def setup(self):
        self.log.info("Configure EventSource...")

        self.event_source = self.add_component(
            EventSource.from_url(self.infile, parent=self)
        )

        self.calibrator = self.add_component(
            CameraCalibrator(subarray=self.event_source.subarray, parent=self)
        )

        self.writer = self.add_component(
            HDF5TableWriter(
                filename=self.outfile, group_name="image_infos", overwrite=True
            )
github cta-observatory / ctapipe / ctapipe / tools / display_events_single_tel.py View on Github external
def setup(self):
        print("TOLLES INFILE", self.infile)
        self.event_source = self.add_component(
            EventSource.from_url(self.infile, parent=self)
        )
        self.event_source.allowed_tels = {
            self.tel,
        }

        self.calibrator = self.add_component(
            CameraCalibrator(parent=self, subarray=self.event_source.subarray)
        )

        self.log.info(f"SELECTING EVENTS FROM TELESCOPE {self.tel}")
github cta-observatory / ctapipe / examples / simple_pipeline.py View on Github external
The most basic pipeline, using no special features of the framework other 
than a for-loop. This is useful for debugging and profiling of speed.
"""

import sys

from ctapipe.calib import CameraCalibrator
from ctapipe.io import event_source

if __name__ == '__main__':

    filename = sys.argv[1]

    source = event_source(filename, max_events=None)

    cal = CameraCalibrator(subarray=source.subarray)

    for ii, event in enumerate(source):

        print(
            "{} EVENT_ID: {}, ENERGY: {:.2f}, NTELS:{}".format(
                ii,
                event.index.event_id, event.mc.energy, len(event.dl0.tels_with_data)
            )
        )

        cal(event)
github cta-observatory / ctapipe / ctapipe / tools / bokeh / file_viewer.py View on Github external
def update_dl1_calibrator(self, extractor=None):
        """
        Recreate the dl1 calibrator with the specified extractor and cleaner

        Parameters
        ----------
        extractor : ctapipe.image.extractor.ImageExtractor
        """
        if extractor is None:
            extractor = self.calibrator.image_extractor

        self.extractor = extractor

        self.calibrator = CameraCalibrator(
            subarray=self.reader.subarray, parent=self, image_extractor=self.extractor,
        )
        self.viewer.refresh()