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

DM-28961: DiaSource centroids outside of image causing crash in cuttout creation in PackageAlerts. #108

Merged
merged 2 commits into from Apr 6, 2021

Conversation

morriscb
Copy link
Contributor

@morriscb morriscb commented Apr 5, 2021

No description provided.

Copy link
Contributor

@isullivan isullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. My main question is whether we should catch all InvalidParameterErrors, or only the ones that were caused by this particular bug. I assume we would want to catch them all, but we might want to hit them for now so that we can try to understand where they are coming from.

skyCenter : `lsst.geom.SpherePoint`
Center point of DiaSource on the sky.
bbox : `lsst.geom.Extent2I`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it a BBox and not and Extent2I?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an Extent2I. Do you want me to change the variable names?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please.

self.exposure.getPhotoCalib())
self.exposure.getBBox().getDimensions(),
self.exposure.getPhotoCalib(),
1234)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please define 1234 as a variable (something like `diaSourceId = 1234) and pass that in, instead of a number. Also for the rest of this file where you are passing in a source ID.

self.log.warn(
"Failed to retrieve cutout from image for DiaSource with "
"id=%i. InvalidParameterError thrown during cutout creation. "
"Returning `None` for cuttout."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cuttout -> cutout

% srcId)
if not geom.Box2D(image.getBBox()).contains(point):
self.log.warn(
"DiaSource centroid lies at pixel (%.2f, %.2f) "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include the source ID in this warning as well.

"which is outside the Exposure with bounding box "
"((%i, %i), (%i, %i))." %
(point.x, point.y,
imBBox.minX, imBBox.maxX, imBBox.minY, imBBox.maxY))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little worried about this swallowing up other as-yet-unknown errors. Would it make sense to only return None for this case, and re-raise the error if it was a different problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I looked over the code for cutouts in C++. The two errors this block can throw are both InvalidParameterError one for centroid outside of exposure bbox and the extent of the cutout bbox is <=0. There may be others further up stream but I haven't investigated that completely. I guess the best I can do here is restructure it to catch the error for outside centroid (by testing it) and then do a raise on anything else. Sound good?

Split raise and warn conditions.

Change from BBox to correct Extent.

Add diaSrcId variable to unittest.

Fix linting.
@morriscb morriscb merged commit 4828449 into master Apr 6, 2021
@morriscb morriscb deleted the tickets/DM-28961 branch April 6, 2021 20:16
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

2 participants