def _dot(self,
             symb,
             c,
             r,
             size,
             ctype,
             fontFamily="helvetica",
             textAngle=None):
        """Draw a symbol onto the specified DS9 frame at (col,row) = (c,r) [0-based coordinates]
    Possible values are:
            +                Draw a +
            x                Draw an x
            *                Draw a *
            o                Draw a circle
            @:Mxx,Mxy,Myy    Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
            An object derived from afwGeom.ellipses.BaseCore Draw the ellipse (argument size is ignored)
    Any other value is interpreted as a string to be drawn. Strings obey the fontFamily (which may be extended
    with other characteristics, e.g. "times bold italic".  Text will be drawn rotated by textAngle (textAngle is
    ignored otherwise).
    N.b. objects derived from BaseCore include Axes and Quadrupole.
    """
        cmd = selectFrame(self.display.frame) + "; "
        for region in ds9Regions.dot(symb, c, r, size, ctype, fontFamily,
                                     textAngle):
            cmd += 'regions command {%s}; ' % region

        ds9Cmd(cmd, silent=True)
Esempio n. 2
0
    def _dot(self,
             symb,
             c,
             r,
             size,
             ctype,
             fontFamily="helvetica",
             textAngle=None):
        """Draw a symbol at (col,row) = (c,r) [0-based coordinates]
    Possible values are:
            +                Draw a +
            x                Draw an x
            *                Draw a *
            o                Draw a circle
            @:Mxx,Mxy,Myy    Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
            An object derived from afwGeom.ellipses.BaseCore Draw the ellipse (argument size is ignored)
    Any other value is interpreted as a string to be drawn. Strings obey the fontFamily (which may be extended
    with other characteristics, e.g. "times bold italic".  Text will be drawn rotated by textAngle (textAngle is
    ignored otherwise).

    N.b. objects derived from BaseCore include Axes and Quadrupole.
    """
        if isinstance(symb, afwGeom.ellipses.BaseCore):
            Ellipse = self._canvas.get_draw_class('ellipse')

            self._canvas.add(
                Ellipse(c,
                        r,
                        xradius=symb.getA(),
                        yradius=symb.getB(),
                        rot_deg=math.degrees(symb.getTheta()),
                        color=ctype))
        elif symb == 'o':
            Circle = self._canvas.get_draw_class('circle')
            self._canvas.add(Circle(c, r, radius=size, color=ctype))
        else:
            Line = self._canvas.get_draw_class('line')
            Text = self._canvas.get_draw_class('text')

            for ds9Cmd in ds9Regions.dot(symb,
                                         c,
                                         r,
                                         size,
                                         fontFamily="helvetica",
                                         textAngle=None):
                tmp = ds9Cmd.split('#')
                cmd = tmp.pop(0).split()
                comment = tmp.pop(0) if tmp else ""

                cmd, args = cmd[0], cmd[1:]
                if cmd == "line":
                    self._canvas.add(
                        Line(*[float(p) - 1 for p in args], color=ctype))
                elif cmd == "text":
                    x, y = [float(p) - 1 for p in args[0:2]]
                    self._canvas.add(Text(x, y, symb, color=ctype))
                else:
                    raise RuntimeError(ds9Cmd)
    def _dot(self, symb, c, r, size, ctype,
             fontFamily="helvetica", textAngle=None):
        """Draw a symbol at (col,row) = (c,r) [0-based coordinates]
    Possible values are:
            +                Draw a +
            x                Draw an x
            *                Draw a *
            o                Draw a circle
            @:Mxx,Mxy,Myy    Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
            An object derived from afwGeom.ellipses.BaseCore Draw the ellipse (argument size is ignored)
    Any other value is interpreted as a string to be drawn. Strings obey the fontFamily (which may be extended
    with other characteristics, e.g. "times bold italic".  Text will be drawn rotated by textAngle (textAngle is
    ignored otherwise).

    N.b. objects derived from BaseCore include Axes and Quadrupole.
    """
        if not ctype:
            ctype = afwDisplay.GREEN

        axis = self._figure.gca()
        x0, y0 = self._xy0
        
        if isinstance(symb, afwGeom.ellipses.BaseCore):
            from matplotlib.patches import Ellipse

            axis.add_artist(Ellipse((c + x0, r + y0), xradius=symb.getA(), yradius=symb.getB(),
                                          rot_deg=math.degrees(symb.getTheta()), color=ctype))
        elif symb == 'o':
            from matplotlib.patches import CirclePolygon as Circle

            axis.add_artist(Circle((c + x0, r + y0), radius=size, color=ctype, fill=False))
        else:
            from matplotlib.lines import Line2D

            for ds9Cmd in ds9Regions.dot(symb, c + x0, r + y0, size, fontFamily="helvetica", textAngle=None):
                tmp = ds9Cmd.split('#')
                cmd = tmp.pop(0).split()
                comment = tmp.pop(0) if tmp else ""

                cmd, args = cmd[0], cmd[1:]
                
                if cmd == "line":
                    args = np.array(args).astype(float) - 1.0

                    x = np.empty(len(args)//2)
                    y = np.empty_like(x)
                    i = np.arange(len(args), dtype=int)
                    x = args[i%2 == 0]
                    y = args[i%2 == 1]

                    axis.add_line(Line2D(x, y, color=ctype))
                elif cmd == "text":
                    x, y = np.array(args[0:2]).astype(float) - 1.0
                    axis.text(x, y, symb, color=ctype,
                              horizontalalignment='center', verticalalignment='center')
                else:
                    raise RuntimeError(ds9Cmd)
Esempio n. 4
0
    def _dot(self,
             symb,
             c,
             r,
             size,
             ctype,
             fontFamily="helvetica",
             textAngle=None):
        """Draw a symbol onto the specified DS9 frame.

        Parameters
        ----------
        symb : `str`, or subclass of `lsst.afw.geom.ellipses.BaseCore`
            Symbol to be drawn. Possible values are:

            - ``"+"``: Draw a "+"
            - ``"x"``: Draw an "x"
            - ``"*"``: Draw a "*"
            - ``"o"``: Draw a circle
            - ``"@:Mxx,Mxy,Myy"``: Draw an ellipse with moments (Mxx, Mxy,
              Myy);(the ``size`` parameter is ignored)
            - An object derived from `lsst.afw.geom.ellipses.BaseCore`: Draw
              the ellipse (argument size is ignored)

            Any other value is interpreted as a string to be drawn.
        c : `int`
            Column to draw symbol [0-based coordinates].
        r : `int`
            Row to draw symbol [0-based coordinates].
        size : `float`
            Size of symbol.
        ctype : `str`
            the name of a colour (e.g. ``"red"``)
        fontFamily : `str`, optional
            String font. May be extended with other characteristics,
            e.g. ``"times bold italic"``.
        textAngle: `float`, optional
            Text will be drawn rotated by ``textAngle``.

        Notes
        -----
        Objects derived from `lsst.afw.geom.ellipses.BaseCore` include
        `~lsst.afw.geom.ellipses.Axes` and `lsst.afw.geom.ellipses.Quadrupole`.
        """
        cmd = selectFrame(self.display.frame) + "; "
        for region in ds9Regions.dot(symb, c, r, size, ctype, fontFamily,
                                     textAngle):
            cmd += 'regions command {%s}; ' % region

        ds9Cmd(cmd, silent=True)
Esempio n. 5
0
    def _dot(self, symb, c, r, size, ctype, fontFamily="helvetica", textAngle=None):
        """Draw a symbol onto the specified DS9 frame at (col,row) = (c,r) [0-based coordinates]
    Possible values are:
            +                Draw a +
            x                Draw an x
            *                Draw a *
            o                Draw a circle
            @:Mxx,Mxy,Myy    Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
            An object derived from afwGeom.ellipses.BaseCore Draw the ellipse (argument size is ignored)
    Any other value is interpreted as a string to be drawn. Strings obey the fontFamily (which may be extended
    with other characteristics, e.g. "times bold italic".  Text will be drawn rotated by textAngle (textAngle is
    ignored otherwise).

    N.b. objects derived from BaseCore include Axes and Quadrupole.
    """
        cmd = selectFrame(self.display.frame) + "; "
        for region in ds9Regions.dot(symb, c, r, size, ctype, fontFamily, textAngle):
            cmd += 'regions command {%s}; ' % region

        ds9Cmd(cmd, silent=True)
Esempio n. 6
0
    def _dot(self,
             symb,
             c,
             r,
             size,
             ctype,
             fontFamily="helvetica",
             textAngle=None):
        """Draw a symbol at (col,row) = (c,r) [0-based coordinates]
    Possible values are:
            +                        Draw a +
            x                        Draw an x
            *                        Draw a *
            o                        Draw a circle
            @:Mxx,Mxy,Myy            Draw an ellipse with moments
                                     (Mxx, Mxy, Myy) (argument size is ignored)
            An afwGeom.ellipses.Axes Draw the ellipse (argument size is
                                     ignored)

    Any other value is interpreted as a string to be drawn. Strings obey the
    fontFamily (which may be extended with other characteristics, e.g.
    "times bold italic".  Text will be drawn rotated by textAngle
    (textAngle is ignored otherwise).
    """
        if not ctype:
            ctype = afwDisplay.GREEN

        axis = self._figure.gca()
        x0, y0 = self._xy0

        if isinstance(symb, afwGeom.ellipses.Axes):
            from matplotlib.patches import Ellipse

            # Following matplotlib.patches.Ellipse documentation 'width' and
            # 'height' are diameters while 'angle' is rotation in degrees
            # (anti-clockwise)
            axis.add_artist(
                Ellipse((c + x0, r + y0),
                        height=2 * symb.getA(),
                        width=2 * symb.getB(),
                        angle=90.0 + math.degrees(symb.getTheta()),
                        edgecolor=mapCtype(ctype),
                        facecolor='none'))
        elif symb == 'o':
            from matplotlib.patches import CirclePolygon as Circle

            axis.add_artist(
                Circle((c + x0, r + y0),
                       radius=size,
                       color=mapCtype(ctype),
                       fill=False))
        else:
            from matplotlib.lines import Line2D

            for ds9Cmd in ds9Regions.dot(symb,
                                         c + x0,
                                         r + y0,
                                         size,
                                         fontFamily="helvetica",
                                         textAngle=None):
                tmp = ds9Cmd.split('#')
                cmd = tmp.pop(0).split()

                cmd, args = cmd[0], cmd[1:]

                if cmd == "line":
                    args = np.array(args).astype(float) - 1.0

                    x = np.empty(len(args) // 2)
                    y = np.empty_like(x)
                    i = np.arange(len(args), dtype=int)
                    x = args[i % 2 == 0]
                    y = args[i % 2 == 1]

                    axis.add_line(Line2D(x, y, color=mapCtype(ctype)))
                elif cmd == "text":
                    x, y = np.array(args[0:2]).astype(float) - 1.0
                    axis.text(x,
                              y,
                              symb,
                              color=mapCtype(ctype),
                              horizontalalignment='center',
                              verticalalignment='center')
                else:
                    raise RuntimeError(ds9Cmd)
Esempio n. 7
0
    def _dot(self,
             symb,
             c,
             r,
             size,
             ctype,
             fontFamily="helvetica",
             textAngle=None,
             label='_dot'):
        """Draw a symbol at (col,row) = (c,r) [0-based coordinates]
        Possible values are:
            +                Draw a +
            x                Draw an x
            *                Draw a *
            o                Draw a circle
            @:Mxx,Mxy,Myy    Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
            An object derived from afwGeom.ellipses.BaseCore Draw the ellipse (argument size is ignored)
            Any other value is interpreted as a string to be drawn. Strings
            obey the fontFamily (which may be extended with other
            characteristics, e.g. "times bold italic".  Text will be drawn
            rotated by textAngle (textAngle is ignored otherwise).
        N.b. objects derived from BaseCore include Axes and Quadrupole.
        """
        dataTable = Table([{'x': c, 'y': r}])
        if symb in '+x*.o':
            self._viewer.marker = {
                'type': self.markerDict[symb],
                'color': ctype,
                'radius': size
            }
            self._viewer.add_markers(dataTable, marker_name=label)
            self._flush()
        # if isinstance(symb, afwGeom.ellipses.BaseCore):
        #     Ellipse = self._canvas.get_draw_class('ellipse')

        #     self._canvas.add(Ellipse(c, r, xradius=symb.getA(), yradius=symb.getB(),
        #                              rot_deg=math.degrees(symb.getTheta()), color=ctype),
        #                      redraw=self._redraw)
        else:
            Line = self._canvas.get_draw_class('line')
            Text = self._canvas.get_draw_class('text')

            for ds9Cmd in ds9Regions.dot(symb,
                                         c,
                                         r,
                                         size,
                                         fontFamily="helvetica",
                                         textAngle=None):
                tmp = ds9Cmd.split('#')
                cmd = tmp.pop(0).split()
                comment = tmp.pop(0) if tmp else ""

                cmd, args = cmd[0], cmd[1:]
                if cmd == "line":
                    self._gingaViewer.canvas.add(Line(
                        *[float(p) - 1 for p in args], color=ctype),
                                                 redraw=self._redraw)
                elif cmd == "text":
                    x, y = [float(p) - 1 for p in args[0:2]]
                    self._gingaViewer.canvas.add(Text(x, y, symb, color=ctype),
                                                 redraw=self._redraw)
                else:
                    raise RuntimeError(ds9Cmd)
                if comment:
                    print(comment)  # CZW