How to use the ctapipe.core.Container 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 / stage1.py View on Github external
def _write_simulation_configuration(self, writer):
        """
        Write the simulation headers to a single row of a table. Later
        if this file is merged with others, that table will grow.

        Note that this function should be run first
        """
        self.log.debug("Writing simulation configuration")

        class ExtraMCInfo(Container):
            container_prefix = ""
            obs_id = Field(0, "MC Run Identifier")

        extramc = ExtraMCInfo()
        extramc.obs_id = self.event_source.obs_id
        self.event_source.mc_header.prefix = ""
        writer.write(
            "configuration/simulation/run", [extramc, self.event_source.mc_header]
        )
github cta-observatory / ctapipe / ctapipe / containers.py View on Github external
None,
        (
            "numpy array containing a set of images, one per ADC sample"
            "Shape: (n_pixels, n_samples)"
        ),
    )
    selected_gain_channel = Field(
        None,
        (
            "Numpy array containing the gain channel chosen for each pixel. "
            "Shape: (n_pixels)"
        ),
    )


class R1Container(Container):
    """
    Storage of a r1 calibrated Data Event
    """

    tels_with_data = Field([], "set of tel_ids for telescopes with data")
    tel = Field(Map(R1CameraContainer), "map of tel_id to R1CameraContainer")


class DL0CameraContainer(Container):
    """
    Storage of data volume reduced dl0 data from a single telescope
    """

    trigger_time = Field(None, "Telescope trigger time, start of waveform " "readout")
    trigger_type = Field(0o0, "camera trigger type")
