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

afwDisplay fails on a DecoratedImage without WCS metadata

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: afw
    • Labels:
      None
    • Team:
      DM Science

      Description

      afwDisplay.Display().mtv() assumes that it can always build a Wcs from the metadata in a DecoratedImage (that may once have been true, but it no longer is) and raises an exception if it fails.

      Please fix this.

        Attachments

          Activity

          Hide
          rhl Robert Lupton added a comment -

          diff --git a/python/lsst/afw/display/interface.py b/python/lsst/afw/display/interface.py
          index 2b3eecc..72970a9 100644
          --- a/python/lsst/afw/display/interface.py
          +++ b/python/lsst/afw/display/interface.py
          @@ -27,6 +27,7 @@
           import re
           import sys
           import importlib
          +import lsst.pex.exceptions as pexExceptions
           import lsst.afw.geom as afwGeom
           import lsst.afw.image as afwImage
           import lsst.log
          @@ -460,7 +461,12 @@ class Display:
                               "You may not specify a wcs with an Exposure")
                       data, wcs = data.getMaskedImage(), data.getWcs()
                   elif isinstance(data, afwImage.DecoratedImage):  # it's a DecoratedImage; display it
          -            data, wcs = data.getImage(), afwGeom.makeSkyWcs(data.getMetadata())
          +            try:
          +                wcs = afwGeom.makeSkyWcs(data.getMetadata())
          +            except pexExceptions.TypeError:
          +                wcs = None
          +            data = data.image
          +
                       self._xy0 = data.getXY0()   # DecoratedImage doesn't have getXY0()
           
                   if isinstance(data, afwImage.Image):  # it's an Image; display it 

          Show
          rhl Robert Lupton added a comment - diff --git a/python/lsst/afw/display/ interface .py b/python/lsst/afw/display/ interface .py index 2b3eecc..72970a9 100644 --- a/python/lsst/afw/display/ interface .py +++ b/python/lsst/afw/display/ interface .py @@ - 27 , 6 + 27 , 7 @@   import re   import sys   import importlib + import lsst.pex.exceptions as pexExceptions   import lsst.afw.geom as afwGeom   import lsst.afw.image as afwImage   import lsst.log @@ - 460 , 7 + 461 , 12 @@ class Display:                      "You may not specify a wcs with an Exposure" )              data, wcs = data.getMaskedImage(), data.getWcs()          elif isinstance(data, afwImage.DecoratedImage):  # it's a DecoratedImage; display it -            data, wcs = data.getImage(), afwGeom.makeSkyWcs(data.getMetadata()) +            try : +                wcs = afwGeom.makeSkyWcs(data.getMetadata()) +            except pexExceptions.TypeError: +                wcs = None +            data = data.image +              self._xy0 = data.getXY0()   # DecoratedImage doesn't have getXY0()            if isinstance(data, afwImage.Image):  # it's an Image; display it
          Hide
          price Paul Price added a comment -

          I think just:

              except TypeError:
          

          should work — I believe lsst.pex.exceptions.TypeError gets translated to a regular TypeError.

          Otherwise, good.

          Show
          price Paul Price added a comment - I think just: except TypeError: should work — I believe lsst.pex.exceptions.TypeError gets translated to a regular TypeError . Otherwise, good.
          Hide
          rhl Robert Lupton added a comment -

          Merged

          Show
          rhl Robert Lupton added a comment - Merged

            People

            Assignee:
            rhl Robert Lupton
            Reporter:
            rhl Robert Lupton
            Reviewers:
            Paul Price
            Watchers:
            Paul Price, Robert Lupton
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Jenkins

                No builds found.