LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
sourceMatchStatistics.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2008, 2009, 2010 LSST Corporation.
4 #
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the LSST License Statement and
19 # the GNU General Public License along with this program. If not,
20 # see <http://www.lsstcorp.org/LegalNotices/>.
21 #
22 
23 
24 import numpy as np
25 
26 
27 def sourceMatchStatistics(matchList, log=None):
28  """ Compute statistics on the accuracy of a wcs solution, using a precomputed list
29  of matches between an image and a catalogue
30 
31  Input:
32  matchList is a lsst::afw::detection::SourceMatch object
33 
34  Output:
35  A dictionary storing the following quanities
36  meanOfDiffInPixels Average distance between image and catalogue position (in pixels)
37  rmsOfDiffInPixels Root mean square of distribution of distances
38  quartilesOfDiffInPixels An array of 5 values giving the boundaries of the quartiles of the
39  distribution.
40  """
41 
42  size = len(matchList)
43  if size == 0:
44  raise ValueError("matchList contains no elements")
45 
46  dist = np.zeros(size)
47  i = 0
48  for match in matchList:
49  catObj = match.first
50  srcObj = match.second
51 
52  cx = catObj.getXAstrom()
53  cy = catObj.getYAstrom()
54 
55  sx = srcObj.getXAstrom()
56  sy = srcObj.getYAstrom()
57 
58  dist[i] = np.hypot(cx-sx, cy-sy)
59  i = i+1
60 
61  dist.sort()
62 
63  quartiles = []
64  for f in (0.25, 0.50, 0.75):
65  i = int(f*size + 0.5)
66  if i >= size:
67  i = size - 1
68  quartiles.append(dist[i])
69 
70  values = {}
71  values['diffInPixels_Q25'] = quartiles[0]
72  values['diffInPixels_Q50'] = quartiles[1]
73  values['diffInPixels_Q75'] = quartiles[2]
74  values['diffInPixels_mean'] = dist.mean()
75  values['diffInPixels_std'] = dist.std()
76 
77  return values