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

Possible fix for world-to-pixel when out of bounding box #497

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bmorris3
Copy link
Contributor

@bmorris3 bmorris3 commented May 9, 2024

This PR attempts to address #496.

GWCS implements an in_image method that returns a False for out-of-bounds world coordinates by converting to pixel coords with invert and then comparing to the bounding box.

This PR simply adds a line to world_to_pixel and world_to_pixel_values which sets pixel results outside of the bounding box to nan. Rather than calling in_image, I moved the logic for pixel coordinate comparisons to the bounding box into a separate function, and call that function in world_to_pixel* transformations, as well as within in_image. The pixel/bounding box comparison logic had to be moved to a separate method because in_image calls invert – so calling in_image to from within invert to mask the result would lead to recursion.

Right now there are two test failures where I would have to change the expected output in the test. I've left these two cases in so you can see what changes. Let me know if you agree that I can change those expected answers to nan.

cc @astrofrog @nden

Copy link

codecov bot commented May 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.37%. Comparing base (eb9d316) to head (9068f7a).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #497      +/-   ##
==========================================
+ Coverage   87.28%   87.37%   +0.09%     
==========================================
  Files          22       22              
  Lines        3821     3834      +13     
==========================================
+ Hits         3335     3350      +15     
+ Misses        486      484       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Successfully merging this pull request may close these issues.

None yet

1 participant