Allow for custom centroiding in find_peaks #656
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows for custom centroiding in the
find_peaks
function. Currently, the function will centroid sources with thesubpixel
keyword (now deprecated) by fitting a 2D Gaussian + constant. As noted in #655, this compound-model fitting method can be slow.This PR makes centroiding in
find_peaks
more flexible by allowing the user to pass any callable (e.g. function/class instance) to compute the local centroid (within the cutout/footprint). This PR also adds a new general function calledcentroid_sources
that performs this functionality given initial (x, y) positions.One small change of behavior is that with
subpixel=True
the fitted peak value was also returned. To keeps things general, that is no longer the case because the passed centroid function need not perform any fit (e.g. a moment-based centroid).To get the same centroid values as
subpixel=True
, one can use thecentroid_func
keyword with thephotutils.centroids.centroid_2dg
function.