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

Checks for NDData and data/subshape dimension length agreement in subtract_psf #833

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Onoddil
Copy link
Contributor

@Onoddil Onoddil commented Apr 24, 2019

This PR fixes a few minor check/edge cases in subtract_psf.

  1. The docstrings say that data can be an astropy.nddata.NDData object, but the first line previously checked for data.ndim which would throw an AttributeError for an NDData object.

  2. Currently the only check on whether the PSF can be subtracted directly from the image or if a cutout is required is if subshape is None, but equally true would be the case where data and subshape are equal in both dimensions, which bypasses unnecessary code in extract_array and add_array.

Closes #818 (at least the case where both dimension lengths are equal; for the final edge case of one equal one non-equal dimension length add_array would need amending)

… checks to see if data is the same size as subshape in both dimensions and not call extract_array/sub_array accordingly
Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

This seems reasonable to me, but tests are definitely needed for both changes 😄

@@ -207,10 +208,13 @@ def subtract_psf(data, psf, posflux, subshape=None):

Returns
-------
subdata : same shape and type as ``data``
subbeddata : same shape and type as ``data``
Copy link
Member

Choose a reason for hiding this comment

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

what about subbed_data or subtracted_data?

if subshape is None:
# data shape being exactly the same as subshape in both dimensions is equivalent to subtracting
# from the entire image, with no need to call extract_array and add_array
if subshape is None or all(data.shape[ind] == subshape[ind] for ind in [0, 1]):
indicies_reversed = indices[::-1]
Copy link
Member

Choose a reason for hiding this comment

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

Can we fix indicies -> indices?

Base automatically changed from master to main March 16, 2021 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subtract_psf in PSF Photometry fails for fitshape equal in length to input data
3 participants