1 from __future__
import absolute_import, division, print_function
2 from builtins
import object
29 __all__ = [
"Warper",
"WarperConfig"]
33 """Compute the bounding box of a warped image 35 The bounding box includes all warped pixels and it may be a bit oversize. 37 @param destWcs: WCS of warped exposure, an lsst.afw.geom.SkyWcs 38 @param srcBBox: parent bounding box of unwarped image 39 @param srcWcs: WCS of unwarped image, an lsst.afw.geom.SkyWcs 41 @return destBBox: bounding box of warped exposure 45 for inX
in (srcPosBox.getMinX(), srcPosBox.getMaxX()):
46 for inY
in (srcPosBox.getMinY(), srcPosBox.getMaxY()):
47 destPos = destWcs.skyToPixel(srcWcs.pixelToSky(inX, inY))
48 destPosBox.include(destPos)
53 _DefaultInterpLength = 10
54 _DefaultCacheSize = 1000000
58 warpingKernelName = pexConfig.ChoiceField(
63 "bilinear":
"bilinear interpolation",
64 "lanczos3":
"Lanczos kernel of order 3",
65 "lanczos4":
"Lanczos kernel of order 4",
66 "lanczos5":
"Lanczos kernel of order 5",
69 maskWarpingKernelName = pexConfig.ChoiceField(
71 doc=
"Warping kernel for mask (use warpingKernelName if '')",
74 "":
"use the regular warping kernel for the mask plane, as well as the image and variance planes",
75 "bilinear":
"bilinear interpolation",
76 "lanczos3":
"Lanczos kernel of order 3",
77 "lanczos4":
"Lanczos kernel of order 4",
78 "lanczos5":
"Lanczos kernel of order 5",
81 interpLength = pexConfig.Field(
83 doc=
"interpLength argument to lsst.afw.math.warpExposure",
84 default=_DefaultInterpLength,
86 cacheSize = pexConfig.Field(
88 doc=
"cacheSize argument to lsst.afw.math.SeparableKernel.computeCache",
89 default=_DefaultCacheSize,
91 growFullMask = pexConfig.Field(
93 doc=
"mask bits to grow to full width of image/variance kernel,",
94 default=afwImage.Mask.getPlaneBitMask(
"EDGE"),
101 ConfigClass = WarperConfig
105 interpLength=_DefaultInterpLength,
106 cacheSize=_DefaultCacheSize,
107 maskWarpingKernelName="",
108 growFullMask=afwImage.Mask.getPlaneBitMask(
"EDGE"),):
112 - warpingKernelName: argument to lsst.afw.math.makeWarpingKernel 113 - interpLength: interpLength argument to lsst.afw.warpExposure 114 - cacheSize: size of computeCache 115 - maskWarpingKernelName: name of mask warping kernel (if "" then use warpingKernelName); 116 an argument to lsst.afw.math.makeWarpingKernel 119 warpingKernelName, maskWarpingKernelName, cacheSize, interpLength, growFullMask)
123 """Create a Warper from a config 125 @param config: an instance of Warper.ConfigClass 128 warpingKernelName=config.warpingKernelName,
129 maskWarpingKernelName=config.maskWarpingKernelName,
130 interpLength=config.interpLength,
131 cacheSize=config.cacheSize,
132 growFullMask=config.growFullMask,
136 """Get the warping kernel""" 140 """Get the mask warping kernel""" 143 def warpExposure(self, destWcs, srcExposure, border=0, maxBBox=None, destBBox=None):
146 @param destWcs: WCS of warped exposure, an lsst.afw.geom.SkyWcs 147 @param srcExposure: exposure to warp 148 @param border: grow bbox of warped exposure by this amount in all directions (int pixels); 149 if negative then the bbox is shrunk; 150 border is applied before maxBBox; 151 ignored if destBBox is not None 152 @param maxBBox: maximum allowed parent bbox of warped exposure (an afwGeom.Box2I or None); 153 if None then the warped exposure will be just big enough to contain all warped pixels; 154 if provided then the warped exposure may be smaller, and so missing some warped pixels; 155 ignored if destBBox is not None 156 @param destBBox: exact parent bbox of warped exposure (an afwGeom.Box2I or None); 157 if None then border and maxBBox are used to determine the bbox, 158 otherwise border and maxBBox are ignored 160 @return destExposure: warped exposure (of same type as srcExposure) 162 @note: calls mathLib.warpExposure insted of self.warpImage because the former 163 copies attributes such as Calib, and that should be done in one place 167 srcImage=srcExposure.getMaskedImage(),
168 srcWcs=srcExposure.getWcs(),
173 destExposure = srcExposure.Factory(destBBox, destWcs)
177 def warpImage(self, destWcs, srcImage, srcWcs, border=0, maxBBox=None, destBBox=None):
178 """Warp an image or masked image 180 @param destWcs: WCS of warped image, an lsst.afw.geom.SkyWcs 181 @param srcImage: image or masked image to warp 182 @param srcWcs: WCS of image, an lsst.afw.geom.SkyWcs 183 @param border: grow bbox of warped image by this amount in all directions (int pixels); 184 if negative then the bbox is shrunk; 185 border is applied before maxBBox; 186 ignored if destBBox is not None 187 @param maxBBox: maximum allowed parent bbox of warped image (an afwGeom.Box2I or None); 188 if None then the warped image will be just big enough to contain all warped pixels; 189 if provided then the warped image may be smaller, and so missing some warped pixels; 190 ignored if destBBox is not None 191 @param destBBox: exact parent bbox of warped image (an afwGeom.Box2I or None); 192 if None then border and maxBBox are used to determine the bbox, 193 otherwise border and maxBBox are ignored 195 @return destImage: warped image or masked image (of same type as srcImage) 205 destImage = srcImage.Factory(destBBox)
206 mathLib.warpImage(destImage, destWcs, srcImage,
210 def _computeDestBBox(self, destWcs, srcImage, srcWcs, border, maxBBox, destBBox):
211 """Process destBBox argument for warpImage and warpExposure 213 @param destWcs: WCS of warped image, an lsst.afw.geom.SkyWcs 214 @param srcImage: image or masked image to warp 215 @param srcWcs: WCS of image, an lsst.afw.geom.SkyWcs 216 @param border: grow bbox of warped image by this amount in all directions (int pixels); 217 if negative then the bbox is shrunk; 218 border is applied before maxBBox; 219 ignored if destBBox is not None 220 @param maxBBox: maximum allowed parent bbox of warped image (an afwGeom.Box2I or None); 221 if None then the warped image will be just big enough to contain all warped pixels; 222 if provided then the warped image may be smaller, and so missing some warped pixels; 223 ignored if destBBox is not None 224 @param destBBox: exact parent bbox of warped image (an afwGeom.Box2I or None); 225 if None then border and maxBBox are used to determine the bbox, 226 otherwise border and maxBBox are ignored 230 destWcs, srcImage.getBBox(afwImage.PARENT), srcWcs)
232 destBBox.grow(border)
233 if maxBBox
is not None:
234 destBBox.clip(maxBBox)
def _computeDestBBox(self, destWcs, srcImage, srcWcs, border, maxBBox, destBBox)
def getMaskWarpingKernel(self)
def warpExposure(self, destWcs, srcExposure, border=0, maxBBox=None, destBBox=None)
def computeWarpedBBox(destWcs, srcBBox, srcWcs)
An integer coordinate rectangle.
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)
A floating-point coordinate rectangle geometry.