From 1cbfc8887407d01d840fb9794d7f1476793fa274 Mon Sep 17 00:00:00 2001 From: fred3m Date: Tue, 14 Aug 2018 06:54:46 -0700 Subject: [PATCH] Use new constraint API for custom constraints --- python/lsst/meas/deblender/deblend.py | 11 +++++------ python/lsst/meas/deblender/plugins.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/python/lsst/meas/deblender/deblend.py b/python/lsst/meas/deblender/deblend.py index b1fbf7fb..eeae7f73 100644 --- a/python/lsst/meas/deblender/deblend.py +++ b/python/lsst/meas/deblender/deblend.py @@ -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" @@ -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) } @@ -927,7 +926,7 @@ 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 @@ -935,7 +934,7 @@ def deblend(self, mExposure, sources, psfs): 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 diff --git a/python/lsst/meas/deblender/plugins.py b/python/lsst/meas/deblender/plugins.py index b0ff223a..6216fae7 100755 --- a/python/lsst/meas/deblender/plugins.py +++ b/python/lsst/meas/deblender/plugins.py @@ -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,