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

Use afw updateRefCentroids and updateSourceCoords #34

Merged
merged 1 commit into from
Jun 22, 2016
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
31 changes: 4 additions & 27 deletions python/lsst/meas/astrom/fitTanSipWcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,17 @@ def fitWcs(self, matches, initWcs, bbox=None, refCat=None, sourceCat=None):

if refCat is not None:
self.log.logdebug("Updating centroids in refCat")
self.updateRefCentroids(wcs, refList=refCat)
afwTable.updateRefCentroids(wcs, refList=refCat)
else:
self.log.warn("Updating reference object centroids in match list; refCat is None")
self.updateRefCentroids(wcs, refList=[match.first for match in matches])
afwTable.updateRefCentroids(wcs, refList=[match.first for match in matches])

if sourceCat is not None:
self.log.logdebug("Updating coords in sourceCat")
self.updateSourceCoords(wcs, sourceList=sourceCat)
afwTable.updateSourceCoords(wcs, sourceList=sourceCat)
else:
self.log.warn("Updating source coords in match list; sourceCat is None")
self.updateSourceCoords(wcs, sourceList=[match.second for match in matches])
afwTable.updateSourceCoords(wcs, sourceList=[match.second for match in matches])

self.log.logdebug("Updating distance in match list")
setMatchDistance(matches)
Expand Down Expand Up @@ -224,29 +224,6 @@ def rejectMatches(self, matches, wcs, rejected):
good = np.logical_not(rejected)
return (dx > self.config.rejSigma*dx[good].std()) | (dy > self.config.rejSigma*dy[good].std())

@staticmethod
def updateRefCentroids(wcs, refList):
"""Update centroids in a collection of reference objects, given a WCS
"""
if len(refList) < 1:
return
schema = refList[0].schema
coordKey = afwTable.CoordKey(schema["coord"])
centroidKey = afwTable.Point2DKey(schema["centroid"])
for refObj in refList:
refObj.set(centroidKey, wcs.skyToPixel(refObj.get(coordKey)))

@staticmethod
def updateSourceCoords(wcs, sourceList):
"""Update coords in a collection of sources, given a WCS
"""
if len(sourceList) < 1:
return
schema = sourceList[1].schema
srcCoordKey = afwTable.CoordKey(schema["coord"])
for src in sourceList:
src.set(srcCoordKey, wcs.pixelToSky(src.getCentroid()))

def plotFit(self, matches, wcs, rejected):
"""Plot the fit

Expand Down
4 changes: 2 additions & 2 deletions tests/testFitTanSipWcsTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ def doTest(self, name, func, order=3, numIter=4, specifyBBox=False, doPlot=False

if self.MatchClass == afwTable.ReferenceMatch:
# reset source coord and reference centroid based on initial WCS
FitTanSipWcsTask.updateRefCentroids(wcs=self.tanWcs, refList=self.refCat)
FitTanSipWcsTask.updateSourceCoords(wcs=self.tanWcs, sourceList=self.sourceCat)
afwTable.updateRefCentroids(wcs=self.tanWcs, refList=self.refCat)
afwTable.updateSourceCoords(wcs=self.tanWcs, sourceList=self.sourceCat)

fitterConfig = FitTanSipWcsTask.ConfigClass()
fitterConfig.order = order
Expand Down