Uploaded image for project: 'Request For Comments'
  1. Request For Comments
  2. RFC-861

Clean up PsfDeterminer configs

    XMLWordPrintable

    Details

      Description

      This is a set of closely related redefinitions and deprecation of fields in BasePsfDeterminerTask and its children classes pcaPsfDeterminerTask, psfexPsfDeterminerTask and piffPsfDeterminerTask.

      The kernelSize config field in concrete classes is used differently from the documentation given in BasePsfDeterminerConfig. In psfexPsfDeterminerTask, if kernelSize<15, only then is it scaled by the median of the square root of the quadrupole moments as mentioned in the docstring and used to set the bounding box of the PSF candidates. If kernelSize>15, it is used without any modification (if samplingSize=1 for psfexPsfDeterminer). This is an undocumented behavior! Similarly, in pcaPsfDeterminerTask, if kernelSize>15, it is used without any modification (there is no samplingSize) and if kernelSize<15, it is scaled by the median of the square root of the semi-major axis computed from the quadrupole moments, which is a bug: https://github.com/lsst/meas_algorithms/blob/main/python/lsst/meas/algorithms/pcaPsfDeterminer.py#L273-L286

      In piffPsfDeterminerTask, unlike the above two, the dimensions of the PSF candidates are not set explicitly within the determinePsf method. The dimensions are set to 21 (default) by the kernelSize parameter in makePsfCandidatesTask. This was completely overridden by pcaPsfDeterminer and psfexPsfDeterminer, making the config redundant.

      Furthermore, because of the different interpretations of kernelSize, PSF models are rendered on postage stamps of size given by:

      • kernelSize for PCA PSFs
      • kernelSize * samplingSize for PSFEx PSFs
      • kernelSize / samplingSize for PiFF PSFs

      By default, samplingSize = 0.5 for PSFEx and 1 for PiFF. Thus, this makes translating kernelSize parameter to postage stamp size confusing and less straightforward. E.g., in the HSC RC2 dataset processed with PSFEx, with samplingSize=0.5, the kernelSize had to be set to 81 to make PSF candidates and the PSF model be 41x41 pixels in size.

      Proposal:

      1. Deprecate the kernelSize field in BasePsfDeterminerConfig.
      2. Redefine kernelSize in makePsfCandidates to mean the exact size of the PSF candidate objects, i.e., size of the star image to consider to build PSF models.
      3. Promote samplingSize (or a better named version of it) to be a config field in BasePsfDeterminerTask.
      4. Define an optional stampSize config field in BasePsfDeterminerTask to mean the size (in native pixels) of the postage stamp when a PSF model gets rendered. This allows one to adjust the core of a PSF model from the extended wings of a star. The value must not exceed kernelSize and defaults to kernelSize.
      5. Deprecate kernelSizeMin and kernelSizeMax in BasePsfDeterminerTask.

      Planned end date is longer than typical, since I’m going to be a bit slow on DM-related tasks for the next few weeks and DMLT and no-meeting weeks are coming up.

        Attachments

          Issue Links

            Activity

            Hide
            Parejkoj John Parejko added a comment -

            Comments on individual proposals:
            1) If you deprecate kernelSize in the base task, do the child tasks still have that field, with their own definitions of it, or is it supposed to be replaced with the `stampSize` defined in 4)?
            2) Did you mean `makePsfCandidates`? And by redefine, do you mean "change the docsstring"?
            3) Does this also include modifying psfex and piff to use `samplingSize` in the same way?
            4) You refer to `kernelSize` here, but you deprecated it in 1)?
            5) I assume pca and psfex both keep these min/max configs because they both do use them to check the calculated kernelSize?

            Show
            Parejkoj John Parejko added a comment - Comments on individual proposals: 1) If you deprecate kernelSize in the base task, do the child tasks still have that field, with their own definitions of it, or is it supposed to be replaced with the `stampSize` defined in 4)? 2) Did you mean `makePsfCandidates`? And by redefine, do you mean "change the docsstring"? 3) Does this also include modifying psfex and piff to use `samplingSize` in the same way? 4) You refer to `kernelSize` here, but you deprecated it in 1)? 5) I assume pca and psfex both keep these min/max configs because they both do use them to check the calculated kernelSize?
            Hide
            kannawad Arun Kannawadi added a comment -

            Hey John,

            1) kernelSize is to be deprecated from BasePsfDeterminer and all its children tasks. Some PSF determiners implicitly redefine kernelSize, which will be replaced with stampSize as you mentioned.

            2) Oops, sorry, I meant makePsfCandidate (now changed in the original proposal above). By redefine, I mean changing the docstring and ensuring that the usage of the config is in accordance with the docstring.

            3) Yes

            4) makePsfCandidates will continue to have kernelSize. Only its namesake in BasePsfDeterminer that I propose to deprecate.

            5) Not in practice. The config values that are set at the instrument level, and by default in the algorithm do not trigger that behavior where `kernelSizeMin` and `kernelSizeMax` are used. We might essentially consider them as unused and remove those parts altogether.

            Show
            kannawad Arun Kannawadi added a comment - Hey John, 1) kernelSize is to be deprecated from BasePsfDeterminer and all its children tasks. Some PSF determiners implicitly redefine kernelSize , which will be replaced with stampSize as you mentioned. 2) Oops, sorry, I meant makePsfCandidate (now changed in the original proposal above). By redefine, I mean changing the docstring and ensuring that the usage of the config is in accordance with the docstring. 3) Yes 4) makePsfCandidates will continue to have kernelSize . Only its namesake in BasePsfDeterminer that I propose to deprecate. 5) Not in practice. The config values that are set at the instrument level, and by default in the algorithm do not trigger that behavior where `kernelSizeMin` and `kernelSizeMax` are used. We might essentially consider them as unused and remove those parts altogether.
            Hide
            jbosch Jim Bosch added a comment -

            This all sounds reasonable to me, and a clear improvement on the status quo. Seems like deprecating those min/max configs John asked about is worth doing at the same time.

            Show
            jbosch Jim Bosch added a comment - This all sounds reasonable to me, and a clear improvement on the status quo. Seems like deprecating those min/max configs John asked about is worth doing at the same time.
            Hide
            tjenness Tim Jenness added a comment -

            Arun Kannawadi are you intending to adopt this RFC or withdraw it?

            Show
            tjenness Tim Jenness added a comment - Arun Kannawadi are you intending to adopt this RFC or withdraw it?
            Hide
            kannawad Arun Kannawadi added a comment -

            Adopting the RFC with DM-36071

            Show
            kannawad Arun Kannawadi added a comment - Adopting the RFC with DM-36071
            Hide
            kannawad Arun Kannawadi added a comment -

            Thoughts that came up while implementing this RFC in DM-36071:

            3) Does it make sense to promote `samplingSize` parameter to the Base class, given that PCA PSF determiner does not use this? Or does it make sense because this will ensure consistency between PSFEx and Piff PSF determiners that do use `samplingSize`?

            4) Because the PSF candidates (in particular, their bounding boxes) are global, modifying them in one part of the pipeline changes them for others as well. Piff and PCA Psfs do this. Either, these algorithms should be modified to make a copy internally, or `stampSize` should become a mandatory config field. The latter is not possible (by design) since until DM-36311, when kernelSize is completely removed (1). So making an internal copy seems to me the best way forward.

            Show
            kannawad Arun Kannawadi added a comment - Thoughts that came up while implementing this RFC in DM-36071 : 3) Does it make sense to promote `samplingSize` parameter to the Base class, given that PCA PSF determiner does not use this? Or does it make sense because this will ensure consistency between PSFEx and Piff PSF determiners that do use `samplingSize`? 4) Because the PSF candidates (in particular, their bounding boxes) are global, modifying them in one part of the pipeline changes them for others as well. Piff and PCA Psfs do this. Either, these algorithms should be modified to make a copy internally, or `stampSize` should become a mandatory config field. The latter is not possible (by design) since until DM-36311 , when kernelSize is completely removed (1). So making an internal copy seems to me the best way forward.
            Hide
            jbosch Jim Bosch added a comment -

            I don't have a very strong opinion on (3), but I lean towards keeping it out of the base class; it's not something anyone downstream of the PSF determiner should depend on, and I can envision an PSF determiner implementation that might have multiple samplingSize parameters for different aspects of the model (perhaps even a Piff-based one) for which a single config option might be awkward.

            For (4), sounds like copy does seem like the best approach, and while I doubt those copies will matter in the big picture, let's add a note to DM-36311 to avoid them there if still possible.

            Show
            jbosch Jim Bosch added a comment - I don't have a very strong opinion on (3), but I lean towards keeping it out of the base class; it's not something anyone downstream of the PSF determiner should depend on, and I can envision an PSF determiner implementation that might have multiple samplingSize parameters for different aspects of the model (perhaps even a Piff-based one) for which a single config option might be awkward. For (4), sounds like copy does seem like the best approach, and while I doubt those copies will matter in the big picture, let's add a note to DM-36311 to avoid them there if still possible.
            Hide
            jmeyers314 Joshua Meyers added a comment -

            I also vote to keep samplingSize out of the base class to avoid designing ourselves into a corner in the future.  We should definitely still make it consistent in the various classes where it is used though.

            Show
            jmeyers314 Joshua Meyers added a comment - I also vote to keep samplingSize out of the base class to avoid designing ourselves into a corner in the future.  We should definitely still make it consistent in the various classes where it is used though.

              People

              Assignee:
              kannawad Arun Kannawadi
              Reporter:
              kannawad Arun Kannawadi
              Watchers:
              Arun Kannawadi, Jim Bosch, John Parejko, Joshua Meyers, Tim Jenness, Yusra AlSayyad
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Planned End:

                  Jenkins

                  No builds found.