Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new constraint API for custom constraints #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions python/lsst/meas/deblender/deblend.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ class MultibandDeblendConfig(pexConfig.Config):
"This must be between 0 and 1."))

# Constraints
constraints = pexConfig.Field(dtype=str, default="1,+,S,M",
constraints = pexConfig.Field(dtype=str, default="1,S,M",
doc=("List of constraints to use for each object"
"(order does not matter)"
"Current options are all used by default:\n"
Expand Down Expand Up @@ -707,13 +707,12 @@ def __init__(self, schema, peakSchema=None, **kwargs):
# all of the sources
constraints = None
_constraints = self.config.constraints.split(",")
if (sorted(_constraints) != ['+', '1', 'M', 'S']
if (sorted(_constraints) != ['1', 'M', 'S']
or ~np.isnan(self.config.l0Thresh)
or ~np.isnan(self.config.l1Thresh)
):
constraintDict = {
"+": scarlet.constraint.PositivityConstraint,
"1": scarlet.constraint.SimpleConstraint,
"1": scarlet.constraint.SimpleConstraint(),
"M": scarlet.constraint.DirectMonotonicityConstraint(use_nearest=False),
"S": scarlet.constraint.DirectSymmetryConstraint(sigma=self.config.symmetryThresh)
}
Expand Down Expand Up @@ -927,15 +926,15 @@ def deblend(self, mExposure, sources, psfs):
fluxCatalogs = {}
for f in filters:
_catalog = afwTable.SourceCatalog(sources.table.clone())
_catalog.extend(sources)
_catalog.extend(sources, deep=True)
fluxCatalogs[f] = _catalog
else:
fluxCatalogs = None
if self.config.saveTemplates:
templateCatalogs = {}
for f in filters:
_catalog = afwTable.SourceCatalog(sources.table.clone())
_catalog.extend(sources)
_catalog.extend(sources, deep=True)
templateCatalogs[f] = _catalog
else:
templateCatalogs = None
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/meas/deblender/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def buildMultibandTemplates(debResult, log, useWeights=False, usePsf=False,
bg_rms = np.array([debResult.deblendedParents[f].avgNoise for f in debResult.filters])*bgScale
if sources is None:
# If only a single constraint was given, use it for all of the sources
if constraints is None or isinstance(constraints[0], scarlet.constraints.Constraint):
if constraints is None or isinstance(constraints[0], scarlet.constraint.Constraint):
constraints = [constraints] * len(peaks)
sources = [
scarlet.source.ExtendedSource(center=peak,
Expand Down