Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-15194

display_matplotlib: dot fails to plot ellipses

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: display_matplotlib
    • Labels:
      None
    • Story Points:
      1
    • Sprint:
      DRP F18-2
    • Team:
      Alert Production

      Description

      From https://github.com/lsst/display_matplotlib/issues/2:

      I've tried to plot source catalog objects as ellipses using the display.dot function and passing source.getShape as the first argument:

      #Display the cutout and sources with afw display
      image = cutout.image
      #image = calexp.image
       
      plt.figure()
      afw_display = afwDisplay.Display()
      afw_display.scale('asinh', 'zscale')
      afw_display.mtv(image)
      plt.gca().axis('off')
       
      # We use display buffering to avoid re-drawing the image after each source is plotted
      with afw_display.Buffering():
          for s in sources:
              afw_display.dot('+', s.getX(), s.getY(), ctype=afwDisplay.RED)
              afw_display.dot('o', s.getX(), s.getY(), size=20, ctype='orange')   
       
              #ADW: This should work, but doesn't?
              afw_display.dot(s.getShape(), s.getX(), s.getY(), size=35, ctype='orange')
          # Our "ultra-faint galaxy" (e.g. smudge)
          afw_display.dot('o', x_target, y_target, size=35, ctype='cyan')
      

      However I get the following error:

      /opt/lsst/software/stack/stack/miniconda3-4.5.4-10a4fa6/Linux64/afw/16.0-19-g2da375352/python/lsst/afw/display/interface.py in dot(self, symb, c, r, size, ctype, origin, *args, **kwargs)
          526             symb = afwGeom.ellipses.Axes(symb)
          527 
      --> 528         self._impl._dot(symb, c, r, size, ctype, **kwargs)
          529 
          530     def line(self, points, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
       
      /opt/lsst/software/stack/stack/miniconda3-4.5.4-10a4fa6/Linux64/display_matplotlib/16.0+11/python/lsst/display/matplotlib/matplotlib.py in _dot(self, symb, c, r, size, ctype, fontFamily, textAngle)
          371 
          372             axis.add_artist(Ellipse((c + x0, r + y0), xradius=symb.getA(), yradius=symb.getB(),
      --> 373                                           rot_deg=math.degrees(symb.getTheta()), color=ctype))
          374         elif symb == 'o':
          375             from matplotlib.patches import CirclePolygon as Circle
       
      TypeError: __init__() missing 2 required positional arguments: 'width' and 'height'
      

      I've confirmed that matplotlib.patches.Ellipse does expect the width and height arguments (at least in recent versions).

        Attachments

          Activity

          Hide
          swinbank John Swinbank added a comment -

          Robert Lupton — you're the expert on display_matplotlib. Any thoughts?

          Show
          swinbank John Swinbank added a comment - Robert Lupton — you're the expert on display_matplotlib. Any thoughts?
          Hide
          swinbank John Swinbank added a comment - - edited

          Alex Drlica-Wagner provided a suggested fix. PR is now here:

          https://github.com/lsst/display_matplotlib/pull/7

          Robert Lupton, could you review please?

          Show
          swinbank John Swinbank added a comment - - edited Alex Drlica-Wagner provided a suggested fix. PR is now here: https://github.com/lsst/display_matplotlib/pull/7 Robert Lupton , could you review please?
          Hide
          rhl Robert Lupton added a comment -

          Looks good.  I wondered if I'd used an old API, but as far as I can tell my code was invented out of whole cloth

           

          Show
          rhl Robert Lupton added a comment - Looks good.  I wondered if I'd used an old API, but as far as I can tell my code was invented out of whole cloth  
          Hide
          swinbank John Swinbank added a comment -

          Merged. Thank you!

          Show
          swinbank John Swinbank added a comment - Merged. Thank you!

            People

            Assignee:
            swinbank John Swinbank
            Reporter:
            swinbank John Swinbank
            Reviewers:
            Robert Lupton
            Watchers:
            John Swinbank, Robert Lupton
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: