30 nChildKeyName =
Field(dtype=str, default=
"deblend_nChild",
31 doc=
"Name of field in schema with number of deblended children")
32 pseudoFilterList =
ListField(dtype=str, default=[
'sky'],
33 doc=
"Names of filters which should never be primary")
37 ConfigClass = SetPrimaryFlagsConfig
40 Task.__init__(self, **kwargs)
43 "detect_isPatchInner", type=
"Flag",
44 doc=
"true if source is in the inner region of a coadd patch",
47 "detect_isTractInner", type=
"Flag",
48 doc=
"true if source is in the inner region of a coadd tract",
51 "detect_isPrimary", type=
"Flag",
52 doc=
"true if source has no children and is in the inner region of a coadd patch " 53 "and is in the inner region of a coadd tract " 54 "and is not \"detected\" in a pseudo-filter (see config.pseudoFilterList)",
57 def run(self, sources, skyMap, tractInfo, patchInfo, includeDeblend=True):
58 """Set is-primary and related flags on sources 60 @param[in,out] sources a SourceTable 61 - reads centroid fields and an nChild field 62 - writes is-patch-inner, is-tract-inner and is-primary flags 63 @param[in] skyMap sky tessellation object (subclass of lsst.skymap.BaseSkyMap) 64 @param[in] tractInfo tract object (subclass of lsst.skymap.TractInfo) 65 @param[in] patchInfo patch object (subclass of lsst.skymap.PatchInfo) 66 @param[in] includeDeblend include deblend information in isPrimary? 70 nChildKey = self.
schema.find(self.
config.nChildKeyName).key
74 innerFloatBBox =
Box2D(patchInfo.getInnerBBox())
80 shrunkInnerFloatBBox =
Box2D(innerFloatBBox)
81 shrunkInnerFloatBBox.grow(-1)
84 for filt
in self.
config.pseudoFilterList:
86 pseudoFilterKeys.append(self.
schema.find(
"merge_peak_%s" % filt).getKey())
88 self.
log.
warn(
"merge_peak is not set for pseudo-filter %s" % filt)
90 tractId = tractInfo.getId()
91 for source
in sources:
92 centroidPos = source.getCentroid()
93 if numpy.any(numpy.isnan(centroidPos)):
95 if source.getCentroidFlag():
97 isPatchInner = shrunkInnerFloatBBox.contains(centroidPos)
99 isPatchInner = innerFloatBBox.contains(centroidPos)
102 skyPos = source.getCoord()
103 sourceInnerTractId = skyMap.findTract(skyPos).getId()
104 isTractInner = sourceInnerTractId == tractId
107 if nChildKey
is None or source.get(nChildKey) == 0:
108 for pseudoFilterKey
in pseudoFilterKeys:
109 if source.get(pseudoFilterKey):
115 source.setFlag(self.
isPrimaryKey, isPatchInner
and isTractInner
and not isPseudo)
A floating-point coordinate rectangle geometry.
def __init__(self, schema, kwargs)
def run(self, sources, skyMap, tractInfo, patchInfo, includeDeblend=True)