Skip to content

Commit

Permalink
Fix bug in making sure catalog is contiguous
Browse files Browse the repository at this point in the history
LoadIndexedReferenceObjectsTask.loadSkyCircle could return
a catalog that was not contigous (despite code that attempted
to guarantee otherwise). Add tests for this to test_htmIndex.py.

Also document that the catalogs returned by
LoadIndexedReferenceObjectsTask.loadSkyCircle and loadSkyBox
are always contiguous.
  • Loading branch information
r-owen committed Sep 4, 2018
1 parent 5479612 commit 1886e8b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions python/lsst/meas/algorithms/loadIndexedReferenceObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ def loadSkyCircle(self, ctrCoord, radius, filterName=None, epoch=None):
else:
refCat.extend(shard)

# make sure catalog is contiguous
if not refCat.isContiguous():
refCat = refCat.copy()

if epoch is not None:
self.applyProperMotions(refCat, epoch)

Expand All @@ -104,6 +100,10 @@ def loadSkyCircle(self, ctrCoord, radius, filterName=None, epoch=None):
expandedCat.extend(refCat, mapper=mapper)
del refCat # avoid accidentally returning the unexpanded reference catalog

# make sure catalog is contiguous
if not expandedCat.isContiguous():
expandedCat = expandedCat.copy(True)

# return reference catalog
return pipeBase.Struct(
refCat=expandedCat,
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/meas/algorithms/loadReferenceObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def loadPixelBox(self, bbox, wcs, filterName=None, calib=None, epoch=None):
@link meas_algorithms_loadReferenceObjects_Schema standard schema @endlink
as documented in LoadReferenceObjects, including photometric, resolved and variable;
hasCentroid is False for all objects.
The catalog is guaranteed to be contiguous.
- fluxField = name of flux field for specified filterName
"""
circle = self._calculateCircle(bbox, wcs)
Expand Down Expand Up @@ -283,6 +284,7 @@ def loadSkyCircle(self, ctrCoord, radius, filterName=None, epoch=None):
@link meas_algorithms_loadReferenceObjects_Schema standard schema @endlink
as documented in LoadReferenceObjects, including photometric, resolved and variable;
hasCentroid is False for all objects.
The catalog is guaranteed to be contiguous.
- fluxField = name of flux field for specified filterName
"""
return
Expand Down
7 changes: 5 additions & 2 deletions tests/test_htmIndex.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,18 @@ def testIngest(self):
config = LoadIndexedReferenceObjectsConfig()
config.ref_dataset_name = "myrefcat"
loader = LoadIndexedReferenceObjectsTask(butler=butler, config=config)
cat = loader.loadSkyCircle(cent, self.search_radius, filterName='a')
cat = loader.loadSkyCircle(cent, self.search_radius, filterName='a').refCat
self.assertTrue(len(cat) > 0)
self.assertTrue(cat.isContiguous())

# test that a catalog can be loaded even with a name not used for ingestion
butler = dafPersist.Butler(self.test_repo_path)
config = LoadIndexedReferenceObjectsConfig()
config.ref_dataset_name = self.test_dataset_name
loader = LoadIndexedReferenceObjectsTask(butler=butler, config=config)
cat = loader.loadSkyCircle(cent, self.search_radius, filterName='a')
cat = loader.loadSkyCircle(cent, self.search_radius, filterName='a').refCat
self.assertTrue(len(cat) > 0)
self.assertTrue(cat.isContiguous())

def testLoadIndexedReferenceConfig(self):
"""Make sure LoadIndexedReferenceConfig has needed fields."""
Expand All @@ -395,6 +397,7 @@ def testLoadSkyCircle(self):
for tupl, idList in self.comp_cats.items():
cent = make_coord(*tupl)
lcat = loader.loadSkyCircle(cent, self.search_radius, filterName='a')
self.assertTrue(lcat.refCat.isContiguous())
self.assertFalse("camFlux" in lcat.refCat.schema)
self.assertEqual(Counter(lcat.refCat['id']), Counter(idList))
if len(lcat.refCat) > 0:
Expand Down

0 comments on commit 1886e8b

Please sign in to comment.