LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
Functions | Variables
lsst.afw.table._match Namespace Reference

Functions

def __repr__ (self)
 
def __str__ (self)
 
def __getitem__ (self, i)
 
def __setitem__ (self, i, val)
 
def __len__ (self)
 
def clone (self)
 
def packMatches (matches)
 

Variables

 clone
 
 matchXy
 
 matchRaDec
 
 first
 
 second
 
 distance
 

Function Documentation

◆ __getitem__()

def lsst.afw.table._match.__getitem__ (   self,
  i 
)
Treat a Match as a tuple of length 3: (first, second, distance)

Definition at line 55 of file _match.py.

55 def __getitem__(self, i): # noqa: N807
56  """Treat a Match as a tuple of length 3: (first, second, distance)"""
57  if i > 2 or i < -3:
58  raise IndexError(i)
59  if i < 0:
60  i += 3
61  if i == 0:
62  return self.first
63  elif i == 1:
64  return self.second
65  else:
66  return self.distance
67 
68 
def __getitem__(self, i)
Definition: _match.py:55

◆ __len__()

def lsst.afw.table._match.__len__ (   self)

Definition at line 83 of file _match.py.

83 def __len__(self): # noqa: N807
84  return 3
85 
86 
def __len__(self)
Definition: _match.py:83

◆ __repr__()

def lsst.afw.table._match.__repr__ (   self)

Definition at line 33 of file _match.py.

33 def __repr__(self): # noqa: N807
34  return "Match(%s,\n %s,\n %g)" % \
35  (repr(self.first), repr(self.second), self.distance)
36 
37 
def __repr__(self)
Definition: _match.py:33

◆ __setitem__()

def lsst.afw.table._match.__setitem__ (   self,
  i,
  val 
)
Treat a Match as a tuple of length 3: (first, second, distance)

Definition at line 69 of file _match.py.

69 def __setitem__(self, i, val): # noqa: N807
70  """Treat a Match as a tuple of length 3: (first, second, distance)"""
71  if i > 2 or i < -3:
72  raise IndexError(i)
73  if i < 0:
74  i += 3
75  if i == 0:
76  self.first = val
77  elif i == 1:
78  self.second = val
79  else:
80  self.distance = val
81 
82 
def __setitem__(self, i, val)
Definition: _match.py:69

◆ __str__()

def lsst.afw.table._match.__str__ (   self)

Definition at line 38 of file _match.py.

38 def __str__(self): # noqa: N807
39  def sourceRaDec(s):
40  if hasattr(s, "getRa") and hasattr(s, "getDec"):
41  return " RA,Dec=(%g,%g) deg" % (s.getRa().asDegrees(), s.getDec().asDegrees())
42  return ""
43 
44  def sourceXy(s):
45  if hasattr(s, "getX") and hasattr(s, "getY"):
46  return " x,y=(%g,%g)" % (s.getX(), s.getY())
47  return ""
48 
49  def sourceStr(s):
50  return s.__class__.__name__ + ("(id %d" % s.getId()) + sourceRaDec(s) + sourceXy(s) + ")"
51 
52  return "Match(%s, %s, dist %g)" % (sourceStr(self.first), sourceStr(self.second), self.distance,)
53 
54 
def __str__(self)
Definition: _match.py:38

◆ clone()

def lsst.afw.table._match.clone (   self)

Definition at line 87 of file _match.py.

87 def clone(self):
88  return self.__class__(self.first, self.second, self.distance)
89 
90 
91 # Pickling support disabled for this type (see testSourceMatch comment for reasoning)
92 # def __getstate__(self):
93 # return self.first, self.second, self.distance
94 #
95 #
96 # def __setstate__(self, state):
97 # self.__init__(*state)
98 
99 

◆ packMatches()

def lsst.afw.table._match.packMatches (   matches)
Make a catalog of matches from a sequence of matches.

The catalog contains three fields:
- first: the ID of the first source record in each match
- second: the ID of the second source record in each match
- distance: the distance of each match

Parameters
----------
matches :
    Sequence of matches, typically of type SimpleMatch,
    ReferenceMatch or SourceMatch.  Each element must support:
    `.first.getId()`->int, `.second.getId()->int` and
    `.distance->float`.

Returns
-------
result :
    The catalog of matches.

Notes
-----
This pure python implementation exists as a historical artifact
related to SWIG limitations. It might be practical to wrap the
overloaded C++ functions with pybind11, but there didn't seem much
point.

Definition at line 111 of file _match.py.

111 def packMatches(matches):
112  """Make a catalog of matches from a sequence of matches.
113 
114  The catalog contains three fields:
115  - first: the ID of the first source record in each match
116  - second: the ID of the second source record in each match
117  - distance: the distance of each match
118 
119  Parameters
120  ----------
121  matches :
122  Sequence of matches, typically of type SimpleMatch,
123  ReferenceMatch or SourceMatch. Each element must support:
124  `.first.getId()`->int, `.second.getId()->int` and
125  `.distance->float`.
126 
127  Returns
128  -------
129  result :
130  The catalog of matches.
131 
132  Notes
133  -----
134  This pure python implementation exists as a historical artifact
135  related to SWIG limitations. It might be practical to wrap the
136  overloaded C++ functions with pybind11, but there didn't seem much
137  point.
138  """
139  schema = Schema()
140  outKey1 = schema.addField("first", type=np.int64,
141  doc="ID for first source record in match.")
142  outKey2 = schema.addField("second", type=np.int64,
143  doc="ID for second source record in match.")
144  keyD = schema.addField("distance", type=np.float64,
145  doc="Distance between matches sources.")
146  result = BaseCatalog(schema)
147  result.table.preallocate(len(matches))
148  for match in matches:
149  record = result.addNew()
150  record.set(outKey1, match.first.getId())
151  record.set(outKey2, match.second.getId())
152  record.set(keyD, match.distance)
153  return result
154 
155 
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71
def packMatches(matches)
Definition: _match.py:111

Variable Documentation

◆ clone

lsst.afw.table._match.clone

Definition at line 106 of file _match.py.

◆ distance

lsst.afw.table._match.distance

Definition at line 80 of file _match.py.

◆ first

lsst.afw.table._match.first

Definition at line 76 of file _match.py.

◆ matchRaDec

lsst.afw.table._match.matchRaDec
Initial value:
2  matchRaDec,
3  reason="Overloads that don't use `MatchControl` are deprecated. To be removed after 20.0.0.")
def deprecate_pybind11(obj, reason, category=FutureWarning)
Definition: deprecated.py:26

Definition at line 159 of file _match.py.

◆ matchXy

lsst.afw.table._match.matchXy
Initial value:
2  matchXy,
3  reason="Overloads that don't use `MatchControl` are deprecated. To be removed after 20.0.0.")
def deprecate_pybind11(obj, reason, category=FutureWarning)
Definition: deprecated.py:26

Definition at line 156 of file _match.py.

◆ second

lsst.afw.table._match.second

Definition at line 78 of file _match.py.