LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Member Functions | Private Member Functions | Private Attributes | List of all members
lsst.afw.math::WarpingControl Class Reference

Parameters to control convolution. More...

#include <warpExposure.h>

Public Member Functions

 WarpingControl (std::string const &warpingKernelName, std::string const &maskWarpingKernelName="", int cacheSize=0, int interpLength=0, lsst::afw::gpu::DevicePreference devicePreference=lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE, lsst::afw::image::MaskPixel growFullMask=0)
 Construct a WarpingControl object. More...
 
 WarpingControl (SeparableKernel &warpingKernel, int interpLength=0, lsst::afw::gpu::DevicePreference devicePreference=lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE)
 This constructor supports the deprecated legacy warping API. More...
 
virtual ~WarpingControl ()
 
int getCacheSize () const
 get the cache size for the interpolation kernel(s) More...
 
void setCacheSize (int cacheSize)
 set the cache size for the interpolation kernel(s) More...
 
int getInterpLength () const
 get the interpolation length (pixels) More...
 
void setInterpLength (int interpLength)
 set the interpolation length More...
 
lsst::afw::gpu::DevicePreference getDevicePreference () const
 get the GPU device preference More...
 
void setDevicePreference (lsst::afw::gpu::DevicePreference devicePreference)
 set the GPU device preference More...
 
boost::shared_ptr
< SeparableKernel
getWarpingKernel () const
 get the warping kernel More...
 
void setWarpingKernelName (std::string const &warpingKernelName)
 set the warping kernel by name More...
 
void setWarpingKernel (SeparableKernel const &warpingKernel)
 set the warping kernel More...
 
boost::shared_ptr
< SeparableKernel
getMaskWarpingKernel () const
 get the mask warping kernel More...
 
bool hasMaskWarpingKernel () const
 return true if there is a mask kernel More...
 
void setMaskWarpingKernelName (std::string const &maskWarpingKernelName)
 set or clear the mask warping kernel by name More...
 
void setMaskWarpingKernel (SeparableKernel const &maskWarpingKernel)
 set the mask warping kernel More...
 
lsst::afw::image::MaskPixel getGrowFullMask () const
 get mask bits to grow to full width of image/variance kernel More...
 
void setGrowFullMask (lsst::afw::image::MaskPixel growFullMask)
 set mask bits to grow to full width of image/variance kernel More...
 

Private Member Functions

void _testWarpingKernels (SeparableKernel const &warpingKernel, SeparableKernel const &maskWarpingKernel) const
 Throw an exception if the two kernels are not compatible in shape. More...
 
void _testDevicePreference (lsst::afw::gpu::DevicePreference const &devicePreference, boost::shared_ptr< SeparableKernel const > const &warpingKernelPtr) const
 test if GPU device preference and main warping kernel are compatible More...
 

Private Attributes

boost::shared_ptr
< SeparableKernel
_warpingKernelPtr
 
boost::shared_ptr
< SeparableKernel
_maskWarpingKernelPtr
 
int _cacheSize
 
int _interpLength
 
lsst::afw::gpu::DevicePreference _devicePreference
 choose CPU or GPU acceleration More...
 
lsst::afw::image::MaskPixel _growFullMask
 

Detailed Description

Parameters to control convolution.

Note
padValue is not member of this class to avoid making this a templated class.
Warning
: GPU acceleration requires interpLength > 0

Definition at line 239 of file warpExposure.h.

Constructor & Destructor Documentation

lsst.afw.math::WarpingControl::WarpingControl ( std::string const &  warpingKernelName,
std::string const &  maskWarpingKernelName = "",
int  cacheSize = 0,
int  interpLength = 0,
lsst::afw::gpu::DevicePreference  devicePreference = lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE,
lsst::afw::image::MaskPixel  growFullMask = 0 
)
inlineexplicit

Construct a WarpingControl object.

