diff --git a/python/lsst/ts/wep/task/cutOutDonutsBase.py b/python/lsst/ts/wep/task/cutOutDonutsBase.py index 02600a30..a3bf28cf 100644 --- a/python/lsst/ts/wep/task/cutOutDonutsBase.py +++ b/python/lsst/ts/wep/task/cutOutDonutsBase.py @@ -608,10 +608,13 @@ def cutOutStamps(self, exposure, donutCatalog, defocalType, cameraName): # Save MaskedImage to stamp finalStamp = finalCutout.getMaskedImage() - # Save centroid positions as str so we can store in header - blendStrX = "" - blendStrY = "" + # Set that as default, unless overwritten + blendCentroidPositions = np.array([["nan"], ["nan"]], dtype=float).T + if len(catalogMeta["blend_centroid_x"]) > 0: + # Save centroid positions as str so we can store in header + blendStrX = "" + blendStrY = "" for blend_cx, blend_cy in zip( catalogMeta["blend_centroid_x"][idx], catalogMeta["blend_centroid_y"][idx], @@ -630,8 +633,7 @@ def cutOutStamps(self, exposure, donutCatalog, defocalType, cameraName): finalBlendXList.append(blendStrX) finalBlendYList.append(blendStrY) - # Prepare blend centroid position information - if len(catalogMeta["blend_centroid_x"]) > 0: + # Prepare blend centroid position information if len(catalogMeta["blend_centroid_x"][idx]) > 0: blendCentroidPositions = np.array( [ @@ -639,10 +641,7 @@ def cutOutStamps(self, exposure, donutCatalog, defocalType, cameraName): catalogMeta["blend_centroid_y"][idx] + donutRow["yShift"], ] ).T - else: - blendCentroidPositions = np.array([["nan"], ["nan"]], dtype=float).T - else: - blendCentroidPositions = np.array([["nan"], ["nan"]], dtype=float).T + # Get the local linear WCS for the donut stamp # Be careful to get the cd matrix from the linearized WCS instead # of the one from the full WCS.