github cta-observatory / ctapipe / ctapipe / containers.py View on Github external
DL1 image information."""

    true_image = Field(
        None,
        "Numpy array of camera image in PE as simulated before noise has been added. "
        "Shape: (n_pixel)",
        dtype=np.float32,
        ndim=1,
    )

    true_parameters = Field(
        ImageParametersContainer(), "Parameters derived from the true_image"
    )


class DL1Container(Container):
    """ DL1 Calibrated Camera Images and associated data"""

    tel = Field(Map(DL1CameraContainer), "map of tel_id to DL1CameraContainer")


class DL1CameraCalibrationContainer(Container):
    """
    Storage of DL1 calibration parameters for the current event
    """

    pedestal_offset = Field(
        0,
        "Additive coefficients for the pedestal calibration of extracted charge "
        "for each pixel",
    )
    absolute_factor = Field(
github cta-observatory / ctapipe / ctapipe / containers.py View on Github external
r1 = Field(R1Container(), "R1 Calibrated Data")
    dl0 = Field(DL0Container(), "DL0 Data Volume Reduced Data")
    dl1 = Field(DL1Container(), "DL1 Calibrated image")
    dl2 = Field(ReconstructedContainer(), "Reconstructed Shower Information")
    mc = Field(MCEventContainer(), "Monte-Carlo data")
    mcheader = Field(MCHeaderContainer(), "Monte-Carlo run header data")
    trigger = Field(TriggerContainer(), "central trigger information")
    count = Field(0, "number of events processed")
    pointing = Field(PointingContainer(), "Array and telescope pointing positions")
    calibration = Field(
        EventCalibrationContainer(),
        "Container for calibration coefficients for the current event",
    )


class MuonRingContainer(Container):
    """Container for the result of a ring fit, center_x, center_y"""

    center_x = Field(nan * u.deg, "center (x) of the fitted muon ring", unit=u.deg)
    center_y = Field(nan * u.deg, "center (y) of the fitted muon ring", unit=u.deg)
    radius = Field(nan * u.deg, "radius of the fitted muon ring", unit=u.deg)
    center_phi = Field(
        nan * u.deg, "Angle of ring center within camera plane", unit=u.deg
    )
    center_distance = Field(
        nan * u.deg, "Distance of ring center from camera center", unit=u.deg
    )


class MuonEfficiencyContainer(Container):
    width = Field(nan * u.deg, "width of the muon ring in degrees")
    impact = Field(nan * u.m, "distance of muon impact position from center of mirror")
github cta-observatory / ctapipe / ctapipe / containers.py View on Github external
alt = Field(nan * u.deg, "Monte-carlo altitude", unit=u.deg)
    az = Field(nan * u.deg, "Monte-Carlo azimuth", unit=u.deg)
    core_x = Field(nan * u.m, "MC core position", unit=u.m)
    core_y = Field(nan * u.m, "MC core position", unit=u.m)
    h_first_int = Field(nan * u.m, "Height of first interaction", unit=u.m)
    x_max = Field(nan * u.g / (u.cm ** 2), "MC Xmax value", unit=u.g / (u.cm ** 2))
    shower_primary_id = Field(
        -1,
        "MC shower primary ID 0 (gamma), 1(e-),"
        "2(mu-), 100*A+Z for nucleons and nuclei,"
        "negative for antimatter.",
    )
    tel = Field(Map(MCCameraEventContainer), "map of tel_id to MCCameraEventContainer")


class MCHeaderContainer(Container):
    """
    Monte-Carlo information that doesn't change per event
    """

    run_array_direction = Field(
        [],
        (
            "the tracking/pointing direction in "
            "[radians]. Depending on 'tracking_mode' "
            "this either contains: "
            "[0]=Azimuth, [1]=Altitude in mode 0, "
            "OR "
            "[0]=R.A., [1]=Declination in mode 1."
        ),
    )
    corsika_version = Field(nan, "CORSIKA version * 1000")
github cta-observatory / ctapipe / ctapipe / pipeline / algorithms / write_file.py View on Github external
def run(self, _input):
        if isinstance(_input, Container):
            self.events.append(_input)
        else:
            outfile = open(_input, "wb")
            objects = self.events
            pickle.dump(objects, outfile)
            outfile.close()
github cta-observatory / ctapipe / ctapipe / containers.py View on Github external
# Standard Physics  stereo trigger
    SUBARRAY = 32

    UNKNOWN = 255


class EventIndexContainer(Container):
    """ index columns to include in event lists, common to all data levels"""

    container_prefix = ""  # don't want to prefix these
    obs_id = Field(0, "observation identifier")
    event_id = Field(0, "event identifier")


class TelEventIndexContainer(Container):
    """
    index columns to include in telescope-wise event lists, common to all data
    levels that have telescope-wise information
    """

    container_prefix = ""  # don't want to prefix these
    obs_id = Field(0, "observation identifier")
    event_id = Field(0, "event identifier")
    tel_id = Field(0, "telescope identifier")


class HillasParametersContainer(Container):
    container_prefix = "hillas"

    intensity = Field(nan, "total intensity (size)")
github cta-observatory / ctapipe / ctapipe / io / hdf5tableio.py View on Github external
def write(self, table_name, containers):
        """
        Write the contents of the given container or containers to a table.
        The first call to write  will create a schema and initialize the table
        within the file.
        The shape of data within the container must not change between
        calls, since variable-length arrays are not supported.

        Parameters
        ----------
        table_name: str
            name of table to write to
        containers: `ctapipe.core.Container` or `Iterable[ctapipe.core.Container]`
            container to write
        """
        if isinstance(containers, Container):
            containers = (containers,)

        if table_name not in self._schemas:
            self._setup_new_table(table_name, containers)

        self._append_row(table_name, containers)
github cta-observatory / ctapipe / ctapipe / containers.py View on Github external
sample_time_min = Field(nan * u.s, "Time of first pedestal event", unit=u.s)
    sample_time_max = Field(nan * u.s, "Time of last pedestal event", unit=u.s)
    charge_mean = Field(None, "np array of pedestal average (n_chan, n_pix)")
    charge_median = Field(None, "np array of the pedestal  median (n_chan, n_pix)")
    charge_std = Field(
        None, "np array of the pedestal standard deviation (n_chan, n_pix)"
    )
    charge_median_outliers = Field(
        None, "Boolean np array of the pedestal median outliers (n_chan, n_pix)"
    )
    charge_std_outliers = Field(
        None, "Boolean np array of the pedestal std outliers (n_chan, n_pix)"
    )


class PixelStatusContainer(Container):
    """
    Container for pixel status information
    It contains masks obtained by several data analysis steps
    At r0/r1 level only the hardware_mask is initialized
    """

    hardware_failing_pixels = Field(
        None,
        "Boolean np array (True = failing pixel) from the hardware pixel status data ("
        "n_chan, n_pix)",
    )

    pedestal_failing_pixels = Field(
        None,
        "Boolean np array (True = failing pixel) from the pedestal data analysis ("
        "n_chan, n_pix)",
github cta-observatory / ctapipe / ctapipe / containers.py View on Github external
class EventCalibrationContainer(Container):
    """
    Container for calibration coefficients for the current event
    """

    tels_with_data = Field([], "set of tel_ids for telescopes with data")

    # create the camera container
    tel = Field(
        Map(EventCameraCalibrationContainer),
        "map of tel_id to EventCameraCalibrationContainer",
    )


class DataContainer(Container):
    """ Top-level container for all event information """

    index = Field(EventIndexContainer(), "event indexing information")
    r0 = Field(R0Container(), "Raw Data")
    r1 = Field(R1Container(), "R1 Calibrated Data")
    dl0 = Field(DL0Container(), "DL0 Data Volume Reduced Data")
    dl1 = Field(DL1Container(), "DL1 Calibrated image")
    dl2 = Field(ReconstructedContainer(), "Reconstructed Shower Information")
    mc = Field(MCEventContainer(), "Monte-Carlo data")
    mcheader = Field(MCHeaderContainer(), "Monte-Carlo run header data")
    trigger = Field(TriggerContainer(), "central trigger information")
    count = Field(0, "number of events processed")
    pointing = Field(PointingContainer(), "Array and telescope pointing positions")
    calibration = Field(
        EventCalibrationContainer(),
        "Container for calibration coefficients for the current event",