Skip to content

Commit

Permalink
fixup! RingsSkyMap: fix bugs in tract numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulPrice committed Jun 26, 2018
1 parent ec6d491 commit 08c8846
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
5 changes: 3 additions & 2 deletions python/lsst/skymap/ringsSkyMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ def _raToTractNum(self, ra, ringNum):
if ringNum in (-1, self.config.numRings):
return 0
assert ringNum in range(self.config.numRings)
return int((ra - self._raStart).wrap().asRadians() /
(2*math.pi/self._ringNums[ringNum]) + 0.5)
tractNum = int((ra - self._raStart).wrap().asRadians() /
(2*math.pi/self._ringNums[ringNum]) + 0.5)
return 0 if tractNum == self._ringNums[ringNum] else tractNum # Allow wraparound

def findTract(self, coord):
"""Find the tract whose center is nearest the specified coord.
Expand Down
28 changes: 16 additions & 12 deletions tests/test_ringsSkyMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ def testDm14809(self):
tract = self.skymap.findTract(coord)
self.assertTrue(tract.contains(coord))

def testWraparound(self):
"""Check wrapping at RA=0
How-to-reproduce of a bug identified by Sogo Mineo.
"""
tractId = 9712
deviation = 10 / 3600.0 # 10 arcsec
tract = self.skymap[tractId]
center = tract.getCtrCoord()
centerRa = center.getRa().asDegrees()
centerDec = center.getDec().asDegrees()
for devRa in [-deviation, deviation]:
coord = lsst.afw.geom.SpherePoint(centerRa + devRa, centerDec, lsst.afw.geom.degrees)
foundTractId = self.skymap.findTract(coord).getId()
self.assertEqual(tractId, foundTractId)

def getFirstTractLastRingCoord(self):
"""Return the coordinates of the first tract in the last ring
Expand Down Expand Up @@ -168,18 +184,6 @@ def testDm14809(self):
tract = self.skymap.findTract(coord)
self.assertFalse(tract.contains(coord))

# Check Mineo-san's bug report
tractId = 9712
deviation = 10 / 3600.0 # 10 arcsec
tract = self.skymap[tractId]
center = tract.getCtrCoord()
centerRa = center.getRa().asDegrees()
centerDec = center.getDec().asDegrees()
for devRa in [-deviation, deviation]:
coord = lsst.afw.geom.SpherePoint(centerRa + devRa, centerDec, lsst.afw.geom.degrees)
foundTractId = self.skymap.findTract(coord).getId()
self.assertEqual(tractId, foundTractId)


class MemoryTester(lsst.utils.tests.MemoryTestCase):
pass
Expand Down

0 comments on commit 08c8846

Please sign in to comment.