LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Functions
lsst.meas.astrom.verifyWcs Namespace Reference

Functions

def checkMatches
 

Function Documentation

def lsst.meas.astrom.verifyWcs.checkMatches (   srcMatchSet,
  exposure,
  log = None 
)

Definition at line 30 of file verifyWcs.py.

30 
31 def checkMatches(srcMatchSet, exposure, log=None):
32  if not exposure:
33  return {}
34 
35  im = exposure.getMaskedImage().getImage()
36  width, height = im.getWidth(), im.getHeight()
37  nx, ny = 3, 3
38  w, h = width//nx, height//ny
39 
40  if w == 0:
41  w = 1
42  while nx*w < width:
43  w += 1
44 
45  if h == 0:
46  h = 1
47  while ny*h < height:
48  h += 1
49 
50  cellSet = afwMath.SpatialCellSet(
51  afwGeom.Box2I(afwGeom.Point2I(0, 0), afwGeom.Extent2I(width, height)), w, h)
52  #
53  # Populate cellSet
54  #
55  i = -1
56  for m in srcMatchSet:
57  i += 1
58 
59  src = m.second
60  csrc = afwDetection.Source()
61  csrc.setId(i)
62  csrc.setXAstrom(src.getXAstrom())
63  csrc.setYAstrom(src.getYAstrom())
64 
65  try:
66  cellSet.insertCandidate(measAlg.PsfCandidateF(csrc, exposure.getMaskedImage()))
67  except Exception, e:
68  log.log(log.WARN, str(e))
69 
70  ncell = len(cellSet.getCellList())
71  nobj = numpy.ndarray(ncell, dtype='i')
72 
73  for i in range(ncell):
74  cell = cellSet.getCellList()[i]
75 
76  nobj[i] = cell.size()
77 
78  dx = numpy.ndarray(cell.size())
79  dy = numpy.ndarray(cell.size())
80 
81  j = 0
82  for cand in cell:
83  #
84  # Swig doesn't know that we're a SpatialCellImageCandidate; all it knows is that we have
85  # a SpatialCellCandidate so we need an explicit (dynamic) cast
86  #
87  cand = measAlg.cast_PsfCandidateF(cand)
88 
89  mid = cand.getSource().getId()
90  dx[j] = srcMatchSet[mid].first.getXAstrom() - srcMatchSet[mid].second.getXAstrom()
91  dy[j] = srcMatchSet[mid].first.getYAstrom() - srcMatchSet[mid].second.getYAstrom()
92 
93  j += 1
94 
95  if log:
96  log.log(log.DEBUG, "%s %-30s %8s dx,dy = %5.2f,%5.2f rms_x,y = %5.2f,%5.2f" % \
97  (cell.getLabel(), cell.getBBox(), ("nobj=%d" % cell.size()),
98  dx.mean(), dy.mean(), dx.std(), dy.std()))
99 
100 
101  nobj.sort()
102 
103  values = {}
104  values["minObjectsPerCell"] = int(nobj[0]) # otherwise it's a numpy integral type
105  values["maxObjectsPerCell"] = int(nobj[-1])
106  values["meanObjectsPerCell"] = nobj.mean()
107  values["stdObjectsPerCell"] = nobj.std()
108 
109  return values
An integer coordinate rectangle.
Definition: Box.h:53
A collection of SpatialCells covering an entire image.
Definition: SpatialCell.h:378