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

EPSFModel and/or FittableImageModel et al. could check if x and y are true 1D arrays and propagate to 2D #1000

Open
Onoddil opened this issue Nov 21, 2019 · 0 comments

Comments

@Onoddil
Copy link
Contributor

Onoddil commented Nov 21, 2019

Currently the evaluate (or __call__) functions of EPSFModel, FittableImageModel etc. require x and y to be 2D arrays (or at least representative of the coordinate values of a 2D grid), and then return that same 2D grid, evaluating the PSF at those points. However, it would be convenient if evaluate was able to check if these were actually 1D arrays (to save the user having to constantly do np.meshgrid and the like just to get a different mapping of the ePSF, e.g.) and did the propagation up to 2D on the fly. This would be useful for cases where the user is doing some simple PSF model creation, or trying to fit a regular grid cutout of a star, such as from extract_stars.

This would have issues with sliced arrays, however, as a slicing of a 2D meshgrid will return a 1D array, which could then incorrectly be propagated back up to 2D by the change. It could still be possible to add masking as an option with the inclusion of mask=None as a keyword to all evaluate functions -- by default then, no masking is applied, but if mask is not None then you would be able to do x = x[mask] etc., slicing after the check for 1/2D-ness has been done.

That said, I am unsure of how likely it is for the user to have done something like that; the PSF photometry routines do, however. These, as private functions, could presumably be changed to pass, rather than the masked, subimage cutouts (fit_model = self.fitter(group_psf, x[usepixel], y[usepixel], image[usepixel])), the usepixel array as a new keyword, to end up passing through to the model evaluate call as mask=usepixel...

Unfortunately, I currently do not see a way to easily implement this, as I don't believe LevMarLSQFitter trivially accepts keywords that aren't x, y, z or weights, so perhaps that is a bridge too far... This might be a WONTFIX-type situation, but on the off chance it's worth looking at I thought I'd put the issue up. Perhaps someone with more knowledge than I of the astropy.modeling infrastructure knows of a way to do this.

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

No branches or pull requests

2 participants