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-35175: Fix the variance plane calculation when the science image is convolved #222

Merged
merged 2 commits into from Jun 25, 2022

Conversation

isullivan
Copy link
Contributor

No description provided.

Copy link
Contributor

@kherner kherner left a comment

Choose a reason for hiding this comment

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

Looks OK; just a couple of minor comments/questions.


# Verify that the variance plane of the difference image is correct
# when the template and science variance planes are incorrect
science.variance.array[...] = scienceVarianceOrig/scaleFactor
# science.variance.array[...] = scienceVarianceOrig/scaleFactor
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking this is intentionally commented out.

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 was able to fix the test, so that this commented-out code could be put back in.

@@ -326,22 +345,29 @@ def runConvolveScience(self, template, science, sources):
# We must invert the background model if the matching kernel is solved for the science image.
kernelResult.backgroundModel.setParameters([-p for p in modelParams])

kernelImage = lsst.afw.image.ImageD(kernelResult.psfMatchingKernel.getDimensions())
norm = kernelResult.psfMatchingKernel.computeImage(kernelImage, doNormalize=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason one might want to allow doNormalize to be configurable here, as opposed to hard-coded false? I think not but doesn't hurt to think about it a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's actually important that it be hard-coded as False here, so that we get the flux scale right.

Set convolutionControl to copy edge pixels instead of producing NaNs

Increase accuracy of model variance plane for tests

Add test coverage of variance plane when science image is convolved

Put normalization factor on its own line

Set the photometric scale and photoCalib when convolving the science image.

Return the matchedScience image.

Add a warning when running in compatibility mode

Scale the science and template variance first instead of the diffim later.

This makes the ratio between the science and template variances correct when the images are subtracted.

SubtractTask tests must assume the inputs can be modified.

This is because ScaleVariance now operates on the science and template images.

Use afw.math statistics to compute image and variance means

Simplify import

Add test of ScaleVariance metadata

fix flake8 errors

Clean up scaleVariance unit test from review
@isullivan isullivan merged commit 7a1e1b3 into main Jun 25, 2022
@isullivan isullivan deleted the tickets/DM-35175 branch June 25, 2022 06:36
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.

None yet

2 participants