Warning
: the GPU code does not yet support warping the mask with a separate kernel. Thus if maskWarpingKernelName is provided the GPU is disabled (or an exception is raised if the GPU is required)
Exceptions
pex_exceptionsInvalidParameterError if the warping kernel is smaller than the mask warping kernel.
pex_exceptionsInvalidParameterError if GPU is required and maskWarpingKernelName supplied.
Parameters
warpingKernelNamename of warping kernel; used as the argument to makeWarpingKernel
maskWarpingKernelNamename of warping kernel used for the mask plane; if "" then the regular warping kernel is used. Intended so one can use a bilinear kernel or other compact kernel for the mask plane to avoid smearing mask bits too far. The theory is that bad pixels are already interpolated over, so we don't need to worry about bad values spreading very far.
cacheSizecache size for warping kernel; no cache if 0 (used as the argument to the warping kernels' computeCache method)
interpLengthdistance over which the WCS can be linearly interpolated
devicePreferenceuse GPU acceleration?
growFullMaskmask bits to grow to full width of image/variance kernel

Definition at line 253 of file warpExposure.h.

268  :
272  _interpLength(interpLength),
273  _devicePreference(devicePreference),
274  _growFullMask(growFullMask)
275  {
276  setMaskWarpingKernelName(maskWarpingKernelName);
278  }
boost::shared_ptr< SeparableKernel > makeWarpingKernel(std::string name)
Return a warping kernel given its name.
boost::shared_ptr< SeparableKernel > _maskWarpingKernelPtr
Definition: warpExposure.h:438
tbl::Key< int > cacheSize
Definition: CoaddPsf.cc:318
boost::shared_ptr< SeparableKernel > _warpingKernelPtr
Definition: warpExposure.h:437
void setMaskWarpingKernelName(std::string const &maskWarpingKernelName)
set or clear the mask warping kernel by name
lsst::afw::gpu::DevicePreference _devicePreference
choose CPU or GPU acceleration
Definition: warpExposure.h:441
void _testDevicePreference(lsst::afw::gpu::DevicePreference const &devicePreference, boost::shared_ptr< SeparableKernel const > const &warpingKernelPtr) const
test if GPU device preference and main warping kernel are compatible
lsst::afw::image::MaskPixel _growFullMask
Definition: warpExposure.h:442
tbl::Key< std::string > warpingKernelName
Definition: CoaddPsf.cc:320
lsst.afw.math::WarpingControl::WarpingControl ( SeparableKernel warpingKernel,
int  interpLength = 0,
lsst::afw::gpu::DevicePreference  devicePreference = lsst::afw::gpu::DEFAULT_DEVICE_PREFERENCE 
)
inlineexplicit

This constructor supports the deprecated legacy warping API.

Parameters
warpingKernelwarping kernel
interpLengthdistance over which the WCS can be linearly interpolated; 0 means no interpolation and uses an optimized branch of the code 1 also performs no interpolation but it runs the interpolation code branch (and so is only intended for unit tests)
devicePreferenceuse GPU acceleration?

Definition at line 283 of file warpExposure.h.

291  :
292  _warpingKernelPtr(boost::dynamic_pointer_cast<SeparableKernel>(warpingKernel.clone())),
294  _cacheSize(warpingKernel.getCacheSize()),
295  _interpLength(interpLength),
296  _devicePreference(devicePreference),
299  {
301  }
boost::shared_ptr< SeparableKernel > _maskWarpingKernelPtr
Definition: warpExposure.h:438
boost::shared_ptr< SeparableKernel > _warpingKernelPtr
Definition: warpExposure.h:437
lsst::afw::gpu::DevicePreference _devicePreference
choose CPU or GPU acceleration
Definition: warpExposure.h:441
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:93
void _testDevicePreference(lsst::afw::gpu::DevicePreference const &devicePreference, boost::shared_ptr< SeparableKernel const > const &warpingKernelPtr) const
test if GPU device preference and main warping kernel are compatible
lsst::afw::image::MaskPixel _growFullMask
Definition: warpExposure.h:442
virtual lsst.afw.math::WarpingControl::~WarpingControl ( )
inlinevirtual

Definition at line 304 of file warpExposure.h.

304 {};

Member Function Documentation

void lsst.afw.math::WarpingControl::_testDevicePreference ( lsst::afw::gpu::DevicePreference const &  devicePreference,
boost::shared_ptr< SeparableKernel const > const &  warpingKernelPtr 
) const
private

test if GPU device preference and main warping kernel are compatible

Exceptions
lsst::pex::exceptions::InvalidParameterErrorif the parameters are incompatible
Parameters
devicePreferenceGPU device preference
warpingKernelPtrwarping kernel

Definition at line 288 of file warpExposure.cc.

291  {
292  CONST_PTR(LanczosWarpingKernel) const lanczosKernelPtr =
293  boost::dynamic_pointer_cast<const LanczosWarpingKernel>(warpingKernelPtr);
294  if (devicePreference == lsst::afw::gpu::USE_GPU && !lanczosKernelPtr) {
295  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
296  "devicePreference = USE_GPU, but warping kernel not Lanczos");
297  }
298 }
#define CONST_PTR(...)
Definition: base.h:47
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
Definition: saturated.cc:47
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void lsst.afw.math::WarpingControl::_testWarpingKernels ( SeparableKernel const &  warpingKernel,
SeparableKernel const &  maskWarpingKernel 
) const
private

