98def compute_approx_psf_size_and_shape(ccd_row, ra, dec, nx=20, ny=20, orderx=2, ordery=2):
99 """Compute the approximate psf size and shape.
101 This routine fits how the psf size and shape varies over a field by approximating
102 with a Chebyshev bounded field.
106 ccd_row : `lsst.afw.table.ExposureRecord`
107 Exposure metadata for a given detector exposure.
109 Right ascension of points to compute size and shape (degrees).
111 Declination of points to compute size and shape (degrees).
113 Number of sampling points in the x direction.
115 Number of sampling points in the y direction.
116 orderx : `int`, optional
117 Chebyshev polynomial order for fit in x direction.
118 ordery : `int`, optional
119 Chebyshev polynomial order for fit in y direction.
123 psf_array : `np.ndarray`
124 Record array with "psf_size", "psf_e1", "psf_e2".
127 r, d
in zip(ra, dec)]
128 pixels = ccd_row.getWcs().skyToPixel(pts)
133 ctrl.triangular =
False
135 bbox = ccd_row.getBBox()
136 xSteps = np.linspace(bbox.getMinX(), bbox.getMaxX(), nx)
137 ySteps = np.linspace(bbox.getMinY(), bbox.getMaxY(), ny)
138 x = np.tile(xSteps, nx)
139 y = np.repeat(ySteps, ny)
141 psf_size = np.zeros(x.size)
142 psf_e1 = np.zeros(x.size)
143 psf_e2 = np.zeros(x.size)
144 psf_area = np.zeros(x.size)
146 psf = ccd_row.getPsf()
147 for i
in range(x.size):
149 psf_size[i] = shape.getDeterminantRadius()
154 psf_e1[i] = (ixx - iyy)/(ixx + iyy + 2.*psf_size[i]**2.)
155 psf_e2[i] = (2.*ixy)/(ixx + iyy + 2.*psf_size[i]**2.)
158 psf_area[i] = np.sum(im.array)/np.sum(im.array**2.)
160 pixel_x = np.array([pix.getX()
for pix
in pixels])
161 pixel_y = np.array([pix.getY()
for pix
in pixels])
163 psf_array = np.zeros(pixel_x.size, dtype=[(
"psf_size",
"f8"),
168 cheb_size = ChebyshevBoundedField.fit(
lsst.geom.Box2I(bbox), x, y, psf_size, ctrl)
169 psf_array[
"psf_size"] = cheb_size.evaluate(pixel_x, pixel_y)
170 cheb_e1 = ChebyshevBoundedField.fit(
lsst.geom.Box2I(bbox), x, y, psf_e1, ctrl)
171 psf_array[
"psf_e1"] = cheb_e1.evaluate(pixel_x, pixel_y)
172 cheb_e2 = ChebyshevBoundedField.fit(
lsst.geom.Box2I(bbox), x, y, psf_e2, ctrl)
173 psf_array[
"psf_e2"] = cheb_e2.evaluate(pixel_x, pixel_y)
174 cheb_area = ChebyshevBoundedField.fit(
lsst.geom.Box2I(bbox), x, y, psf_area, ctrl)
175 psf_array[
"psf_area"] = cheb_area.evaluate(pixel_x, pixel_y)