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-38555: Implement BFE code improvements suggested by Lance Miller and Euclid colleagues #260

Merged
merged 8 commits into from May 9, 2023

Conversation

plazas
Copy link
Contributor

@plazas plazas commented May 4, 2023

No description provided.

@plazas plazas requested a review from czwa May 4, 2023 17:46
Copy link
Contributor

@czwa czwa left a comment

Choose a reason for hiding this comment

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

The majority of comments are about docstrings, and although they're not critical, it'd be good to get them right from the start.
One suggestion of variable renaming that confused me, but I think the algorithm is fine. After discussions earlier in the day, I think all of the indexing here is correct and consistent, with the convention that the input kernel here is already in the (y, x) orientation it should be for direct use in an afwImage.ExposureF.image.array.

@@ -85,6 +85,12 @@ def test_BrighterFatterInterface(self):
isrFunctions.brighterFatterCorrection(exp, kernelToUse, 5, 100, False)
self.assertImagesEqual(ref_image, image)

isrFunctions.brighterFatterCorrection(exp, kernelToUse, 5, 100, False)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a copy/paste went wrong and put an additional copy of this test here.

def fluxConservingBrighterFatterCorrection(exposure, kernel, maxIter, threshold, applyGain,
gains=None, correctionMode=True):
"""Apply brighter fatter correction in place for the image.
Modified version conserves flux, with improved correction of PSF core.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this docstring needs to be reworded a bit. I'd move this line and the next to a new paragraph, switching "modified" for "this", such that

This version presents a modified version of the algorithm found in ``lsst.ip.isr.isrFunctions.brighterFatterCorrection`` which conserves the image flux, resulting in improved correction of the cores of stars.  The convolution has also been modified to mitigate edge effects.

This correction takes a kernel that has been derived from flat
field images to redistribute the charge. The gradient of the
kernel is the deflection field due to the accumulated charge.
Given the original image I(x) and the kernel K(x) we can compute
Copy link
Contributor

Choose a reason for hiding this comment

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

The original blank lines are required for this to format correctly in the auto-generated documentation. New lines before "Given", "Ic(x)", "Improved", "Because", and "Edges."

a physical model for the edge, but avoids discontinuity in the correction.

Author of modified version: Lance.Miller@physics.ox.ac.uk
(see DM-33555).
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo? DM-38555 instead?

Author of modified version: Lance.Miller@physics.ox.ac.uk
(see DM-33555).
"""

Copy link
Contributor

Choose a reason for hiding this comment

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

But this newline isn't allowed, and needs to be removed.

# allows us to pad the image with zeros and avoid wrap-around effects
# (although still not handling the image edges with a physical model)
# This wouldn't be great if there were a strong image gradient.
imydim, imxdim = tempImage.array.shape
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these be renamed to imYdim and imXdim? I'm fine with any other name, but without some separation, I read the first one as i-my-dim, which confused me.

outArray = outImage.getArray()

# trim convolution output back to original shape
outArray = outArray[:imydim, :imxdim]
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to match above as well (I think this is the only place they're used).

@plazas plazas merged commit 07e61e7 into main May 9, 2023
1 check passed
@plazas plazas deleted the tickets/DM-38555 branch May 9, 2023 16:26
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