Throw an exception if the two kernels are not compatible in shape.

Exceptions
lsst::pex::exceptions::InvalidParameterErrorif the two kernels are not compatible in shape
Parameters
warpingKernelwarping kernel
maskWarpingKernelmask warping kernel

Definition at line 270 of file warpExposure.cc.

273  {
275  lsst::afw::geom::Point2I(0, 0) - lsst::afw::geom::Extent2I(warpingKernel.getCtr()),
276  warpingKernel.getDimensions()
277  );
279  lsst::afw::geom::Point2I(0, 0) - lsst::afw::geom::Extent2I(maskWarpingKernel.getCtr()),
280  maskWarpingKernel.getDimensions()
281  );
282  if (!kernelBBox.contains(maskKernelBBox)) {
283  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
284  "warping kernel is smaller than mask warping kernel");
285  }
286 }
An integer coordinate rectangle.
Definition: Box.h:53
bool contains(Point2I const &point) const
Return true if the box contains the point.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int lsst.afw.math::WarpingControl::getCacheSize ( ) const
inline

get the cache size for the interpolation kernel(s)

Definition at line 309 of file warpExposure.h.

309 { return _cacheSize; };
lsst::afw::gpu::DevicePreference lsst.afw.math::WarpingControl::getDevicePreference ( ) const
inline

get the GPU device preference

Definition at line 343 of file warpExposure.h.

343 { return _devicePreference; };
lsst::afw::gpu::DevicePreference _devicePreference
choose CPU or GPU acceleration
Definition: warpExposure.h:441
lsst::afw::image::MaskPixel lsst.afw.math::WarpingControl::getGrowFullMask ( ) const
inline

get mask bits to grow to full width of image/variance kernel

Definition at line 406 of file warpExposure.h.

406 { return _growFullMask; };
lsst::afw::image::MaskPixel _growFullMask
Definition: warpExposure.h:442
int lsst.afw.math::WarpingControl::getInterpLength ( ) const
inline

get the interpolation length (pixels)

Definition at line 326 of file warpExposure.h.

326 { return _interpLength; };
boost::shared_ptr< afwMath::SeparableKernel > lsst.afw.math::WarpingControl::getMaskWarpingKernel ( ) const

get the mask warping kernel

Definition at line 242 of file warpExposure.cc.

242  {
243  if (_maskWarpingKernelPtr) { // lazily update kernel cache
244  if (_maskWarpingKernelPtr->getCacheSize() != _cacheSize) {
245  _maskWarpingKernelPtr->computeCache(_cacheSize);
246  }
247  }
248  return _maskWarpingKernelPtr;
249 }
boost::shared_ptr< SeparableKernel > _maskWarpingKernelPtr
Definition: warpExposure.h:438
boost::shared_ptr< afwMath::SeparableKernel > lsst.afw.math::WarpingControl::getWarpingKernel ( ) const

get the warping kernel

Definition at line 216 of file warpExposure.cc.

