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

fix float comparison bug for non-square subarrays #640

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

mperrin
Copy link
Collaborator

@mperrin mperrin commented Sep 30, 2024

Fixes a floating comparison that can cause a bug under some circumstances when trying to make a PSF on a non-square subarray.

Currently:

import webbpsf
miri = webbpsf.MIRI()
miri.set_position_from_aperture_name('MIRIM_TA1140_UR')   # Aperture used in some MIRI coron TAs

rect_psf = miri.calc_psf(nlambda=1, fov_pixels=(224, 288))   # Compute PSF with the shape of that subarray
--------------------------------------------
[... long trace of error text ]
NotImplementedError: Different pixel scales in X and Y directions (i.e. non-square pixels) not yet supported.

It's incorrect to trigger that error. The pixel scale is the same in both dimensions (or should be), and it's just the dimension which is different. Right now the check is being confused by a floating point precision issue.

With this PR:
It works as intended, and makes a PSF on a rectangular subarray.

Unknown-1

@mperrin mperrin self-assigned this Sep 30, 2024
@mperrin mperrin added the bug Something isn't working label Sep 30, 2024
Copy link
Collaborator

@obi-wan76 obi-wan76 left a comment

Choose a reason for hiding this comment

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

looks good, works as intended
image

@mperrin mperrin merged commit 3a83d51 into spacetelescope:develop Oct 1, 2024
7 checks passed
@mperrin mperrin deleted the fix_float_comparison branch October 1, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants