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

Don't pad numerator with zeros in smoothArray during SkyCorrection

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Story Points:
      1
    • Sprint:
      DRP S19-6b
    • Team:
      Data Release Production

      Description

      In smoothArray multiplying the convolved image by numerator/denominator, was supposed to correct the roll-off produced by padding the input image with zeros.

      See the last comment on https://jira.lsstcorp.org/browse/DM-17426?focusedCommentId=196713&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-196713

      And conversation on #subaru_hsc:

      Sogo Mineo [8:42 PM] These lines https://github.com/lsst/pipe_drivers/blob/master/python/lsst/pipe/drivers/background.py#L869

      should be fixed (naively) as:

      convolved = gaussian_filter(numpy.where(bad, 0.0, array), sigma, mode="constant", cval=0.0)
      -numerator = gaussian_filter(numpy.ones_like(array), sigma, mode="constant", cval=0.0)
      +numerator = gaussian_filter(numpy.ones_like(array), sigma, mode="constant", cval=1.0)
       denominator = gaussian_filter(numpy.where(bad, 0.0, 1.0), sigma, mode="constant", cval=0.0)
       return convolved*numerator/denominator
      

      Let me explain: we set bad pixels to 0 in computing convolved. Doing it wrongly lowers the pixels around the bad pixels in convolved . We compensate this effect with *numerator/denominator. In computing convolved , pixels outside the input image are also set to 0 ( cval=0.0 ). It is that these pixels are regarded as a kind of bad pixels, and their effect should have been compensated together with the effect of the bad pixels inside the input image. This is why the numerator needs the fix above.

      But if we compute numerator according to this fix, all elements of numerator are 1. Therefore, we can drop it altogether, hence Koike-san's proposal:

      convolved = gaussian_filter(numpy.where(bad, 0.0, array), sigma, mode="constant", cval=0.0)
      -numerator = gaussian_filter(numpy.ones_like(array), sigma, mode="constant", cval=0.0)
       denominator = gaussian_filter(numpy.where(bad, 0.0, 1.0), sigma, mode="constant", cval=0.0)
      -return convolved*numerator/denominator
      +return convolved/denominator
      

        Attachments

          Issue Links

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                yusra Yusra AlSayyad
                Reporter:
                yusra Yusra AlSayyad
                Watchers:
                Yusra AlSayyad
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel