22 from __future__
import absolute_import, division, print_function
24 __all__ = [
"checkMatches"]
26 from builtins
import range
30 import lsst.afw.detection
as afwDetection
31 import lsst.afw.geom
as afwGeom
32 import lsst.afw.math
as afwMath
33 import lsst.meas.algorithms
as measAlg
34 from lsst.log
import Log
42 log = Log.getLogger(
"meas.astrom.verifyWcs.checkMatches")
44 im = exposure.getMaskedImage().getImage()
45 width, height = im.getWidth(), im.getHeight()
47 w, h = width//nx, height//ny
59 cellSet = afwMath.SpatialCellSet(
60 afwGeom.Box2I(afwGeom.Point2I(0, 0), afwGeom.Extent2I(width, height)), w, h)
69 csrc = afwDetection.Source()
71 csrc.setXAstrom(src.getXAstrom())
72 csrc.setYAstrom(src.getYAstrom())
75 cellSet.insertCandidate(measAlg.PsfCandidateF(csrc, exposure.getMaskedImage()))
76 except Exception
as e:
79 ncell = len(cellSet.getCellList())
80 nobj = np.ndarray(ncell, dtype=
'i')
82 for i
in range(ncell):
83 cell = cellSet.getCellList()[i]
87 dx = np.ndarray(cell.size())
88 dy = np.ndarray(cell.size())
96 mid = cand.getSource().getId()
97 dx[j] = srcMatchSet[mid].first.getXAstrom() - srcMatchSet[mid].second.getXAstrom()
98 dy[j] = srcMatchSet[mid].first.getYAstrom() - srcMatchSet[mid].second.getYAstrom()
102 log.debug(
"%s %-30s %8s dx,dy = %5.2f,%5.2f rms_x,y = %5.2f,%5.2f",
103 cell.getLabel(), cell.getBBox(), (
"nobj=%d" % cell.size()),
104 dx.mean(), dy.mean(), dx.std(), dy.std())
109 values[
"minObjectsPerCell"] = int(nobj[0])
110 values[
"maxObjectsPerCell"] = int(nobj[-1])
111 values[
"meanObjectsPerCell"] = nobj.mean()
112 values[
"stdObjectsPerCell"] = nobj.std()
def checkMatches(srcMatchSet, exposure, log=None)