LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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