23__all__ = [
"checkMatches"]
32import lsst.meas.algorithms
as measAlg
34_LOG = logging.getLogger(__name__)
38 """Check astrometric matches and assess Wcs quality by computing statics
39 over spacial cells in the image.
44 List of matched sources to a reference catalog.
46 Image the sources
in srcMatchSet were detected/measured
in.
53 Result dictionary
with fields:
55 - ``minObjectsPerCell`` : (`int`)
56 - ``maxObjectsPerCell`` : (`int`)
57 - ``meanObjectsPerCell`` : (`float`)
58 - ``stdObjectsPerCell`` : (`float`)
66 im = exposure.getMaskedImage().getImage()
67 width, height = im.getWidth(), im.getHeight()
69 w, h = width//nx, height//ny
81 cellSet = afwMath.SpatialCellSet(
91 csrc = afwDetection.Source()
93 csrc.setXAstrom(src.getXAstrom())
94 csrc.setYAstrom(src.getYAstrom())
97 cellSet.insertCandidate(measAlg.PsfCandidateF(csrc, exposure.getMaskedImage()))
98 except Exception
as e:
101 ncell = len(cellSet.getCellList())
102 nobj = np.ndarray(ncell, dtype=
'i')
104 for i
in range(ncell):
105 cell = cellSet.getCellList()[i]
107 nobj[i] = cell.size()
109 dx = np.ndarray(cell.size())
110 dy = np.ndarray(cell.size())
118 mid = cand.getSource().getId()
119 dx[j] = srcMatchSet[mid].first.getXAstrom() - srcMatchSet[mid].second.getXAstrom()
120 dy[j] = srcMatchSet[mid].first.getYAstrom() - srcMatchSet[mid].second.getYAstrom()
124 log.debug(
"%s %-30s %8s dx,dy = %5.2f,%5.2f rms_x,y = %5.2f,%5.2f",
125 cell.getLabel(), cell.getBBox(), (
"nobj=%d" % cell.size()),
126 dx.mean(), dy.mean(), dx.std(), dy.std())
131 values[
"minObjectsPerCell"] =
int(nobj[0])
132 values[
"maxObjectsPerCell"] =
int(nobj[-1])
133 values[
"meanObjectsPerCell"] = nobj.mean()
134 values[
"stdObjectsPerCell"] = nobj.std()
def checkMatches(srcMatchSet, exposure, log=None)