From 28270285e480db06d151cc7babe7e432d298a31f Mon Sep 17 00:00:00 2001 From: Pierre-Francois Leget Date: Mon, 27 May 2024 22:05:16 -0700 Subject: [PATCH] write proto to setup mask for interpolated pixels --- python/lsst/meas/algorithms/gp_interpolation.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/lsst/meas/algorithms/gp_interpolation.py b/python/lsst/meas/algorithms/gp_interpolation.py index d6ea56791..89bcd690e 100644 --- a/python/lsst/meas/algorithms/gp_interpolation.py +++ b/python/lsst/meas/algorithms/gp_interpolation.py @@ -78,6 +78,13 @@ def jax_rbf_h(x1, x2, sigma, correlation_length): K = (sigma**2) * jnp.exp(-0.5 * l1 / (correlation_length**2)) return K +def updateMaskFromArray(mask, bad_pixel, interpBit): + x0 = mask.getX0() + y0 = mask.getY0() + for row in bad_pixel: + x = int(row[0] - x0) + y = int(row[1] - y0) + mask.array[x, y] |= interpBit class GaussianProcessJax: def __init__(self, std=1.0, correlation_length=1.0, white_noise=0.0, mean=0.0): @@ -239,6 +246,8 @@ def __init__( self.defects = defects self.correlation_length = fwhm + self.interpBit = self.maskedImage.mask.getPlaneBitMask("INTRP") + def interpolate_over_defects(self): """ Interpolates over defects using the spanset method. @@ -345,6 +354,7 @@ def interpolate_sub_masked_image(self, sub_masked_image): # update_value ctUtils.updateImageFromArray(sub_masked_image.image, bad_pixel) + updateMaskFromArray(sub_masked_image.mask, bad_pixel, self.interpBit) return sub_masked_image def interpolateOverDefectsGP(image, fwhm, badList, method="treegp", bin_spacing=15, threshold_subdivide=20000):