Skip to content

Commit

Permalink
switch name
Browse files Browse the repository at this point in the history
  • Loading branch information
PFLeget committed Sep 18, 2024
1 parent f17b65a commit 0cf369b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions python/lsst/meas/algorithms/gp_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ def run(self):
xmin, xmax = max([global_xmin, bbox.minX]), min(global_xmax, bbox.maxX)
ymin, ymax = max([global_ymin, bbox.minY]), min(global_ymax, bbox.maxY)
localBox = Box2I(Point2I(xmin, ymin), Extent2I(xmax - xmin, ymax - ymin))
sub_masked_image = self.masked_image[localBox]
masked_sub_image = self.masked_image[localBox]

sub_masked_image = self.interpolate_sub_masked_image(sub_masked_image)
self.masked_image[localBox] = sub_masked_image
masked_sub_image = self.interpolate_masked_sub_image(masked_sub_image)
self.masked_image[localBox] = masked_sub_image

def _good_pixel_binning(self, pixels):
"""
Expand Down Expand Up @@ -379,13 +379,13 @@ def _good_pixel_binning(self, pixels):
[binning.coords0[:, 0], binning.coords0[:, 1], binning.params0]
).T

def interpolate_sub_masked_image(self, sub_masked_image):
def interpolate_masked_sub_image(self, masked_sub_image):
"""
Interpolate the masked sub-image.
Parameters:
-----------
sub_masked_image : `lsst.afw.image.MaskedImage`
masked_sub_image : `lsst.afw.image.MaskedImage`
The sub-masked image to be interpolated.
Returns:
Expand All @@ -398,16 +398,16 @@ def interpolate_sub_masked_image(self, sub_masked_image):
self.correlation_length * self.correlation_length_cut
) # need integer as input.
bad_pixel, good_pixel = ctUtils.findGoodPixelsAroundBadPixels(
sub_masked_image, self.defects, buffer=cut
masked_sub_image, self.defects, buffer=cut
)
# Do nothing if bad pixel is None.
if bad_pixel.size == 0 or good_pixel.size == 0:
self.log.info("No bad or good pixels found. No interpolation performed.")
return sub_masked_image
return masked_sub_image
# Do GP interpolation if bad pixel found.
else:
# gp interpolation
sub_image_array = sub_masked_image.getVariance().array
sub_image_array = masked_sub_image.getVariance().array
white_noise = np.sqrt(
np.mean(sub_image_array[np.isfinite(sub_image_array)])
)
Expand All @@ -419,7 +419,7 @@ def interpolate_sub_masked_image(self, sub_masked_image):
self.log.info(
"No bad or good pixels found. No interpolation performed."
)
return sub_masked_image
return masked_sub_image
# kernel amplitude might be better described by maximum value of good pixel given
# the data and not really a random gaussian field.
kernel_amplitude = np.max(good_pixel[:, 2:])
Expand Down Expand Up @@ -453,6 +453,6 @@ def interpolate_sub_masked_image(self, sub_masked_image):
)

# Update values
ctUtils.updateImageFromArray(sub_masked_image.image, bad_pixel)
updateMaskFromArray(sub_masked_image.mask, bad_pixel, self.interpBit)
return sub_masked_image
ctUtils.updateImageFromArray(masked_sub_image.image, bad_pixel)
updateMaskFromArray(masked_sub_image.mask, bad_pixel, self.interpBit)
return masked_sub_image

0 comments on commit 0cf369b

Please sign in to comment.