diff --git a/doc/versionHistory.rst b/doc/versionHistory.rst index eb1be469e..bfc164420 100644 --- a/doc/versionHistory.rst +++ b/doc/versionHistory.rst @@ -6,6 +6,14 @@ Version History ################## +.. _lsst.ts.wep-1.5.2: + +------------- +1.5.2 +------------- + +* Fix the ``ZernikeMaskedFit()`` when passing masked data + .. _lsst.ts.wep-1.5.1: ------------- diff --git a/python/lsst/ts/wep/cwfs/DonutTemplateModel.py b/python/lsst/ts/wep/cwfs/DonutTemplateModel.py index 47e30e431..ea7ea066d 100644 --- a/python/lsst/ts/wep/cwfs/DonutTemplateModel.py +++ b/python/lsst/ts/wep/cwfs/DonutTemplateModel.py @@ -101,7 +101,7 @@ def makeTemplate( sensorXPixel = float(sensorXMicron) / pixelSizeInUm sensorYPixel = float(sensorYMicron) / pixelSizeInUm - # Multiply by pixelScale then divide by 3600 for arcsec -> deg conversion + # Multiply by pixelScale then divide by 3600 for arcsec->deg conversion sensorXDeg = sensorXPixel * pixelScale / 3600 sensorYDeg = sensorYPixel * pixelScale / 3600 fieldXY = [sensorXDeg, sensorYDeg] diff --git a/python/lsst/ts/wep/cwfs/Tool.py b/python/lsst/ts/wep/cwfs/Tool.py index 9ea61e8b0..ebe812ec5 100644 --- a/python/lsst/ts/wep/cwfs/Tool.py +++ b/python/lsst/ts/wep/cwfs/Tool.py @@ -210,7 +210,7 @@ def ZernikeAnnularFit(s, x, y, numTerms, e, nMax=28): h[:, ii] = ZernikeAnnularEval(z, xFinite, yFinite, e, nMax=nMax) # Solve the equation: H*Z = S => Z = H^(-1)S - z = np.linalg.lstsq(h, s, rcond=None)[0] + z = np.linalg.lstsq(h, sFinite, rcond=None)[0] return z diff --git a/tests/cwfs/test_tool.py b/tests/cwfs/test_tool.py index d3fb19405..0b9577b52 100644 --- a/tests/cwfs/test_tool.py +++ b/tests/cwfs/test_tool.py @@ -30,6 +30,7 @@ ZernikeAnnularGrad, ZernikeAnnularJacobian, ZernikeAnnularFit, + ZernikeMaskedFit, padArray, extractArray, ) @@ -219,6 +220,26 @@ def testZernikeAnnularFit(self): allOpdAns = np.loadtxt(ansOpdFilePath) self.assertLess(np.sum(np.abs(coef - allOpdAns[0, :])), 1e-10) + def testZernikeMaskFit(self): + e = 0.2 + nc = 6 + surface = ZernikeAnnularEval(self.zerCoef[0:nc], self.xx, self.yy, e) + + # mask data + cut = -0.9 + r = np.sqrt(self.xx**2 + self.yy**2) + idx = (r > 1) | (r < e) | (self.xx < cut) + + xx = self.xx[:].copy() + yy = self.yy[:].copy() + xx[idx] = np.nan + yy[idx] = np.nan + mask = ~np.isnan(xx) + + zr = ZernikeMaskedFit(surface, xx, yy, nc, mask, e) + + self.assertLess(np.sum(np.abs(zr - self.zerCoef[0:nc])**2), 1e-10) + def testPadArray(self): imgDim = 10