LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+bd2ed33bd6,g1470d8bcf6+de7501a2e0,g14a832a312+ff425fae3c,g2079a07aa2+86d27d4dc4,g2305ad1205+91a32aca49,g295015adf3+762506a1ad,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+c34e8be1fa,g487adcacf7+5fae3daba8,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ea1711114f,g5a732f18d5+53520f316c,g64a986408d+bd2ed33bd6,g858d7b2824+bd2ed33bd6,g8a8a8dda67+585e252eca,g99cad8db69+016a06b37a,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+09e12c87ab,gc120e1dc64+bc2e06c061,gc28159a63d+0e5473021a,gcf0d15dbbd+c34e8be1fa,gdaeeff99f8+f9a426f77a,ge6526c86ff+508d0e0a30,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+8d59551888,gf1cff7945b+bd2ed33bd6,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Functions | Variables
lsst.afw.table._match Namespace Reference

Functions

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

Variables

 clone
 
 first
 
 second
 
 distance
 

Function Documentation

◆ __getitem__()

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

Definition at line 53 of file _match.py.

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

◆ __len__()

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

Definition at line 81 of file _match.py.

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

◆ __repr__()

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

Definition at line 31 of file _match.py.

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

◆ __setitem__()

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

Definition at line 67 of file _match.py.

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

◆ __str__()

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

Definition at line 36 of file _match.py.

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

◆ clone()

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

Definition at line 85 of file _match.py.

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

◆ packMatches()

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 109 of file _match.py.

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

Variable Documentation

◆ clone

lsst.afw.table._match.clone

Definition at line 104 of file _match.py.

◆ distance

lsst.afw.table._match.distance

Definition at line 33 of file _match.py.

◆ first

lsst.afw.table._match.first

Definition at line 33 of file _match.py.

◆ second

lsst.afw.table._match.second

Definition at line 33 of file _match.py.