Skip to content

Commit

Permalink
Compute pixel central stats before subtracting background
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Meyers committed Feb 13, 2024
1 parent 0a59c4b commit 587e5d4
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions python/lsst/summit/utils/peekExposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,15 @@ def run(
def _run(self, exposure, doDisplay, doDisplayIndices, mode, binSize, donutDiameter):
""" The actual run method, called by run().
"""
# If image is ~large, then use a subsampling of the image for
# speedy median/mode estimates.
arr = exposure.getMaskedImage().getImage().array
sampling = 1
if arr.size > 250_000:
sampling = int(np.floor(np.sqrt(arr.size / 250_000)))
pixelMedian = np.nanmedian(arr[::sampling, ::sampling])
pixelMode = _estimateMode(arr[::sampling, ::sampling])

if donutDiameter is None:
donutDiameter = self.getDonutDiameter(exposure)

Expand Down Expand Up @@ -904,13 +913,6 @@ def _run(self, exposure, doDisplay, doDisplayIndices, mode, binSize, donutDiamet
exposure, binSize, binnedSourceCat, maxFluxIdx, doDisplayIndices
)

# If image is still ~large, then use a subsampling of the image for
# speedy median/mode estimates.
arr = exposure.getMaskedImage().getImage().array
sampling = 1
if arr.size > 250_000:
sampling = int(np.floor(np.sqrt(arr.size / 250_000)))

return pipeBase.Struct(
mode=mode,
binSize=binSize,
Expand All @@ -924,8 +926,8 @@ def _run(self, exposure, doDisplay, doDisplayIndices, mode, binSize, donutDiamet
psfPixelShape=psfShape,
psfEquatorialShape=equatorialShapes[1],
psfAltAzShape=altAzShapes[1],
pixelMedian=np.nanmedian(arr[::sampling, ::sampling]),
pixelMode=_estimateMode(arr[::sampling, ::sampling]),
pixelMedian=pixelMedian,
pixelMode=pixelMode,
)

def runPeek(self, exposure, mode, donutDiameter, binSize=None):
Expand Down

0 comments on commit 587e5d4

Please sign in to comment.