-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Reimplement NDCube.crop to "crop by points" and Extend Support to Crop by ExtraCoords #472
Conversation
CompoundWCS's check as to whether input world values resulted in compatible pixel values when world dimensions share pixel dimensions was not appropriate for all mappings. This commit introduces an alternative implementation to overcome this.
Co-authored-by: Stuart Mumford <stuart@cadair.com>
…nto crop_by_ec
This enables the item to be calculated without slicing the cube which can be useful, for example when trying to mimic crop's behaviour for NDCubeSequence.
Refactor avoids errors caused by creating corners by permutating values of world axes that share the same pixel axis. When this is the case, it leads to an undefined location on the pixel grid. Tests not yet passing.
…xel dims is the same. This leads to a simpler code path in most cases.
…world and pixel axes the same. Closer inspection reveals the simpler implementation for this case is not always valid.
…s in terms of world coord equivalents.
@Cadair, this PR now has all tests passing and is ready for review. Outstanding Questions
|
Failing tests should be fixes once #482 is merged. |
If you don't want to do it here, what about in sunraster instead? |
I'm implementing it here. |
…ange along an axis is within one pixel.
I think this makes a lot of sense if N points is one along a given axis?
👍 I am happy for this to be a feature request and not hold up 2.0 on it.
👍 this was my recollection also as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor points.
Co-authored-by: Stuart Mumford <stuart@cadair.com>
…alar Co-authored-by: Stuart Mumford <stuart@cadair.com>
…mpy.isscalar" This reverts commit e322953.
Changes made. Tests passing. Merging! |
Description
This PR reimplements
NDCube.crop
(andNDCube.crop_by_values
) to use the "crop by points" algorithm. Instead of taking lower and upper bounds on the world axes and calculating the corners of the bounding box in pixel space, this PR makesNDCube.crop
return the smallest cube in pixel space that includes the user-input points described using world coords. It is not assumed that the entered points are corners. This is degenerate with the bounding box implementation when the world and pixel axes are aligned. However, when the coordinate systems are rotated, the returned cube can be much smaller.This PR also extends the crop functionality to enable cropping by extra coords. As a result, it introduces a new property,
ExtraCoords.cube_wcs
, which returns a WCS of the extra coords that describes the cube itself. If not all array axes are associated with an extra coord, dummy world axes are added.This PR is a follow on attempt to #452
Fixes #345 and #476
Requires #482 to be merged.