22 from __future__
import absolute_import, division, print_function
24 from .aggregates
import CoordKey, Point2DKey
26 __all__ = [
"updateRefCentroids",
"updateSourceCoords"]
30 """Update centroids in a collection of reference objects
32 This code supports any kind of collection, instead of requiring a catalog,
33 to make it easy to use with match lists. For example:
35 updateRefCentroids(wcs, refList=[match.first for match in matches])
37 @param[in] wcs WCS to map from sky to pixels; an lsst.afw.image.Wcs
38 @param[in,out] refList collection of reference objects (lsst.afw.table.SimpleRecords); for each:
39 - read field "coords", an lsst.afw.coord.Coord
40 - write field "centroid", an lsst.afw.geom.Point2D
44 schema = refList[0].schema
45 coordKey = CoordKey(schema[
"coord"])
47 for refObj
in refList:
48 refObj.set(centroidKey, wcs.skyToPixel(refObj.get(coordKey)))
52 """Update coords in a collection of sources
54 This code supports any kind of collection, instead of requiring a catalog,
55 to make it easy to use with match lists. For example:
57 updateSourceCoords(wcs, sourceList=[match.second for match in matches])
59 @param[in] wcs WCS to map from pixels to sky; an lsst.afw.image.Wcs
60 @param[in,out] sourceList collection of sources (lsst.afw.table.SourceRecords); for each:
61 - read centroid using getCentroid()
62 - write field "coord", an lsst.afw.coord.Coord
64 if len(sourceList) < 1:
66 schema = sourceList[0].schema
67 srcCoordKey = CoordKey(schema[
"coord"])
68 for src
in sourceList:
69 src.set(srcCoordKey, wcs.pixelToSky(src.getCentroid()))