From cd544902b24eeb62d98bc3f5bda807546787213d Mon Sep 17 00:00:00 2001 From: Bryce Kalmbach Date: Mon, 9 Oct 2023 16:31:21 -0700 Subject: [PATCH] Update test data and tests with rotated DonutStamps. Quick fix to get WEP pipeline running on macOS. Update docs. --- doc/versionHistory.rst | 10 ++- python/lsst/ts/wep/task/cutOutDonutsBase.py | 21 ++--- python/lsst/ts/wep/task/donutStamp.py | 8 +- tests/task/test_calcZernikesTaskCwfs.py | 85 +++++++++---------- tests/task/test_cutOutDonutsBase.py | 4 +- .../donutStamps/R04_SW0_donutStamps.fits | 4 +- .../donutStamps/R04_SW1_donutStamps.fits | 4 +- .../donutStamps/R40_SW0_donutStamps.fits | 4 +- .../donutStamps/R40_SW1_donutStamps.fits | 4 +- 9 files changed, 72 insertions(+), 72 deletions(-) diff --git a/doc/versionHistory.rst b/doc/versionHistory.rst index d6d3650b6..9267ce193 100644 --- a/doc/versionHistory.rst +++ b/doc/versionHistory.rst @@ -6,6 +6,14 @@ Version History ################## +.. _lsst.ts.wep-7.1.0: + +------------- +7.1.0 +------------- + +* Save all DonutStamps with images aligned with focal plane science sensors. + .. _lsst.ts.wep-7.0.0: ------------- @@ -20,7 +28,7 @@ Version History 6.4.12 ------------- -* Update ts_pre_commit_config with ruff. +* Update ts_pre_commit_config with ruff. .. _lsst.ts.wep-6.4.11: diff --git a/python/lsst/ts/wep/task/cutOutDonutsBase.py b/python/lsst/ts/wep/task/cutOutDonutsBase.py index 245e2171e..f50c25b0c 100644 --- a/python/lsst/ts/wep/task/cutOutDonutsBase.py +++ b/python/lsst/ts/wep/task/cutOutDonutsBase.py @@ -28,7 +28,6 @@ import lsst.afw.cameraGeom import lsst.pex.config as pexConfig import lsst.pipe.base as pipeBase -import lsst.obs.lsst as obs_lsst import numpy as np from lsst.daf.base import PropertyList from lsst.fgcmcal.utilities import lookupStaticCalibrations @@ -40,10 +39,10 @@ from lsst.ts.wep.utils import ( DonutTemplateType, createInstDictFromConfig, - getCamTypeFromButlerName, getCameraFromButlerName, + getCamTypeFromButlerName, ) -from scipy.ndimage import binary_dilation, shift, rotate +from scipy.ndimage import binary_dilation, rotate, shift from scipy.signal import correlate @@ -156,6 +155,7 @@ class CutOutDonutsBaseTaskConfig( optional=True, ) + class CutOutDonutsBaseTask(pipeBase.PipelineTask): """ Base class for CutOutDonuts tasks. @@ -533,17 +533,12 @@ def cutOutStamps(self, exposure, donutCatalog, defocalType, cameraName): camera = getCameraFromButlerName(cameraName) detectorInfo = camera.get(detectorName) - # Rotate any sensors that are not lined up with the focal plane. - # Mostly just for the corner wavefront sensors. The negative sign - # creates the correct rotation based upon closed loop tests - # with R04 and R40 corner sensors. + # Rotate sensors to line up with the science sensors in the + # focal plane. eulerZ = -detectorInfo.getOrientation().getYaw().asDegrees() - donutStamp.stamp_im.image.array = rotate(donutStamp.stamp_im.image.array, eulerZ) - - # NOTE: TS_WEP expects these images to be transposed - # TODO: Look into this - # if self.transposeImages: - # finalStamp.image.array = finalStamp.image.array.T + donutStamp.stamp_im.image.array = rotate( + donutStamp.stamp_im.image.array, eulerZ + ) donutStamp.stamp_im.setMask(donutStamp.mask_comp) diff --git a/python/lsst/ts/wep/task/donutStamp.py b/python/lsst/ts/wep/task/donutStamp.py index 18e7aaa28..3b91603cf 100644 --- a/python/lsst/ts/wep/task/donutStamp.py +++ b/python/lsst/ts/wep/task/donutStamp.py @@ -27,12 +27,16 @@ import lsst.afw.image as afwImage import lsst.afw.table as afwTable import lsst.geom -import lsst.obs.lsst as obs_lsst import numpy as np from lsst.afw.cameraGeom import FIELD_ANGLE, PIXELS from lsst.meas.algorithms.stamps import AbstractStamp from lsst.ts.wep.cwfs.compensableImage import CompensableImage -from lsst.ts.wep.utils import DefocalType, FilterType, getFilterTypeFromBandLabel, getCameraFromButlerName +from lsst.ts.wep.utils import ( + DefocalType, + FilterType, + getCameraFromButlerName, + getFilterTypeFromBandLabel, +) @dataclass diff --git a/tests/task/test_calcZernikesTaskCwfs.py b/tests/task/test_calcZernikesTaskCwfs.py index e049a8d02..b12105939 100644 --- a/tests/task/test_calcZernikesTaskCwfs.py +++ b/tests/task/test_calcZernikesTaskCwfs.py @@ -23,7 +23,6 @@ import lsst.utils.tests import numpy as np -from scipy.ndimage import rotate from lsst.daf import butler as dafButler from lsst.ts.wep.task.calcZernikesTask import CalcZernikesTask, CalcZernikesTaskConfig from lsst.ts.wep.task.combineZernikesMeanTask import CombineZernikesMeanTask @@ -150,38 +149,34 @@ def testEstimateCornerZernikes(self): donutStampsExtra = DonutStamps.readFits( os.path.join(donutStampDir, "R04_SW0_donutStamps.fits") ) - for stamp in donutStampsExtra: - stamp.stamp_im.image.array = rotate(stamp.stamp_im.image.array, 90).T donutStampsIntra = DonutStamps.readFits( os.path.join(donutStampDir, "R04_SW1_donutStamps.fits") ) - for stamp in donutStampsIntra: - stamp.stamp_im.image.array = rotate(stamp.stamp_im.image.array, -90).T zernCoeffAllR04 = self.task.estimateZernikes(donutStampsExtra, donutStampsIntra) zernCoeffAvgR04 = self.task.combineZernikes.run( zernCoeffAllR04 ).combinedZernikes trueZernCoeffR04 = np.array( [ - -0.71201408, - 1.12248525, - 0.77794367, - -0.04085477, - -0.05272933, - 0.16054277, - 0.081405, - -0.04382461, - -0.04830676, - -0.06218882, - 0.10246469, - 0.0197683, - 0.007953, - 0.00668697, - -0.03570788, - -0.03020376, - 0.0039522, - 0.04793133, - -0.00804605, + -0.35353452, + -0.07365128, + 0.62222451, + -0.06206281, + -0.09065757, + 0.21722746, + -0.20491936, + 0.00849322, + -0.01150489, + 0.02599147, + -0.00150702, + -0.14100845, + 0.02294787, + 0.02284791, + 0.02116483, + -0.02537743, + 0.01866772, + 0.01653037, + -0.00552862, ] ) # Make sure the total rms error is less than 0.35 microns off @@ -194,38 +189,34 @@ def testEstimateCornerZernikes(self): donutStampsExtra = DonutStamps.readFits( os.path.join(donutStampDir, "R40_SW0_donutStamps.fits") ) - for stamp in donutStampsExtra: - stamp.stamp_im.image.array = rotate(stamp.stamp_im.image.array, -90).T donutStampsIntra = DonutStamps.readFits( os.path.join(donutStampDir, "R40_SW1_donutStamps.fits") ) - for stamp in donutStampsIntra: - stamp.stamp_im.image.array = rotate(stamp.stamp_im.image.array, 90).T zernCoeffAllR40 = self.task.estimateZernikes(donutStampsExtra, donutStampsIntra) zernCoeffAvgR40 = self.task.combineZernikes.run( zernCoeffAllR40 ).combinedZernikes trueZernCoeffR40 = np.array( [ - -0.6535694, - 1.00838499, - 0.55968811, - -0.08899825, - 0.00173607, - 0.04133107, - -0.10913093, - -0.04363778, - -0.03149601, - -0.04941225, - 0.09980538, - 0.03704486, - -0.00210766, - 0.01737253, - 0.01727539, - 0.01278011, - 0.01212878, - 0.03876888, - -0.00559142, + -3.83610201e-01, + -2.06528254e-01, + 5.42893431e-01, + 7.74255848e-02, + 3.40529812e-02, + 5.45565149e-02, + 8.65849308e-02, + 1.75029212e-02, + -1.40149246e-04, + 4.11223127e-02, + -2.42644902e-03, + -1.52392233e-01, + -1.24547354e-02, + -2.33075716e-02, + 7.35477674e-04, + 1.93518814e-02, + -3.65768735e-03, + 4.12718699e-02, + -6.93386734e-03, ] ) # Make sure the total rms error is less than 0.35 microns off diff --git a/tests/task/test_cutOutDonutsBase.py b/tests/task/test_cutOutDonutsBase.py index 22f618a40..47ca6592a 100644 --- a/tests/task/test_cutOutDonutsBase.py +++ b/tests/task/test_cutOutDonutsBase.py @@ -265,7 +265,9 @@ def testCutOutStamps(self): lsst.geom.Extent2I(160), ) expCutOut = exposure[stampBBox].image.array - np.testing.assert_array_equal(donutStamps[0].stamp_im.image.array, expCutOut) + np.testing.assert_array_almost_equal( + donutStamps[0].stamp_im.image.array, expCutOut + ) def testCutOutStampsBlended(self): exposure = self.butler.get( diff --git a/tests/testData/donutImg/donutStamps/R04_SW0_donutStamps.fits b/tests/testData/donutImg/donutStamps/R04_SW0_donutStamps.fits index 9f51e7773..7d371f5ed 100644 --- a/tests/testData/donutImg/donutStamps/R04_SW0_donutStamps.fits +++ b/tests/testData/donutImg/donutStamps/R04_SW0_donutStamps.fits @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fcb59bb1334703b9c7d05ef79db054aa111b71372db8c5f02c2b1965507ff17e -size 645120 +oid sha256:274c27cd094553f00c504776af62155baeaf0c82ba8829bb73d32b1db173246d +size 322560 diff --git a/tests/testData/donutImg/donutStamps/R04_SW1_donutStamps.fits b/tests/testData/donutImg/donutStamps/R04_SW1_donutStamps.fits index 97b8d3ed9..15bcaef70 100644 --- a/tests/testData/donutImg/donutStamps/R04_SW1_donutStamps.fits +++ b/tests/testData/donutImg/donutStamps/R04_SW1_donutStamps.fits @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b57c394ff30fac1341ba9d61e03ce05f859a5d4854c9d7656a6700ba353321fb -size 645120 +oid sha256:891dd7d45a1459f7f7dbd9dac2714c7826744a993ac83bc03085c450471683c3 +size 322560 diff --git a/tests/testData/donutImg/donutStamps/R40_SW0_donutStamps.fits b/tests/testData/donutImg/donutStamps/R40_SW0_donutStamps.fits index ae04112a0..124ca4fa0 100644 --- a/tests/testData/donutImg/donutStamps/R40_SW0_donutStamps.fits +++ b/tests/testData/donutImg/donutStamps/R40_SW0_donutStamps.fits @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bab2a00c62ccbad2065ab6552c18d324eefa1c70cd402c8d66af7b95041462bf -size 645120 +oid sha256:36ae72dc413640c744cbb0a9eeb72b2cdfb7b781bd7acf0bf8f2fc787e3d5392 +size 322560 diff --git a/tests/testData/donutImg/donutStamps/R40_SW1_donutStamps.fits b/tests/testData/donutImg/donutStamps/R40_SW1_donutStamps.fits index 228181369..cc2d40b21 100644 --- a/tests/testData/donutImg/donutStamps/R40_SW1_donutStamps.fits +++ b/tests/testData/donutImg/donutStamps/R40_SW1_donutStamps.fits @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3cb6413c2005cdfe4a5371f4cb455aff912a0669b55091dee8d98105759412ca -size 645120 +oid sha256:cada467fc3fc770b88517690410d5fcea095f140fb8eac9dc737500ef4585c5e +size 322560