216  {
217  if (_warpingKernelPtr->getCacheSize() != _cacheSize) {
218  _warpingKernelPtr->computeCache(_cacheSize);
219  }
220  return _warpingKernelPtr;
221 };
boost::shared_ptr< SeparableKernel > _warpingKernelPtr
Definition: warpExposure.h:437
bool lsst.afw.math::WarpingControl::hasMaskWarpingKernel ( ) const
inline

return true if there is a mask kernel

Definition at line 384 of file warpExposure.h.

384 { return static_cast<bool>(_maskWarpingKernelPtr); }
boost::shared_ptr< SeparableKernel > _maskWarpingKernelPtr
Definition: warpExposure.h:438
void lsst.afw.math::WarpingControl::setCacheSize ( int  cacheSize)
inline

set the cache size for the interpolation kernel(s)

A value of 0 disables the cache for maximum accuracy. 10,000 typically results in a warping error of a fraction of a count. 100,000 typically results in a warping error of less than 0.01 count. Note the new cache is not computed until getWarpingKernel or getMaskWarpingKernel is called.

Parameters
cacheSizecache size

Definition at line 319 of file warpExposure.h.

321  { _cacheSize = cacheSize; };
tbl::Key< int > cacheSize
Definition: CoaddPsf.cc:318
void lsst.afw.math::WarpingControl::setDevicePreference ( lsst::afw::gpu::DevicePreference  devicePreference)
inline

set the GPU device preference

Parameters
devicePreferencedevice preference

Definition at line 348 of file warpExposure.h.

350  {
351  _testDevicePreference(devicePreference, _warpingKernelPtr);
352  _devicePreference = devicePreference;
353  }
boost::shared_ptr< SeparableKernel > _warpingKernelPtr
Definition: warpExposure.h:437
lsst::afw::gpu::DevicePreference _devicePreference
choose CPU or GPU acceleration
Definition: warpExposure.h:441
void _testDevicePreference(lsst::afw::gpu::DevicePreference const &devicePreference, boost::shared_ptr< SeparableKernel const > const &warpingKernelPtr) const
test if GPU device preference and main warping kernel are compatible
void lsst.afw.math::WarpingControl::setGrowFullMask ( lsst::afw::image::MaskPixel  growFullMask)
inline

set mask bits to grow to full width of image/variance kernel

Parameters
growFullMaskdevice preference

Definition at line 411 of file warpExposure.h.

413  { _growFullMask = growFullMask; }
lsst::afw::image::MaskPixel _growFullMask
Definition: warpExposure.h:442
void lsst.afw.math::WarpingControl::setInterpLength ( int  interpLength)
inline

set the interpolation length

Interpolation length is the distance over which the WCS can be linearly interpolated, in pixels:

  • 0 means no interpolation and uses an optimized branch of the code
  • 1 also performs no interpolation but it runs the interpolation code branch (and so is only intended for unit tests)
Parameters
interpLengthinterpolation length (pixels)

Definition at line 336 of file warpExposure.h.

338  { _interpLength = interpLength; };
void lsst.afw.math::WarpingControl::setMaskWarpingKernel ( SeparableKernel const &  maskWarpingKernel)

set the mask warping kernel

Note
To clear the mask warping kernel use setMaskWarpingKernelName("").
Parameters
maskWarpingKernelmask warping kernel

Definition at line 262 of file warpExposure.cc.

264  {
265  _testWarpingKernels(*_warpingKernelPtr, maskWarpingKernel);
266  _maskWarpingKernelPtr = boost::static_pointer_cast<SeparableKernel>(maskWarpingKernel.clone());
267 }
boost::shared_ptr< SeparableKernel > _maskWarpingKernelPtr
Definition: warpExposure.h:438
boost::shared_ptr< SeparableKernel > _warpingKernelPtr
Definition: warpExposure.h:437
void _testWarpingKernels(SeparableKernel const &warpingKernel, SeparableKernel const &maskWarpingKernel) const
Throw an exception if the two kernels are not compatible in shape.
void lsst.afw.math::WarpingControl::setMaskWarpingKernelName ( std::string const &  maskWarpingKernelName)

set or clear the mask warping kernel by name

