コード例 #1
0
ファイル: hplot.py プロジェクト: HiPERCAM/hipercam
def buttonPressEvent(event):
    """
    callback 
    """
    global fig, mccd, caxes, hsbox

    pzoom = fig.canvas.manager.toolbar.mode == "pan/zoom"

    if not pzoom:
        # only when not in pan/zoom mode
        if event.inaxes is not None:
            cnam = caxes[event.inaxes]
            ccd = mccd[cnam]
            x, y = event.xdata, event.ydata
            utils.print_stats(ccd, cnam, x, y, hsbox)
コード例 #2
0
    def _point(self):
        """Once all set to add a Point defect, this routine actually carries out the
        necessary operations

        """

        # search for enclosing window, print stats
        wnam, wind = utils.print_stats(self.mccd[self._cnam], self._cnam,
                                       self._x, self._y, self.hsbox, False)

        if wnam is None:
            print("  cannot set defects outside windows")

        else:

            if self.ffield:
                # flat-field defect
                dfct = defect.Point(self._severity, self._x, self._y)
                name = 'defect'

            else:
                wind = self.mccd[self._cnam][wnam]
                dexpose = self.mccd.head["EXPTIME"]
                xp = int(round(wind.x_pixel(self._x)))
                yp = int(round(wind.y_pixel(self._y)))
                if xp < 0 or xp >= wind.nx or yp < 0 or yp >= wind.ny:
                    print(f"  xp = {xp}, yp = {yp} outside window")
                    self.action_prompt(True)
                    return

                # translate back to physical space
                self._x = wind.x(xp)
                self._y = wind.y(yp)

                # hot pixel
                dfct = defect.Hot(self._severity, self._x, self._y,
                                  wind.data[yp, xp] / dexpose)
                name = 'hot pixel'

            self.mccd_dfct[self._cnam][self._buffer] = dfct

            # add defect to the plot, store plot objects
            self.pobjs[self._cnam][self._buffer] = hcam.mpl.pDefect(
                self._axes, dfct)

            # make sure it appears
            plt.draw()

            # let user know what has happened
            level = ("moderate" if self._severity == defect.Severity.MODERATE
                     else "severe")

            print(
                f"added {level} level {name} {self._buffer} to CCD {self._cnam}"
                f" at x,y = {self._x:.2f},{self._y:.2f}")

        self.action_prompt(True)
コード例 #3
0
    def _show(self):
        """
        Prints stats on pixels around selected place
        """

        # search for enclosing window, print stats
        wnam, wind = utils.print_stats(self.mccd[self._cnam], self._cnam,
                                       self._x, self._y, self.hsbox, False)
        if wnam is None:
            print('  must hit "s" inside a window')

        self.action_prompt(True)
コード例 #4
0
ファイル: setdefect.py プロジェクト: coclar/hipercam
    def _point(self):
        """Once all set to add a Point defect, this routine actually carries out the
        necessary operations

        """

        # search for enclosing window, print stats
        wnam, wind = utils.print_stats(
            self.mccd[self._cnam], self._cnam, self._x, self._y, self.hsbox, False
        )

        if wnam is None:
            print("  cannot set defects outside windows")

        else:

            if self.ffield:
                # flat-field defect
                dfct = defect.Point(self._severity, self._x, self._y)

            else:
                # hot pixel
                dfct = defect.Hot(self._severity, self._x, self._y)

            self.mccd_dfct[self._cnam][self._buffer] = dfct

            # add defect to the plot, store plot objects
            self.pobjs[self._cnam][self._buffer] = hcam.mpl.pDefect(self._axes, dfct)

            # make sure it appears
            plt.draw()

            # let user know what has happened
            level = (
                "moderate" if self._severity == defect.Severity.MODERATE else "severe"
            )

            print(
                "added {:s} level defect {:s} to CCD {:s} at x,y = {:.2f},{:.2f}".format(
                    level, self._buffer, self._cnam, self._x, self._y
                )
            )

        self.action_prompt(True)