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-30465 Implement decorrelation afterburner for maximum likelihood images #197
Conversation
kgabor
commented
Aug 13, 2021
- Add preConvMode argument to task run.
- Add likelihood image correction for the image.
- Add variance plane estimation for the likelihood image.
- Use new variance plane estimation for the difference image.
- Add full variance plane propagation.
- Add support for Inf/NaN values in variance plane handling.
- Add preConvKernel, preConvMode consistency check at run entry point.
- Default preconvolution kernel to getLocalKernel for average psf position.
- Add unit test of new task config option.
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.
I left comments on a few typos and missing documentation. Otherwise, the main change is that I think we always want to do the full variance plane calculation, rather than the estimation. Aside from speed concerns, is there a case when the estimate would be more robust or otherwise preferable?
completeVarPlanePropagation = pexConfig.Field( | ||
dtype=bool, | ||
default=False, | ||
doc="Compute the full effect of the decorrelated matching kernel on the variance plane." | ||
" Otherwise use a model weighed sum of the input variances." | ||
) |
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.
Is there ever a case when we would not want to do the full computation? I'm thinking this should at least default to True, if not be required (instead of being a config option).
if not None, then the `scienceExposure` was pre-convolved with this kernel. | ||
Allowed only if ``templateMatched==True``. | ||
If not `None`, then the `scienceExposure` was pre-convolved with (the reflection of) | ||
this kernel. Must be normed to sum 1. |
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.
"normalized" instead of "normed"
|
||
Parameters | ||
---------- | ||
scienceExposure : `lsst.afw.image.Exposure` | ||
The original science exposure (before `preConvKernel` applied). | ||
The original science exposure (before pre-convolution, if ``preConvMode==True``). | ||
templateExposure : `lsst.afw.image.Exposure` | ||
The original template exposure warped into the science exposure dimensions. | ||
subtractedExposure : `lsst.afw.iamge.Exposure` |
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.
Typo: "iamge"
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.
Also, include a description of this parameter when preConvMode=True
spatially fixed PSF. It is calculated as the center of image PSF corrected by the center of | ||
image matching kernel. | ||
If ``preConvMode==True``, ``subtractedExposure`` is assumed to be a | ||
score image and a the noise correction for likelihood images |
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.
Typo: "and a the..."
If ``preConvMode==True``, ``subtractedExposure`` is assumed to be a | ||
score image and a the noise correction for likelihood images | ||
is applied. The resulting image is an optimal detection likelihood image | ||
when the templateExposure has noise. (See DMTN-179) If ``preConvKernel`` is |
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.
Add double backticks around templateExposure
when the templateExposure has noise. (See DMTN-179) If ``preConvKernel`` is | ||
not specified, the PSF of ``scienceExposure`` is assumed as pre-convolution kernel. | ||
|
||
The `subtractedExposure` is NOT updated. The returned `correctedExposure` |
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.
Use double backticks here as well
if preConvKernel is None: | ||
preConvKernel = scienceExposure.getPsf().getLocalKernel() # at average position | ||
preConvImg = afwImage.ImageD(preConvKernel.getDimensions()) | ||
preConvKernel.computeImage(preConvImg, True) |
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.
Please add a code comment above this line to briefly describe the operation.
# Allow for numpy type casting | ||
varImg[...] = preSum*preSum*exposure.variance.array + kSumSq*matchedExposure.variance.array | ||
if self.config.completeVarPlanePropagation: | ||
self.log.debug("Complete variance plane calculation") |
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.
I think these log messages need to be raised to info
, and re-worded to be more meaningful in the logs.
exposure.variance.array, matchedExposure.variance.array, | ||
expVar, matchedVar, corr.cnft, corr.crft) | ||
else: | ||
self.log.debug("Estimation of variance plane") |
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.
Raise to info
@@ -682,7 +839,7 @@ def computeVarianceMean(self, exposure): | |||
return var | |||
|
|||
def run(self, scienceExposure, templateExposure, subtractedExposure, psfMatchingKernel, | |||
spatiallyVarying=True, preConvKernel=None, templateMatched=True): | |||
spatiallyVarying=True, preConvKernel=None, templateMatched=True, preConvMode=False): |
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.
Add the definition of preConvMode
to the docstring
* Add preConvMode argument to task run. * Add likelihood image correction for the image. * Add variance plane estimation for the likelihood image. * Use new variance plane estimation for the difference image. * Add full variance plane propagation. * Add support for Inf/NaN values in variance plane handling. * Add preConvKernel, preConvMode consistency check at run entry point. * Default preconvolution kernel to getLocalKernel for average psf position. * Add unit test of new task config option.
6a30304
to
c5ab107
Compare