27 __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. 35 @param destWcs: WCS of warped exposure, an lsst.afw.geom.SkyWcs 36 @param srcBBox: parent bounding box of unwarped image 37 @param srcWcs: WCS of unwarped image, an lsst.afw.geom.SkyWcs 39 @return destBBox: bounding box of warped exposure 43 for inX
in (srcPosBox.getMinX(), srcPosBox.getMaxX()):
44 for inY
in (srcPosBox.getMinY(), srcPosBox.getMaxY()):
45 destPos = destWcs.skyToPixel(srcWcs.pixelToSky(inX, inY))
46 destPosBox.include(destPos)
51 _DefaultInterpLength = 10
52 _DefaultCacheSize = 1000000
56 warpingKernelName = pexConfig.ChoiceField(
61 "bilinear":
"bilinear interpolation",
62 "lanczos3":
"Lanczos kernel of order 3",
63 "lanczos4":
"Lanczos kernel of order 4",
64 "lanczos5":
"Lanczos kernel of order 5",
67 maskWarpingKernelName = pexConfig.ChoiceField(
69 doc=
"Warping kernel for mask (use warpingKernelName if '')",
72 "":
"use the regular warping kernel for the mask plane, as well as the image and variance planes",
73 "bilinear":
"bilinear interpolation",
74 "lanczos3":
"Lanczos kernel of order 3",
75 "lanczos4":
"Lanczos kernel of order 4",
76 "lanczos5":
"Lanczos kernel of order 5",
79 interpLength = pexConfig.Field(
81 doc=
"interpLength argument to lsst.afw.math.warpExposure",
82 default=_DefaultInterpLength,
84 cacheSize = pexConfig.Field(
86 doc=
"cacheSize argument to lsst.afw.math.SeparableKernel.computeCache",
87 default=_DefaultCacheSize,
89 growFullMask = pexConfig.Field(
91 doc=
"mask bits to grow to full width of image/variance kernel,",
92 default=afwImage.Mask.getPlaneBitMask(
"EDGE"),
99 ConfigClass = WarperConfig
103 interpLength=_DefaultInterpLength,
104 cacheSize=_DefaultCacheSize,
105 maskWarpingKernelName="",
106 growFullMask=afwImage.Mask.getPlaneBitMask(
"EDGE"),):
110 - warpingKernelName: argument to lsst.afw.math.makeWarpingKernel 111 - interpLength: interpLength argument to lsst.afw.warpExposure 112 - cacheSize: size of computeCache 113 - maskWarpingKernelName: name of mask warping kernel (if "" then use warpingKernelName); 114 an argument to lsst.afw.math.makeWarpingKernel 117 warpingKernelName, maskWarpingKernelName, cacheSize, interpLength, growFullMask)
121 """Create a Warper from a config 123 @param config: an instance of Warper.ConfigClass 126 warpingKernelName=config.warpingKernelName,
127 maskWarpingKernelName=config.maskWarpingKernelName,
128 interpLength=config.interpLength,
129 cacheSize=config.cacheSize,
130 growFullMask=config.growFullMask,
134 """Get the warping kernel""" 138 """Get the mask warping kernel""" 141 def warpExposure(self, destWcs, srcExposure, border=0, maxBBox=None, destBBox=None):
144 @param destWcs: WCS of warped exposure, an lsst.afw.geom.SkyWcs 145 @param srcExposure: exposure to warp 146 @param border: grow bbox of warped exposure by this amount in all directions (int pixels); 147 if negative then the bbox is shrunk; 148 border is applied before maxBBox; 149 ignored if destBBox is not None 150 @param maxBBox: maximum allowed parent bbox of warped exposure (an lsst.geom.Box2I or None); 151 if None then the warped exposure will be just big enough to contain all warped pixels; 152 if provided then the warped exposure may be smaller, and so missing some warped pixels; 153 ignored if destBBox is not None 154 @param destBBox: exact parent bbox of warped exposure (an lsst.geom.Box2I or None); 155 if None then border and maxBBox are used to determine the bbox, 156 otherwise border and maxBBox are ignored 158 @return destExposure: warped exposure (of same type as srcExposure) 160 @note: calls mathLib.warpExposure insted of self.warpImage because the former 161 copies attributes such as Calib, and that should be done in one place 165 srcImage=srcExposure.getMaskedImage(),
166 srcWcs=srcExposure.getWcs(),
171 destExposure = srcExposure.Factory(destBBox, destWcs)
175 def warpImage(self, destWcs, srcImage, srcWcs, border=0, maxBBox=None, destBBox=None):
176 """Warp an image or masked image 178 @param destWcs: WCS of warped image, an lsst.afw.geom.SkyWcs 179 @param srcImage: image or masked image to warp 180 @param srcWcs: WCS of image, an lsst.afw.geom.SkyWcs 181 @param border: grow bbox of warped image by this amount in all directions (int pixels); 182 if negative then the bbox is shrunk; 183 border is applied before maxBBox; 184 ignored if destBBox is not None 185 @param maxBBox: maximum allowed parent bbox of warped image (an lsst.geom.Box2I or None); 186 if None then the warped image will be just big enough to contain all warped pixels; 187 if provided then the warped image may be smaller, and so missing some warped pixels; 188 ignored if destBBox is not None 189 @param destBBox: exact parent bbox of warped image (an lsst.geom.Box2I or None); 190 if None then border and maxBBox are used to determine the bbox, 191 otherwise border and maxBBox are ignored 193 @return destImage: warped image or masked image (of same type as srcImage) 203 destImage = srcImage.Factory(destBBox)
204 mathLib.warpImage(destImage, destWcs, srcImage,
208 def _computeDestBBox(self, destWcs, srcImage, srcWcs, border, maxBBox, destBBox):
209 """Process destBBox argument for warpImage and warpExposure 211 @param destWcs: WCS of warped image, an lsst.afw.geom.SkyWcs 212 @param srcImage: image or masked image to warp 213 @param srcWcs: WCS of image, an lsst.afw.geom.SkyWcs 214 @param border: grow bbox of warped image by this amount in all directions (int pixels); 215 if negative then the bbox is shrunk; 216 border is applied before maxBBox; 217 ignored if destBBox is not None 218 @param maxBBox: maximum allowed parent bbox of warped image (an lsst.geom.Box2I or None); 219 if None then the warped image will be just big enough to contain all warped pixels; 220 if provided then the warped image may be smaller, and so missing some warped pixels; 221 ignored if destBBox is not None 222 @param destBBox: exact parent bbox of warped image (an lsst.geom.Box2I or None); 223 if None then border and maxBBox are used to determine the bbox, 224 otherwise border and maxBBox are ignored 228 destWcs, srcImage.getBBox(afwImage.PARENT), srcWcs)
230 destBBox.grow(border)
231 if maxBBox
is not None:
232 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.