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-24371 Implement fixed correction fixed PSF support decorrelation afterburner #154

Merged
merged 1 commit into from Apr 30, 2020

Conversation

kgabor
Copy link
Member

@kgabor kgabor commented Apr 13, 2020

No description provided.

Copy link
Contributor

@isullivan isullivan left a comment

Choose a reason for hiding this comment

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

Looks good. Please address the individual comments below, but note that a few came up multiple times:

  • You should make use of exposure attributes instead of get in many places. E.g. replace instances of exposure.getMaskedImage().getVariance().getArray() with exposure.variance.array.
  • When you return a Struct with only one element, you should think about whether you really want the Struct at all.
  • Watch out for reusing the same variable for different purposes within a method, that could easily lead to bugs or at least confusion later on.

result : `Struct`
a `lsst.pipe.base.Struct` containing:

result : `lsst.pipe.base.Struct`
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're now only returning correctedExposure, do you still need to wrap it in a Struct?

Copy link
Member Author

@kgabor kgabor Apr 29, 2020

Choose a reason for hiding this comment

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

This is a result of dropping the correction kernel from the return. I am not 100% sure that we don't want to return any additional information; I'll postpone the removal of the Struct for the spatially varying correction implementation DM-23857. Add TODO comment to the task description and to the return statement.

Considerations: It'd be logical to return something about the correction, but...

  • returning the Fourier space correction needs the freqSpaceShape and may not suit for any outside operation.
  • Returning the image space correction (full image size) needs one additional, otherwise unnecessary, IFT. Also where the origin is placed would need detailed description or additional, otherwise unnecessary, copying (re-centering) of the array.
  • If a matchingKernel size cropped version is returned then we throw away the main lesson from this whole change i.e. that the correction can be larger than the original matching kernel in general so should not be used.

python/lsst/ip/diffim/imageDecorrelation.py Outdated Show resolved Hide resolved
python/lsst/ip/diffim/imageDecorrelation.py Show resolved Hide resolved
python/lsst/ip/diffim/imageDecorrelation.py Show resolved Hide resolved
return pipeBase.Struct(correctedExposure=outExposure, )

tOverSVar = tvar/svar
if tOverSVar > 1e8:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment describing why 1e8 was chosen. Also, since this is only a warning, you might want to consider lowering the threshold. Finally, I'm a bit surprised by this check: isn't the template variance usually smaller than the science image, rather than the other way around?

Copy link
Member Author

@kgabor kgabor Apr 28, 2020

Choose a reason for hiding this comment

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

As the matching kernel high frequency components go to zero, the correction factor converges to sqrt(tvar/svar) i.e. this is a warning when high frequency pixels of the difference image is multiplied by more than 4 orders of magnitude as correction. Yes, in the regular case, the template variance is the smaller one and this is no concern; tvar>svar can happen if we convolve the science image thus the arguments are swapped for this task.

I don't have a really good justification for the value itself at the moment, just wanted an indicator to watch for diverging solutions. We won't coadd ~1e8 images, so I don't expect that any coadd variance will be this small (i.e. this large when swapped in science exposure convolution mode) but this scaling is still acceptable at double precision.

python/lsst/ip/diffim/imageDecorrelation.py Outdated Show resolved Hide resolved
python/lsst/ip/diffim/imageDecorrelation.py Outdated Show resolved Hide resolved
python/lsst/ip/diffim/imageDecorrelation.py Show resolved Hide resolved
tests/test_imageDecorrelation.py Show resolved Hide resolved
tests/test_imageDecorrelation.py Outdated Show resolved Hide resolved
@kgabor kgabor force-pushed the tickets/DM-24371 branch 2 times, most recently from 5288283 to f8ce90b Compare April 30, 2020 08:02
 * Add padding methods for DFT.
 * Update docstrings, fix shape bug.
 * Disable ImageMapReduce testing.
 * Add direct correlation correction unit test.
   * Add sourceless test image generation modification to `makeFakeImages`.
   * Add direct correlation estimation function `estimatePixelCorrelation`.
   * Add new test case `testNoiseDiffimCorrection`.
 * Update docstrings, improve code readability.
@kgabor kgabor merged commit b85e94b into master Apr 30, 2020
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