Skip to content

Commit

Permalink
Make nSigma of width of line to mask configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
isullivan committed Dec 5, 2024
1 parent 5bd1297 commit 36fd315
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions python/lsst/meas/algorithms/maskStreaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def __init__(self, data, weights, line=None):
self.mask = (weights != 0)

self._initLine = line
self.setLineMask(line, maxStreakWidth=0)
self.setLineMask(line, maxStreakWidth=0, nSigmaMask=5)

def getLineXY(self, line):
"""Return the pixel coordinates of the ends of the line.
Expand Down Expand Up @@ -191,7 +191,7 @@ def getLineXY(self, line):

return boxIntersections

def setLineMask(self, line, maxStreakWidth):
def setLineMask(self, line, maxStreakWidth, nSigmaMask):
"""Set mask around the image region near the line.
Parameters
Expand All @@ -203,7 +203,7 @@ def setLineMask(self, line, maxStreakWidth):
# Only fit pixels within 5 sigma of the estimated line
radtheta = np.deg2rad(line.theta)
distance = (np.cos(radtheta) * self._xmesh + np.sin(radtheta) * self._ymesh - line.rho)
width = maxStreakWidth/2 if maxStreakWidth > 0 else 5 * line.sigma
width = maxStreakWidth/2 if maxStreakWidth > 0 else nSigmaMask * line.sigma
m = (abs(distance) < width)
self.lineMask = self.mask & m
else:
Expand Down Expand Up @@ -438,6 +438,11 @@ class MaskStreaksConfig(pexConfig.Config):
dtype=float,
default=2,
)
nSigmaMask = pexConfig.Field(
doc="Number of sigmas from center of kernel to mask",
dtype=float,
default=5,
)
rhoBinSize = pexConfig.Field(
doc="Binsize in pixels for position parameter rho when finding "
"clusters of detected lines",
Expand Down Expand Up @@ -766,7 +771,7 @@ def _fitProfile(self, lines, maskedImage):
continue

# Make mask
lineModel.setLineMask(fit, self.config.maxStreakWidth)
lineModel.setLineMask(fit, self.config.maxStreakWidth, self.config.nSigmaMask)
finalModel = lineModel.makeProfile(fit)
# Take absolute value, as streaks are allowed to be negative
finalModelMax = abs(finalModel).max()
Expand Down

0 comments on commit 36fd315

Please sign in to comment.