LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+f5613e8b4f,g1470d8bcf6+190ad2ba91,g14a832a312+311607e4ab,g2079a07aa2+86d27d4dc4,g2305ad1205+a8e3196225,g295015adf3+b67ee847e5,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+a761f810f3,g487adcacf7+17c8fdbcbd,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+65b5bd823e,g5a732f18d5+53520f316c,g64a986408d+f5613e8b4f,g6c1bc301e9+51106c2951,g858d7b2824+f5613e8b4f,g8a8a8dda67+585e252eca,g99cad8db69+6729933424,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e9bba80f27,gc120e1dc64+eee469a5e5,gc28159a63d+0e5473021a,gcf0d15dbbd+a761f810f3,gdaeeff99f8+f9a426f77a,ge6526c86ff+d4c1d4bfef,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf1cff7945b+f5613e8b4f,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Functions
lsst.meas.astrom.sip.genDistortedImage Namespace Reference

Functions

 noDistort (src)
 
 linearXDistort (src, frac=.001)
 
 quadraticDistortX (src, frac=1e-6)
 
 cubicDistortX (src, frac=1e-9)
 
 manyTermX (src, frac=1e-9)
 
 linearYDistort (src, frac=.001)
 
 quadraticDistortY (src, frac=1e-6)
 
 cubicDistortY (src, frac=1e-9)
 
 manyTermY (src, frac=1e-9)
 
 crossTerms1 (src, frac=1e-11)
 
 crossTerms2 (src, frac=1e-11)
 
 crossTerms3 (src, frac=1e-9)
 
 quadraticDistort (src, frac=1e-6)
 
 T2DistortX (src, frac=1e-6)
 
 distortList (srcList, function)
 

Function Documentation

◆ crossTerms1()

lsst.meas.astrom.sip.genDistortedImage.crossTerms1 ( src,
frac = 1e-11 )
Distort image Y by X, leaving X unchanged, 'x**3 - 2*x**2'.

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change Y by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of Y changed

Definition at line 255 of file genDistortedImage.py.

255def crossTerms1(src, frac=1e-11):
256 """Distort image Y by X, leaving X unchanged, 'x**3 - 2*x**2'.
257
258 Parameters
259 ----------
260 src : `lsst.afw.table.SourceRecord`
261 A Source object
262 frac : `float`
263 How much to change Y by
264
265 Returns
266 -------
267 out : `lsst.afw.table.SourceRecord`
268 A deep copy of src, with the value of Y changed
269 """
270 out = src.table.copyRecord(src)
271 x = out.getX()
272 y = out.getY()
273 val = x**3 - 2*x**2 # + 4*x - 9
274
275 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x)
276 out.set(out.table.getCentroidSlot().getMeasKey().getY(), y + val*frac)
277 return out
278
279

◆ crossTerms2()

lsst.meas.astrom.sip.genDistortedImage.crossTerms2 ( src,
frac = 1e-11 )
Distort image X by Y, leaving Y unchanged, 'y**3 - 2*y**2 + 4*y - 9'.

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change X by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of X changed

Definition at line 280 of file genDistortedImage.py.

280def crossTerms2(src, frac=1e-11):
281 """Distort image X by Y, leaving Y unchanged, 'y**3 - 2*y**2 + 4*y - 9'.
282
283 Parameters
284 ----------
285 src : `lsst.afw.table.SourceRecord`
286 A Source object
287 frac : `float`
288 How much to change X by
289
290 Returns
291 -------
292 out : `lsst.afw.table.SourceRecord`
293 A deep copy of src, with the value of X changed
294 """
295 out = src.table.copyRecord(src)
296 x = out.getX()
297 y = out.getY()
298 val = y**3 - 2*y**2 + 4*y - 9
299
300 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x + val*frac)
301 out.set(out.table.getCentroidSlot().getMeasKey().getY(), y)
302 return out
303
304

◆ crossTerms3()

lsst.meas.astrom.sip.genDistortedImage.crossTerms3 ( src,
frac = 1e-9 )
Distort image X and Y , 'dx=x**3 - 2*x**2 + 4*x - 9',
'dy=y**3 - 2*y**2 + 4*y - 9'.

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change X and Y by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of X and Y changed

Definition at line 305 of file genDistortedImage.py.

