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

DM-30105: Get children sources without repeatedly checking if the afw SourceCatalog is sorted by parent #176

Merged
merged 3 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions python/lsst/meas/base/forcedMeasurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,25 +353,26 @@ def run(self, measCat, exposure, refCat, refWcs, exposureId=None, beginOrder=Non
# Create parent cat which slices both the refCat and measCat (sources)
# first, get the reference and source records which have no parent
refParentCat, measParentCat = refCat.getChildren(0, measCat)
for parentIdx, (refParentRecord, measParentRecord) in enumerate(zip(refParentCat, measParentCat)):

# first process the records which have the current parent as children
refChildCat, measChildCat = refCat.getChildren(refParentRecord.getId(), measCat)
childrenIter = refCat.getChildren((refParentRecord.getId() for refParentRecord in refCat), measCat)
for parentIdx, records in enumerate(zip(refParentCat, measParentCat, childrenIter)):
# Unpack records
refParentRecord, measParentRecord, (refChildCat, measChildCat) = records
# First process the records which have the current parent as children
# TODO: skip this loop if there are no plugins configured for single-object mode
for refChildRecord, measChildRecord in zip(refChildCat, measChildCat):
noiseReplacer.insertSource(refChildRecord.getId())
self.callMeasure(measChildRecord, exposure, refChildRecord, refWcs,
beginOrder=beginOrder, endOrder=endOrder)
noiseReplacer.removeSource(refChildRecord.getId())

# then process the parent record
# Then process the parent record
noiseReplacer.insertSource(refParentRecord.getId())
self.callMeasure(measParentRecord, exposure, refParentRecord, refWcs,
beginOrder=beginOrder, endOrder=endOrder)
self.callMeasureN(measParentCat[parentIdx:parentIdx+1], exposure,
refParentCat[parentIdx:parentIdx+1],
beginOrder=beginOrder, endOrder=endOrder)
# measure all the children simultaneously
# Measure all the children simultaneously
self.callMeasureN(measChildCat, exposure, refChildCat,
beginOrder=beginOrder, endOrder=endOrder)
noiseReplacer.removeSource(refParentRecord.getId())
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/meas/base/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ def subset(self, sources, bbox, wcs):
parentSources = catalog.getChildren(0)
skyCoordList = [source.getCoord() for source in parentSources]
pixelPosList = wcs.skyToPixel(skyCoordList)
for parent, pixel in zip(parentSources, pixelPosList):
if boxD.contains(pixel):
yield parent
for child in catalog.getChildren(parent.getId()):
yield child
parentList = [parent for parent, pixel in zip(parentSources, pixelPosList) if boxD.contains(pixel)]
childrenIter = catalog.getChildren((parent.getId() for parent in parentList))
arunkannawadi marked this conversation as resolved.
Show resolved Hide resolved
for parent, children in zip(parentList, childrenIter):
yield parent
yield from children


class CoaddSrcReferencesConfig(BaseReferencesTask.ConfigClass):
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/meas/base/sfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ def runPlugins(self, noiseReplacer, measCat, exposure, beginOrder=None, endOrder
nMeasParentCat, ("" if nMeasParentCat == 1 else "s"),
nMeasCat - nMeasParentCat, ("" if nMeasCat - nMeasParentCat == 1 else "ren"))

for parentIdx, measParentRecord in enumerate(measParentCat):
childrenIter = measCat.getChildren([measParentRecord.getId() for measParentRecord in measParentCat])
for parentIdx, (measParentRecord, measChildCat) in enumerate(zip(measParentCat, childrenIter)):
# first get all the children of this parent, insert footprint in
# turn, and measure
measChildCat = measCat.getChildren(measParentRecord.getId())
# TODO: skip this loop if there are no plugins configured for
# single-object mode
for measChildRecord in measChildCat:
Expand Down