Skip to content

Convert get_crop_item_from_points to work self-consistently in pixel space until min/max array indices calculated#1

Merged
ayshih merged 9 commits into
ayshih:crop_fixfrom
DanRyanIrish:ayshih_crop_fix
Jul 14, 2025
Merged

Convert get_crop_item_from_points to work self-consistently in pixel space until min/max array indices calculated#1
ayshih merged 9 commits into
ayshih:crop_fixfrom
DanRyanIrish:ayshih_crop_fix

Conversation

@DanRyanIrish

Copy link
Copy Markdown

This PR alters ndcube#874 to work explicitly work from world space to pixel space until the min and max array indices are calculated.

This was inspired because at the time of writing this PR, ndcube#874 used pixel coordinates arranged in array order. This was a consequence of how the function was originally written, but made the new variable names confusing. Explicitly working in pixel space first and then switching to array space allows some of the code in get_crop_item_from_points function to be simplified.

Additionally, this PR moves the warning so that a separate one is raised for each array axis for which all world values correspond to a single pixel edge. This allows more explicit information in the warning. Since the likelihood of all world coords corresponding to the same exact pixel edge is very small, the likelihood of this resulting in 1, let alone multiple, warnings for a single crop operation very low.

…ray index space.

This is preferred so that it can be determined whether the maximum input world coordinate
corresponds to a pixel edge. In this case, the rightward pixel can be excluded from the
cropped cube.
This commit raises a warning for each axis when the input points
all correspond to the same pixel edge. This allows more explicit
information in the warning and less code.
…array axis correspond to pixel edge.

Previously it was raised if all coords for the array axis were in the same pixel.
…revious implementation.

Previous implementation was correct and is simpler.  Also, raise warning of whether
all world values land on a single pixel edge once, but build message on an axis by axis
basis.
@ayshih ayshih merged commit 3fb8932 into ayshih:crop_fix Jul 14, 2025
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.

2 participants