当前位置: 首页>>代码示例>>Python>>正文


Python CameraDisplay.cmap方法代码示例

本文整理汇总了Python中ctapipe.visualization.CameraDisplay.cmap方法的典型用法代码示例。如果您正苦于以下问题:Python CameraDisplay.cmap方法的具体用法?Python CameraDisplay.cmap怎么用?Python CameraDisplay.cmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ctapipe.visualization.CameraDisplay的用法示例。


在下文中一共展示了CameraDisplay.cmap方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: transform_and_clean_hex_samples

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
def transform_and_clean_hex_samples(pmt_samples, cam_geom):

    # rotate all samples in the image to a rectangular image
    rot_geom, rot_samples = convert_geometry_1d_to_2d(
        cam_geom, pmt_samples, cam_geom.cam_id)

    print("rot samples.shape:", rot_samples.shape)

    # rotate the samples back to hex image
    unrot_geom, unrot_samples = convert_geometry_back(rot_geom, rot_samples,
                                                      cam_geom.cam_id)

    global fig
    global cb1, ax1
    global cb2, ax2
    global cb3, ax3
    if fig is None:
        fig = plt.figure(figsize=(10, 10))
    else:
        fig.delaxes(ax1)
        fig.delaxes(ax2)
        fig.delaxes(ax3)
        cb1.remove()
        cb2.remove()
        cb3.remove()

    ax1 = fig.add_subplot(221)
    disp1 = CameraDisplay(rot_geom, image=np.sum(rot_samples, axis=-1), ax=ax1)
    plt.gca().set_aspect('equal', adjustable='box')
    plt.title("rotated image")
    disp1.cmap = plt.cm.inferno
    disp1.add_colorbar()
    cb1 = disp1.colorbar

    ax2 = fig.add_subplot(222)
    disp2 = CameraDisplay(cam_geom, image=np.sum(pmt_samples, axis=-1), ax=ax2)
    plt.gca().set_aspect('equal', adjustable='box')
    plt.title("original image")
    disp2.cmap = plt.cm.inferno
    disp2.add_colorbar()
    cb2 = disp2.colorbar

    ax3 = fig.add_subplot(223)
    disp3 = CameraDisplay(unrot_geom, image=np.sum(unrot_samples, axis=-1), ax=ax3)
    plt.gca().set_aspect('equal', adjustable='box')
    plt.title("de-rotated image")
    disp3.cmap = plt.cm.inferno
    disp3.add_colorbar()
    cb3 = disp3.colorbar

    plt.pause(.1)
    response = input("press return to continue")
    if response != "":
        exit()
开发者ID:jdhp-sap,项目名称:tino_cta,代码行数:56,代码来源:compare_cleaned_images.py

示例2: draw_camera

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
    def draw_camera(self, tel, data, axes=None):
        """
        Draw a camera image using the correct geometry.

        Parameters
        ----------
        tel : int
            The telescope you want drawn.
        data : `np.array`
            1D array with length equal to npix.
        axes : `matplotlib.axes.Axes`
            A matplotlib axes object to plot on, or None to create a new one.

        Returns
        -------
        `ctapipe.visualization.CameraDisplay`
        """

        geom = self.get_geometry(tel)
        axes = axes if axes is not None else plt.gca()
        camera = CameraDisplay(geom, ax=axes)
        camera.image = data
        camera.cmap = plt.cm.viridis
        # camera.add_colorbar(ax=axes, label="Amplitude (ADC)")
        # camera.set_limits_percent(95)  # autoscale
        return camera
开发者ID:wrijupan,项目名称:ctapipe,代码行数:28,代码来源:camera.py

示例3: display_event

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
def display_event(event, geoms):
    """an extremely inefficient display. It creates new instances of
    CameraDisplay for every event and every camera, and also new axes
    for each event. It's hacked, but it works
    """
    print("Displaying... please wait (this is an inefficient implementation)")
    global fig
    ntels = len(event.r0.tels_with_data)
    fig.clear()

    plt.suptitle("EVENT {}".format(event.r0.event_id))

    disps = []

    for ii, tel_id in enumerate(event.r0.tels_with_data):
        print("\t draw cam {}...".format(tel_id))
        nn = int(ceil(sqrt(ntels)))
        ax = plt.subplot(nn, nn, ii + 1)

        x, y = event.inst.pixel_pos[tel_id]
        geom = geoms[tel_id]
        disp = CameraDisplay(geom, ax=ax, title="CT{0}".format(tel_id))
        disp.pixels.set_antialiaseds(False)
        disp.autoupdate = False
        disp.cmap = 'afmhot'
        chan = 0
        signals = event.r0.tel[tel_id].adc_sums[chan].astype(float)
        signals -= signals.mean()
        disp.image = signals
        disp.set_limits_percent(95)
        disp.add_colorbar()
        disps.append(disp)

    return disps
