Skip to content

Commit

Permalink
Updated offset names
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcrenshaw committed Jun 10, 2024
1 parent 755c29c commit 92e2e63
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
6 changes: 3 additions & 3 deletions python/lsst/ts/wep/task/cutOutDonutsBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def cutOutStamps(self, exposure, donutCatalog, defocalType, cameraName):
defocal_type=defocalType.value,
# Save defocal offsets in mm.
detector_offset=instrument.defocalOffset * 1e3, # m -> mm
real_offset=instrument.batoidOffsetValue * 1e3, # m -> mm
optic_offset=instrument.batoidOffsetValue * 1e3, # m -> mm
bandpass=bandLabel,
archive_element=linear_wcs,
)
Expand All @@ -433,10 +433,10 @@ def cutOutStamps(self, exposure, donutCatalog, defocalType, cameraName):
stampsMetadata["DFC_TYPE"] = np.array(
[defocalType.value] * catalogLength, dtype=str
)
stampsMetadata["DET_OFFSET"] = np.array(
stampsMetadata["DET_DZ"] = np.array(
[instrument.defocalOffset * 1e3] * catalogLength
)
stampsMetadata["REAL_OFFSET"] = np.array(
stampsMetadata["OPTIC_DZ"] = np.array(
[instrument.batoidOffsetValue * 1e3] * catalogLength
)
# Save the centroid values
Expand Down
35 changes: 18 additions & 17 deletions python/lsst/ts/wep/task/donutStamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ class DonutStamp(AbstractStamp):
detector_offset : `float`
Defocal offset of the detector in mm. If the detector was not
actually shifted, this should be the equivalent detector offset.
real_offset : `float`
The real offset that was used to capture defocused images, in mm.
For LSSTCam, this corresponds to detector_offset, but for AuxTel
this corresponds to the M2 offset.
optic_offset : `float`
The real offset applied to an optic element to capture defocused
images, in mm. For LSSTCam, this corresponds to detector_offset,
for LSST full-array and ComCam this corresponds to the camera offset,
and for AuxTel this corresponds to the M2 offset.
detector_name : `str`
CCD where the donut is found
cam_name : `str`
Expand All @@ -91,7 +92,7 @@ class DonutStamp(AbstractStamp):
blend_centroid_positions: np.ndarray
defocal_type: str
detector_offset: float
real_offset: float
optic_offset: float
detector_name: str
cam_name: str
bandpass: str
Expand Down Expand Up @@ -157,17 +158,17 @@ def factory(cls, stamp_im, metadata, index, archive_element=None):
# "CAM_NAME" stands for camera name
cam_name = metadata.getArray("CAM_NAME")[index]

# Get the detector offset and real offset info (see the class docstring
# Get the detector offset and optic offset info (see class docstring
# for the difference in these numbers). All values in mm
try:
detector_offset = (
metadata.getArray("DET_OFFSET")[index]
if metadata.getArray("DET_OFFSET") is not None
metadata.getArray("DET_DZ")[index]
if metadata.getArray("DET_DZ") is not None
else 1.5
)
real_offset = (
metadata.getArray("REAL_OFFSET")[index]
if metadata.getArray("REAL_OFFSET") is not None
optic_offset = (
metadata.getArray("OPTIC_DZ")[index]
if metadata.getArray("OPTIC_DZ") is not None
else 1.5
)
# This might fail for old stamps, in which case we use these hard-coded
Expand All @@ -176,15 +177,15 @@ def factory(cls, stamp_im, metadata, index, archive_element=None):
if cam_name == "LATISS":
detector_offset = 34.7
if defocal_type == "extra":
real_offset = +0.8
optic_offset = +0.8
else:
real_offset = -0.8
optic_offset = -0.8
else:
detector_offset = 1.5
if defocal_type == "extra":
real_offset = +1.5
optic_offset = +1.5
else:
real_offset = -1.5
optic_offset = -1.5

return cls(
stamp_im=stamp_im,
Expand All @@ -206,7 +207,7 @@ def factory(cls, stamp_im, metadata, index, archive_element=None):
# Set the defocal offset info
defocal_type=defocal_type,
detector_offset=detector_offset,
real_offset=real_offset,
optic_offset=optic_offset,
# "BANDPASS" stands for the exposure bandpass
# If this is an old version of the stamps without bandpass
# information then an empty string ("") will be set as default.
Expand Down Expand Up @@ -325,7 +326,7 @@ def _setWepImage(self):
bandLabel=self.bandpass,
blendOffsets=blendOffsets,
defocalOffset=self.detector_offset / 1e3, # mm -> m
batoidOffsetValue=self.real_offset / 1e3, # mm -> m
batoidOffsetValue=self.optic_offset / 1e3, # mm -> m
)

self.wep_im = wepImage
Expand Down
14 changes: 7 additions & 7 deletions python/lsst/ts/wep/task/donutStamps.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def _refresh_metadata(self):
defocal_types = self.getDefocalTypes()
self.metadata["DFC_TYPE"] = [dfc for dfc in defocal_types]
detector_offsets = self.getDetectorOffsets()
self.metadata["DET_OFFSET"] = [offset for offset in detector_offsets]
real_offsets = self.getRealOffsets()
self.metadata["REAL_OFFSET"] = [offset for offset in real_offsets]
self.metadata["DET_DZ"] = [offset for offset in detector_offsets]
optic_offsets = self.getOpticOffsets()
self.metadata["OPTIC_DZ"] = [offset for offset in optic_offsets]
bandpasses = self.getBandpasses()
self.metadata["BANDPASS"] = [bandpass for bandpass in bandpasses]

Expand Down Expand Up @@ -170,16 +170,16 @@ def getDetectorOffsets(self):
"""
return [stamp.detector_offset for stamp in self]

def getRealOffsets(self):
def getOpticOffsets(self):
"""
Get the real offset for each stamp.
Get the optic offset for each stamp.
Returns
-------
list [float]
Real offset for each stamp, in mm.
Optic offset for each stamp, in mm.
"""
return [stamp.real_offset for stamp in self]
return [stamp.optic_offset for stamp in self]

def getBandpasses(self):
"""
Expand Down
8 changes: 4 additions & 4 deletions tests/task/test_donutStamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _makeStamps(self, nStamps, stampSize, testDefaults=False):
halfStampIdx = int(nStamps / 2)
dfcTypes[:halfStampIdx] = [DefocalType.Intra.value] * halfStampIdx
detectorOffsets = np.ones(nStamps) * 1.25
realOffsets = np.ones(nStamps) * 1.25
opticOffsets = np.ones(nStamps) * 1.25
bandpass = ["r"] * nStamps

metadata = PropertyList()
Expand All @@ -80,8 +80,8 @@ def _makeStamps(self, nStamps, stampSize, testDefaults=False):
metadata["CAM_NAME"] = camNames
metadata["DFC_TYPE"] = dfcTypes
if testDefaults is False:
metadata["DET_OFFSET"] = detectorOffsets
metadata["REAL_OFFSET"] = realOffsets
metadata["DET_DZ"] = detectorOffsets
metadata["OPTIC_DZ"] = opticOffsets
metadata["BLEND_CX"] = blendCentX
metadata["BLEND_CY"] = blendCentY
metadata["BANDPASS"] = bandpass
Expand Down Expand Up @@ -123,7 +123,7 @@ def testFactory(self):
else:
self.assertEqual(defocalType, DefocalType.Extra.value)
self.assertEqual(donutStamp.detector_offset, 1.25)
self.assertEqual(donutStamp.real_offset, 1.25)
self.assertEqual(donutStamp.optic_offset, 1.25)
bandpass = donutStamp.bandpass
self.assertEqual(bandpass, "r")

Expand Down
6 changes: 3 additions & 3 deletions tests/task/test_donutStamps.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ def testGetDetectorOffsets(self):
for idx in range(self.nStamps):
self.assertEqual(detectorOffsets[idx], 1.5)

def testGetRealOffsets(self):
realOffsets = self.donutStamps.getRealOffsets()
def testGetOpticOffsets(self):
opticOffsets = self.donutStamps.getOpticOffsets()
defocalTypes = self.donutStamps.getDefocalTypes()
for idx in range(self.nStamps):
sign = +1 if defocalTypes[idx] == "extra" else -1
self.assertEqual(realOffsets[idx], sign * 1.5)
self.assertEqual(opticOffsets[idx], sign * 1.5)

def testGetBandpass(self):
bandpasses = self.donutStamps.getBandpasses()
Expand Down

0 comments on commit 92e2e63

Please sign in to comment.