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


Python CameraDisplay.update方法代码示例

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


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

示例1: ImagePlotter

# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import update [as 别名]
class ImagePlotter(Component):
    name = 'ImagePlotter'

    display = Bool(False,
                   help='Display the photoelectron images on-screen as they '
                        'are produced.').tag(config=True)
    output_path = Unicode(None, allow_none=True,
                          help='Output path for the pdf containing all the '
                               'images. Set to None for no saved '
                               'output.').tag(config=True)

    def __init__(self, config, tool, **kwargs):
        """
        Plotter for camera images.

        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
            Tool executable that is calling this component.
            Passes the correct logger to the component.
            Set to None if no Tool to pass.
        kwargs
        """
        super().__init__(config=config, parent=tool, **kwargs)
        self._current_tel = None
        self.c_intensity = None
        self.c_peakpos = None
        self.cb_intensity = None
        self.cb_peakpos = None
        self.pdf = None

        self._init_figure()

    def _init_figure(self):
        self.fig = plt.figure(figsize=(16, 7))
        self.ax_intensity = self.fig.add_subplot(1, 2, 1)
        self.ax_peakpos = self.fig.add_subplot(1, 2, 2)
        if self.output_path:
            self.log.info("Creating PDF: {}".format(self.output_path))
            self.pdf = PdfPages(self.output_path)

    def get_geometry(self, event, telid):
        return event.inst.subarray.tel[telid].camera

    def plot(self, event, telid):
        chan = 0
        image = event.dl1.tel[telid].image[chan]
        peakpos = event.dl1.tel[telid].peakpos[chan]

        if self._current_tel != telid:
            self._current_tel = telid

            self.ax_intensity.cla()
            self.ax_peakpos.cla()

            # Redraw camera
            geom = self.get_geometry(event, telid)
            self.c_intensity = CameraDisplay(geom, cmap=plt.cm.viridis,
                                             ax=self.ax_intensity)
            self.c_peakpos = CameraDisplay(geom, cmap=plt.cm.viridis,
                                           ax=self.ax_peakpos)

            tmaxmin = event.dl0.tel[telid].pe_samples.shape[2]
            t_chargemax = peakpos[image.argmax()]
            cmap_time = colors.LinearSegmentedColormap.from_list(
                'cmap_t', [(0 / tmaxmin, 'darkgreen'),
                           (0.6 * t_chargemax / tmaxmin, 'green'),
                           (t_chargemax / tmaxmin, 'yellow'),
                           (1.4 * t_chargemax / tmaxmin, 'blue'),
                           (1, 'darkblue')])
            self.c_peakpos.pixels.set_cmap(cmap_time)

            if not self.cb_intensity:
                self.c_intensity.add_colorbar(ax=self.ax_intensity,
                                              label='Intensity (p.e.)')
                self.cb_intensity = self.c_intensity.colorbar
            else:
                self.c_intensity.colorbar = self.cb_intensity
                self.c_intensity.update(True)
            if not self.cb_peakpos:
                self.c_peakpos.add_colorbar(ax=self.ax_peakpos,
                                            label='Peakpos (ns)')
                self.cb_peakpos = self.c_peakpos.colorbar
            else:
                self.c_peakpos.colorbar = self.cb_peakpos
                self.c_peakpos.update(True)

        self.c_intensity.image = image
        if peakpos is not None:
            self.c_peakpos.image = peakpos

        self.fig.suptitle("Event_index={}  Event_id={}  Telescope={}"
                          .format(event.count, event.r0.event_id, telid))


        if self.display:
#.........这里部分代码省略.........
开发者ID:epuesche,项目名称:ctapipe,代码行数:103,代码来源:calibration_pipeline.py


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