Skip to content

Commit

Permalink
Added tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcrenshaw committed Nov 8, 2024
1 parent 03fbb55 commit 38bebb7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions pipelines/production/comCamRapidAnalysisPipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ tasks:
config:
estimateZernikes.maxNollIndex: 22
estimateZernikes.convergeTol: 10.0e-9
estimateZernikes.requireConverge: True
estimateZernikes.saveHistory: False
estimateZernikes.maskKwargs: { "doMaskBlends": False }
donutStampSelector.maxSelect: 5
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/ts/wep/estimation/tie.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class TieAlgorithm(WfAlgorithm):
requireConverge : bool, optional
Whether to require that the TIE converges. If True, and the TIE
did not converge, the TIE returns NaNs.
(the default is True)
(the default is False)
"""

def __init__(
Expand All @@ -114,7 +114,7 @@ def __init__(
maskKwargs: Optional[dict] = None,
modelPupilKernelSize: float = 2,
binning: int = 1,
requireConverge: bool = True,
requireConverge: bool = False,
) -> None:
self.opticalModel = opticalModel
self.maxIter = maxIter
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ts/wep/task/estimateZernikesTieTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class EstimateZernikesTieConfig(EstimateZernikesBaseConfig):
)
requireConverge = pexConfig.Field(
dtype=bool,
default=True,
default=False,
doc="Whether to require that the TIE converges. "
+ "If True, and the TIE did not converge, the TIE returns NaNs. ",
)
Expand Down
23 changes: 23 additions & 0 deletions tests/task/test_calcZernikesTieTaskCwfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ def testValidateConfigs(self):

self.assertEqual(type(self.task.combineZernikes), CombineZernikesMeanTask)

self.config.estimateZernikes.binning = 2
self.assertEqual(self.task.estimateZernikes.wfAlgoConfig.binning, 2)

def testEstimateZernikes(self):
zernCoeff = self.task.estimateZernikes.run(
self.donutStampsExtra, self.donutStampsIntra
Expand Down Expand Up @@ -281,3 +284,23 @@ def testUnevenPairs(self):

# Now estimate Zernikes
self.task.run(stampsExtra, stampsIntra)

def testRequireConverge(self):
config = CalcZernikesTaskConfig()
config.estimateZernikes.requireConverge = True # Require to converge
config.estimateZernikes.convergeTol = 0 # But don't allow convergence
task = CalcZernikesTask(config=config, name="Test requireConverge")

# Estimate zernikes
donutStampDir = os.path.join(self.testDataDir, "donutImg", "donutStamps")
donutStampsExtra = DonutStamps.readFits(
os.path.join(donutStampDir, "R04_SW0_donutStamps.fits")
)
donutStampsIntra = DonutStamps.readFits(
os.path.join(donutStampDir, "R04_SW1_donutStamps.fits")
)
output = task.estimateZernikes.run(donutStampsExtra, donutStampsIntra)
zernikes = output.zernikes

# Everything should be NaN because we did not converge
self.assertTrue(np.isnan(zernikes).all())

0 comments on commit 38bebb7

Please sign in to comment.