开发者ID:epuesche,项目名称:ctapipe,代码行数:36,代码来源:mock_generator.py

示例4: _display_camera_animation

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
    def _display_camera_animation(self):
        #plt.style.use("ggplot")
        fig = plt.figure(num="ctapipe Camera Demo", figsize=(7, 7))
        ax = plt.subplot(111)

        # load the camera
        geom = CameraGeometry.from_name(self.camera)
        disp = CameraDisplay(geom, ax=ax, autoupdate=True, )
        disp.cmap = plt.cm.terrain

        def update(frame):

            centroid = np.random.uniform(-0.5, 0.5, size=2)
            width = np.random.uniform(0, 0.01)
            length = np.random.uniform(0, 0.03) + width
            angle = np.random.uniform(0, 360)
            intens = np.random.exponential(2) * 50
            model = toymodel.generate_2d_shower_model(centroid=centroid,
                                                      width=width,
                                                      length=length,
                                                      psi=angle * u.deg)
            image, sig, bg = toymodel.make_toymodel_shower_image(geom, model.pdf,
                                                                 intensity=intens,
                                                                 nsb_level_pe=5000)

            # alternate between cleaned and raw images
            if self._counter == self.cleanframes:
                plt.suptitle("Image Cleaning ON")
                self.imclean = True
            if self._counter == self.cleanframes*2:
                plt.suptitle("Image Cleaning OFF")
                self.imclean = False
                self._counter = 0

            if self.imclean:
                cleanmask = tailcuts_clean(geom, image/80.0)
                for ii in range(3):
                    dilate(geom, cleanmask)
                image[cleanmask == 0] = 0  # zero noise pixels

            self.log.debug("count = {}, image sum={} max={}"
                .format(self._counter, image.sum(), image.max()))
            disp.image = image

            if self.autoscale:
                disp.set_limits_percent(95)
            else:
                disp.set_limits_minmax(-100, 4000)

            disp.axes.figure.canvas.draw()
            self._counter += 1
            return [ax,]

        self.anim = FuncAnimation(fig, update, interval=self.delay,
                                  blit=self.blit)
        plt.show()
开发者ID:wrijupan,项目名称:ctapipe,代码行数:58,代码来源:camdemo.py

示例5: draw_several_cams

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
def draw_several_cams(geom, ncams=4):

    cmaps = ['jet', 'afmhot', 'terrain', 'autumn']
    fig, axs = plt.subplots(
        1, ncams, figsize=(15, 4),
    )

    for ii in range(ncams):
        disp = CameraDisplay(
            geom,
            ax=axs[ii],
            title="CT{}".format(ii + 1),
        )
        disp.cmap = cmaps[ii]

        model = toymodel.generate_2d_shower_model(
            centroid=(0.2 - ii * 0.1, -ii * 0.05),
            width=0.05 + 0.001 * ii,
            length=0.15 + 0.05 * ii,
            psi=ii * 20 * u.deg,
        )

        image, sig, bg = toymodel.make_toymodel_shower_image(
            geom,
            model.pdf,
            intensity=1500,
            nsb_level_pe=5,
        )

        mask = tailcuts_clean(
            geom,
            image,
            picture_thresh=6 * image.mean(),
            boundary_thresh=4 * image.mean()
        )
        cleaned = image.copy()
        cleaned[~mask] = 0

        hillas = hillas_parameters(geom, cleaned)

        disp.image = image
        disp.add_colorbar(ax=axs[ii])

        disp.set_limits_percent(95)
        disp.overlay_moments(hillas, linewidth=3, color='blue')
开发者ID:ParsonsRD,项目名称:ctapipe,代码行数:47,代码来源:camera_display_multi.py

