22 __all__ = [
"Warper",
"WarperConfig"]
27 from .warpExposure
import warpImage
28 from .warpExposure
import WarpingControl
29 from .warpExposure
import warpExposure
33 """Compute the bounding box of a warped image.
35 The bounding box includes all warped pixels and it may be a bit oversize.
39 destWcs : `lsst.afw.geom.SkyWcs`
40 WCS of warped exposure
41 srcBBox : `lsst.geom.Box2I`
42 parent bounding box of unwarped image
43 srcWcs : `lsst.afw.geom.SkyWcs`
48 destBBox: `lsst.geom.Box2I`
49 bounding box of warped exposure
53 for inX
in (srcPosBox.getMinX(), srcPosBox.getMaxX()):
54 for inY
in (srcPosBox.getMinY(), srcPosBox.getMaxY()):
55 destPos = destWcs.skyToPixel(srcWcs.pixelToSky(inX, inY))
56 destPosBox.include(destPos)
61 _DefaultInterpLength = 10
62 _DefaultCacheSize = 1000000
66 warpingKernelName = pexConfig.ChoiceField(
71 "bilinear":
"bilinear interpolation",
72 "lanczos3":
"Lanczos kernel of order 3",
73 "lanczos4":
"Lanczos kernel of order 4",
74 "lanczos5":
"Lanczos kernel of order 5",
77 maskWarpingKernelName = pexConfig.ChoiceField(
79 doc=
"Warping kernel for mask (use ``warpingKernelName`` if '')",
82 "":
"use the regular warping kernel for the mask plane, as well as the image and variance planes",
83 "bilinear":
"bilinear interpolation",
84 "lanczos3":
"Lanczos kernel of order 3",
85 "lanczos4":
"Lanczos kernel of order 4",
86 "lanczos5":
"Lanczos kernel of order 5",
89 interpLength = pexConfig.Field(
91 doc=
"``interpLength`` argument to `lsst.afw.math.warpExposure`",
92 default=_DefaultInterpLength,
94 cacheSize = pexConfig.Field(
96 doc=
"``cacheSize`` argument to `lsst.afw.math.SeparableKernel.computeCache`",
97 default=_DefaultCacheSize,
99 growFullMask = pexConfig.Field(
101 doc=
"mask bits to grow to full width of image/variance kernel,",
102 default=afwImage.Mask.getPlaneBitMask(
"EDGE"),
111 warpingKernelName : `str`
112 see `WarperConfig.warpingKernelName`
113 interpLength : `int`, optional
114 ``interpLength`` argument to `lsst.afw.math.warpExposure`
115 cacheSize : `int`, optional
117 maskWarpingKernelName : `str`, optional
118 name of mask warping kernel (if ``""`` then use ``warpingKernelName``);
119 see `WarperConfig.maskWarpingKernelName`
120 growFullMask : `int`, optional
121 mask bits to grow to full width of image/variance kernel
123 ConfigClass = WarperConfig
127 interpLength=_DefaultInterpLength,
128 cacheSize=_DefaultCacheSize,
129 maskWarpingKernelName="",
130 growFullMask=afwImage.Mask.getPlaneBitMask(
"EDGE"),):
132 warpingKernelName, maskWarpingKernelName, cacheSize, interpLength, growFullMask)
136 """Create a Warper from a config.
140 config : `WarperConfig`
141 The config to initialize the Warper with.
144 warpingKernelName=config.warpingKernelName,
145 maskWarpingKernelName=config.maskWarpingKernelName,
146 interpLength=config.interpLength,
147 cacheSize=config.cacheSize,
148 growFullMask=config.growFullMask,
152 """Get the warping kernel.
157 """Get the mask warping kernel.
161 def warpExposure(self, destWcs, srcExposure, border=0, maxBBox=None, destBBox=None):
166 destWcs : `lsst.afw.geom.SkyWcs`
167 WCS of warped exposure
170 border : `int`, optional
171 grow bbox of warped exposure by this amount in all directions
172 (in pixels); if negative then the bbox is shrunk; border is applied
173 before ``maxBBox``; ignored if ``destBBox`` is not `None`
174 maxBBox : `lsst.geom.Box2I`, optional
175 maximum allowed parent bbox of warped exposure; if `None` then the
176 warped exposure will be just big enough to contain all warped pixels;
177 if provided then the warped exposure may be smaller, and so
178 missing some warped pixels; ignored if ``destBBox`` is not `None`
179 destBBox : `lsst.geom.Box2I`, optional
180 exact parent bbox of warped exposure; if `None` then ``border`` and
181 ``maxBBox`` are used to determine the bbox, otherwise ``border``
182 and ``maxBBox`` are ignored
186 destExposure : same type as ``srcExposure``
191 calls `lsst.afw.math.warpExposure` insted of `~Warper.warpImage` because the former
192 copies attributes such as ``Calib``, and that should be done in one place
194 The PSF is not warped. To warp the PSF, use `lsst.meas.algorithms.WarpedPsf`
198 srcImage=srcExposure.getMaskedImage(),
199 srcWcs=srcExposure.getWcs(),
204 destExposure = srcExposure.Factory(destBBox, destWcs)
208 def warpImage(self, destWcs, srcImage, srcWcs, border=0, maxBBox=None, destBBox=None):
209 """Warp an image or masked image.
213 destWcs : `lsst.afw.geom.SkyWcs`
216 image or masked image to warp
217 srcWcs : `lsst.afw.geom.SkyWcs`
219 border : `int`, optional
220 grow bbox of warped image by this amount in all directions
221 (in pixels); if negative then the bbox is shrunk; border is applied
222 before ``maxBBox``; ignored if ``destBBox`` is not `None`
223 maxBBox : `lsst.geom.Box2I`, optional
224 maximum allowed parent bbox of warped image; if `None` then the
225 warped image will be just big enough to contain all warped pixels;
226 if provided then the warped image may be smaller, and so
227 missing some warped pixels; ignored if ``destBBox`` is not `None`
228 destBBox : `lsst.geom.Box2I`, optional
229 exact parent bbox of warped image; if `None` then ``border`` and
230 ``maxBBox`` are used to determine the bbox, otherwise ``border``
231 and ``maxBBox`` are ignored
235 destImage : same type as ``srcExposure``
236 warped image or masked image
246 destImage = srcImage.Factory(destBBox)
251 def _computeDestBBox(self, destWcs, srcImage, srcWcs, border, maxBBox, destBBox):
252 """Process destBBox argument for warpImage and warpExposure.
256 destWcs : `lsst.afw.geom.SkyWcs`
259 image or masked image to warp
260 srcWcs : `lsst.afw.geom.SkyWcs`
262 border : `int`, optional
263 grow bbox of warped image by this amount in all directions
264 (in pixels); if negative then the bbox is shrunk; border is applied
265 before ``maxBBox``; ignored if ``destBBox`` is not `None`
266 maxBBox : `lsst.geom.Box2I`, optional
267 maximum allowed parent bbox of warped image; if `None` then the
268 warped image will be just big enough to contain all warped pixels;
269 if provided then the warped image may be smaller, and so
270 missing some warped pixels; ignored if ``destBBox`` is not `None`
271 destBBox : `lsst.geom.Box2I`, optional
272 exact parent bbox of warped image; if `None` then ``border`` and
273 ``maxBBox`` are used to determine the bbox, otherwise ``border``
274 and ``maxBBox`` are ignored
278 destWcs, srcImage.getBBox(afwImage.PARENT), srcWcs)
280 destBBox.grow(border)
281 if maxBBox
is not None:
282 destBBox.clip(maxBBox)
def __init__(self, warpingKernelName, interpLength=_DefaultInterpLength, cacheSize=_DefaultCacheSize, maskWarpingKernelName="", growFullMask=afwImage.Mask.getPlaneBitMask("EDGE"))
def _computeDestBBox(self, destWcs, srcImage, srcWcs, border, maxBBox, destBBox)
def getMaskWarpingKernel(self)
def warpExposure(self, destWcs, srcExposure, border=0, maxBBox=None, destBBox=None)
def getWarpingKernel(self)
def fromConfig(cls, config)
def warpImage(self, destWcs, srcImage, srcWcs, border=0, maxBBox=None, destBBox=None)
A floating-point coordinate rectangle geometry.
An integer coordinate rectangle.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
def computeWarpedBBox(destWcs, srcBBox, srcWcs)