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

HSC backport: allow for use of Approximate model in background estimation

    Details

    • Story Points:
      6
    • Sprint:
      Science Pipelines DM-S15-3, Science Pipelines DM-S15-4
    • Team:
      Data Release Production

      Description

      This issue involves transferring changesets from the following HSC issues:

      • HSC-145 Investigate approximating rather than interpolating backgrounds
      • HSC-1047 Background object cannot be loaded with butler
      • HSC-1213 Set background 'approximate' control settings when background control is created.
      • HSC-1221 tests failing in ip_diffim
      • HSC-1217 Verify backgroundList IO works properly when Approximate is enabled in background control - HSC JIRA

      The Approximate (Chebyshev) approach greatly improves the background subtraction around bright objects compared with the interpolation scheme currently in use (which over-subtracts near bright objects).

        Attachments

          Issue Links

            Activity

            Hide
            lauren Lauren MacArthur added a comment -

            In looking into the relevant code in afw/math while working on this issue, it is clear there is some clean-up and restructuring that needs to be done before resetting the defaults (which may also require adjusting some defaults in the calibrate stage to be more appropriate for the approximation, as opposed to inperpolation, scheme). Therefore, the default setting will not be changed as part of this ticket (i.e. useApprox is set to False). A separate issue (DM-2920) has been created to clean up the code and make sure it all operates coherently. Another ticket (DM-2921) has been created to actually reset the defaults and make any other config default changes required.

            In the meantime, a temporary check has been added here in meas.algoritms.detection.getBackground() so that it is currently "safe" to run with useApprox=True and any other user overridden config setting (binSize, approxOrderX, undersampleStyle) (and there currently exists similar checks in pipe.tasks.matchBackground), but these should be removed once DM-2920 has been implemented.

            Show
            lauren Lauren MacArthur added a comment - In looking into the relevant code in afw/math while working on this issue, it is clear there is some clean-up and restructuring that needs to be done before resetting the defaults (which may also require adjusting some defaults in the calibrate stage to be more appropriate for the approximation, as opposed to inperpolation, scheme). Therefore, the default setting will not be changed as part of this ticket (i.e. useApprox is set to False). A separate issue ( DM-2920 ) has been created to clean up the code and make sure it all operates coherently. Another ticket ( DM-2921 ) has been created to actually reset the defaults and make any other config default changes required. In the meantime, a temporary check has been added here in meas.algoritms.detection.getBackground() so that it is currently "safe" to run with useApprox=True and any other user overridden config setting (binSize, approxOrderX, undersampleStyle) (and there currently exists similar checks in pipe.tasks.matchBackground ), but these should be removed once DM-2920 has been implemented.
            Hide
            lauren Lauren MacArthur added a comment -

            Yusra, would you mind having a look at this? The relevant commits are all in u/lauren/DM-2778 branches on the following repos:

            • afw
            • meas_algorithms
            • pipe_tasks
            • ip_diffim

            I ran a Buildbot against them and it was successful. I've also put running with useApprox=True through its paces with various config settings using testProcessCcd.py in pipe_tasks and have processed some real data (see attached figures). Formal unittests await a refactoring of some code in DM-2920.

            Show
            lauren Lauren MacArthur added a comment - Yusra, would you mind having a look at this? The relevant commits are all in u/lauren/ DM-2778 branches on the following repos: afw meas_algorithms pipe_tasks ip_diffim I ran a Buildbot against them and it was successful. I've also put running with useApprox=True through its paces with various config settings using testProcessCcd.py in pipe_tasks and have processed some real data (see attached figures). Formal unittests await a refactoring of some code in DM-2920 .
            Hide
            yusra Yusra AlSayyad added a comment -

            Looks good. Couple minor questions/comments:

            pipe_tasks/meas_algorithms:
            In MatchBackgroundsConfig there is a config parameter called "usePolynomial" which is used the same way that "useApprox" is being used in meas_algorithms. We'll want eventual consistency, but it is not necessary on this ticket. I'm not sure useApprox is all that transparent to Task users.
            python/lsst/meas/algorithms/detection.py: Double check that the comment starting at line 579 is current.

            afw:
            Are we temporarily losing the ability to do spline interpolation on doubles? I'm not too worried though since we will get this back with a stand alone interpolate2D class.

            include/lsst/afw/math/Approximate.h: line 59-68 getters have comments but setters don't. I don't necessarily think the setters need comments, but I'm realizing our styles in header files are diverging.

            approximate.i: Copyleft in brand new files says 2008, 2009, 2010? (I see tests/background.py was updated on this ticket to use 2008-2015 AURA/LSST)

            python/lsst/afw/math/background.py:
            *I like that there is a section for backwards compatibility here. Will we be supporting these new property set keys when they change in the future?

            • line 171/172. ApproxOrderX/Y defaults when not useApprox: Please add a comment as to why is one default is -1 and the other +1.
            • 809/820 commented-out print statements

            ip_diffim: look good; no comments.

            Show
            yusra Yusra AlSayyad added a comment - Looks good. Couple minor questions/comments: pipe_tasks/meas_algorithms: In MatchBackgroundsConfig there is a config parameter called "usePolynomial" which is used the same way that "useApprox" is being used in meas_algorithms. We'll want eventual consistency, but it is not necessary on this ticket. I'm not sure useApprox is all that transparent to Task users. python/lsst/meas/algorithms/detection.py : Double check that the comment starting at line 579 is current. afw: Are we temporarily losing the ability to do spline interpolation on doubles? I'm not too worried though since we will get this back with a stand alone interpolate2D class. include/lsst/afw/math/Approximate.h: line 59-68 getters have comments but setters don't. I don't necessarily think the setters need comments, but I'm realizing our styles in header files are diverging. approximate.i: Copyleft in brand new files says 2008, 2009, 2010? (I see tests/background.py was updated on this ticket to use 2008-2015 AURA/LSST) python/lsst/afw/math/background.py: *I like that there is a section for backwards compatibility here. Will we be supporting these new property set keys when they change in the future? line 171/172. ApproxOrderX/Y defaults when not useApprox: Please add a comment as to why is one default is -1 and the other +1. 809/820 commented-out print statements ip_diffim : look good; no comments.
            Hide
            lauren Lauren MacArthur added a comment -

            Thanks Yusra AlSayyad

            RE consistency between useApprox & usePolynomial: I totally agree, but I think that can be addressed in DM-2920 (for which we will be consulting you and Simon Krughoff on!).

            RE interpolation on doubles: I think this is indeed the case for now. Here are the comments Steve Bickerton [X] wrote in the HSC-1047 ticket:

            – Background was templated over double,float,int; but Approximate was only using float. My first effort was to add double and int to Approximate, but this proved difficult and I could never quite get the explicit instantiations to behave. However, since we don't actually use double or int Backgrounds, it seemed sensible to just stop instantiating them and move on.

            I think his last statement is still valid here, and there don't seem to be any noticeable effects (e.g. lsst_dm_stack_demo passes). If you're not worried, I'm not either

            RE supporting property keys: I don't know, but that will certainly be part of the discussions re DM-2920.

            I went ahead and updated the copyright on every file touched in this this issue and addressed all other comments. I've rebased onto master, re-pushed the branches, and kicked off another Buildbot. Are you ok with me pushing to master if that passes?

            Show
            lauren Lauren MacArthur added a comment - Thanks Yusra AlSayyad RE consistency between useApprox & usePolynomial : I totally agree, but I think that can be addressed in DM-2920 (for which we will be consulting you and Simon Krughoff on!). RE interpolation on doubles : I think this is indeed the case for now. Here are the comments Steve Bickerton [X] wrote in the HSC-1047 ticket: – Background was templated over double,float,int; but Approximate was only using float. My first effort was to add double and int to Approximate, but this proved difficult and I could never quite get the explicit instantiations to behave. However, since we don't actually use double or int Backgrounds, it seemed sensible to just stop instantiating them and move on. I think his last statement is still valid here, and there don't seem to be any noticeable effects (e.g. lsst_dm_stack_demo passes). If you're not worried, I'm not either RE supporting property keys : I don't know, but that will certainly be part of the discussions re DM-2920 . I went ahead and updated the copyright on every file touched in this this issue and addressed all other comments. I've rebased onto master, re-pushed the branches, and kicked off another Buildbot. Are you ok with me pushing to master if that passes?
            Hide
            swinbank John Swinbank added a comment -

            Lauren MacArthur – when you get chance, could you add a few words describing what's been done here to the release notes at https://confluence.lsstcorp.org/display/DM/Data+Release+Production+WIP+S15+release+notes? Thanks!

            Show
            swinbank John Swinbank added a comment - Lauren MacArthur – when you get chance, could you add a few words describing what's been done here to the release notes at https://confluence.lsstcorp.org/display/DM/Data+Release+Production+WIP+S15+release+notes? Thanks!

              People

              • Assignee:
                lauren Lauren MacArthur
                Reporter:
                lauren Lauren MacArthur
                Reviewers:
                Yusra AlSayyad
                Watchers:
                Jim Bosch, John Swinbank, Lauren MacArthur, Paul Price, Simon Krughoff, Yusra AlSayyad
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel