Skip to content

Commit

Permalink
Add zeroWeightMaskBits
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeyers314 committed Dec 10, 2021
1 parent 8141377 commit 72e1eab
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions python/lsst/meas/extensions/piff/piffPsfDeterminer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,19 @@ class PiffPsfDeterminerConfig(BasePsfDeterminerTask.ConfigClass):
dtype=float,
default=200.0
)
zeroWeightMaskBits = pexConfig.ListField(
doc="List of mask bits for which to set pixel weights to zero.",
dtype=str,
default=['BAD', 'CR', 'INTRP', 'SAT', 'SUSPECT', 'NO_DATA']
)

def setDefaults(self):
self.kernelSize = 21
self.kernelSizeMin = 11
self.kernelSizeMax = 35


def computeWeight(maskedImage, maxSNR):
def computeWeight(maskedImage, maxSNR, zeroWeightMaskBits):
"""Derive a weight map without Poisson variance component due to signal.
Parameters
Expand All @@ -75,6 +80,8 @@ def computeWeight(maskedImage, maxSNR):
PSF candidate postage stamp
maxSNR : `float`
Maximum SNR applying variance floor.
zeroWeightMaskBits : `List[str]`
List of mask bits for which to set pixel weights to zero.
Returns
-------
Expand All @@ -83,7 +90,13 @@ def computeWeight(maskedImage, maxSNR):
"""
imArr = maskedImage.image.array
varArr = maskedImage.variance.array
good = (varArr != 0) & np.isfinite(varArr) & np.isfinite(imArr)
bitmask = maskedImage.mask.getPlaneBitMask(zeroWeightMaskBits)
good = (
(varArr != 0)
& (np.isfinite(varArr))
& (np.isfinite(imArr))
& ((maskedImage.mask.array & bitmask) == 0)
)

# Fit a straight line to variance vs (sky-subtracted) signal.
# The evaluate that line at zero signal to get an estimate of the
Expand Down Expand Up @@ -202,7 +215,11 @@ def determinePsf(
stars = []
for candidate in psfCandidateList:
cmi = candidate.getMaskedImage()
weight = computeWeight(cmi, self.config.maxSNR)
weight = computeWeight(
cmi,
self.config.maxSNR,
self.config.zeroWeightMaskBits
)

bbox = cmi.getBBox()
bds = galsim.BoundsI(
Expand Down

0 comments on commit 72e1eab

Please sign in to comment.