22 __all__ = [
"Warper",
"WarperConfig"]
31 """Compute the bounding box of a warped image. 33 The bounding box includes all warped pixels and it may be a bit oversize. 37 destWcs : `lsst.afw.geom.SkyWcs` 38 WCS of warped exposure 39 srcBBox : `lsst.geom.Box2I` 40 parent bounding box of unwarped image 41 srcWcs : `lsst.afw.geom.SkyWcs` 46 destBBox: `lsst.geom.Box2I` 47 bounding box of warped exposure 51 for inX
in (srcPosBox.getMinX(), srcPosBox.getMaxX()):
52 for inY
in (srcPosBox.getMinY(), srcPosBox.getMaxY()):
53 destPos = destWcs.skyToPixel(srcWcs.pixelToSky(inX, inY))
54 destPosBox.include(destPos)
59 _DefaultInterpLength = 10
60 _DefaultCacheSize = 1000000
64 warpingKernelName = pexConfig.ChoiceField(
69 "bilinear":
"bilinear interpolation",
70 "lanczos3":
"Lanczos kernel of order 3",
71 "lanczos4":
"Lanczos kernel of order 4",
72 "lanczos5":
"Lanczos kernel of order 5",
75 maskWarpingKernelName = pexConfig.ChoiceField(
77 doc=
"Warping kernel for mask (use ``warpingKernelName`` if '')",
80 "":
"use the regular warping kernel for the mask plane, as well as the image and variance planes",
81 "bilinear":
"bilinear interpolation",
82 "lanczos3":
"Lanczos kernel of order 3",
83 "lanczos4":
"Lanczos kernel of order 4",
84 "lanczos5":
"Lanczos kernel of order 5",
87 interpLength = pexConfig.Field(
89 doc=
"``interpLength`` argument to `lsst.afw.math.warpExposure`",
90 default=_DefaultInterpLength,
92 cacheSize = pexConfig.Field(
94 doc=
"``cacheSize`` argument to `lsst.afw.math.SeparableKernel.computeCache`",
95 default=_DefaultCacheSize,
97 growFullMask = pexConfig.Field(
99 doc=
"mask bits to grow to full width of image/variance kernel,",
100 default=afwImage.Mask.getPlaneBitMask(
"EDGE"),
109 warpingKernelName : `str` 110 see `WarperConfig.warpingKernelName` 111 interpLength : `int`, optional 112 ``interpLength`` argument to `lsst.afw.math.warpExposure` 113 cacheSize : `int`, optional 115 maskWarpingKernelName : `str`, optional 116 name of mask warping kernel (if ``""`` then use ``warpingKernelName``); 117 see `WarperConfig.maskWarpingKernelName` 118 growFullMask : `int`, optional 119 mask bits to grow to full width of image/variance kernel 121 ConfigClass = WarperConfig
125 interpLength=_DefaultInterpLength,
126 cacheSize=_DefaultCacheSize,
127 maskWarpingKernelName="",
128 growFullMask=afwImage.Mask.getPlaneBitMask(
"EDGE"),):
130 warpingKernelName, maskWarpingKernelName, cacheSize, interpLength, growFullMask)
134 """Create a Warper from a config. 138 config : `WarperConfig` 139 The config to initialize the Warper with. 142 warpingKernelName=config.warpingKernelName,
143 maskWarpingKernelName=config.maskWarpingKernelName,
144 interpLength=config.interpLength,
145 cacheSize=config.cacheSize,
146 growFullMask=config.growFullMask,
150 """Get the warping kernel. 155 """Get the mask warping kernel. 159 def warpExposure(self, destWcs, srcExposure, border=0, maxBBox=None, destBBox=None):
164 destWcs : `lsst.afw.geom.SkyWcs` 165 WCS of warped exposure 168 border : `int`, optional 169 grow bbox of warped exposure by this amount in all directions 170 (in pixels); if negative then the bbox is shrunk; border is applied 171 before ``maxBBox``; ignored if ``destBBox`` is not `None` 172 maxBBox : `lsst.geom.Box2I`, optional 173 maximum allowed parent bbox of warped exposure; if `None` then the 174 warped exposure will be just big enough to contain all warped pixels; 175 if provided then the warped exposure may be smaller, and so 176 missing some warped pixels; ignored if ``destBBox`` is not `None` 177 destBBox : `lsst.geom.Box2I`, optional 178 exact parent bbox of warped exposure; if `None` then ``border`` and 179 ``maxBBox`` are used to determine the bbox, otherwise ``border`` 180 and ``maxBBox`` are ignored 184 destExposure : same type as ``srcExposure`` 189 calls `lsst.afw.math.warpExposure` insted of `~Warper.warpImage` because the former 190 copies attributes such as ``Calib``, and that should be done in one place 194 srcImage=srcExposure.getMaskedImage(),
195 srcWcs=srcExposure.getWcs(),
200 destExposure = srcExposure.Factory(destBBox, destWcs)
204 def warpImage(self, destWcs, srcImage, srcWcs, border=0, maxBBox=None, destBBox=None):
205 """Warp an image or masked image. 209 destWcs : `lsst.afw.geom.SkyWcs` 212 image or masked image to warp 213 srcWcs : `lsst.afw.geom.SkyWcs` 215 border : `int`, optional 216 grow bbox of warped image by this amount in all directions 217 (in pixels); if negative then the bbox is shrunk; border is applied 218 before ``maxBBox``; ignored if ``destBBox`` is not `None` 219 maxBBox : `lsst.geom.Box2I`, optional 220 maximum allowed parent bbox of warped image; if `None` then the 221 warped image will be just big enough to contain all warped pixels; 222 if provided then the warped image may be smaller, and so 223 missing some warped pixels; ignored if ``destBBox`` is not `None` 224 destBBox : `lsst.geom.Box2I`, optional 225 exact parent bbox of warped image; if `None` then ``border`` and 226 ``maxBBox`` are used to determine the bbox, otherwise ``border`` 227 and ``maxBBox`` are ignored 231 destImage : same type as ``srcExposure`` 232 warped image or masked image 242 destImage = srcImage.Factory(destBBox)
243 mathLib.warpImage(destImage, destWcs, srcImage,
247 def _computeDestBBox(self, destWcs, srcImage, srcWcs, border, maxBBox, destBBox):
248 """Process destBBox argument for warpImage and warpExposure. 252 destWcs : `lsst.afw.geom.SkyWcs` 255 image or masked image to warp 256 srcWcs : `lsst.afw.geom.SkyWcs` 258 border : `int`, optional 259 grow bbox of warped image by this amount in all directions 260 (in pixels); if negative then the bbox is shrunk; border is applied 261 before ``maxBBox``; ignored if ``destBBox`` is not `None` 262 maxBBox : `lsst.geom.Box2I`, optional 263 maximum allowed parent bbox of warped image; if `None` then the 264 warped image will be just big enough to contain all warped pixels; 265 if provided then the warped image may be smaller, and so 266 missing some warped pixels; ignored if ``destBBox`` is not `None` 267 destBBox : `lsst.geom.Box2I`, optional 268 exact parent bbox of warped image; if `None` then ``border`` and 269 ``maxBBox`` are used to determine the bbox, otherwise ``border`` 270 and ``maxBBox`` are ignored 274 destWcs, srcImage.getBBox(afwImage.PARENT), srcWcs)
276 destBBox.grow(border)
277 if maxBBox
is not None:
278 destBBox.clip(maxBBox)
def _computeDestBBox(self, destWcs, srcImage, srcWcs, border, maxBBox, destBBox)
A floating-point coordinate rectangle geometry.
def getMaskWarpingKernel(self)
def warpExposure(self, destWcs, srcExposure, border=0, maxBBox=None, destBBox=None)
def computeWarpedBBox(destWcs, srcBBox, srcWcs)
def getWarpingKernel(self)
def __init__(self, warpingKernelName, interpLength=_DefaultInterpLength, cacheSize=_DefaultCacheSize, maskWarpingKernelName="", growFullMask=afwImage.Mask.getPlaneBitMask("EDGE"))
def warpImage(self, destWcs, srcImage, srcWcs, border=0, maxBBox=None, destBBox=None)
def fromConfig(cls, config)
An integer coordinate rectangle.