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-46141: Use ScienceSourceSelector to select kernel candidates #340

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

isullivan
Copy link
Contributor

This PR also makes a few other changes:

  • Fixes a bug in the test code that generated heaps of warnings about missing coordinate error columns
  • Refactors the subtractImages unit tests to configure the Task used in the tests in a common method.
  • Uses the new source selector to apply additional constraints on the sources used to construct the PSF matching kernel
  • Extends the check of the template mask plane to the central 3x3 pixels, not just the center pixel

@mrawls mrawls self-requested a review September 12, 2024 20:42
Copy link
Contributor

@mrawls mrawls left a comment

Choose a reason for hiding this comment

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

Thanks for doing this, most of my comments are minor.

def _setup_subtraction(self, doSubtractBackground=False, **kwargs):
"""Setup and configure the image subtraction PipelineTask.

Parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing doSubtractBackground parameter in the docs.

Is this EVER set to True? Previously it was manually set to False in a handful of tests only, but now that it's the default, I'm not seeing any instances of True, which seems odd and implies we may be missing test coverage in that scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doSubtractBackground = True is set in test_background_subtraction, but that test has to set configs for subtasks which can't be handled by _setup_subtraction. I will remove the keyword since it isn't ever used.

@@ -1057,8 +1033,7 @@ def test_clear_template_mask(self):
templateBorderSize=20, doApplyCalibration=True,
xSize=xSize, ySize=ySize)
diffimEmptyMaskPlanes = ["DETECTED", "DETECTED_NEGATIVE"]
config = subtractImages.AlardLuptonPreconvolveSubtractTask.ConfigClass()
config.doSubtractBackground = False # Ensure that each each mask plane is set for some pixels
task = self._setup_subtraction() # Ensure that each each mask plane is set for some pixels
Copy link
Contributor

Choose a reason for hiding this comment

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

This in-line comment doesn't really make sense with the task instantiation now that doSubtractBackground defaults to false across the board

@@ -206,6 +210,7 @@ class AlardLuptonSubtractBaseConfig(lsst.pex.config.Config):
"base_PixelFlags_flag_saturated",
"base_PixelFlags_flag_bad",
),
deprecated="This field is no longer used and will be removed after v28.",
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use excludeMaskPlanes instead, right? Maybe mention this for clarity

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, you should now set the config for the sourceSelector subtask instead. Except we should not typically do that, and should use the defaults.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah OK, maybe say that here, then, in so many words, if feasible 😄

nInitialSelected = np.count_nonzero(selected)
selected *= self._checkMask(mask, sources, self.config.excludeMaskPlanes)
nSelected = np.count_nonzero(selected)
self.log.info("%i candidate sources rejected from template mask", nInitialSelected - nSelected)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of "rejected from template mask", perhaps "rejected due to regions in template with one or more excludeMaskPlanes" ?

selected *= self._checkMask(mask, sources, self.config.excludeMaskPlanes)
nSelected = np.count_nonzero(selected)
self.log.info("%i candidate sources rejected from template mask", nInitialSelected - nSelected)
selectSources = sources[selected].copy(deep=True)
if (len(selectSources) > self.config.maxKernelSources) & (self.config.maxKernelSources > 0):
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a one-line comment along the lines of # Trim selectSources so it doesn't exceed maxKernalSources. I presume selectSources is not ordered in any meaningful way? So we won't, for example, throw out all the sources in one region of the image, or those with certain S/N or brightness properties?

@isullivan isullivan merged commit 91f4dbe into main Sep 18, 2024
2 checks passed
@isullivan isullivan deleted the tickets/DM-46141 branch September 18, 2024 23:43
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.

2 participants