Parameters
maskWarpingKernelNamename of mask warping kernel; use "" to clear the kernel

Definition at line 251 of file warpExposure.cc.

253  {
254  if (!maskWarpingKernelName.empty()) {
255  PTR(SeparableKernel) maskWarpingKernelPtr(makeWarpingKernel(maskWarpingKernelName));
256  setMaskWarpingKernel(*maskWarpingKernelPtr);
257  } else {
258  _maskWarpingKernelPtr.reset();
259  }
260 }
#define PTR(...)
Definition: base.h:41
boost::shared_ptr< SeparableKernel > makeWarpingKernel(std::string name)
Return a warping kernel given its name.
boost::shared_ptr< SeparableKernel > _maskWarpingKernelPtr
Definition: warpExposure.h:438
void setMaskWarpingKernel(SeparableKernel const &maskWarpingKernel)
set the mask warping kernel
void lsst.afw.math::WarpingControl::setWarpingKernel ( SeparableKernel const &  warpingKernel)

set the warping kernel

Exceptions
lsst::pex::exceptions::InvalidParameterErrorif new kernel pointer is empty.
Parameters
warpingKernelwarping kernel

Definition at line 230 of file warpExposure.cc.

232  {
233  if (_maskWarpingKernelPtr) {
235  }
236  PTR(SeparableKernel) warpingKernelPtr(boost::static_pointer_cast<SeparableKernel>(warpingKernel.clone()));
237  _testDevicePreference(_devicePreference, warpingKernelPtr);
238  _warpingKernelPtr = warpingKernelPtr;
239 }
#define PTR(...)
Definition: base.h:41
boost::shared_ptr< SeparableKernel > _maskWarpingKernelPtr
Definition: warpExposure.h:438
boost::shared_ptr< SeparableKernel > _warpingKernelPtr
Definition: warpExposure.h:437
lsst::afw::gpu::DevicePreference _devicePreference
choose CPU or GPU acceleration
Definition: warpExposure.h:441
void _testDevicePreference(lsst::afw::gpu::DevicePreference const &devicePreference, boost::shared_ptr< SeparableKernel const > const &warpingKernelPtr) const
test if GPU device preference and main warping kernel are compatible
void _testWarpingKernels(SeparableKernel const &warpingKernel, SeparableKernel const &maskWarpingKernel) const
Throw an exception if the two kernels are not compatible in shape.
void lsst.afw.math::WarpingControl::setWarpingKernelName ( std::string const &  warpingKernelName)

set the warping kernel by name

Parameters
warpingKernelNamename of warping kernel

Definition at line 223 of file warpExposure.cc.

225  {
226  PTR(SeparableKernel) warpingKernelPtr(makeWarpingKernel(warpingKernelName));
227  setWarpingKernel(*warpingKernelPtr);
228 }
void setWarpingKernel(SeparableKernel const &warpingKernel)
set the warping kernel
#define PTR(...)
Definition: base.h:41
boost::shared_ptr< SeparableKernel > makeWarpingKernel(std::string name)
Return a warping kernel given its name.
tbl::Key< std::string > warpingKernelName
Definition: CoaddPsf.cc:320

Member Data Documentation

int lsst.afw.math::WarpingControl::_cacheSize
private

Definition at line 439 of file warpExposure.h.

lsst::afw::gpu::DevicePreference lsst.afw.math::WarpingControl::_devicePreference
private

choose CPU or GPU acceleration

Definition at line 441 of file warpExposure.h.

lsst::afw::image::MaskPixel lsst.afw.math::WarpingControl::_growFullMask
private

Definition at line 442 of file warpExposure.h.

int lsst.afw.math::WarpingControl::_interpLength
private

Definition at line 440 of file warpExposure.h.

boost::shared_ptr< SeparableKernel > lsst.afw.math::WarpingControl::_maskWarpingKernelPtr
private

Definition at line 438 of file warpExposure.h.

boost::shared_ptr< SeparableKernel > lsst.afw.math::WarpingControl::_warpingKernelPtr
private

Definition at line 437 of file warpExposure.h.


The documentation for this class was generated from the following files: