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

afw display ds9 fails on numpy arrays

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Won't Fix
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: afw
    • Labels:
      None
    • Team:
      Alert Production

      Description

      afw.display apparently cannot deal with pure numpy arrays. They have to be wrapped in an afw.image first. It would be very useful to be able to just stuff a numpy array through to ds9 (or whatever display system is configured).

      The following command sequence fails:

      import lsst.afw.display.ds9 as ds9
      data = np.zeros((10,10), dtype=np.float32)
      In [3]: ds9.mtv(data)
      ---------------------------------------------------------------------------
      RuntimeError                              Traceback (most recent call last)
      <ipython-input-3-38b73304e0e0> in <module>()
      ----> 1 ds9.mtv(data)
       
      /Users/parejkoj/lsst/lsstsw/stack/DarwinX86/afw/2.2016.10-20-g39312e7/python/lsst/afw/display/ds9.pyc in mtv(data, frame, title, wcs, *args, **kwargs)
           78
           79 def mtv(data, frame=None, title="", wcs=None, *args, **kwargs):
      ---> 80     return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs)
           81
           82 def erase(frame=None):
       
      /Users/parejkoj/lsst/lsstsw/stack/DarwinX86/afw/2.2016.10-20-g39312e7/python/lsst/afw/display/interface.pyc in mtv(self, data, title, wcs)
          384             self._impl._mtv(data.getImage(), data.getMask(True), wcs, title)
          385         else:
      --> 386             raise RuntimeError, "Unsupported type %s" % repr(data)
          387     #
          388     # Graphics commands
       
      RuntimeError: Unsupported type array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]], dtype=float32)
      

      But this works:

      img = afwImage.ImageF(data)
      ds9.mtv(img)
      

        Attachments

          Issue Links

            Activity

            Hide
            Parejkoj John Parejko added a comment - - edited

            While looking for technical debt to deal with, I found this one and re-tested it: I received a different exception this time, which looks like a code bug (maybe due to scope changes in python3?). lsst.afw.display.ds9 needs some linter love and/or to have a DeprecatedWarning raised on import.

            In [9]: ds9.mtv(x)
            ---------------------------------------------------------------------------
            NameError                                 Traceback (most recent call last)
            <ipython-input-9-6b39caf68641> in <module>()
            ----> 1 ds9.mtv(x)
             
            /home/parejkoj/lsst/lsstsw/stack/Linux64/afw/12.1-30-ga6be655+2/python/lsst/afw/display/ds9.py in mtv(data, frame, title, wcs, *args, **kwargs)
                 82 
                 83 def mtv(data, frame=None, title="", wcs=None, *args, **kwargs):
            ---> 84     return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs)
                 85 
                 86 def erase(frame=None):
             
            /home/parejkoj/lsst/lsstsw/stack/Linux64/afw/12.1-30-ga6be655+2/python/lsst/afw/display/ds9.py in getDisplay(*args, **kwargs)
                 44 
                 45         def getDisplay(*args, **kwargs):
            ---> 46             raise e
                 47 
                 48         class DisplayImpl(object):
             
            NameError: name 'e' is not defined
            

            Show
            Parejkoj John Parejko added a comment - - edited While looking for technical debt to deal with, I found this one and re-tested it: I received a different exception this time, which looks like a code bug (maybe due to scope changes in python3?). lsst.afw.display.ds9 needs some linter love and/or to have a DeprecatedWarning raised on import. In [9]: ds9.mtv(x) --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-9-6b39caf68641> in <module>() ----> 1 ds9.mtv(x)   /home/parejkoj/lsst/lsstsw/stack/Linux64/afw/12.1-30-ga6be655+2/python/lsst/afw/display/ds9.py in mtv(data, frame, title, wcs, *args, **kwargs) 82 83 def mtv(data, frame=None, title="", wcs=None, *args, **kwargs): ---> 84 return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs) 85 86 def erase(frame=None):   /home/parejkoj/lsst/lsstsw/stack/Linux64/afw/12.1-30-ga6be655+2/python/lsst/afw/display/ds9.py in getDisplay(*args, **kwargs) 44 45 def getDisplay(*args, **kwargs): ---> 46 raise e 47 48 class DisplayImpl(object):   NameError: name 'e' is not defined
            Hide
            tjenness Tim Jenness added a comment - - edited

            The problem reported in the comment above was fixed in DM-9433.

            Show
            tjenness Tim Jenness added a comment - - edited The problem reported in the comment above was fixed in DM-9433 .
            Hide
            swinbank John Swinbank added a comment -

            It feels like wrapping in afwImage isn't a big hurdle, and this ticket has clearly not bubbled to the top of anybody's list in ~4 years, so I'll close it down. Please feel free to reopen if you strongly disagree.

            Show
            swinbank John Swinbank added a comment - It feels like wrapping in afwImage isn't a big hurdle, and this ticket has clearly not bubbled to the top of anybody's list in ~4 years, so I'll close it down. Please feel free to reopen if you strongly disagree.

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              Parejkoj John Parejko
              Watchers:
              Colin Slater, John Parejko, John Swinbank, Russell Owen, Simon Krughoff, Tim Jenness
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.