Skip to content

Commit

Permalink
Add transforms for closed loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkalmbach committed Oct 10, 2023
1 parent 9b16999 commit c996ee0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
13 changes: 7 additions & 6 deletions python/lsst/ts/wep/task/calcZernikesTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,24 @@ def estimateZernikes(self, donutStampsExtra, donutStampsIntra):
eulerZExtra = -detectorExtra.getOrientation().getYaw().asDegrees()
eulerZIntra = -detectorIntra.getOrientation().getYaw().asDegrees()

# NOTE: TS_WEP expects these images to be transposed
# TODO: Look into this
blendOffsetsExtra = self.calcBlendOffsets(donutExtra, eulerZExtra)
blendOffsetsIntra = self.calcBlendOffsets(donutIntra, eulerZIntra)

# Transform image and coordinates from DVCS
# (Data Visualization Coordinate System)
# to ZCS (Zemax Coordinate System).
wfEsti.setImg(
fieldXYExtra,
np.array([-fieldXYExtra[1], fieldXYExtra[0]]),
DefocalType.Extra,
filterLabel=getFilterTypeFromBandLabel(donutExtra.bandpass),
image=donutExtra.stamp_im.image.array,
image=np.fliplr(donutExtra.stamp_im.image.array.T),
blendOffsets=blendOffsetsExtra.tolist(),
)
wfEsti.setImg(
fieldXYIntra,
np.array([-fieldXYIntra[1], fieldXYIntra[0]]),
DefocalType.Intra,
filterLabel=getFilterTypeFromBandLabel(donutIntra.bandpass),
image=donutIntra.stamp_im.image.array,
image=np.fliplr(donutIntra.stamp_im.image.array.T),
blendOffsets=blendOffsetsIntra.tolist(),
)
wfEsti.reset()
Expand Down
29 changes: 14 additions & 15 deletions python/lsst/ts/wep/task/cutOutDonutsBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def cutOutStamps(self, exposure, donutCatalog, defocalType, cameraName):
)
xCornerList.append(xCorner)
yCornerList.append(yCorner)
finalCutout = exposure[finalBBox]
finalCutout = exposure[finalBBox].clone()

# Save MaskedImage to stamp
finalStamp = finalCutout.getMaskedImage()
Expand Down Expand Up @@ -487,17 +487,6 @@ def cutOutStamps(self, exposure, donutCatalog, defocalType, cameraName):
else:
blendCentroidPositions = np.array([["nan"], ["nan"]], dtype=float).T

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.
eulerZ = -detectorInfo.getOrientation().getYaw().asDegrees()

finalStamp.image.array = rotate(finalStamp.image.array, eulerZ)

donutStamp = DonutStamp(
stamp_im=finalStamp,
sky_position=lsst.geom.SpherePoint(
Expand Down Expand Up @@ -541,11 +530,21 @@ def cutOutStamps(self, exposure, donutCatalog, defocalType, cameraName):
shiftedMask -= 1
donutStamp.stamp_im.image.array *= shiftedMask

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.
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:
donutStamp.stamp_im.image.array = donutStamp.stamp_im.image.array.T
donutStamp.mask_comp.array = donutStamp.mask_comp.array.T
# if self.transposeImages:
# finalStamp.image.array = finalStamp.image.array.T

donutStamp.stamp_im.setMask(donutStamp.mask_comp)

finalStamps.append(donutStamp)
Expand Down

0 comments on commit c996ee0

Please sign in to comment.