From b33bb7ac9051de28134b3097a4097abebe544a40 Mon Sep 17 00:00:00 2001 From: Andrew Connolly Date: Tue, 23 Feb 2021 10:03:27 -0800 Subject: [PATCH 1/3] fixed ZernikeMaskedFit when passing masked data and included unit test --- python/lsst/ts/wep/cwfs/DonutTemplateModel.py | 2 +- python/lsst/ts/wep/cwfs/Tool.py | 2 +- tests/cwfs/test_tool.py | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/python/lsst/ts/wep/cwfs/DonutTemplateModel.py b/python/lsst/ts/wep/cwfs/DonutTemplateModel.py index 47e30e43..ea7ea066 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 9ea61e8b..ebe812ec 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 d3fb1940..0b9577b5 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 From 1a2e87c2f6e6d39576b4f6dacf23845d07e57c18 Mon Sep 17 00:00:00 2001 From: Andrew Connolly Date: Thu, 25 Feb 2021 17:53:05 -0800 Subject: [PATCH 2/3] updated versionHistory.rst for new release --- doc/versionHistory.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/versionHistory.rst b/doc/versionHistory.rst index eb1be469..cbe9f221 100644 --- a/doc/versionHistory.rst +++ b/doc/versionHistory.rst @@ -6,6 +6,14 @@ Version History ################## +.. _lsst.ts.wep-1.5.2: + +------------- +1.5.1 +------------- + +* Fix the ``ZernikeMaskedFit()`` when passing masked data + .. _lsst.ts.wep-1.5.1: ------------- From 34262f4c1991876b0c24f9f4dcb06b67143d6373 Mon Sep 17 00:00:00 2001 From: Andrew Connolly Date: Thu, 25 Feb 2021 17:55:12 -0800 Subject: [PATCH 3/3] typo in updated versionHistory.rst --- doc/versionHistory.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/versionHistory.rst b/doc/versionHistory.rst index cbe9f221..bfc16442 100644 --- a/doc/versionHistory.rst +++ b/doc/versionHistory.rst @@ -9,7 +9,7 @@ Version History .. _lsst.ts.wep-1.5.2: ------------- -1.5.1 +1.5.2 ------------- * Fix the ``ZernikeMaskedFit()`` when passing masked data