23 __all__ = [
"checkMatches"]
 
   36     """Check astrometric matches and assess Wcs quality by computing statics 
   37     over spacial cells in the image. 
   41     srcMatchSet : `list` of `lsst.afw.table.ReferenceMatch` 
   42         List of matched sources to a reference catalog. 
   43     exposure : `lsst.afw.image.Exposure` 
   44         Image the sources in srcMatchSet were detected/measured in. 
   51         Result dictionary with fields: 
   53         - ``minObjectsPerCell`` : (`int`) 
   54         - ``maxObjectsPerCell`` : (`int`) 
   55         - ``meanObjectsPerCell`` : (`float`) 
   56         - ``stdObjectsPerCell`` : (`float`) 
   62         log = Log.getLogger(
"meas.astrom.verifyWcs.checkMatches")
 
   64     im = exposure.getMaskedImage().getImage()
 
   65     width, height = im.getWidth(), im.getHeight()
 
   67     w, h = width//nx, height//ny
 
   89         csrc = afwDetection.Source()
 
   91         csrc.setXAstrom(src.getXAstrom())
 
   92         csrc.setYAstrom(src.getYAstrom())
 
   95             cellSet.insertCandidate(measAlg.PsfCandidateF(csrc, exposure.getMaskedImage()))
 
   96         except Exception 
as e:
 
   99     ncell = len(cellSet.getCellList())
 
  100     nobj = np.ndarray(ncell, dtype=
'i')
 
  102     for i 
in range(ncell):
 
  103         cell = cellSet.getCellList()[i]
 
  105         nobj[i] = cell.size()
 
  107         dx = np.ndarray(cell.size())
 
  108         dy = np.ndarray(cell.size())
 
  116             mid = cand.getSource().getId()
 
  117             dx[j] = srcMatchSet[mid].first.getXAstrom() - srcMatchSet[mid].second.getXAstrom()
 
  118             dy[j] = srcMatchSet[mid].first.getYAstrom() - srcMatchSet[mid].second.getYAstrom()
 
  122         log.debug(
"%s %-30s  %8s  dx,dy = %5.2f,%5.2f  rms_x,y = %5.2f,%5.2f",
 
  123                   cell.getLabel(), cell.getBBox(), (
"nobj=%d" % cell.size()),
 
  124                   dx.mean(), dy.mean(), dx.std(), dy.std())
 
  129     values[
"minObjectsPerCell"] = int(nobj[0])  
 
  130     values[
"maxObjectsPerCell"] = int(nobj[-1])
 
  131     values[
"meanObjectsPerCell"] = nobj.mean()
 
  132     values[
"stdObjectsPerCell"] = nobj.std()