示例6: start

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
    def start(self):
        geom = None
        imsum = None
        disp = None

        for data in hessio_event_source(self.infile,
                                        allowed_tels=self._selected_tels,
                                        max_events=self.max_events):

            self.calibrator.calibrate(data)

            if geom is None:
                x, y = data.inst.pixel_pos[self._base_tel]
                flen = data.inst.optical_foclen[self._base_tel]
                geom = CameraGeometry.guess(x, y, flen)
                imsum = np.zeros(shape=x.shape, dtype=np.float)
                disp = CameraDisplay(geom, title=geom.cam_id)
                disp.add_colorbar()
                disp.cmap = 'viridis'

            if len(data.dl0.tels_with_data) <= 2:
                continue

            imsum[:] = 0
            for telid in data.dl0.tels_with_data:
                imsum += data.dl1.tel[telid].image[0]

            self.log.info("event={} ntels={} energy={}" \
                          .format(data.r0.event_id,
                                  len(data.dl0.tels_with_data),
                                  data.mc.energy))
            disp.image = imsum
            plt.pause(0.1)

            if self.output_suffix is not "":
                filename = "{:020d}{}".format(data.r0.event_id,
                                              self.output_suffix)
                self.log.info("saving: '{}'".format(filename))
                plt.savefig(filename)
开发者ID:wrijupan,项目名称:ctapipe,代码行数:41,代码来源:display_summed_images.py

示例7: start

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
    def start(self):
        geom = None
        imsum = None
        disp = None

        for event in self.reader:

            self.calibrator(event)

            if geom is None:
                geom = event.inst.subarray.tel[self._base_tel].camera
                imsum = np.zeros(shape=geom.pix_x.shape, dtype=np.float)
                disp = CameraDisplay(geom, title=geom.cam_id)
                disp.add_colorbar()
                disp.cmap = 'viridis'

            if len(event.dl0.tels_with_data) <= 2:
                continue

            imsum[:] = 0
            for telid in event.dl0.tels_with_data:
                imsum += event.dl1.tel[telid].image[0]

            self.log.info(
                "event={} ntels={} energy={}".format(
                    event.r0.event_id, len(event.dl0.tels_with_data),
                    event.mc.energy
                )
            )
            disp.image = imsum
            plt.pause(0.1)

            if self.output_suffix is not "":
                filename = "{:020d}{}".format(
                    event.r0.event_id, self.output_suffix
                )
                self.log.info(f"saving: '{filename}'")
                plt.savefig(filename)
开发者ID:kosack,项目名称:ctapipe,代码行数:40,代码来源:display_summed_images.py

示例8: tailcuts_clean

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
                                              psi='35d')

    image, sig, bg = toymodel.make_toymodel_shower_image(geom, model.pdf,
                                                         intensity=50,
                                                         nsb_level_pe=1000)

    # Apply image cleaning
    cleanmask = tailcuts_clean(geom, image, picture_thresh=200,
                               boundary_thresh=100)
    clean = image.copy()
    clean[~cleanmask] = 0.0

    # Calculate image parameters
    hillas = hillas_parameters(geom.pix_x, geom.pix_y, clean)
    print(hillas)

    # Show the camera image and overlay Hillas ellipse and clean pixels
    disp.image = image
    disp.cmap = 'PuOr'
    disp.highlight_pixels(cleanmask, color='black')
    disp.overlay_moments(hillas, color='cyan', linewidth=3)

    # Draw the neighbors of pixel 100 in red, and the neighbor-neighbors in
    # green
    for ii in geom.neighbors[130]:
        draw_neighbors(geom, ii, color='green')

    draw_neighbors(geom, 130, color='cyan', lw=2)

    plt.show()
开发者ID:epuesche,项目名称:ctapipe,代码行数:32,代码来源:camera_display.py

