Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to exclude local background in residual image (#1690) #1691

Merged
merged 10 commits into from
Feb 13, 2024

Conversation

m-samland
Copy link
Contributor

@m-samland m-samland commented Jan 10, 2024

This pull request is to solve issue #1690. I added a new keyword to the function make_model_image' and make_residual_image' of the PSFPhotometry-class to toggle whether the local background model is included or not.

At the moment it is only possible to make a model image of the fitted PSF Photometry that includes the locally measured background for each star. However, when there is highly structures background and a crowded field, it may be desirable to only subtract a model of the fit stars from the image, without the local background estimate (that currently can only be a scalar). Otherwise we have overlapping regions of subtracted scalar backgrounds in the residual image when stars are close to each other.
This option may also be useful for iterative PSF fitting of clustered stars.
The solution would simply to add one more parameter ``include_bkg'' to both functions in the PSFPhotometry-class.

The changes should not break existing code, as far as I can tell.

Closes #1690

Copy link
Member

@larrybradley larrybradley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @m-samland. I have just a few suggested changes.

photutils/psf/photometry.py Outdated Show resolved Hide resolved
photutils/psf/photometry.py Outdated Show resolved Hide resolved
photutils/psf/photometry.py Outdated Show resolved Hide resolved
photutils/psf/photometry.py Outdated Show resolved Hide resolved
photutils/psf/photometry.py Outdated Show resolved Hide resolved
@pep8speaks
Copy link

pep8speaks commented Feb 12, 2024

Hello @m-samland! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-02-12 15:27:58 UTC

@m-samland
Copy link
Contributor Author

Thanks for the suggestions @larrybradley, I commited them. Happy to have this merged. :)

Copy link
Member

@larrybradley larrybradley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again, @m-samland. This needs a test and a changelog entry, but I'll add those in a followup PR. I'm also considering making the default be to not include the local background subtraction (unfortunately that would be a breaking change, but it might be sensible).

@larrybradley larrybradley merged commit 7fe5ef6 into astropy:main Feb 13, 2024
21 checks passed
@SterlingYM
Copy link

Can the same feature (to turn off local bkg) be supported for IterativePSFPhotometry class too?

https://github.com/astropy/photutils/blob/d78f2acde625a8f526c99fd0fa021f52bfe7297f/photutils/psf/photometry.py#L1550C1-L1550C60

@larrybradley
Copy link
Member

@SterlingYM Yes, I'll add that feature to IterativePSFPhotometry. Thanks!

@larrybradley
Copy link
Member

@SterlingYM This was added in #1756.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PSF photometry: include option to exclude local background in make_model_image() and make_residual_image()
4 participants