23 __all__ = [
"noDistort",
"linearXDistort",
"quadraticDistortX",
24 "cubicDistortX",
"manyTermX",
"crossTerms1",
25 "crossTerms2",
"crossTerms3",
"quadraticDistort",
26 "T2DistortX",
"T2DistortX"]
35 """Do no distortion. Used for sanity checking
39 src : `lsst.afw.table.SourceRecord`
44 out : `lsst.afw.table.SourceRecord`
48 out = src.table.copyRecord(src)
53 """Increase the x value in a Source object by frac. E.g
54 src.x = 1000 --> 1001 if frac=.001
58 src : `lsst.afw.table.SourceRecord`
61 How much to change X by
65 out : `lsst.afw.table.SourceRecord`
66 A deep copy of src, with the value of x changed
69 out = src.table.copyRecord(src)
70 out.set(out.table.getCentroidKey().getX(), out.getX()*(1+frac))
75 """Distort image by terms with power <=2
76 i.e y, y^2, x, xy, x^2
80 src : `lsst.afw.table.SourceRecord`
83 How much to change X by
87 out : `lsst.afw.table.SourceRecord`
88 A deep copy of src, with the value of x changed
91 out = src.table.copyRecord(src)
96 out.set(out.table.getCentroidKey().getX(), x + val*frac)
97 out.set(out.table.getCentroidKey().getY(), y)
102 """Distort image by terms with power <=2
103 i.e y, y^2, x, xy, x^2
107 src : `lsst.afw.table.SourceRecord`
110 How much to change X by
114 out : `lsst.afw.table.SourceRecord`
115 A deep copy of src, with the value of x changed
118 out = src.table.copyRecord(src)
123 out.set(out.table.getCentroidKey().getX(), x + val*frac)
124 out.set(out.table.getCentroidKey().getY(), y)
129 """Distort image by multiple powers of x, 'x**3 - 2*x**2 + 4*x - 9'.
133 src : `lsst.afw.table.SourceRecord`
136 How much to change X by
140 out : `lsst.afw.table.SourceRecord`
141 A deep copy of src, with the value of x changed
144 out = src.table.copyRecord(src)
147 val = x**3 - 2*x**2 + 4*x - 9
149 out.set(out.table.getCentroidKey().getX(), x + val*frac)
150 out.set(out.table.getCentroidKey().getY(), y)
155 """Increase the y value in a Source object by frac. E.g
156 src.x = 1000 --> 1001 if frac=.001
160 src : `lsst.afw.table.SourceRecord`
163 How much to change Y by
167 out : `lsst.afw.table.SourceRecord`
168 A deep copy of src, with the value of Y changed
171 out = src.table.copyRecord(src)
172 out.set(out.table.getCentroidKey().getY(), out.getY()*(1+frac))
177 """Distort image by terms with power <=2
178 i.e y, y^2, x, xy, x^2
182 src : `lsst.afw.table.SourceRecord`
185 How much to change Y by
189 out : `lsst.afw.table.SourceRecord`
190 A deep copy of src, with the value of Y changed
193 out = src.table.copyRecord(src)
198 out.set(out.table.getCentroidKey().getX(), x)
199 out.set(out.table.getCentroidKey().getY(), y + val*frac)
204 """Distort image by terms with power <=2
205 i.e y, y^2, x, xy, x^2
209 src : `lsst.afw.table.SourceRecord`
212 How much to change Y by
216 out : `lsst.afw.table.SourceRecord`
217 A deep copy of src, with the value of Y changed
220 out = src.table.copyRecord(src)
225 out.set(out.table.getCentroidKey().getX(), x)
226 out.set(out.table.getCentroidKey().getY(), y + val*frac)
231 """Distort image by multiple terms of Y, 'y**3 - 2*y**2 + 4*y - 9'.
235 src : `lsst.afw.table.SourceRecord`
238 How much to change Y by
242 out : `lsst.afw.table.SourceRecord`
243 A deep copy of src, with the value of Y changed
245 out = src.table.copyRecord(src)
248 val = y**3 - 2*y**2 + 4*y - 9
250 out.set(out.table.getCentroidKey().getX(), x)
251 out.set(out.table.getCentroidKey().getY(), y + val*frac)
256 """Distort image Y by X, leaving X unchanged, 'x**3 - 2*x**2'.
260 src : `lsst.afw.table.SourceRecord`
263 How much to change Y by
267 out : `lsst.afw.table.SourceRecord`
268 A deep copy of src, with the value of Y changed
270 out = src.table.copyRecord(src)
275 out.set(out.table.getCentroidKey().getX(), x)
276 out.set(out.table.getCentroidKey().getY(), y + val*frac)
281 """Distort image X by Y, leaving Y unchanged, 'y**3 - 2*y**2 + 4*y - 9'.
285 src : `lsst.afw.table.SourceRecord`
288 How much to change X by
292 out : `lsst.afw.table.SourceRecord`
293 A deep copy of src, with the value of X changed
295 out = src.table.copyRecord(src)
298 val = y**3 - 2*y**2 + 4*y - 9
300 out.set(out.table.getCentroidKey().getX(), x + val*frac)
301 out.set(out.table.getCentroidKey().getY(), y)
306 """Distort image X and Y , 'dx=x**3 - 2*x**2 + 4*x - 9',
307 'dy=y**3 - 2*y**2 + 4*y - 9'.
311 src : `lsst.afw.table.SourceRecord`
314 How much to change X and Y by
318 out : `lsst.afw.table.SourceRecord`
319 A deep copy of src, with the value of X and Y changed
321 out = src.table.copyRecord(src)
324 valx = x**3 - 2*x**2 + 4*x - 9
325 valy = y**3 - 2*y**2 + 4*y - 9
327 out.set(out.table.getCentroidKey().getX(), x + valy*frac)
328 out.set(out.table.getCentroidKey().getY(), y + valx*frac)
333 """Distort image by terms with power <=2
334 i.e y, y^2, x, xy, x^2
338 src : `lsst.afw.table.SourceRecord`
345 out : `lsst.afw.table.SourceRecord`
346 A deep copy of src, with the value of X
349 out = src.table.copyRecord(src)
356 out.set(out.table.getCentroidKey().getX(), x + val*frac)
357 out.set(out.table.getCentroidKey().getY(), y)
362 """Distort image by a 2nd order Cheby polynomial
366 src : `lsst.afw.table.SourceRecord`
373 out : `lsst.afw.table.SourceRecord`
374 A deep copy of src, with the value of X
377 out = src.table.copyRecord(src)
380 out.set(out.table.getCentroidKey().getX(), x + frac*val)
385 """Create a copy of srcList, and apply function to distort the
390 srcList : `list` of `lsst.afw.table.SourceRecord`
391 Input list of source to distort.
392 function : `callable`
393 A function that does a deep copy of a single Source
397 out : `lsst.afw.table.SourceCatalog`
398 Output catalog with distorted positions.
402 out.reserve(len(srcList))
408 for i
in range(len(srcList)):
412 x1, y1 = s.getX(), s.getY()
413 x2, y2 = o.getX(), o.getY()
415 diff = math.hypot(x1-x2, y1-y2)
416 maxDiff =
max(diff, maxDiff)
418 print(
"Max deviation is %e pixels" % (maxDiff))