示例9: CameraDisplay

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
if __name__ == '__main__':

    plt.style.use("ggplot")
    fig, ax = plt.subplots()

    # load the camera
    tel = TelescopeDescription.from_name("SST-1M", "DigiCam")
    geom = tel.camera

    fov = 0.3
    maxwid = 0.05
    maxlen = 0.1

    disp = CameraDisplay(geom, ax=ax)
    disp.cmap = 'inferno'
    disp.add_colorbar(ax=ax)

    def update(frame):
        x, y = np.random.uniform(-fov, fov, size=2)
        width = np.random.uniform(0.01, maxwid)
        length = np.random.uniform(width, maxlen)
        angle = np.random.uniform(0, 180)
        intens = width * length * (5e4 + 1e5 * np.random.exponential(2))

        model = toymodel.Gaussian(
            x=x * u.m,
            y=y * u.m,
            width=width * u.m,
            length=length * u.m,
            psi=angle * u.deg,
开发者ID:dipierr,项目名称:ctapipe,代码行数:32,代码来源:camera_animation.py

示例10: _display_camera_animation

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
    def _display_camera_animation(self):
        # plt.style.use("ggplot")
        fig = plt.figure(num="ctapipe Camera Demo", figsize=(7, 7))
        ax = plt.subplot(111)

        # load the camera
        tel = TelescopeDescription.from_name(optics_name=self.optics,
                                             camera_name=self.camera)
        geom = tel.camera

        # poor-man's coordinate transform from telscope to camera frame (it's
        # better to use ctapipe.coordiantes when they are stable)
        foclen = tel.optics.equivalent_focal_length.to(geom.pix_x.unit).value
        fov = np.deg2rad(4.0)
        scale = foclen
        minwid = np.deg2rad(0.1)
        maxwid = np.deg2rad(0.3)
        maxlen = np.deg2rad(0.5)

        self.log.debug("scale={} m, wid=({}-{})".format(scale, minwid, maxwid))

        disp = CameraDisplay(
            geom, ax=ax, autoupdate=True,
            title="{}, f={}".format(tel, tel.optics.equivalent_focal_length)
        )
        disp.cmap = plt.cm.terrain

        def update(frame):


            centroid = np.random.uniform(-fov, fov, size=2) * scale
            width = np.random.uniform(0, maxwid-minwid) * scale + minwid
            length = np.random.uniform(0, maxlen) * scale + width
            angle = np.random.uniform(0, 360)
            intens = np.random.exponential(2) * 500
            model = toymodel.generate_2d_shower_model(centroid=centroid,
                                                      width=width,
                                                      length=length,
                                                      psi=angle * u.deg)
            self.log.debug(
                "Frame=%d width=%03f length=%03f intens=%03d",
                frame, width, length, intens
            )

            image, sig, bg = toymodel.make_toymodel_shower_image(
                geom,
                model.pdf,
                intensity=intens,
                nsb_level_pe=3,
            )

            # alternate between cleaned and raw images
            if self._counter == self.cleanframes:
                plt.suptitle("Image Cleaning ON")
                self.imclean = True
            if self._counter == self.cleanframes * 2:
                plt.suptitle("Image Cleaning OFF")
                self.imclean = False
                self._counter = 0
                disp.clear_overlays()

            if self.imclean:
                cleanmask = tailcuts_clean(geom, image,
                                           picture_thresh=10.0,
                                           boundary_thresh=5.0)
                for ii in range(2):
                    dilate(geom, cleanmask)
                image[cleanmask == 0] = 0  # zero noise pixels
                try:
                    hillas = hillas_parameters(geom, image)
                    disp.overlay_moments(hillas, with_label=False,
                                         color='red', alpha=0.7,
                                         linewidth=2, linestyle='dashed')
                except HillasParameterizationError:
                    disp.clear_overlays()
                    pass

            self.log.debug("Frame=%d  image_sum=%.3f max=%.3f",
                           self._counter, image.sum(), image.max())
            disp.image = image

            if self.autoscale:
                disp.set_limits_percent(95)
            else:
                disp.set_limits_minmax(-5, 200)

            disp.axes.figure.canvas.draw()
            self._counter += 1
            return [ax, ]

        frames = None if self.num_events == 0 else self.num_events
        repeat = True if self.num_events == 0 else False

        self.log.info("Running for {} frames".format(frames))
        self.anim = FuncAnimation(fig, update,
                                  interval=self.delay,
                                  frames=frames,
                                  repeat=repeat,
                                  blit=self.blit)

#.........这里部分代码省略.........
开发者ID:ParsonsRD,项目名称:ctapipe,代码行数:103,代码来源:camdemo.py

示例11: plot

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]

