LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
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 32 of file verifyWcs.py.

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