LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
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