#.........这里部分代码省略.........
        # Draw min pixel traces
        ax_min_pix.plot(dl0[min_pix])
        ax_min_pix.set_xlabel("Time (ns)")
        ax_min_pix.set_ylabel("DL0 Samples (ADC)")
        ax_min_pix.set_title("(Min) Pixel: {}, True: {}, Measured = {:.3f}"
                             .format(min_pix, t_pe[min_pix], dl1[min_pix]))
        ax_min_pix.set_ylim(max_ylim)
        ax_min_pix.plot([start[min_pix], start[min_pix]],
                        ax_min_pix.get_ylim(), color='r', alpha=1)
        ax_min_pix.plot([end[min_pix], end[min_pix]],
                        ax_min_pix.get_ylim(), color='r', alpha=1)
        for i, ax in ax_min_nei.items():
            if len(min_pixel_nei) > i:
                pix = min_pixel_nei[i]
                ax.plot(dl0[pix])
                ax.set_xlabel("Time (ns)")
                ax.set_ylabel("DL0 Samples (ADC)")
                ax.set_title("(Min Nei) Pixel: {}, True: {}, Measured = {:.3f}"
                             .format(pix, t_pe[pix], dl1[pix]))
                ax.set_ylim(max_ylim)
                ax.plot([start[pix], start[pix]],
                        ax.get_ylim(), color='r', alpha=1)
                ax.plot([end[pix], end[pix]],
                        ax.get_ylim(), color='r', alpha=1)

        # Draw cameras
        nei_camera = np.zeros_like(max_charges, dtype=np.int)
        nei_camera[min_pixel_nei] = 2
        nei_camera[min_pix] = 1
        nei_camera[max_pixel_nei] = 3
        nei_camera[max_pix] = 4
        camera = CameraDisplay(geom, ax=ax_img_nei)
        camera.image = nei_camera
        camera.cmap = plt.cm.viridis
        ax_img_nei.set_title("Neighbour Map")
        ax_img_nei.annotate("Pixel: {}".format(max_pix),
                            xy=(geom.pix_x.value[max_pix],
                                geom.pix_y.value[max_pix]),
                            xycoords='data', xytext=(0.05, 0.98),
                            textcoords='axes fraction',
                            arrowprops=dict(facecolor='red', width=2,
                                            alpha=0.4),
                            horizontalalignment='left',
                            verticalalignment='top')
        ax_img_nei.annotate("Pixel: {}".format(min_pix),
                            xy=(geom.pix_x.value[min_pix],
                                geom.pix_y.value[min_pix]),
                            xycoords='data', xytext=(0.05, 0.94),
                            textcoords='axes fraction',
                            arrowprops=dict(facecolor='orange', width=2,
                                            alpha=0.4),
                            horizontalalignment='left',
                            verticalalignment='top')
        camera = CameraDisplay(geom, ax=ax_img_max)
        camera.image = dl0[:, max_time]
        camera.cmap = plt.cm.viridis
        camera.add_colorbar(ax=ax_img_max, label="DL0 Samples (ADC)")
        ax_img_max.set_title("Max Timeslice (T = {})".format(max_time))
        ax_img_max.annotate("Pixel: {}".format(max_pix),
                            xy=(geom.pix_x.value[max_pix],
                                geom.pix_y.value[max_pix]),
                            xycoords='data', xytext=(0.05, 0.98),
                            textcoords='axes fraction',
                            arrowprops=dict(facecolor='red', width=2,
                                            alpha=0.4),
                            horizontalalignment='left',
开发者ID:cocov,项目名称:ctapipe,代码行数:70,代码来源:display_integrator.py

示例12: test_convert_geometry

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
def test_convert_geometry():
    filename = get_path("gamma_test.simtel.gz")

    cam_geom = {}

    source = hessio_event_source(filename)

    # testing a few images just for the sake of being thorough
    counter = 5

    for event in source:

        for tel_id in event.dl0.tels_with_data:
            if tel_id not in cam_geom:
                cam_geom[tel_id] = CameraGeometry.guess(
                                        event.inst.pixel_pos[tel_id][0],
                                        event.inst.pixel_pos[tel_id][1],
                                        event.inst.optical_foclen[tel_id])


            # we want to test conversion of hex to rectangular pixel grid
            if cam_geom[tel_id].pix_type is not "hexagonal":
                continue

            print(tel_id, cam_geom[tel_id].pix_type)

            pmt_signal = apply_mc_calibration(
                        #event.dl0.tel[tel_id].adc_samples[0],
                        event.dl0.tel[tel_id].adc_sums[0],
                        event.mc.tel[tel_id].dc_to_pe[0],
                        event.mc.tel[tel_id].pedestal[0])

            new_geom, new_signal = convert_geometry_1d_to_2d(
                cam_geom[tel_id], pmt_signal, cam_geom[tel_id].cam_id, add_rot=-2)

            unrot_geom, unrot_signal = convert_geometry_back(
                new_geom, new_signal, cam_geom[tel_id].cam_id,
                event.inst.optical_foclen[tel_id], add_rot=4)

            # if run as main, do some plotting
            if __name__ == "__main__":
                fig = plt.figure()
                plt.style.use('seaborn-talk')

                ax1 = fig.add_subplot(131)
                disp1 = CameraDisplay(cam_geom[tel_id],
                                      image=np.sum(pmt_signal, axis=1)
                                      if pmt_signal.shape[-1] == 25 else pmt_signal,
                                      ax=ax1)
                disp1.cmap = plt.cm.hot
                disp1.add_colorbar()
                plt.title("original geometry")

                ax2 = fig.add_subplot(132)
                disp2 = CameraDisplay(new_geom,
                                      image=np.sum(new_signal, axis=2)
                                      if new_signal.shape[-1] == 25 else new_signal,
                                      ax=ax2)
                disp2.cmap = plt.cm.hot
                disp2.add_colorbar()
                plt.title("slanted geometry")

                ax3 = fig.add_subplot(133)
                disp3 = CameraDisplay(unrot_geom, image=np.sum(unrot_signal, axis=1)
                                      if unrot_signal.shape[-1] == 25 else unrot_signal,
                                      ax=ax3)
                disp3.cmap = plt.cm.hot
                disp3.add_colorbar()
                plt.title("geometry converted back to hex")

                plt.show()


            # do some tailcuts cleaning
            mask1 = tailcuts_clean(cam_geom[tel_id], pmt_signal, 1,
                                   picture_thresh=10.,
                                   boundary_thresh=5.)

            mask2 = tailcuts_clean(unrot_geom, unrot_signal, 1,
                                   picture_thresh=10.,
                                   boundary_thresh=5.)
            pmt_signal[mask1==False] = 0
            unrot_signal[mask2==False] = 0

            '''
            testing back and forth conversion on hillas parameters... '''
            try:
                moments1 = hillas_parameters(cam_geom[tel_id].pix_x,
                                             cam_geom[tel_id].pix_y,
                                             pmt_signal)

                moments2 = hillas_parameters(unrot_geom.pix_x,
                                             unrot_geom.pix_y,
                                             unrot_signal)
            except (HillasParameterizationError, AssertionError) as e:
                '''
                we don't want this test to fail because the hillas code
                threw an error '''
                print(e)
                counter -= 1
#.........这里部分代码省略.........
开发者ID:cocov,项目名称:ctapipe,代码行数:103,代码来源:test_geometry_converter.py

示例13: print

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
    fig, ax = plt.subplots()

    # load the camera
    tel = TelescopeDescription.from_name("SST-1M","DigiCam")
    print(tel, tel.optics.effective_focal_length)
    geom = tel.camera

    # poor-man's coordinate transform from telscope to camera frame (it's
    # better to use ctapipe.coordiantes when they are stable)
    scale = tel.optics.effective_focal_length.to(geom.pix_x.unit).value
    fov = np.deg2rad(4.0)
    maxwid = np.deg2rad(0.01)
    maxlen = np.deg2rad(0.03)

    disp = CameraDisplay(geom, ax=ax)
    disp.cmap = plt.cm.terrain
    disp.add_colorbar(ax=ax)

    def update(frame):
        centroid = np.random.uniform(-fov, fov, size=2) * scale
        width = np.random.uniform(0, maxwid) * scale
        length = np.random.uniform(0, maxlen) * scale + width
        angle = np.random.uniform(0, 360)
        intens = np.random.exponential(2) * 50
        model = toymodel.generate_2d_shower_model(
            centroid=centroid,
            width=width,
            length=length,
            psi=angle * u.deg,
        )
        image, sig, bg = toymodel.make_toymodel_shower_image(
开发者ID:epuesche,项目名称:ctapipe,代码行数:33,代码来源:camera_animation.py

示例14: transform_and_clean_hex_image

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import cmap [as 别名]
def transform_and_clean_hex_image(pmt_signal, cam_geom, photo_electrons):

    start_time = time.time()

    colors = cm.inferno(pmt_signal/max(pmt_signal))

    new_geom, new_signal = convert_geometry_1d_to_2d(
        cam_geom, pmt_signal, cam_geom.cam_id)

    print("rot_signal", np.count_nonzero(np.isnan(new_signal)))

    square_mask = new_geom.mask
    cleaned_img = wavelet_transform(new_signal,
                                    raw_option_string=args.raw)

    unrot_img = cleaned_img[square_mask]
    unrot_colors = cm.inferno(unrot_img/max(unrot_img))

    cleaned_img_ik = kill_isolpix(cleaned_img, threshold=.5)
    unrot_img_ik = cleaned_img_ik[square_mask]
    unrot_colors_ik = cm.inferno(unrot_img_ik/max(unrot_img_ik))

    square_image_add_noise = np.copy(new_signal)
    square_image_add_noise[~square_mask] = \
        np.random.normal(0.13, 5.77, np.count_nonzero(~square_mask))

    square_image_add_noise_cleaned = wavelet_transform(square_image_add_noise,
                                                       raw_option_string=args.raw)

    square_image_add_noise_cleaned_ik = kill_isolpix(square_image_add_noise_cleaned,
                                                     threshold=1.5)

    unrot_geom, unrot_noised_signal = convert_geometry_back(
        new_geom, square_image_add_noise_cleaned_ik, cam_geom.cam_id)

    end_time = time.time()
    print(end_time - start_time)

    global fig
    global cb1, ax1
    global cb2, ax2
    global cb3, ax3
    global cb4, ax4
    global cb5, ax5
    global cb6, ax6
    global cb7, ax7
    global cb8, ax8
    global cb9, ax9
    if fig is None:
        fig = plt.figure(figsize=(10, 10))
    else:
        fig.delaxes(ax1)
        fig.delaxes(ax2)
        fig.delaxes(ax3)
        fig.delaxes(ax4)
        fig.delaxes(ax5)
        fig.delaxes(ax6)
        fig.delaxes(ax7)
        fig.delaxes(ax8)
        fig.delaxes(ax9)
        cb1.remove()
        cb2.remove()
        cb3.remove()
        cb4.remove()
        cb5.remove()
        cb6.remove()
        cb7.remove()
        cb8.remove()
        cb9.remove()

    ax1 = fig.add_subplot(333)
    disp1 = CameraDisplay(cam_geom, image=photo_electrons, ax=ax1)
    plt.gca().set_aspect('equal', adjustable='box')
    plt.title("photo-electron image")
    disp1.cmap = plt.cm.inferno
    disp1.add_colorbar()
    cb1 = disp1.colorbar

    ax2 = fig.add_subplot(336)
    disp2 = CameraDisplay(cam_geom, image=pmt_signal, ax=ax2)
    plt.gca().set_aspect('equal', adjustable='box')
    disp2.cmap = plt.cm.inferno
    disp2.add_colorbar()
    cb2 = disp2.colorbar
    plt.title("noisy image")

    ax3 = fig.add_subplot(331)
    plt.imshow(new_signal, interpolation='none', cmap=cm.inferno,
               origin='lower')
    plt.gca().set_aspect('equal', adjustable='box')
    plt.title("noisy, slanted image")
    cb3 = plt.colorbar()

    ax4 = fig.add_subplot(334)
    plt.imshow(cleaned_img, interpolation='none', cmap=cm.inferno,
               origin='lower')
    plt.gca().set_aspect('equal', adjustable='box')
    plt.title("cleaned, slanted image, islands not killed")
    cb4 = plt.colorbar()
    ax4.set_axis_off()
#.........这里部分代码省略.........
开发者ID:jdhp-sap,项目名称:tino_cta,代码行数:103,代码来源:compare_cleaned_images.py


注:本文中的ctapipe.visualization.CameraDisplay.cmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。