-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
tests/test_subtractTask.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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.", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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?
Exclude sources from being used for PSF matching if any of the 3x3 central pixels are masked.
fcd1c07
to
0b9d46f
Compare
This PR also makes a few other changes:
subtractImages
unit tests to configure the Task used in the tests in a common method.