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

Warping an ExposureU gives all zeroes back

    XMLWordPrintable

    Details

    • Type: Story
    • Status: To Do
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: afw
    • Labels:
      None

      Description

      When warping an exposure (and I think an image), if the datatype is U then it comes back as all zeroes, and silently. This can be worked around by casting to F.

      A minimal working example is:

      import lsst.afw.math as afwMath
      import lsst.daf.persistence as dafPersist
      import numpy as np
       
      butler = dafPersist.Butler('/datasets/hsc/repo/')
       
      dataId = {'visit': 902872, 'ccd': 20}
      exp = butler.get('raw', dataId=dataId)
      print(exp.getMaskedImage().getImage().getArray())
      print("Max:", np.max(exp.getMaskedImage().getImage().getArray()))
      print("Min:", np.min(exp.getMaskedImage().getImage().getArray()))
       
      kernelName = "lanczos2"
      warper = afwMath.Warper(kernelName)
      rotatedExp = warper.warpExposure(exp.getWcs(), exp)
       
      print(rotatedExp.getMaskedImage().getImage().getArray())
      print("Max:", np.max(rotatedExp.getMaskedImage().getImage().getArray()))
      print("Min:", np.min(rotatedExp.getMaskedImage().getImage().getArray()))
      

      If you go all the way back to w_2018_06 I think the problem is fixed, but since then the bug seems to have been present.

      Yusra AlSayyadtook a look (and in fact it was her who discovered the bug's details) and says it's way down in the C++.

        Attachments

          Activity

          Hide
          mfisherlevine Merlin Fisher-Levine added a comment -

          Changelog for that weekly is:

          DM-10765, DM-13269, DM-13511, DM-13539, DM-13548, DM-13554, DM-13557, DM-13571

          Show
          mfisherlevine Merlin Fisher-Levine added a comment - Changelog for that weekly is: DM-10765 , DM-13269 , DM-13511 , DM-13539 , DM-13548 , DM-13554 , DM-13557 , DM-13571
          Hide
          yusra Yusra AlSayyad added a comment - - edited

          A little more isolation:

          warper.warpImage(<ImageU>) works fine
          warper.warpImage(<MaskedImageU>) produces all zeros.

          For use with Merlin's how to reproduce above:

          rotatedIm = warper.warpImage(exp.getWcs(), exp.getImage(), exp.getWcs(),  destBBox=exp.getBBox())
          print(np.max(rotatedIm.array))
           
          rotatedIm = warper.warpImage(exp.getWcs(), exp.getMaskedImage(), exp.getWcs(),  destBBox=exp.getBBox())
          print(np.max(rotatedIm.image.array))
          # will print 0
          

          Show
          yusra Yusra AlSayyad added a comment - - edited A little more isolation: warper.warpImage(<ImageU>) works fine warper.warpImage(<MaskedImageU>) produces all zeros. For use with Merlin's how to reproduce above: rotatedIm = warper.warpImage(exp.getWcs(), exp.getImage(), exp.getWcs(), destBBox=exp.getBBox()) print(np.max(rotatedIm.array))   rotatedIm = warper.warpImage(exp.getWcs(), exp.getMaskedImage(), exp.getWcs(), destBBox=exp.getBBox()) print(np.max(rotatedIm.image.array)) # will print 0
          Hide
          mfisherlevine Merlin Fisher-Levine added a comment -

          I just thought about this for a second and realised: what is this supposed to even do?!

          When warping an image of ints, what is reasonable for the return? Round all the pixel values? Return an object of a different type so that it can actually do something sensible? Raise? Warn? Warn and return rounded ints?

          I'd tentatively suggest it should either be: "warn and convert to float" or "raise" but I'm interested in what the more sensible & experience people say.

          Show
          mfisherlevine Merlin Fisher-Levine added a comment - I just thought about this for a second and realised: what is this supposed to even do?! When warping an image of ints, what is reasonable for the return? Round all the pixel values? Return an object of a different type so that it can actually do something sensible? Raise? Warn? Warn and return rounded ints? I'd tentatively suggest it should either be: "warn and convert to float" or "raise" but I'm interested in what the more sensible & experience people say.
          Hide
          mfisherlevine Merlin Fisher-Levine added a comment -

          Though I wrote that without rereading Yusra AlSayyad's comment above, which makes me wonder, if warping an ImageU works fine, what's it doing when that's a not a minimal-working-example no-op warp? Maybe I'm worrying about nothing and this is just a simple bug after all.

          Show
          mfisherlevine Merlin Fisher-Levine added a comment - Though I wrote that without rereading Yusra AlSayyad 's comment above, which makes me wonder, if warping an ImageU works fine, what's it doing when that's a not a minimal-working-example no-op warp? Maybe I'm worrying about nothing and this is just a simple bug after all.
          Hide
          czw Christopher Waters added a comment -

          The team/pair programming suggestion is that this should likely raise in afw, as attempting to warp an integer image isn't something we should allow, for the exact reasons Merlin Fisher-Levine mentions above.

          Show
          czw Christopher Waters added a comment - The team/pair programming suggestion is that this should likely raise in afw, as attempting to warp an integer image isn't something we should allow, for the exact reasons Merlin Fisher-Levine  mentions above.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            mfisherlevine Merlin Fisher-Levine
            Watchers:
            Christopher Waters, Merlin Fisher-Levine, Yusra AlSayyad
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Jenkins Builds

                No builds found.