Skip to content

Conversation

@fred3m
Copy link
Contributor

@fred3m fred3m commented May 17, 2024

The previous deblending algorith was not properly deblending, as it was attempting to use meas_deblender for use cases that were not algorithmically suitable.

This commit only runs the deblender on blends that have all positive peaks, the regime that it is designed for.

@fred3m fred3m force-pushed the tickets/DM-44319 branch 2 times, most recently from e481cd7 to 8af121f Compare May 17, 2024 15:26
Copy link
Contributor

@parejkoj parejkoj left a comment

Choose a reason for hiding this comment

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

One concern is that downstream processing will have to filter on something to remove the "multiple parent copies". I don't know if we should also do that on this ticket, but we maybe should. I think that would be in FilterDiaSourceCatalogTask in ap_assocation. I don't know if we need to do it elsewhere, too; having both parents and children in the diaSource catalogs is something we're not fully familiar with yet.

merged_footprints.makeSources(sources)

# Sky sources must be added before deblending, otherwise the
# sources with parent == 0 will be out of order and SFM cannot run.
Copy link
Contributor

Choose a reason for hiding this comment

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

We're not really running "SFM" here; maybe this instead sources with parent == 0 will be out of order and measurement will fail.?

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'll change to "measurement tasks." The point is that measurement plugins require all of the children with the same parent ID to be contiguous, but the old version of this task added the sky sources after deblending, so if deblending had worked as expected then measurement would fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit surprised by that, because I think that deblending was working on "isolated" positive blends before (it was just messing up other things), and we didn't see failures.

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, it's actually because before it wasn't doing any deblending, so all of the sources had parent==0. The measurement framework has a call to SourceCatalog.getChildren(0), where the argument is the parent ID. This is done to run all of the measurements on the parents, but in the new catalog if the sky objects were appended to it then the records with parent == 0 was discontinuous.


# Update the deblended parents and add their children
# to the sources catalog.
sources.extend(temp_cat[first_child_index:], deep=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you want to do a deep copy here to ensure the catalog is contiguous, but maybe that's not necessary for the measurement tasks that are run in after this? And then the catalog is written to disk. I guess we can see if we get failures when running on larger data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we actually don't want a deep copy (see Jim's comments in slack). The temporary catalog actually created a view to the original records, that way the source IDs stay in order and the original records are updated in place.

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 checked and verified that using this procedure the sources are always contiguous.

Comment on lines 466 to 470
# Set detection and primary flags
for sid in skipped_ids:
src = sources.find(sid)
self.deblend.skipParent(src, difference.mask)
self.setPrimaryFlags.run(sources)
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand what setPrimaryFlags is doing here, but I'm not familiar with skipParent. Could you please expand the comment above, since I don't think we're setting any "flags" here, but rather the "not deblended" mask plane (I think?)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. The basic idea is that the deblender already has a method to set all of the appropriate flags for a parent source when deblending is skipped, so we just call that method to set those flags here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think calling it "detection" as the comment does isn't quite correct, though, since we've already done detection. Maybe Set blending-related mask planes and flags on the non-deblended parents. would be more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, see my latest commit. But for the setPrimary section I still use this comment because technically all of the flags set by isPrimary are detect_<flagName>, since they are about detection.

@parejkoj
Copy link
Contributor

Couple more comments about comments, otherwise this looks good, thank you

@fred3m fred3m force-pushed the tickets/DM-44319 branch from 3c211c0 to c1145ec Compare May 17, 2024 23:40
The previous deblending algorith was not properly deblending,
as it was attempting to use meas_deblender for use cases
that were not algorithmically suitable.

This commit only runs the deblender on blends that have
all positive peaks, the regime that it is designed for.
@fred3m fred3m force-pushed the tickets/DM-44319 branch from c1145ec to 145f463 Compare May 20, 2024 13:53
@fred3m fred3m merged commit 9621bc4 into main May 20, 2024
@fred3m fred3m deleted the tickets/DM-44319 branch May 20, 2024 16:09
fred3m added a commit that referenced this pull request May 21, 2024
This reverts commit 9621bc4, reversing
changes made to db0af17.
fred3m added a commit that referenced this pull request May 21, 2024
Revert "Merge pull request #316 from lsst/tickets/DM-44319"
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.

3 participants