Possible fix for world-to-pixel when out of bounding box #497
+25
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 withinvert
and then comparing to the bounding box.This PR simply adds a line to
world_to_pixel
andworld_to_pixel_values
which sets pixel results outside of the bounding box to nan. Rather than callingin_image
, I moved the logic for pixel coordinate comparisons to the bounding box into a separate function, and call that function inworld_to_pixel*
transformations, as well as withinin_image
. The pixel/bounding box comparison logic had to be moved to a separate method becausein_image
callsinvert
– so callingin_image
to from withininvert
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