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-31849: Fix miscellaneous forced photometry bugs. #192

Merged
merged 10 commits into from Sep 29, 2021
Merged

Conversation

TallJimbo
Copy link
Member

No description provided.

yalsayyad and others added 5 commits September 27, 2021 13:40
This avoids duplicate WCS transforms, which can be slow, and it makes
TransformedCentroidFromCoordPlugin actually useful with most
photometry plugins.
Forced photometry reference catalogs are expected to remain in their
original coordinate systems, and that includes their footprints.
Footprints attached to the forced photometry measurement catalog were
already being created by transforming the reference catalog ones.

This addresses DM-31686.
Copy link
Contributor

@natelust natelust left a comment

Choose a reason for hiding this comment

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

A few minor comments. It all seems fine, but I make no guarantees about subtitle issues, all this forced stuff takes a lot to load into memory and grok. I support a rewrite soon.

spans = lsst.afw.geom.SpanSet.fromShape(ellipse)
footprint = lsst.afw.detection.Footprint(spans.clippedTo(bbox), bbox)
localIntPoint = lsst.geom.Point2I(localPoint)
assert bbox.contains(localIntPoint), (
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move this higher. Spans probably should have the int point anyway. No sense doing the other stuff if the point is not in there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Given that it's an assert, it really shouldn't be tripping at all, so short-circuit performance shouldn't be a concern here. But I'm happy to move it earlier.

(I added this because prior to this ticket generateMeasCat wasn't guaranteeing this even though it intended to, and this assert helped catch the bug, which resulted in 1280219)

to which footprints should be attached.
exposure : `lsst.afw.image.Exposure`
Image object from which peak values and the PSF are obtained.
scaling : `int`, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to dilate by this? It does not seemed to be used

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch; I was planning to scale the ellipses before making SpanSets out of them, but completely forgot. Will fix.

throw LSST_EXCEPT(pex::exceptions::RuntimeError, "No footprint present.");
}
auto fullSpans = footprint->getSpans();
if (!footprint) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the wrong condition.

afw::detection::Footprint const& footprint(*measRecord.getFootprint());
footprint.getSpans()->clippedTo(mimage.getBBox())->applyFunctor(func, *(mimage.getMask()));
auto footprint = measRecord.getFootprint();
if (!footprint) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought best practice with pointers wasn't to explicitly test against nullptr

Copy link
Member Author

Choose a reason for hiding this comment

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

It's possible this is one of those things we wrote down one way in our style guide, and then the rest of the went the opposite way, but if so, I can't find it in our style guide (one way or another) and the most authoritative rest-of-the-world guide I know of says to use this form:

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es87-dont-add-redundant--or--to-conditions

This extends the fix for DM-31686 to forced photometry with DataFrame
reference catalogs.
I think this was previously overriding the derived-class defaults with
any base-class defaults for the same fields.
This should have been included on DM-17689, but the code here was on a
branch that was in progress at the same time and got merged later.

Some (but not all) of this fixup commit then got orphaned on a
DM-29729 branch, because the main purpose of that ticket was something
that got marked invalid.
Pass a float to a method that takes an int, and you get truncation, not
rounding; this led to points not quite on the
image being included.
@TallJimbo TallJimbo merged commit 5822f6d into master Sep 29, 2021
@TallJimbo TallJimbo deleted the tickets/DM-31849 branch September 29, 2021 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants