Skip to content

Commit

Permalink
Streamlining zk4up and caches in instrument.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcrenshaw committed Jan 18, 2024
1 parent 07323d0 commit 3cdf25b
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions python/lsst/ts/wep/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ def _getIntrinsicZernikesCached(
yAngle: float,
band: Union[BandLabel, str],
jmax: int,
return4Up: bool,
) -> np.ndarray:
"""Cached interior function for the getIntrinsicZernikes method.
Expand All @@ -533,8 +532,6 @@ def _getIntrinsicZernikesCached(
"{band}".
jmax : int, optional
The maximum Noll index of the intrinsic Zernikes.
return4Up : bool
Whether to only return the coefficients for Noll indices >= 4.
Returns
-------
Expand Down Expand Up @@ -563,11 +560,7 @@ def _getIntrinsicZernikesCached(
# Multiply by wavelength to get Zernikes in meters
zkIntrinsic *= self.wavelength[band]

if return4Up:
# Keep only Noll indices >= 4
zkIntrinsic = zkIntrinsic[4:]

return zkIntrinsic.copy()
return zkIntrinsic

def getIntrinsicZernikes(
self,
Expand Down Expand Up @@ -601,9 +594,13 @@ def getIntrinsicZernikes(
np.ndarray
The Zernike coefficients in meters
"""
return self._getIntrinsicZernikesCached(
xAngle, yAngle, band, jmax, return4Up
).copy()
zk = self._getIntrinsicZernikesCached(xAngle, yAngle, band, jmax).copy()

if return4Up:
# Keep only Noll indices >= 4
zk = zk[4:]

return zk

@lru_cache(100)
def _getOffAxisCoeffCached(
Expand All @@ -613,7 +610,6 @@ def _getOffAxisCoeffCached(
defocalType: DefocalType,
band: Union[BandLabel, str],
jmax: int,
return4Up: bool,
) -> np.ndarray:
"""Cached interior function for the getOffAxisCoeff method.
Expand All @@ -634,8 +630,6 @@ def _getOffAxisCoeffCached(
contains "{band}".
jmax : int
The maximum Noll index of the off-axis model Zernikes.
return4Up : bool
Whether to only return the coefficients for Noll indices >= 4.
Returns
-------
Expand Down Expand Up @@ -673,10 +667,6 @@ def _getOffAxisCoeffCached(
# Multiply by wavelength to get Zernikes in meters
zkIntrinsic *= self.wavelength[band]

if return4Up:
# Keep only Noll indices >= 4
zkIntrinsic = zkIntrinsic[4:]

return zkIntrinsic

def getOffAxisCoeff(
Expand Down Expand Up @@ -715,15 +705,20 @@ def getOffAxisCoeff(
np.ndarray
The Zernike coefficients in meters, for Noll indices >= 4
"""
return self._getOffAxisCoeffCached(
zk = self._getOffAxisCoeffCached(
xAngle,
yAngle,
defocalType,
band,
jmax,
return4Up,
).copy()

if return4Up:
# Keep only Noll indices >= 4
zk = zk[4:]

return zk

@property
def maskParams(self) -> dict:
"""The mask parameter dictionary."""
Expand Down

0 comments on commit 3cdf25b

Please sign in to comment.