LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Functions | Variables
lsst.afw.table.match.matchContinued 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
 
 first
 
 second
 
 distance
 

Function Documentation

◆ __getitem__()

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

Definition at line 52 of file matchContinued.py.

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

◆ __len__()

def lsst.afw.table.match.matchContinued.__len__ (   self)

Definition at line 80 of file matchContinued.py.

80 def __len__(self): # noqa: N807
81  return 3
82 
83 

◆ __repr__()

def lsst.afw.table.match.matchContinued.__repr__ (   self)

Definition at line 30 of file matchContinued.py.

30 def __repr__(self): # noqa: N807
31  return "Match(%s,\n %s,\n %g)" % \
32  (repr(self.first), repr(self.second), self.distance)
33 
34 

◆ __setitem__()

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

Definition at line 66 of file matchContinued.py.

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

◆ __str__()

def lsst.afw.table.match.matchContinued.__str__ (   self)

Definition at line 35 of file matchContinued.py.

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

◆ clone()

def lsst.afw.table.match.matchContinued.clone (   self)

Definition at line 84 of file matchContinued.py.

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

◆ packMatches()

def lsst.afw.table.match.matchContinued.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

@param[in] matches  Sequence of matches, typically of type SimpleMatch, ReferenceMatch or SourceMatch.
    Each element must support: `.first.getId()`->int, `.second.getId()->int` and `.distance->float`.
@return a catalog of matches.

@note this pure python implementation exists because SWIG could not easily be used to wrap
the overloaded C++ functions, so this was written and tested. It might be practical
to wrap the overloaded C++ functions with pybind11, but there didn't seem much point.

Definition at line 108 of file matchContinued.py.

108 def packMatches(matches):
109  """Make a catalog of matches from a sequence of matches.
110 
111  The catalog contains three fields:
112  - first: the ID of the first source record in each match
113  - second: the ID of the second source record in each match
114  - distance: the distance of each match
115 
116  @param[in] matches Sequence of matches, typically of type SimpleMatch, ReferenceMatch or SourceMatch.
117  Each element must support: `.first.getId()`->int, `.second.getId()->int` and `.distance->float`.
118  @return a catalog of matches.
119 
120  @note this pure python implementation exists because SWIG could not easily be used to wrap
121  the overloaded C++ functions, so this was written and tested. It might be practical
122  to wrap the overloaded C++ functions with pybind11, but there didn't seem much point.
123  """
124  schema = Schema()
125  outKey1 = schema.addField("first", type=np.int64,
126  doc="ID for first source record in match.")
127  outKey2 = schema.addField("second", type=np.int64,
128  doc="ID for second source record in match.")
129  keyD = schema.addField("distance", type=np.float64,
130  doc="Distance between matches sources.")
131  result = BaseCatalog(schema)
132  result.table.preallocate(len(matches))
133  for match in matches:
134  record = result.addNew()
135  record.set(outKey1, match.first.getId())
136  record.set(outKey2, match.second.getId())
137  record.set(keyD, match.distance)
138  return result
139 
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71

Variable Documentation

◆ clone

lsst.afw.table.match.matchContinued.clone

Definition at line 103 of file matchContinued.py.

◆ distance

lsst.afw.table.match.matchContinued.distance

Definition at line 77 of file matchContinued.py.

◆ first

lsst.afw.table.match.matchContinued.first

Definition at line 73 of file matchContinued.py.

◆ second

lsst.afw.table.match.matchContinued.second

Definition at line 75 of file matchContinued.py.