Skip to content

Commit

Permalink
Merge pull request #66 from lsst-ts/origin/issue/65/fix_ZernikeAnnula…
Browse files Browse the repository at this point in the history
…rFit_for_masked_data

fixed ZernikeMaskedFit when passing masked data and included unit test
  • Loading branch information
connolly authored Feb 26, 2021
2 parents aea2584 + 34262f4 commit 3b29f3e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
8 changes: 8 additions & 0 deletions doc/versionHistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

-------------
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ts/wep/cwfs/DonutTemplateModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ts/wep/cwfs/Tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 21 additions & 0 deletions tests/cwfs/test_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
ZernikeAnnularGrad,
ZernikeAnnularJacobian,
ZernikeAnnularFit,
ZernikeMaskedFit,
padArray,
extractArray,
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3b29f3e

Please sign in to comment.