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
DM-14690: Add ability to construct centered boxes #361
Conversation
src/image/Exposure.cc
Outdated
buffer << "Cannot create bounding box with dimensions " << size; | ||
throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, buffer.str()); | ||
} | ||
lsst::geom::Box2I bbox = lsst::geom::Box2I::makeCenteredBox(pixelCenter, size, false); |
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.
I don't see a good way to simplify this, though I'm also not too bothered by that - the overall code complexity is the same; you've just moved this check from one place to another.
But it may be worth noting that given the check for both the center coordinate being in within the Exposure bbox and the size being positive, I believe it's guaranteed that overlapBox.isEmpty()
is always false
up in _copyCommonPixels
, and could perhaps be turned into an assert
, if this is the only caller.
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.
I'd prefer to leave it in, in case somebody later wants to promote _copyCommonPixels
to a public method or function. I had quite a bit of trouble generalizing makeCenteredBox
to work correctly with negative boxes, and assign
's behavior is pretty surprising.
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.
assign
's behavior is pretty surprising
I had no idea that's how it worked until I saw your comment, and now that I do know, it makes me sad, too.
What happens if the centre's on the Exposure but the box extends off the edge? It's convenient for the user to return something sane under these circumstances (presumably with NaNs and mask bits set)
R
|
As stated in the NaNs are not a terribly practical choice for the filler because we would need to adopt a different convention anyway for integer Setting mask bits is not possible because |
I should have thought of this this on the previous ticket, but I think the |
After some Slack discussion that doesn't seem as unreasonable as I first thought. I've logged the feature request as DM-14814. |
73dbde1
to
1ad5455
Compare
This PR modifies the implementation of
Exposure::getCutout
to use theBox2I::makeCenteredBox
factory introduced by lsst/geom#4. However, as a side effect thegetCutout
method became considerably more complex (17 LLOC for input validation plus three logical processing steps); any suggestions on how to break it up would be appreciated.