305def crossTerms3(src, frac=1e-9):
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'.
308
309 Parameters
310 ----------
311 src : `lsst.afw.table.SourceRecord`
312 A Source object
313 frac : `float`
314 How much to change X and Y by
315
316 Returns
317 -------
318 out : `lsst.afw.table.SourceRecord`
319 A deep copy of src, with the value of X and Y changed
320 """
321 out = src.table.copyRecord(src)
322 x = out.getX()
323 y = out.getY()
324 valx = x**3 - 2*x**2 + 4*x - 9
325 valy = y**3 - 2*y**2 + 4*y - 9
326
327 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x + valy*frac)
328 out.set(out.table.getCentroidSlot().getMeasKey().getY(), y + valx*frac)
329 return out
330
331

◆ cubicDistortX()

lsst.meas.astrom.sip.genDistortedImage.cubicDistortX ( src,
frac = 1e-9 )
Distort image by terms with power <=2
i.e y, y^2, x, xy, x^2

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change X by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of x changed

Definition at line 101 of file genDistortedImage.py.

101def cubicDistortX(src, frac=1e-9):
102 """Distort image by terms with power <=2
103 i.e y, y^2, x, xy, x^2
104
105 Parameters
106 ----------
107 src : `lsst.afw.table.SourceRecord`
108 A Source object
109 frac : `float`
110 How much to change X by
111
112 Returns
113 -------
114 out : `lsst.afw.table.SourceRecord`
115 A deep copy of src, with the value of x changed
116 """
117
118 out = src.table.copyRecord(src)
119 x = out.getX()
120 y = out.getY()
121 val = x**3
122
123 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x + val*frac)
124 out.set(out.table.getCentroidSlot().getMeasKey().getY(), y)
125 return out
126
127

◆ cubicDistortY()

lsst.meas.astrom.sip.genDistortedImage.cubicDistortY ( src,
frac = 1e-9 )
Distort image by terms with power <=2
i.e y, y^2, x, xy, x^2

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change Y by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of Y changed

Definition at line 203 of file genDistortedImage.py.

203def cubicDistortY(src, frac=1e-9):
204 """Distort image by terms with power <=2
205 i.e y, y^2, x, xy, x^2
206
207 Parameters
208 ----------
209 src : `lsst.afw.table.SourceRecord`
210 A Source object
211 frac : `float`
212 How much to change Y by
213
214 Returns
215 -------
216 out : `lsst.afw.table.SourceRecord`
217 A deep copy of src, with the value of Y changed
218 """
219
220 out = src.table.copyRecord(src)
221 x = out.getX()
222 y = out.getY()
223 val = x**3
224
225 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x)
226 out.set(out.table.getCentroidSlot().getMeasKey().getY(), y + val*frac)
227 return out
228
229

◆ distortList()

lsst.meas.astrom.sip.genDistortedImage.distortList ( srcList,
function )
Create a copy of srcList, and apply function to distort the
values of x and y.

Parameters
----------
srcList : `list` of `lsst.afw.table.SourceRecord`
    Input list of source to distort.
function : `callable`
    A function that does a deep copy of a single Source

Returns
-------
out : `lsst.afw.table.SourceCatalog`
    Output catalog with distorted positions.

Definition at line 384 of file genDistortedImage.py.

384def distortList(srcList, function):
385 """Create a copy of srcList, and apply function to distort the
386 values of x and y.
387
388 Parameters
389 ----------
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
394
395 Returns
396 -------
397 out : `lsst.afw.table.SourceCatalog`
398 Output catalog with distorted positions.
399 """
400
401 out = afwTable.SourceCatalog(srcList.table)
402 out.reserve(len(srcList))
403
404 for src in srcList:
405 out.append(function(src))
406
407 maxDiff = 0
408 for i in range(len(srcList)):
409 s = srcList[i]
410 o = out[i]
411
412 x1, y1 = s.getX(), s.getY()
413 x2, y2 = o.getX(), o.getY()
414
415 diff = math.hypot(x1-x2, y1-y2)
416 maxDiff = max(diff, maxDiff)
417
418 print("Max deviation is %e pixels" % (maxDiff))
419
420 return out
int max

◆ linearXDistort()

lsst.meas.astrom.sip.genDistortedImage.linearXDistort ( src,
frac = .001 )
Increase the x value in a Source object by frac. E.g
src.x = 1000 --> 1001 if frac=.001

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change X by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of x changed

Definition at line 52 of file genDistortedImage.py.

52def linearXDistort(src, frac=.001):
53 """Increase the x value in a Source object by frac. E.g
54 src.x = 1000 --> 1001 if frac=.001
55
56 Parameters
57 ----------
58 src : `lsst.afw.table.SourceRecord`
59 A Source object
60 frac : `float`
61 How much to change X by
62
63 Returns
64 -------
65 out : `lsst.afw.table.SourceRecord`
66 A deep copy of src, with the value of x changed
67 """
68
69 out = src.table.copyRecord(src)
70 out.set(out.table.getCentroidSlot().getMeasKey().getX(), out.getX()*(1+frac))
71 return out
72
73

◆ linearYDistort()

lsst.meas.astrom.sip.genDistortedImage.linearYDistort ( src,
frac = .001 )
Increase the y value in a Source object by frac. E.g
src.x = 1000 --> 1001 if frac=.001

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change Y by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of Y changed

Definition at line 154 of file genDistortedImage.py.

154def linearYDistort(src, frac=.001):
155 """Increase the y value in a Source object by frac. E.g
156 src.x = 1000 --> 1001 if frac=.001
157
158 Parameters
159 ----------
160 src : `lsst.afw.table.SourceRecord`
161 A Source object
162 frac : `float`
163 How much to change Y by
164
165 Returns
166 -------
167 out : `lsst.afw.table.SourceRecord`
168 A deep copy of src, with the value of Y changed
169 """
170
171 out = src.table.copyRecord(src)
172 out.set(out.table.getCentroidSlot().getMeasKey().getY(), out.getY()*(1+frac))
173 return out
174
175

◆ manyTermX()

lsst.meas.astrom.sip.genDistortedImage.manyTermX ( src,
frac = 1e-9 )
Distort image by multiple powers of x, 'x**3 - 2*x**2 + 4*x - 9'.

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change X by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of x changed

Definition at line 128 of file genDistortedImage.py.

128def manyTermX(src, frac=1e-9):
129 """Distort image by multiple powers of x, 'x**3 - 2*x**2 + 4*x - 9'.
130
131 Parameters
132 ----------
133 src : `lsst.afw.table.SourceRecord`
134 A Source object
135 frac : `float`
136 How much to change X by
137
138 Returns
139 -------
140 out : `lsst.afw.table.SourceRecord`
141 A deep copy of src, with the value of x changed
142 """
143
144 out = src.table.copyRecord(src)
145 x = out.getX()
146 y = out.getY()
147 val = x**3 - 2*x**2 + 4*x - 9
148
149 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x + val*frac)
150 out.set(out.table.getCentroidSlot().getMeasKey().getY(), y)
151 return out
152
153

◆ manyTermY()

lsst.meas.astrom.sip.genDistortedImage.manyTermY ( src,
frac = 1e-9 )
Distort image by multiple terms of Y, 'y**3 - 2*y**2 + 4*y - 9'.

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change Y by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of Y changed

Definition at line 230 of file genDistortedImage.py.

230def manyTermY(src, frac=1e-9):
231 """Distort image by multiple terms of Y, 'y**3 - 2*y**2 + 4*y - 9'.
232
233 Parameters
234 ----------
235 src : `lsst.afw.table.SourceRecord`
236 A Source object
237 frac : `float`
238 How much to change Y by
239
240 Returns
241 -------
242 out : `lsst.afw.table.SourceRecord`
243 A deep copy of src, with the value of Y changed
244 """
245 out = src.table.copyRecord(src)
246 x = out.getX()
247 y = out.getY()
248 val = y**3 - 2*y**2 + 4*y - 9
249
250 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x)
251 out.set(out.table.getCentroidSlot().getMeasKey().getY(), y + val*frac)
252 return out
253
254

◆ noDistort()

lsst.meas.astrom.sip.genDistortedImage.noDistort ( src)
Do no distortion. Used for sanity checking

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    Input record

Returns
-------
out : `lsst.afw.table.SourceRecord`
    Copy of input record.

Definition at line 34 of file genDistortedImage.py.

34def noDistort(src):
35 """Do no distortion. Used for sanity checking
36
37 Parameters
38 ----------
39 src : `lsst.afw.table.SourceRecord`
40 Input record
41
42 Returns
43 -------
44 out : `lsst.afw.table.SourceRecord`
45 Copy of input record.
46 """
47
48 out = src.table.copyRecord(src)
49 return out
50
51

◆ quadraticDistort()

lsst.meas.astrom.sip.genDistortedImage.quadraticDistort ( src,
frac = 1e-6 )
Distort image by terms with power <=2
i.e y, y^2, x, xy, x^2

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change X

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of X

Definition at line 332 of file genDistortedImage.py.

332def quadraticDistort(src, frac=1e-6):
333 """Distort image by terms with power <=2
334 i.e y, y^2, x, xy, x^2
335
336 Parameters
337 ----------
338 src : `lsst.afw.table.SourceRecord`
339 A Source object
340 frac : `float`
341 How much to change X
342
343 Returns
344 -------
345 out : `lsst.afw.table.SourceRecord`
346 A deep copy of src, with the value of X
347 """
348
349 out = src.table.copyRecord(src)
350 x = out.getX()
351 y = out.getY()
352 val = y + 2*y**2
353 val += 3*x + 4*x*y
354 val += x**2
355
356 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x + val*frac)
357 out.set(out.table.getCentroidSlot().getMeasKey().getY(), y)
358 return out
359
360

◆ quadraticDistortX()

lsst.meas.astrom.sip.genDistortedImage.quadraticDistortX ( src,
frac = 1e-6 )
Distort image by terms with power <=2
i.e y, y^2, x, xy, x^2

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change X by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of x changed

Definition at line 74 of file genDistortedImage.py.

74def quadraticDistortX(src, frac=1e-6):
75 """Distort image by terms with power <=2
76 i.e y, y^2, x, xy, x^2
77
78 Parameters
79 ----------
80 src : `lsst.afw.table.SourceRecord`
81 A Source object
82 frac : `float`
83 How much to change X by
84
85 Returns
86 -------
87 out : `lsst.afw.table.SourceRecord`
88 A deep copy of src, with the value of x changed
89 """
90
91 out = src.table.copyRecord(src)
92 x = out.getX()
93 y = out.getY()
94 val = x**2
95
96 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x + val*frac)
97 out.set(out.table.getCentroidSlot().getMeasKey().getY(), y)
98 return out
99
100

◆ quadraticDistortY()

lsst.meas.astrom.sip.genDistortedImage.quadraticDistortY ( src,
frac = 1e-6 )
Distort image by terms with power <=2
i.e y, y^2, x, xy, x^2

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change Y by

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of Y changed

Definition at line 176 of file genDistortedImage.py.

176def quadraticDistortY(src, frac=1e-6):
177 """Distort image by terms with power <=2
178 i.e y, y^2, x, xy, x^2
179
180 Parameters
181 ----------
182 src : `lsst.afw.table.SourceRecord`
183 A Source object
184 frac : `float`
185 How much to change Y by
186
187 Returns
188 -------
189 out : `lsst.afw.table.SourceRecord`
190 A deep copy of src, with the value of Y changed
191 """
192
193 out = src.table.copyRecord(src)
194 x = out.getX()
195 y = out.getY()
196 val = y**2
197
198 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x)
199 out.set(out.table.getCentroidSlot().getMeasKey().getY(), y + val*frac)
200 return out
201
202

◆ T2DistortX()

lsst.meas.astrom.sip.genDistortedImage.T2DistortX ( src,
frac = 1e-6 )
Distort image by a 2nd order Cheby polynomial

Parameters
----------
src : `lsst.afw.table.SourceRecord`
    A Source object
frac : `float`
    How much to change X

Returns
-------
out : `lsst.afw.table.SourceRecord`
    A deep copy of src, with the value of X

Definition at line 361 of file genDistortedImage.py.

361def T2DistortX(src, frac=1e-6):
362 """Distort image by a 2nd order Cheby polynomial
363
364 Parameters
365 ----------
366 src : `lsst.afw.table.SourceRecord`
367 A Source object
368 frac : `float`
369 How much to change X
370
371 Returns
372 -------
373 out : `lsst.afw.table.SourceRecord`
374 A deep copy of src, with the value of X
375 """
376
377 out = src.table.copyRecord(src)
378 x = src.getX()
379 val = 2*(x**2) - 1
380 out.set(out.table.getCentroidSlot().getMeasKey().getX(), x + frac*val)
381 return out
382
383