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-42914: Add edgeCenter and edgeCenterAll flags #264

Merged
merged 4 commits into from Feb 16, 2024
Merged

Conversation

parejkoj
Copy link
Contributor

No description provided.

Copy link
Member

@kfindeisen kfindeisen 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, just some clarification/style comments.

src/PixelFlags.cc Show resolved Hide resolved
self.dataset.addSource(100000, lsst.geom.Point2D(80, 30))
# Half on the edge; no offimage or edgeCenterAll, but edge and edgeCenter.
self.dataset.addSource(100000, lsst.geom.Point2D(115, 30))
Copy link
Member

Choose a reason for hiding this comment

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

Does "half on the edge" mean the source sits on the border of the edge region? Is the centroid exactly on the border, or merely <1px off (I can see different actual/desired behavior for the two cases)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've clarified the comments. It's about whether edgeCenter vs. edgeCenterAll is set. All that I care about is where central 3x3 region is, not the exact centroid.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but the position of the 3×3 region will depend on where the centroid is, and by how much...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do the updated comments help?

Copy link
Member

Choose a reason for hiding this comment

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

I guess? I'm not sure how the pixels can be "half" on the edge (a pixel is either flagged or not, no?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I meant "half of the" - I'll fix that.

Copy link
Member

Choose a reason for hiding this comment

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

I meant that I'm not sure how you can get half of them like that -- I would have expected e.g. one row on and two off, or vice versa.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pedantism strikes again! You're right, but that doesn't matter for the test itself (nothing cares about the centroid itself, just the box around it).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about Central 3x3 pixels are partly on the masked EDGE?

np.testing.assert_array_equal(catalog["base_PixelFlags_flag_edgeCenter"],
np.array([False, True, True, True, True, True, True]))
np.testing.assert_array_equal(catalog["base_PixelFlags_flag_edgeCenterAll"],
np.array([False, True, True, True, True, False, True]))
Copy link
Member

Choose a reason for hiding this comment

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

This style of testing is very hard to validate (which index is which source? 😵‍💫), but I suppose that's out of scope for this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I know. I am responsible for adding these tests myself, so I can't blame history on this part. It was useful to have them all in one test so I could look at them on the image with afw.display to check that I'd put them where I thought I had, and then to look at the arrays being tested to see that they covered the cases I wanted.

Suggestions on how to clean it up? I could pull each source into its own test, but then it's a bit harder to reason about having caught an appropriate number of cases.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, a separate method for each would probably be best. The "loop over examples" idiom wouldn't really work here, especially if you need explanatory comments for each source. 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I separated the edge from the offImage tests, so at least there are many fewer bools in the arrays. I think because they're grouped together and only 2 or 4 entries to check, this is clear enough now. Thoughts?

We don't need special handling if we just assign the EDGE table key as
the NO_DATA mapping value.
These flags will help distinguish sources that are near an edge vs.
those whose center is fully contained in the edge region.
* We don't need the centered source in all the tests, it just clutters
the result when checking bools.
* Separate testEdgeFlags from testOffImage
@parejkoj parejkoj merged commit 4cf4654 into main Feb 16, 2024
2 checks passed
@parejkoj parejkoj deleted the tickets/DM-42914 branch February 16, 2024 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants