LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
lsst::afw::math Namespace Reference

Namespaces

namespace  _background
 
namespace  _backgroundList
 
namespace  _chebyshevBoundedField
 
namespace  _chebyshevBoundedFieldConfig
 
namespace  _spatialCell
 
namespace  _warper
 
namespace  detail
 
namespace  details
 

Classes

class  AnalyticKernel
 A kernel described by a function. More...
 
class  Approximate
 Approximate values for a MaskedImage. More...
 
class  ApproximateControl
 Control how to make an approximation. More...
 
class  Background
 A virtual base class to evaluate image background levels. More...
 
class  BackgroundControl
 Pass parameters to a Background object. More...
 
class  BackgroundMI
 A class to evaluate image background levels. More...
 
class  BasePolynomialFunction2
 Base class for 2-dimensional polynomials of the form: More...
 
class  BilinearWarpingKernel
 Bilinear warping: fast; good for undersampled data. More...
 
class  BoundedField
 An abstract base class for 2-d functions defined on an integer bounding boxes. More...
 
class  CandidateVisitor
 
class  Chebyshev1Function1
 1-dimensional weighted sum of Chebyshev polynomials of the first kind. More...
 
class  Chebyshev1Function2
 2-dimensional weighted sum of Chebyshev polynomials of the first kind. More...
 
class  ChebyshevBoundedField
 A BoundedField based on 2-d Chebyshev polynomials of the first kind. More...
 
class  ChebyshevBoundedFieldControl
 A control object used when fitting ChebyshevBoundedField to data (see ChebyshevBoundedField::fit) More...
 
class  ConvolutionControl
 Parameters to control convolution. More...
 
class  Covariogram
 The parent class of covariogram functions for use in Gaussian Process interpolation. More...
 
struct  deltafunction_kernel_tag
 Kernel has only one non-zero pixel. More...
 
class  DeltaFunctionKernel
 A kernel that has only one non-zero pixel (of value 1) More...
 
class  DoubleGaussianFunction2
 double Guassian (sum of two Gaussians) More...
 
struct  FitResults
 Results from minimizing a function. More...
 
class  FixedKernel
 A kernel created from an Image. More...
 
class  Function
 Basic Function class. More...
 
class  Function1
 A Function taking one argument. More...
 
class  Function2
 A Function taking two arguments. More...
 
class  GaussianFunction1
 1-dimensional Gaussian More...
 
class  GaussianFunction2
 2-dimensional Gaussian More...
 
class  GaussianProcess
 Stores values of a function sampled on an image and allows you to interpolate the function to unsampled points. More...
 
class  GaussianProcessTimer
 This is a structure for keeping track of how long the interpolation methods spend on different parts of the interpolation. More...
 
struct  generic_kernel_tag
 Tags carrying information about Kernels Kernel with no special properties. More...
 
class  ImageImposter
 A vector wrapper to provide a vector with the necessary methods and typedefs to be processed by Statistics as though it were an Image. More...
 
class  infinite_iterator
 This iterator will never increment. More...
 
class  IntegerDeltaFunction1
 1-dimensional integer delta function. More...
 
class  IntegerDeltaFunction2
 2-dimensional integer delta function. More...
 
class  Interpolate
 
class  InterpolateConstant
 
class  InterpolateGsl
 
struct  IntRegion
 
struct  is_analyticKernel
 traits class to determine if a Kernel is represented as an analytic function More...
 
struct  is_analyticKernel< AnalyticKernel >
 
struct  is_analyticKernel< KernelT * >
 
struct  is_analyticKernel< std::shared_ptr< KernelT > >
 
class  KdTree
 The data for GaussianProcess is stored in a KD tree to facilitate nearest-neighbor searches. More...
 
class  Kernel
 Kernels are used for convolution with MaskedImages and (eventually) Images. More...
 
struct  kernel_traits
 template trait class with information about Kernels More...
 
class  LanczosFunction1
 1-dimensional Lanczos function More...
 
class  LanczosFunction2
 2-dimensional separable Lanczos function More...
 
class  LanczosWarpingKernel
 Lanczos warping: accurate but slow and can introduce ringing artifacts. More...
 
class  LeastSquares
 Solver for linear least-squares problems. More...
 
class  LinearCombinationKernel
 A kernel that is a linear combination of fixed basis kernels. More...
 
class  MaskedVector
 
class  MaskImposter
 A Mask wrapper to provide an infinite_iterator for Mask::row_begin(). More...
 
class  NearestWarpingKernel
 Nearest neighbor warping: fast; good for undersampled data. More...
 
class  NeuralNetCovariogram
 a Covariogram that recreates a neural network with one hidden layer and infinite units in that layer More...
 
class  NullFunction1
 a class used in function calls to indicate that no Function1 is being provided More...
 
class  NullFunction2
 a class used in function calls to indicate that no Function2 is being provided More...
 
class  PixelAreaBoundedField
 A BoundedField that evaluate the pixel area of a SkyWcs in angular units. More...
 
class  PolynomialFunction1
 1-dimensional polynomial function. More...
 
class  PolynomialFunction2
 2-dimensional polynomial function with cross terms More...
 
class  ProductBoundedField
 A BoundedField that lazily multiplies a sequence of other BoundedFields. More...
 
class  Random
 A class that can be used to generate sequences of random numbers according to a number of different algorithms. More...
 
class  SeparableKernel
 A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y) More...
 
class  SpatialCell
 Class to ensure constraints for spatial modeling. More...
 
class  SpatialCellCandidate
 Base class for candidate objects in a SpatialCell. More...
 
class  SpatialCellCandidateIterator
 An iterator that only returns usable members of the SpatialCell. More...
 
class  SpatialCellImageCandidate
 Base class for candidate objects in a SpatialCell that are able to return an Image of some sort (e.g. More...
 
class  SpatialCellSet
 A collection of SpatialCells covering an entire image. More...
 
class  SquaredExpCovariogram
 SquaredExpCovariogram. More...
 
class  Statistics
 A class to evaluate image statistics. More...
 
class  StatisticsControl
 Pass parameters to a Statistics object. More...
 
class  TransformBoundedField
 A BoundedField based on geom::Transform<Poin2Endpoint, GenericEndpoint<1>>. More...
 
class  WarpingControl
 Parameters to control convolution. More...
 

Typedefs

using KernelList = std::vector<std::shared_ptr<Kernel>>
 
using WeightPixel = lsst::afw::image::VariancePixel
 
using PyClass = py::class_<PixelAreaBoundedField, std::shared_ptr<PixelAreaBoundedField>, BoundedField>
 
using ClsField = py::class_<TransformBoundedField, std::shared_ptr<TransformBoundedField>, BoundedField>
 

Enumerations

enum  UndersampleStyle { THROW_EXCEPTION , REDUCE_INTERP_ORDER , INCREASE_NXNYSAMPLE }
 
enum  Property {
  NOTHING = 0x0 , ERRORS = 0x1 , NPOINT = 0x2 , MEAN = 0x4 ,
  STDEV = 0x8 , VARIANCE = 0x10 , MEDIAN = 0x20 , IQRANGE = 0x40 ,
  MEANCLIP = 0x80 , STDEVCLIP = 0x100 , VARIANCECLIP = 0x200 , MIN = 0x400 ,
  MAX = 0x800 , SUM = 0x1000 , MEANSQUARE = 0x2000 , ORMASK = 0x4000 ,
  NCLIPPED = 0x8000 , NMASKED = 0x10000
}
 control what is calculated More...
 

Functions

template<typename PixelT >
std::shared_ptr< Approximate< PixelT > > makeApproximate (std::vector< double > const &x, std::vector< double > const &y, image::MaskedImage< PixelT > const &im, lsst::geom::Box2I const &bbox, ApproximateControl const &ctrl)
 Construct a new Approximate object, inferring the type from the type of the given MaskedImage.
 
UndersampleStyle stringToUndersampleStyle (std::string const &style)
 Conversion function to switch a string to an UndersampleStyle.
 
template<typename ImageT >
std::shared_ptr< BackgroundmakeBackground (ImageT const &img, BackgroundControl const &bgCtrl)
 A convenience function that uses function overloading to make the correct type of Background.
 
std::shared_ptr< BoundedFieldoperator* (double const scale, std::shared_ptr< BoundedField const > bf)
 
template<typename OutImageT , typename InImageT >
void scaledPlus (OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
 Compute the scaled sum of two images.
 
template<typename OutImageT , typename InImageT >
OutImageT::SinglePixel convolveAtAPoint (typename InImageT::const_xy_locator inImageLocator, image::Image< Kernel::Pixel >::const_xy_locator kernelLocator, int kWidth, int kHeight)
 Apply convolution kernel to an image at one point.
 
template<typename OutImageT , typename InImageT >
OutImageT::SinglePixel convolveAtAPoint (typename InImageT::const_xy_locator inImageLocator, std::vector< Kernel::Pixel > const &kernelXList, std::vector< Kernel::Pixel > const &kernelYList)
 Apply separable convolution kernel to an image at one point.
 
template<typename OutImageT , typename InImageT , typename KernelT >
void convolve (OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
 Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image.
 
template<typename ImageT >
ImageT::SinglePixel edgePixel (lsst::afw::image::detail::Image_tag)
 Return an off-the-edge pixel appropriate for a given Image type.
 
template<typename MaskedImageT >
MaskedImageT::SinglePixel edgePixel (lsst::afw::image::detail::MaskedImage_tag)
 Return an off-the-edge pixel appropriate for a given MaskedImage type.
 
template<typename UnaryFunctionT , typename Arg >
Arg int1d (UnaryFunctionT func, IntRegion< Arg > &reg, Arg const &abserr=DEFABSERR, Arg const &relerr=DEFRELERR)
 Front end for the 1d integrator.
 
template<typename UnaryFunctionT , typename Arg >
auto integrate (UnaryFunctionT func, Arg const a, Arg const b, double eps=1.0e-6)
 The 1D integrator.
 
template<typename BinaryFunctionT , typename X , typename Y >
auto integrate2d (BinaryFunctionT func, X x1, X x2, Y y1, Y y2, double eps=1.0e-6)
 The 2D integrator.
 
std::shared_ptr< InterpolatemakeInterpolate (std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
 A factory function to make Interpolate objects.
 
std::shared_ptr< InterpolatemakeInterpolate (ndarray::Array< double const, 1 > const &x, ndarray::Array< double const, 1 > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
 
Interpolate::Style stringToInterpStyle (std::string const &style)
 Conversion function to switch a string to an Interpolate::Style.
 
Interpolate::Style lookupMaxInterpStyle (int const n)
 Get the highest order Interpolation::Style available for 'n' points.
 
int lookupMinInterpPoints (Interpolate::Style const style)
 Get the minimum number of points needed to use the requested interpolation style.
 
void printKernel (lsst::afw::math::Kernel const &kernel, bool doNormalize, double x=0, double y=0, std::string pixelFmt="%7.3f")
 Print the pixel values of a Kernel to std::cout.
 
template<typename ReturnT >
FitResults minimize (lsst::afw::math::Function1< ReturnT > const &function, std::vector< double > const &initialParameterList, std::vector< double > const &stepSizeList, std::vector< double > const &measurementList, std::vector< double > const &varianceList, std::vector< double > const &xPositionList, double errorDef)
 Find the minimum of a function(x)
 
template<typename ReturnT >
FitResults minimize (lsst::afw::math::Function2< ReturnT > const &function, std::vector< double > const &initialParameterList, std::vector< double > const &stepSizeList, std::vector< double > const &measurementList, std::vector< double > const &varianceList, std::vector< double > const &xPositionList, std::vector< double > const &yPositionList, double errorDef)
 Find the minimum of a function(x, y)
 
template<typename ImageT >
std::shared_ptr< ImageT > offsetImage (ImageT const &image, float dx, float dy, std::string const &algorithmName="lanczos5", unsigned int buffer=0)
 Return an image offset by (dx, dy) using the specified algorithm.
 
template<typename ImageT >
std::shared_ptr< ImageT > rotateImageBy90 (ImageT const &image, int nQuarter)
 Rotate an image by an integral number of quarter turns.
 
template<typename ImageT >
std::shared_ptr< ImageT > flipImage (ImageT const &inImage, bool flipLR, bool flipTB)
 Flip an image left–right and/or top–bottom.
 
template<typename ImageT >
std::shared_ptr< ImageT > binImage (ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
 
template<typename ImageT >
std::shared_ptr< ImageT > binImage (ImageT const &inImage, int const binsize, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
 
template<typename ImageT >
void randomUniformImage (ImageT *image, Random &rand)
 Set image to random numbers uniformly distributed in the range [0, 1)
 
template<typename ImageT >
void randomUniformPosImage (ImageT *image, Random &rand)
 Set image to random numbers uniformly distributed in the range (0, 1)
 
template<typename ImageT >
void randomUniformIntImage (ImageT *image, Random &rand, unsigned long n)
 Set image to random integers uniformly distributed in the range 0 ... n - 1.
 
template<typename ImageT >
void randomFlatImage (ImageT *image, Random &rand, double const a, double const b)
 Set image to random numbers uniformly distributed in the range [a, b)
 
template<typename ImageT >
void randomGaussianImage (ImageT *image, Random &rand)
 Set image to random numbers with a gaussian N(0, 1) distribution.
 
template<typename ImageT >
void randomChisqImage (ImageT *image, Random &rand, double const nu)
 Set image to random numbers with a chi^2_{nu} distribution.
 
template<typename ImageT >
void randomPoissonImage (ImageT *image, Random &rand, double const mu)
 Set image to random numbers with a Poisson distribution with mean mu (n.b.
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::Image< PixelT > > statisticsStack (std::vector< std::shared_ptr< lsst::afw::image::Image< PixelT > > > &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 A function to compute some statistics of a stack of Images.
 
template<typename PixelT >
void statisticsStack (lsst::afw::image::Image< PixelT > &out, std::vector< std::shared_ptr< lsst::afw::image::Image< PixelT > > > &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 @ brief compute statistical stack of Image.
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > statisticsStack (std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > > &images, Property flags, StatisticsControl const &sctrl, std::vector< lsst::afw::image::VariancePixel > const &wvector, image::MaskPixel clipped, std::vector< std::pair< image::MaskPixel, image::MaskPixel > > const &maskMap)
 A function to compute some statistics of a stack of Masked Images.
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > statisticsStack (std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > > &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0), image::MaskPixel clipped=0, image::MaskPixel excuse=0)
 A function to compute some statistics of a stack of Masked Images.
 
template<typename PixelT >
void statisticsStack (lsst::afw::image::MaskedImage< PixelT > &out, std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > > &images, Property flags, StatisticsControl const &sctrl, std::vector< lsst::afw::image::VariancePixel > const &wvector, image::MaskPixel clipped, std::vector< std::pair< image::MaskPixel, image::MaskPixel > > const &maskMap)
 A function to compute some statistics of a stack of Masked Images.
 
template<typename PixelT >
void statisticsStack (lsst::afw::image::MaskedImage< PixelT > &out, std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > > &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0), image::MaskPixel clipped=0, image::MaskPixel excuse=0)
 @ brief compute statistical stack of MaskedImage.
 
template<typename PixelT >
std::vector< PixelT > statisticsStack (std::vector< std::vector< PixelT > > &vectors, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 A function to compute some statistics of a stack of std::vectors.
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > statisticsStack (lsst::afw::image::Image< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl=StatisticsControl())
 A function to compute statistics on the rows or columns of an image.
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > statisticsStack (lsst::afw::image::MaskedImage< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl=StatisticsControl())
 A function to compute statistics on the rows or columns of an image.
 
Property stringToStatisticsProperty (std::string const property)
 Conversion function to switch a string to a Property (see Statistics.h)
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle a watered-down front-end to the constructor (no variance)
 
template<typename ImageT , typename MaskT , typename VarianceT >
Statistics makeStatistics (ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle a straight front-end to the constructor.
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::MaskedImage< Pixel > const &mimg, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle MaskedImages, just pass the getImage() and getMask() values right on through.
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::MaskedImage< Pixel > const &mimg, lsst::afw::image::Image< WeightPixel > const &weights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle MaskedImages, just pass the getImage() and getMask() values right on through.
 
Statistics makeStatistics (lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Specialization to handle Masks.
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::Image< Pixel > const &img, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle regular (non-masked) Images.
 
template<typename EntryT >
Statistics makeStatistics (std::vector< EntryT > const &v, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle std::vector<>
 
template<typename EntryT >
Statistics makeStatistics (std::vector< EntryT > const &v, std::vector< WeightPixel > const &vweights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle std::vector<>
 
template<typename EntryT >
Statistics makeStatistics (lsst::afw::math::MaskedVector< EntryT > const &mv, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>
 
template<typename EntryT >
Statistics makeStatistics (lsst::afw::math::MaskedVector< EntryT > const &mv, std::vector< WeightPixel > const &vweights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>
 
std::shared_ptr< SeparableKernelmakeWarpingKernel (std::string name)
 Return a warping kernel given its name.
 
template<typename DestExposureT , typename SrcExposureT >
int warpExposure (DestExposureT &destExposure, SrcExposureT const &srcExposure, WarpingControl const &control, typename DestExposureT::MaskedImageT::SinglePixel padValue=lsst::afw::math::edgePixel< typename DestExposureT::MaskedImageT >(typename lsst::afw::image::detail::image_traits< typename DestExposureT::MaskedImageT >::image_category()))
 Warp (remap) one exposure to another.
 
template<typename DestImageT , typename SrcImageT >
int warpImage (DestImageT &destImage, geom::SkyWcs const &destWcs, SrcImageT const &srcImage, geom::SkyWcs const &srcWcs, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
 Warp an Image or MaskedImage to a new Wcs.
 
template<typename DestImageT , typename SrcImageT >
int warpImage (DestImageT &destImage, SrcImageT const &srcImage, geom::TransformPoint2ToPoint2 const &srcToDest, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
 A variant of warpImage that uses a Transform<Point2Endpoint, Point2Endpoint> instead of a pair of WCS to describe the transformation.
 
template<typename DestImageT , typename SrcImageT >
int warpCenteredImage (DestImageT &destImage, SrcImageT const &srcImage, lsst::geom::LinearTransform const &linearTransform, lsst::geom::Point2D const &centerPosition, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
 Warp an image with a LinearTranform about a specified point.
 
void wrapApproximate (lsst::utils::python::WrapperCollection &wrappers)
 
void declareBackground (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapBackground (lsst::utils::python::WrapperCollection &wrappers)
 
void declareBoundedField (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapBoundedField (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapChebyshevBoundedField (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapConvolveImage (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapFunction (lsst::utils::python::WrapperCollection &wrappers)
 
template<typename ReturnT >
void declarePolynomialFunctions (lsst::utils::python::WrapperCollection &wrappers, const std::string &suffix)
 
template<typename ReturnT >
void declareChebyshevFunctions (lsst::utils::python::WrapperCollection &wrappers, const std::string &suffix)
 
template<typename ReturnT >
void declareGaussianFunctions (lsst::utils::python::WrapperCollection &wrappers, const std::string &suffix)
 
template<typename ReturnT >
void declareIntegerDeltaFunctions (lsst::utils::python::WrapperCollection &wrappers, const std::string &suffix)
 
template<typename ReturnT >
void declareLanczosFunctions (lsst::utils::python::WrapperCollection &wrappers, const std::string &suffix)
 
void wrapFunctionLibrary (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapGaussianProcess (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapInterpolate (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapKernel (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapLeastSquares (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapMinimize (lsst::utils::python::WrapperCollection &)
 
void wrapOffsetImage (lsst::utils::python::WrapperCollection &)
 
void wrapPixelAreaBoundedField (lsst::utils::python::WrapperCollection &)
 
void wrapProductBoundedField (lsst::utils::python::WrapperCollection &)
 
void wrapRandom (lsst::utils::python::WrapperCollection &)
 
void wrapSpatialCell (lsst::utils::python::WrapperCollection &)
 
void wrapStack (lsst::utils::python::WrapperCollection &)
 
void wrapStatistics (lsst::utils::python::WrapperCollection &)
 
void wrapTransformBoundedField (lsst::utils::python::WrapperCollection &)
 
void wrapWarpExposure (lsst::utils::python::WrapperCollection &)
 
 PYBIND11_MODULE (_math, mod)
 
template<typename ImageT >
void declareRandomImage (lsst::utils::python::WrapperCollection &wrappers)
 
void declareRandom (lsst::utils::python::WrapperCollection &wrappers)
 
template<typename Pixel >
void declareStatistics (lsst::utils::python::WrapperCollection &wrappers)
 
template<typename Pixel >
void declareStatisticsVectorOverloads (lsst::utils::python::WrapperCollection &wrappers)
 
void declareStatistics (lsst::utils::python::WrapperCollection &wrappers)
 
void declareTransformBoundedField (lsst::utils::python::WrapperCollection &wrappers)
 
double integrateTn (int n)
 
template<typename OutImageT , typename InImageT , typename KernelT >
void convolve (OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, bool doNormalize, bool doCopyEdge)
 
template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > statisticsStack (std::vector< std::shared_ptr< image::MaskedImage< PixelT > > > &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector, image::MaskPixel clipped, image::MaskPixel excuse)
 
template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > statisticsStack (std::vector< std::shared_ptr< image::MaskedImage< PixelT > > > &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector, image::MaskPixel clipped, std::vector< std::pair< image::MaskPixel, image::MaskPixel > > const &maskMap)
 
template<typename PixelT >
void statisticsStack (image::MaskedImage< PixelT > &out, std::vector< std::shared_ptr< image::MaskedImage< PixelT > > > &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector, image::MaskPixel clipped, image::MaskPixel excuse)
 
template<typename PixelT >
void statisticsStack (image::MaskedImage< PixelT > &out, std::vector< std::shared_ptr< image::MaskedImage< PixelT > > > &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector, image::MaskPixel clipped, std::vector< std::pair< image::MaskPixel, image::MaskPixel > > const &maskMap)
 
template<typename PixelT >
std::shared_ptr< image::Image< PixelT > > statisticsStack (std::vector< std::shared_ptr< image::Image< PixelT > > > &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector)
 
template<typename PixelT >
void statisticsStack (image::Image< PixelT > &out, std::vector< std::shared_ptr< image::Image< PixelT > > > &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector)
 
template<typename PixelT >
std::vector< PixelT > statisticsStack (std::vector< std::vector< PixelT > > &vectors, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector)
 
template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > statisticsStack (image::Image< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl)
 A function to compute statistics on the rows or columns of an image.
 
template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > statisticsStack (image::MaskedImage< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl)
 A function to compute statistics on the rows or columns of an image.
 

Variables

template<typename T >
bool constexpr IS_NOTHROW_INIT = noexcept(static_cast<T>(1.0))
 Test that a Function's return value is nothrow-castable to T.
 
double const MOCK_INF = 1.e10
 
double const DEFABSERR = 1.e-15
 
double const DEFRELERR = 1.e-6
 
generic_kernel_tag generic_kernel_tag_
 Used as default value in argument lists.
 
deltafunction_kernel_tag deltafunction_kernel_tag_
 Used as default value in argument lists.
 

Typedef Documentation

◆ ClsField

Definition at line 42 of file _transformBoundedField.cc.

◆ KernelList

Definition at line 462 of file Kernel.h.

◆ PyClass

Definition at line 35 of file _pixelAreaBoundedField.cc.

◆ WeightPixel

Definition at line 48 of file Statistics.h.

Enumeration Type Documentation

◆ Property

control what is calculated

Enumerator
NOTHING 

We don't want anything.

ERRORS 

Include errors of requested quantities.

NPOINT 

number of sample points

MEAN 

estimate sample mean

STDEV 

estimate sample standard deviation

VARIANCE 

estimate sample variance

MEDIAN 

estimate sample median

IQRANGE 

estimate sample inter-quartile range

MEANCLIP 

estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)

STDEVCLIP 

estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)

VARIANCECLIP 

estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)

MIN 

estimate sample minimum

MAX 

estimate sample maximum

SUM 

find sum of pixels in the image

MEANSQUARE 

find mean value of square of pixel values

ORMASK 

get the or-mask of all pixels used.

NCLIPPED 

number of clipped points

NMASKED 

number of masked points

Definition at line 53 of file Statistics.h.

53 {
54 NOTHING = 0x0,
55 ERRORS = 0x1,
56 NPOINT = 0x2,
57 MEAN = 0x4,
58 STDEV = 0x8,
59 VARIANCE = 0x10,
60 MEDIAN = 0x20,
61 IQRANGE = 0x40,
62 MEANCLIP = 0x80,
63 STDEVCLIP = 0x100,
64 VARIANCECLIP = 0x200,
66 MIN = 0x400,
67 MAX = 0x800,
68 SUM = 0x1000,
69 MEANSQUARE = 0x2000,
70 ORMASK = 0x4000,
71 NCLIPPED = 0x8000,
72 NMASKED = 0x10000
73};
@ ORMASK
get the or-mask of all pixels used.
Definition Statistics.h:70
@ ERRORS
Include errors of requested quantities.
Definition Statistics.h:55
@ VARIANCECLIP
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
Definition Statistics.h:64
@ MEANSQUARE
find mean value of square of pixel values
Definition Statistics.h:69
@ MIN
estimate sample minimum
Definition Statistics.h:66
@ NCLIPPED
number of clipped points
Definition Statistics.h:71
@ NOTHING
We don't want anything.
Definition Statistics.h:54
@ STDEV
estimate sample standard deviation
Definition Statistics.h:58
@ NMASKED
number of masked points
Definition Statistics.h:72
@ STDEVCLIP
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition Statistics.h:63
@ VARIANCE
estimate sample variance
Definition Statistics.h:59
@ MEDIAN
estimate sample median
Definition Statistics.h:60
@ MAX
estimate sample maximum
Definition Statistics.h:67
@ SUM
find sum of pixels in the image
Definition Statistics.h:68
@ IQRANGE
estimate sample inter-quartile range
Definition Statistics.h:61
@ MEAN
estimate sample mean
Definition Statistics.h:57
@ NPOINT
number of sample points
Definition Statistics.h:56

◆ UndersampleStyle

Enumerator
THROW_EXCEPTION 
REDUCE_INTERP_ORDER 
INCREASE_NXNYSAMPLE 

Definition at line 47 of file Background.h.

Function Documentation

◆ binImage() [1/2]

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::math::binImage ( ImageT const & inImage,
int const binsize,
lsst::afw::math::Property const flags = lsst::afw::math::MEAN )
Parameters
inImageThe image to bin
binsizeOutput pixels are binsize*binsize input pixels
flagshow to generate super-pixels

Definition at line 39 of file binImage.cc.

39 {
40 return binImage(in, binsize, binsize, flags);
41}
std::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
Definition binImage.cc:44

◆ binImage() [2/2]

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::math::binImage ( ImageT const & inImage,
int const binX,
int const binY,
lsst::afw::math::Property const flags = lsst::afw::math::MEAN )
Parameters
inImageThe image to bin
binXOutput pixels are binX*binY input pixels
binYOutput pixels are binX*binY input pixels
flagshow to generate super-pixels

Definition at line 44 of file binImage.cc.

45 {
46 if (flags != lsst::afw::math::MEAN) {
48 (boost::format("Only afwMath::MEAN is supported, saw 0x%x") % flags).str());
49 }
50 if (binX <= 0 || binY <= 0) {
52 (boost::format("Binning must be >= 0, saw %dx%d") % binX % binY).str());
53 }
54
55 int const outWidth = in.getWidth() / binX;
56 int const outHeight = in.getHeight() / binY;
57
59 std::shared_ptr<ImageT>(new ImageT(lsst::geom::Extent2I(outWidth, outHeight)));
60 out->setXY0(in.getXY0());
61 *out = typename ImageT::SinglePixel(0);
62
63 for (int oy = 0, iy = 0; oy < out->getHeight(); ++oy) {
64 for (int i = 0; i != binY; ++i, ++iy) {
65 typename ImageT::x_iterator optr = out->row_begin(oy);
66 for (typename ImageT::x_iterator iptr = in.row_begin(iy), iend = iptr + binX * outWidth;
67 iptr < iend;) {
68 typename ImageT::SinglePixel val = *iptr;
69 ++iptr;
70 for (int j = 1; j != binX; ++j, ++iptr) {
71 val += *iptr;
72 }
73 *optr += val;
74 ++optr;
75 }
76 }
77 for (typename ImageT::x_iterator ptr = out->row_begin(oy), end = out->row_end(oy); ptr != end;
78 ++ptr) {
79 *ptr /= binX * binY;
80 }
81 }
82
83 return out;
84}
int end
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
uint64_t * ptr
Definition RangeSet.cc:95
Reports arguments outside the domain of an operation.
Definition Runtime.h:57
Reports invalid arguments.
Definition Runtime.h:66
ImageT val
Definition CR.cc:146

◆ convolve() [1/2]

template<typename OutImageT , typename InImageT , typename KernelT >
void lsst::afw::math::convolve ( OutImageT & convolvedImage,
InImageT const & inImage,
KernelT const & kernel,
bool doNormalize,
bool doCopyEdge )

Definition at line 190 of file ConvolveImage.cc.

191 {
192 ConvolutionControl convolutionControl;
193 convolutionControl.setDoNormalize(doNormalize);
194 convolutionControl.setDoCopyEdge(doCopyEdge);
195 convolve(convolvedImage, inImage, kernel, convolutionControl);
196}
Parameters to control convolution.
void setDoCopyEdge(bool doCopyEdge)
void setDoNormalize(bool doNormalize)

◆ convolve() [2/2]

template<typename OutImageT , typename InImageT , typename KernelT >
void lsst::afw::math::convolve ( OutImageT & convolvedImage,
InImageT const & inImage,
KernelT const & kernel,
ConvolutionControl const & convolutionControl = ConvolutionControl() )

Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image.

Various convolution kernels are available, including:

If a kernel is spatially varying, its spatial model is computed at each pixel position on the image (pixel position, not pixel index). At present (2009-09-24) this position is computed relative to the lower left corner of the sub-image, but it will almost certainly change to be the lower left corner of the parent image.

All convolution is performed in real space. This allows convolution to handle masked pixels and spatially varying kernels. Although convolution of an Image with a spatially invariant kernel could, in fact, be performed in Fourier space, the code does not do this.

Note that mask bits are smeared by convolution; all nonzero pixels in the kernel smear the mask, even pixels that have very small values. Larger kernels smear the mask more and are also slower to convolve. Use the smallest kernel that will do the job.

convolvedImage has a border of edge pixels which cannot be computed normally. Normally these pixels are set to the standard edge pixel, as returned by edgePixel(). However, if your code cannot handle nans in the image or infs in the variance, you may set doCopyEdge true, in which case the edge pixels are set to the corresponding pixels of the input image and (if there is a mask) the mask EDGE bit is set.

The border of edge pixels has size:

  • kernel.getCtr().getX() along the left edge
  • kernel.getCtr().getY() along the bottom edge
  • kernel.getWidth() - 1 - kernel.getCtr().getX() along the right edge
  • kernel.getHeight() - 1 - kernel.getCtr().getY() along the top edge You can obtain a bounding box for the good pixels in the convolved image from a bounding box for the entire image using the Kernel method shrinkBBox.

Convolution has been optimized for the various kinds of kernels, as follows (listed approximately in order of decreasing speed):

  • DeltaFunctionKernel convolution is a simple image shift.
  • SeparableKernel convolution is performed by convolving the input by one of the two functions, then the result by the other function. Thus convolution with a kernel of size nCols x nRows becomes convolution with a kernel of size nCols x 1, followed by convolution with a kernel of size 1 x nRows.
  • Convolution with spatially invariant versions of the other kernels is performed by computing the kernel image once and convolving with that. The code has been optimized for cache performance and so should be fairly efficient.
  • Convolution with a spatially varying LinearCombinationKernel is performed by convolving the image by each basis kernel and combining the result by solving the spatial model. This will be efficient provided the kernel does not contain too many or very large basis kernels.
  • Convolution with spatially varying AnalyticKernel is likely to be slow. The code simply computes the output one pixel at a time by computing the AnalyticKernel at that point and applying it to the input image. This is not favorable for cache performance (especially for large kernels) but avoids recomputing the AnalyticKernel. It is probably possible to do better.

Additional convolution functions include:

Parameters
[out]convolvedImageconvolved image; must be the same size as inImage
[in]inImageimage to convolve
[in]kernelconvolution kernel
[in]convolutionControlconvolution control parameters
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif convolvedImage is not the same size as inImage
lsst::pex::exceptions::InvalidParameterErrorif inImage is smaller than kernel in columns and/or rows.
std::bad_allocwhen allocation of memory fails

Definition at line 181 of file ConvolveImage.cc.

182 {
183 detail::basicConvolve(convolvedImage, inImage, kernel, convolutionControl);
184 setEdgePixels(convolvedImage, kernel, inImage, convolutionControl.getDoCopyEdge(),
186 convolvedImage.setXY0(inImage.getXY0());
187}
typename ImageT::image_category image_category
Definition ImageBase.h:67

◆ convolveAtAPoint() [1/2]

template<typename OutImageT , typename InImageT >
OutImageT::SinglePixel lsst::afw::math::convolveAtAPoint ( typename InImageT::const_xy_locator inImageLocator,
image::Image< Kernel::Pixel >::const_xy_locator kernelLocator,
int kWidth,
int kHeight )
inline

Apply convolution kernel to an image at one point.

Note
This subroutine sacrifices convenience for performance. The user is expected to figure out the kernel center and adjust the supplied pixel accessors accordingly. For an example of how to do this see convolve().
Parameters
inImageLocatorlocator for image pixel that overlaps pixel (0,0) of kernel (the origin of the kernel, not its center)
kernelLocatorlocator for (0,0) pixel of kernel (the origin of the kernel, not its center)
kWidthnumber of columns in kernel
kHeightnumber of rows in kernel

Definition at line 257 of file ConvolveImage.h.

259 {
260 typename OutImageT::SinglePixel outValue = 0;
261 for (int kRow = 0; kRow != kHeight; ++kRow) {
263 kernelLocator + image::detail::difference_type(kWidth, 0);
264 kernelLocator != kEnd; ++inImageLocator.x(), ++kernelLocator.x()) {
265 typename Kernel::Pixel const kVal = kernelLocator[0];
266 if (kVal != 0) {
267 outValue += *inImageLocator * kVal;
268 }
269 }
270
271 inImageLocator += image::detail::difference_type(-kWidth, 1);
272 kernelLocator += image::detail::difference_type(-kWidth, 1);
273 }
274
275 return outValue;
276}
typename _view_t::xy_locator::const_t const_xy_locator
A const_xy_locator.
Definition ImageBase.h:123

◆ convolveAtAPoint() [2/2]

template<typename OutImageT , typename InImageT >
OutImageT::SinglePixel lsst::afw::math::convolveAtAPoint ( typename InImageT::const_xy_locator inImageLocator,
std::vector< Kernel::Pixel > const & kernelXList,
std::vector< Kernel::Pixel > const & kernelYList )
inline

Apply separable convolution kernel to an image at one point.

Note
This subroutine sacrifices convenience for performance. The user is expected to figure out the kernel center and adjust the supplied pixel accessors accordingly. For an example of how to do this see convolve().
Parameters
inImageLocatorlocator for image pixel that overlaps pixel (0,0) of kernel (the origin of the kernel, not its center)
kernelXListkernel column vector
kernelYListkernel row vector

Definition at line 293 of file ConvolveImage.h.

295 {
296 using k_iter = typename std::vector<Kernel::Pixel>::const_iterator;
297
298 using OutT = typename OutImageT::SinglePixel;
299 OutT outValue = 0;
300 for (double kValY : kernelYList) {
301 OutT outValueY = 0;
302 for (k_iter kernelXIter = kernelXList.begin(), xEnd = kernelXList.end(); kernelXIter != xEnd;
303 ++kernelXIter, ++inImageLocator.x()) {
304 typename Kernel::Pixel const kValX = *kernelXIter;
305 if (kValX != 0) {
306 outValueY += *inImageLocator * kValX;
307 }
308 }
309
310 if (kValY != 0) {
311 outValue += outValueY * kValY;
312 }
313
314 inImageLocator += image::detail::difference_type(-kernelXList.size(), 1);
315 }
316
317 return outValue;
318}
T begin(T... args)
T end(T... args)
T size(T... args)

◆ declareBackground()

void lsst::afw::math::declareBackground ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 73 of file _background.cc.

73 {
74 /* Member types and enums */
75 wrappers.wrapType(py::enum_<UndersampleStyle>(wrappers.module, "UndersampleStyle"),
76 [](auto &mod, auto &enm) {
77 enm.value("THROW_EXCEPTION", UndersampleStyle::THROW_EXCEPTION);
78 enm.value("REDUCE_INTERP_ORDER", UndersampleStyle::REDUCE_INTERP_ORDER);
79 enm.value("INCREASE_NXNYSAMPLE", UndersampleStyle::INCREASE_NXNYSAMPLE);
80 enm.export_values();
81 });
82
83 using PyBackgroundControl = py::class_<BackgroundControl, std::shared_ptr<BackgroundControl>>;
84 wrappers.wrapType(PyBackgroundControl(wrappers.module, "BackgroundControl"), [](auto &mod, auto &cls) {
85 /* Constructors */
86 cls.def(py::init<int const, int const, StatisticsControl const, Property const,
87 ApproximateControl const>(),
88 "nxSample"_a, "nySample"_a, "sctrl"_a = StatisticsControl(), "prop"_a = MEANCLIP,
89 "actrl"_a = ApproximateControl(ApproximateControl::UNKNOWN, 1));
90 cls.def(py::init<int const, int const, StatisticsControl const, std::string const &,
91 ApproximateControl const>(),
92 "nxSample"_a, "nySample"_a, "sctrl"_a, "prop"_a,
93 "actrl"_a = ApproximateControl(ApproximateControl::UNKNOWN, 1));
94 cls.def(py::init<Interpolate::Style const, int const, int const, UndersampleStyle const,
95 StatisticsControl const, Property const, ApproximateControl const>(),
96 "style"_a, "nxSample"_a = 10, "nySample"_a = 10, "undersampleStyle"_a = THROW_EXCEPTION,
97 "sctrl"_a = StatisticsControl(), "prop"_a = MEANCLIP,
98 "actrl"_a = ApproximateControl(ApproximateControl::UNKNOWN, 1));
99 cls.def(py::init<std::string const &, int const, int const, std::string const &,
100 StatisticsControl const, std::string const &, ApproximateControl const>(),
101 "style"_a, "nxSample"_a = 10, "nySample"_a = 10, "undersampleStyle"_a = "THROW_EXCEPTION",
102 "sctrl"_a = StatisticsControl(), "prop"_a = "MEANCLIP",
103 "actrl"_a = ApproximateControl(ApproximateControl::UNKNOWN, 1));
104
105 /* Members */
106 cls.def("setNxSample", &BackgroundControl::setNxSample);
107 cls.def("setNySample", &BackgroundControl::setNySample);
108 cls.def("setInterpStyle",
109 (void (BackgroundControl::*)(Interpolate::Style const)) & BackgroundControl::setInterpStyle);
110 cls.def("setInterpStyle",
111 (void (BackgroundControl::*)(std::string const &)) & BackgroundControl::setInterpStyle);
112 cls.def("setUndersampleStyle", (void (BackgroundControl::*)(UndersampleStyle const)) &
113 BackgroundControl::setUndersampleStyle);
114 cls.def("setUndersampleStyle",
115 (void (BackgroundControl::*)(std::string const &)) & BackgroundControl::setUndersampleStyle);
116 cls.def("getNxSample", &BackgroundControl::getNxSample);
117 cls.def("getNySample", &BackgroundControl::getNySample);
118 cls.def("getInterpStyle", &BackgroundControl::getInterpStyle);
119 cls.def("getUndersampleStyle", &BackgroundControl::getUndersampleStyle);
120 cls.def("getStatisticsControl", (std::shared_ptr<StatisticsControl>(BackgroundControl::*)()) &
121 BackgroundControl::getStatisticsControl);
122 cls.def("getStatisticsProperty", &BackgroundControl::getStatisticsProperty);
123 cls.def("setStatisticsProperty",
124 (void (BackgroundControl::*)(Property)) & BackgroundControl::setStatisticsProperty);
125 cls.def("setStatisticsProperty",
126 (void (BackgroundControl::*)(std::string)) & BackgroundControl::setStatisticsProperty);
127 cls.def("setApproximateControl", &BackgroundControl::setApproximateControl);
128 cls.def("getApproximateControl", (std::shared_ptr<ApproximateControl>(BackgroundControl::*)()) &
129 BackgroundControl::getApproximateControl);
130 });
131 using PyBackground = py::class_<Background, std::shared_ptr<Background>>;
132 wrappers.wrapType(PyBackground(wrappers.module, "Background"), [](auto &mod, auto &cls) {
133 /* Members */
134 declareGetImage<float>(cls, "F");
135
136 cls.def("getAsUsedInterpStyle", &Background::getAsUsedInterpStyle);
137 cls.def("getAsUsedUndersampleStyle", &Background::getAsUsedUndersampleStyle);
138 cls.def("getApproximate", &Background::getApproximate, "actrl"_a,
139 "undersampleStyle"_a = THROW_EXCEPTION);
140 cls.def("getBackgroundControl",
141 (std::shared_ptr<BackgroundControl>(Background::*)()) & Background::getBackgroundControl);
142 });
143
144 using PyBackgroundMI = py::class_<BackgroundMI, std::shared_ptr<BackgroundMI>, Background>;
145 wrappers.wrapType(PyBackgroundMI(wrappers.module, "BackgroundMI"), [](auto &mod, auto &cls) {
146 /* Constructors */
147 cls.def(py::init<lsst::geom::Box2I const,
148 image::MaskedImage<typename Background::InternalPixelT> const &>(),
149 "imageDimensions"_a, "statsImage"_a);
150
151 /* Operators */
152 cls.def("__iadd__", &BackgroundMI::operator+=);
153 cls.def("__isub__", &BackgroundMI::operator-=);
154
155 /* Members */
156 cls.def("getStatsImage", &BackgroundMI::getStatsImage);
157 cls.def("getImageBBox", &BackgroundMI::getImageBBox);
158
159 // Yes, really only float
160 });
161}
A virtual base class to evaluate image background levels.
Definition Background.h:235

◆ declareBoundedField()

void lsst::afw::math::declareBoundedField ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 62 of file _boundedField.cc.

62 {
63 wrappers.wrapType(PyClass(wrappers.module, "BoundedField"), [](auto &mod, auto &cls) {
64 table::io::python::addPersistableMethods<BoundedField>(cls);
65
66 cls.def(
67 "__rmul__", [](BoundedField &bf, double const scale) { return bf * scale; },
68 py::is_operator());
69 cls.def("__mul__", &BoundedField::operator*, py::is_operator());
70 cls.def("__truediv__", &BoundedField::operator/, py::is_operator());
71 cls.def("__eq__", &BoundedField::operator==, py::is_operator());
72 cls.def("__ne__", &BoundedField::operator!=, py::is_operator());
73
74 cls.def("evaluate", (double (BoundedField::*)(double, double) const) & BoundedField::evaluate);
75 cls.def("evaluate", (ndarray::Array<double, 1, 1>(BoundedField::*)(
76 ndarray::Array<double const, 1> const &,
77 ndarray::Array<double const, 1> const &) const) &
78 BoundedField::evaluate);
79 cls.def("evaluate",
80 (double (BoundedField::*)(lsst::geom::Point2D const &) const) & BoundedField::evaluate);
81 cls.def("integrate", &BoundedField::integrate);
82 cls.def("mean", &BoundedField::mean);
83 cls.def("getBBox", &BoundedField::getBBox);
84
85 // Pybind11 resolves overloads by picking the first one that might work
86 declareTemplates<double>(cls);
87 declareTemplates<float>(cls);
88
89 utils::python::addOutputOp(cls, "__str__");
90 cls.def("__repr__", [](BoundedField const &self) {
92 os << "BoundedField(" << self << ")";
93 return os.str();
94 });
95 });
96}
std::ostream * os
Definition Schema.cc:557
An abstract base class for 2-d functions defined on an integer bounding boxes.
lsst::geom::Box2I getBBox() const
Return the bounding box that defines the region where the field is valid.
virtual double integrate() const
Compute the integral of this function over its bounding-box.
virtual double mean() const
Compute the mean of this function over its bounding-box.
py::class_< PixelAreaBoundedField, std::shared_ptr< PixelAreaBoundedField >, BoundedField > PyClass

◆ declareChebyshevFunctions()

template<typename ReturnT >
void lsst::afw::math::declareChebyshevFunctions ( lsst::utils::python::WrapperCollection & wrappers,
const std::string & suffix )

Definition at line 79 of file _functionLibrary.cc.

79 {
80 /* Chebyshev1Function1 */
81
82 wrappers.wrapType(
84 Function1<ReturnT>>(wrappers.module, ("Chebyshev1Function1" + suffix).c_str()),
85 [](auto &mod, auto &cls) {
86 cls.def(py::init<std::vector<double>, double, double>(), "params"_a, "minX"_a = -1,
87 "maxX"_a = 1);
88 cls.def(py::init<unsigned int, double, double>(), "order"_a, "minX"_a = -1, "maxX"_a = 1);
89
90 cls.def("__call__", &Chebyshev1Function1<ReturnT>::operator(), "x"_a);
91 cls.def("clone", &Chebyshev1Function1<ReturnT>::clone);
92 cls.def("getMinX", &Chebyshev1Function1<ReturnT>::getMinX);
93 cls.def("getMaxX", &Chebyshev1Function1<ReturnT>::getMaxX);
94 cls.def("getOrder", &Chebyshev1Function1<ReturnT>::getOrder);
95 cls.def("isLinearCombination", &Chebyshev1Function1<ReturnT>::isLinearCombination);
96 cls.def("toString", &Chebyshev1Function1<ReturnT>::toString, "prefix"_a = "");
97
98 /* Chebyshev1Function2 */
99 });
101 BasePolynomialFunction2<ReturnT>>(wrappers.module,
102 ("Chebyshev1Function2" + suffix).c_str()),
103 [](auto &mod, auto &cls) {
104 cls.def(py::init<std::vector<double>, lsst::geom::Box2D const &>(), "params"_a,
105 "xyRange"_a = lsst::geom::Box2D(lsst::geom::Point2D(-1.0, -1.0),
106 lsst::geom::Point2D(1.0, 1.0)));
107 cls.def(py::init<unsigned int, lsst::geom::Box2D const &>(), "order"_a,
108 "xyRange"_a = lsst::geom::Box2D(lsst::geom::Point2D(-1.0, -1.0),
109 lsst::geom::Point2D(1.0, 1.0)));
110
111 cls.def("__call__", &Chebyshev1Function2<ReturnT>::operator(), "x"_a, "y"_a);
112 cls.def("clone", &Chebyshev1Function2<ReturnT>::clone);
113 cls.def("getXYRange", &Chebyshev1Function2<ReturnT>::getXYRange);
114 cls.def("truncate", &Chebyshev1Function2<ReturnT>::truncate, "order"_a);
115 cls.def("toString", &Chebyshev1Function2<ReturnT>::toString, "prefix"_a = "");
116 cls.def("isPersistable", &Chebyshev1Function2<ReturnT>::isPersistable);
117 });
118};
Base class for 2-dimensional polynomials of the form:
Definition Function.h:326
1-dimensional weighted sum of Chebyshev polynomials of the first kind.
2-dimensional weighted sum of Chebyshev polynomials of the first kind.
A Function taking one argument.
Definition Function.h:202

◆ declareGaussianFunctions()

template<typename ReturnT >
void lsst::afw::math::declareGaussianFunctions ( lsst::utils::python::WrapperCollection & wrappers,
const std::string & suffix )

Definition at line 121 of file _functionLibrary.cc.

121 {
122 /* GaussianFunction1 */
124 Function1<ReturnT>>(wrappers.module, ("GaussianFunction1" + suffix).c_str()),
125 [](auto &mod, auto &cls) {
126 cls.def(py::init<double>(), "sigma"_a);
127
128 cls.def("__call__", &GaussianFunction1<ReturnT>::operator(), "x"_a);
129 cls.def("clone", &GaussianFunction1<ReturnT>::clone);
130 cls.def("toString", &GaussianFunction1<ReturnT>::toString, "prefix"_a = "");
131 });
132
134 Function2<ReturnT>>(wrappers.module, ("GaussianFunction2" + suffix).c_str()),
135 [](auto &mod, auto &cls) {
136 /* GaussianFunction2 */
137
138 cls.def(py::init<double, double, double>(), "sigma1"_a, "sigma2"_a,
139 "angle"_a = 0.0);
140
141 cls.def("__call__", &GaussianFunction2<ReturnT>::operator(), "x"_a, "y"_a);
142 cls.def("clone", &GaussianFunction2<ReturnT>::clone);
143 cls.def("toString", &GaussianFunction2<ReturnT>::toString, "prefix"_a = "");
144 cls.def("isPersistable", &GaussianFunction2<ReturnT>::isPersistable);
145 });
146 /* DoubleGaussianFunction2 */
147
148 wrappers.wrapType(
150 Function2<ReturnT>>(wrappers.module, ("DoubleGaussianFunction2" + suffix).c_str()),
151 [](auto &mod, auto &cls) {
152 cls.def(py::init<double, double, double>(), "sigma1"_a, "sigma2"_a = 0, "ampl"_a = 0);
153
154 cls.def("__call__", &DoubleGaussianFunction2<ReturnT>::operator(), "x"_a, "y"_a);
155 cls.def("clone", &DoubleGaussianFunction2<ReturnT>::clone);
156 cls.def("toString", &DoubleGaussianFunction2<ReturnT>::toString, "prefix"_a = "");
157 cls.def("isPersistable", &DoubleGaussianFunction2<ReturnT>::isPersistable);
158 });
159};
double Guassian (sum of two Gaussians)
A Function taking two arguments.
Definition Function.h:259

◆ declareIntegerDeltaFunctions()

template<typename ReturnT >
void lsst::afw::math::declareIntegerDeltaFunctions ( lsst::utils::python::WrapperCollection & wrappers,
const std::string & suffix )

Definition at line 162 of file _functionLibrary.cc.

163 {
164 /* IntegerDeltaFunction1 */
165
166 wrappers.wrapType(
168 Function1<ReturnT>>(wrappers.module, ("IntegerDeltaFunction1" + suffix).c_str()),
169 [](auto &mod, auto &cls) {
170 cls.def(py::init<double>(), "xo"_a);
171
172 cls.def("__call__", &IntegerDeltaFunction1<ReturnT>::operator(), "x"_a);
173 cls.def("clone", &IntegerDeltaFunction1<ReturnT>::clone);
174 cls.def("toString", &IntegerDeltaFunction1<ReturnT>::toString, "prefix"_a = "");
175 });
176 /* IntegerDeltaFunction2 */
177
178 wrappers.wrapType(
180 Function2<ReturnT>>(wrappers.module, ("IntegerDeltaFunction2" + suffix).c_str()),
181 [](auto &mod, auto &cls) {
182 cls.def(py::init<double, double>(), "xo"_a, "yo"_a);
183
184 cls.def("__call__", &IntegerDeltaFunction2<ReturnT>::operator(), "x"_a, "y"_a);
185 cls.def("clone", &IntegerDeltaFunction2<ReturnT>::clone);
186 cls.def("toString", &IntegerDeltaFunction2<ReturnT>::toString, "prefix"_a = "");
187 });
188};
1-dimensional integer delta function.
2-dimensional integer delta function.

◆ declareLanczosFunctions()

template<typename ReturnT >
void lsst::afw::math::declareLanczosFunctions ( lsst::utils::python::WrapperCollection & wrappers,
const std::string & suffix )

Definition at line 191 of file _functionLibrary.cc.

191 {
192 /* LanczosFunction1 */
193
195 Function1<ReturnT>>(wrappers.module, ("LanczosFunction1" + suffix).c_str()),
196 [](auto &mod, auto &cls) {
197 cls.def(py::init<unsigned int, double>(), "n"_a, "xOffset"_a = 0.0);
198
199 cls.def("__call__", &LanczosFunction1<ReturnT>::operator(), "x"_a);
200 cls.def("clone", &LanczosFunction1<ReturnT>::clone);
201 cls.def("getOrder", &LanczosFunction1<ReturnT>::getOrder);
202 cls.def("toString", &LanczosFunction1<ReturnT>::toString, "prefix"_a = "");
203 });
204 /* LanczosFunction2 */
205
207 Function2<ReturnT>>(wrappers.module, ("LanczosFunction2" + suffix).c_str()),
208 [](auto &mod, auto &cls) {
209 /* LanczosFunction2 */
210 cls.def(py::init<unsigned int, double, double>(), "n"_a, "xOffset"_a = 0.0,
211 "yOffset"_a = 0.0);
212
213 cls.def("__call__", &LanczosFunction2<ReturnT>::operator(), "x"_a, "y"_a);
214 cls.def("clone", &LanczosFunction2<ReturnT>::clone);
215 cls.def("getOrder", &LanczosFunction2<ReturnT>::getOrder);
216 cls.def("toString", &LanczosFunction2<ReturnT>::toString, "prefix"_a = "");
217 });
218};
1-dimensional Lanczos function
2-dimensional separable Lanczos function

◆ declarePolynomialFunctions()

template<typename ReturnT >
void lsst::afw::math::declarePolynomialFunctions ( lsst::utils::python::WrapperCollection & wrappers,
const std::string & suffix )

Definition at line 45 of file _functionLibrary.cc.

45 {
46 /* PolynomialFunction1 */
47
48 wrappers.wrapType(
50 Function1<ReturnT>>(wrappers.module, ("PolynomialFunction1" + suffix).c_str()),
51 [](auto &mod, auto &cls) {
52 cls.def(py::init<std::vector<double> const &>(), "params"_a);
53 cls.def(py::init<unsigned int>(), "order"_a);
54
55 cls.def("__call__", &PolynomialFunction1<ReturnT>::operator(), "x"_a);
56 cls.def("clone", &PolynomialFunction1<ReturnT>::clone);
57 cls.def("isLinearCombination", &PolynomialFunction1<ReturnT>::isLinearCombination);
58 cls.def("getOrder", &PolynomialFunction1<ReturnT>::getOrder);
59 cls.def("toString", &PolynomialFunction1<ReturnT>::toString, "prefix"_a = "");
60 });
61 /* PolynomialFunction2 */
63 BasePolynomialFunction2<ReturnT>>(wrappers.module,
64 ("PolynomialFunction2" + suffix).c_str()),
65 [](auto &mod, auto &cls) {
66 cls.def(py::init<std::vector<double> const &>(), "params"_a);
67 cls.def(py::init<unsigned int>(), "order"_a);
68
69 cls.def("__call__", &PolynomialFunction2<ReturnT>::operator(), "x"_a, "y"_a);
70 cls.def("clone", &PolynomialFunction2<ReturnT>::clone);
71 cls.def("getOrder", &PolynomialFunction2<ReturnT>::getOrder);
72 cls.def("getDFuncDParameters", &PolynomialFunction2<ReturnT>::getDFuncDParameters);
73 cls.def("toString", &PolynomialFunction2<ReturnT>::toString, "prefix"_a = "");
74 cls.def("isPersistable", &PolynomialFunction2<ReturnT>::isPersistable);
75 });
76};
1-dimensional polynomial function.
2-dimensional polynomial function with cross terms

◆ declareRandom()

void lsst::afw::math::declareRandom ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 52 of file _random.cc.

52 {
53 auto clsRandom = wrappers.wrapType(py::class_<Random>(wrappers.module, "Random"), [](auto &mod,
54 auto &cls) {
55 /* Constructors */
56 cls.def(py::init<Random::Algorithm, unsigned long>(), "algorithm"_a = Random::Algorithm::MT19937,
57 "seed"_a = 1);
58 cls.def(py::init<std::string const &, unsigned long>(), "algorithm"_a, "seed"_a = 1);
59
60 /* Members */
61 cls.def("deepCopy", &Random::deepCopy);
62 cls.def("getAlgorithm", &Random::getAlgorithm);
63 cls.def("getAlgorithmName", &Random::getAlgorithmName);
64 cls.def_static("getAlgorithmNames", &Random::getAlgorithmNames);
65 cls.def("getSeed", &Random::getSeed);
66 cls.def("uniform", &Random::uniform);
67 cls.def("uniformPos", &Random::uniformPos);
68 cls.def("uniformInt", &Random::uniformInt);
69 cls.def("flat", &Random::flat);
70 cls.def("gaussian", &Random::gaussian);
71 cls.def("chisq", &Random::chisq);
72 cls.def("poisson", &Random::poisson);
73
74 // getState and setState are special, their std::string cannot
75 // be converted to a Python string (needs to go to bytes instead)
76 // thus use the same solution as employed with Swig
77 cls.def("getState", [](Random &self) -> py::object {
78 std::string state = self.getState();
79 return py::reinterpret_steal<py::object>(PyBytes_FromStringAndSize(state.data(), state.size()));
80 });
81 cls.def("setState", [](Random &self, py::bytes const &state) { self.setState(state); });
82 });
83 /* Member types and enums */
84 wrappers.wrapType(py::enum_<Random::Algorithm>(clsRandom, "Algorithm"), [](auto &mod, auto &enm) {
85 enm.value("MT19937", Random::Algorithm::MT19937);
86 enm.value("RANLXS0", Random::Algorithm::RANLXS0);
87 enm.value("RANLXS1", Random::Algorithm::RANLXS1);
88 enm.value("RANLXS2", Random::Algorithm::RANLXS2);
89 enm.value("RANLXD1", Random::Algorithm::RANLXD1);
90 enm.value("RANLXD2", Random::Algorithm::RANLXD2);
91 enm.value("RANLUX", Random::Algorithm::RANLUX);
92 enm.value("RANLUX389", Random::Algorithm::RANLUX389);
93 enm.value("CMRG", Random::Algorithm::CMRG);
94 enm.value("MRG", Random::Algorithm::MRG);
95 enm.value("TAUS", Random::Algorithm::TAUS);
96 enm.value("TAUS2", Random::Algorithm::TAUS2);
97 enm.value("GFSR4", Random::Algorithm::GFSR4);
98 enm.value("NUM_ALGORITHMS", Random::Algorithm::NUM_ALGORITHMS);
99 enm.export_values();
100 });
101}
A class that can be used to generate sequences of random numbers according to a number of different a...
Definition Random.h:57

◆ declareRandomImage()

template<typename ImageT >
void lsst::afw::math::declareRandomImage ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 38 of file _random.cc.

38 {
39 wrappers.wrap([](auto &mod) {
40 mod.def("randomUniformImage", (void (*)(ImageT *, Random &))randomUniformImage<ImageT>);
41 mod.def("randomUniformPosImage", (void (*)(ImageT *, Random &))randomUniformPosImage<ImageT>);
42 mod.def("randomUniformIntImage",
43 (void (*)(ImageT *, Random &, unsigned long))randomUniformIntImage<ImageT>);
44 mod.def("randomFlatImage",
45 (void (*)(ImageT *, Random &, double const, double const))randomFlatImage<ImageT>);
46 mod.def("randomGaussianImage", (void (*)(ImageT *, Random &))randomGaussianImage<ImageT>);
47 mod.def("randomChisqImage", (void (*)(ImageT *, Random &, double const))randomChisqImage<ImageT>);
48 mod.def("randomPoissonImage", (void (*)(ImageT *, Random &, double const))randomPoissonImage<ImageT>);
49 });
50}

◆ declareStatistics() [1/2]

template<typename Pixel >
void lsst::afw::math::declareStatistics ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 37 of file _statistics.cc.

37 {
38 wrappers.wrap([](auto &mod) {
39 mod.def("makeStatistics",
40 (Statistics(*)(image::Image<Pixel> const &, image::Mask<image::MaskPixel> const &, int const,
41 StatisticsControl const &))makeStatistics<Pixel>,
42 "img"_a, "msk"_a, "flags"_a, "sctrl"_a = StatisticsControl());
43 mod.def("makeStatistics",
44 (Statistics(*)(image::MaskedImage<Pixel> const &, int const,
45 StatisticsControl const &))makeStatistics<Pixel>,
46 "mimg"_a, "flags"_a, "sctrl"_a = StatisticsControl());
47 mod.def("makeStatistics",
49 int const, StatisticsControl const &))makeStatistics<Pixel>,
50 "mimg"_a, "weights"_a, "flags"_a, "sctrl"_a = StatisticsControl());
51 mod.def("makeStatistics",
52 (Statistics(*)(image::Mask<image::MaskPixel> const &, int const, StatisticsControl const &))
53 makeStatistics, // this is not a template, just a regular overload
54 "msk"_a, "flags"_a, "sctrl"_a = StatisticsControl());
55 mod.def("makeStatistics",
56 (Statistics(*)(image::Image<Pixel> const &, int const,
57 StatisticsControl const &))makeStatistics<Pixel>,
58 "img"_a, "flags"_a, "sctrl"_a = StatisticsControl());
59 });
60}
A class to represent a 2-dimensional array of pixels.
Definition Image.h:51
Represent a 2-dimensional array of bitmask pixels.
Definition Mask.h:77
A class to manipulate images, masks, and variance as a single object.
Definition MaskedImage.h:74
Pass parameters to a Statistics object.
Definition Statistics.h:83
A class to evaluate image statistics.
Definition Statistics.h:222

◆ declareStatistics() [2/2]

void lsst::afw::math::declareStatistics ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 76 of file _statistics.cc.

76 {
77 /* Module level */
78 wrappers.wrapType(py::enum_<Property>(wrappers.module, "Property", py::arithmetic()),
79 [](auto &mod, auto &enm) {
80 enm.value("NOTHING", Property::NOTHING);
81 enm.value("ERRORS", Property::ERRORS);
82 enm.value("NPOINT", Property::NPOINT);
83 enm.value("MEAN", Property::MEAN);
84 enm.value("STDEV", Property::STDEV);
85 enm.value("VARIANCE", Property::VARIANCE);
86 enm.value("MEDIAN", Property::MEDIAN);
87 enm.value("IQRANGE", Property::IQRANGE);
88 enm.value("MEANCLIP", Property::MEANCLIP);
89 enm.value("STDEVCLIP", Property::STDEVCLIP);
90 enm.value("VARIANCECLIP", Property::VARIANCECLIP);
91 enm.value("MIN", Property::MIN);
92 enm.value("MAX", Property::MAX);
93 enm.value("SUM", Property::SUM);
94 enm.value("MEANSQUARE", Property::MEANSQUARE);
95 enm.value("ORMASK", Property::ORMASK);
96 enm.value("NCLIPPED", Property::NCLIPPED);
97 enm.value("NMASKED", Property::NMASKED);
98 enm.export_values();
99 });
100
101 wrappers.wrap([](auto &mod) { mod.def("stringToStatisticsProperty", stringToStatisticsProperty); });
102
103 using PyClass = py::class_<StatisticsControl, std::shared_ptr<StatisticsControl>>;
104 auto control = wrappers.wrapType(PyClass(wrappers.module, "StatisticsControl"), [](auto &mod, auto &cls) {
105 cls.def(py::init<double, int, lsst::afw::image::MaskPixel, bool,
106 typename StatisticsControl::WeightsBoolean>(),
107 "numSigmaClip"_a = 3.0, "numIter"_a = 3, "andMask"_a = 0x0, "isNanSafe"_a = true,
108 "useWeights"_a = StatisticsControl::WEIGHTS_NONE);
109
110 cls.def("getMaskPropagationThreshold", &StatisticsControl::getMaskPropagationThreshold);
111 cls.def("setMaskPropagationThreshold", &StatisticsControl::setMaskPropagationThreshold);
112 cls.def("getNumSigmaClip", &StatisticsControl::getNumSigmaClip);
113 cls.def("getNumIter", &StatisticsControl::getNumIter);
114 cls.def("getAndMask", &StatisticsControl::getAndMask);
115 cls.def("getNoGoodPixelsMask", &StatisticsControl::getNoGoodPixelsMask);
116 cls.def("getNanSafe", &StatisticsControl::getNanSafe);
117 cls.def("getWeighted", &StatisticsControl::getWeighted);
118 cls.def("getWeightedIsSet", &StatisticsControl::getWeightedIsSet);
119 cls.def("getCalcErrorFromInputVariance", &StatisticsControl::getCalcErrorFromInputVariance);
120 cls.def("getCalcErrorMosaicMode", &StatisticsControl::getCalcErrorMosaicMode);
121 cls.def("setNumSigmaClip", &StatisticsControl::setNumSigmaClip);
122 cls.def("setNumIter", &StatisticsControl::setNumIter);
123 cls.def("setAndMask", &StatisticsControl::setAndMask);
124 cls.def("setNoGoodPixelsMask", &StatisticsControl::setNoGoodPixelsMask);
125 cls.def("setNanSafe", &StatisticsControl::setNanSafe);
126 cls.def("setWeighted", &StatisticsControl::setWeighted);
127 cls.def("setCalcErrorFromInputVariance", &StatisticsControl::setCalcErrorFromInputVariance);
128 cls.def("setCalcErrorMosaicMode", &StatisticsControl::setCalcErrorMosaicMode);
129 });
130
131 wrappers.wrapType(py::enum_<StatisticsControl::WeightsBoolean>(control, "WeightsBoolean"),
132 [](auto &mod, auto &enm) {
133 enm.value("WEIGHTS_FALSE", StatisticsControl::WeightsBoolean::WEIGHTS_FALSE);
134 enm.value("WEIGHTS_TRUE", StatisticsControl::WeightsBoolean::WEIGHTS_TRUE);
135 enm.value("WEIGHTS_NONE", StatisticsControl::WeightsBoolean::WEIGHTS_NONE);
136 enm.export_values();
137 });
138
139 wrappers.wrapType(py::class_<Statistics>(wrappers.module, "Statistics"), [](auto &mod, auto &cls) {
140 cls.def("getResult", &Statistics::getResult, "prop"_a = Property::NOTHING);
141 cls.def("getError", &Statistics::getError, "prop"_a = Property::NOTHING);
142 cls.def("getValue", &Statistics::getValue, "prop"_a = Property::NOTHING);
143 cls.def("getOrMask", &Statistics::getOrMask);
144 });
145}

◆ declareStatisticsVectorOverloads()

template<typename Pixel >
void lsst::afw::math::declareStatisticsVectorOverloads ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 63 of file _statistics.cc.

63 {
64 wrappers.wrap([](auto &mod) {
65 mod.def("makeStatistics",
66 (Statistics(*)(std::vector<Pixel> const &, int const,
67 StatisticsControl const &))makeStatistics<Pixel>,
68 "v"_a, "flags"_a, "sctrl"_a = StatisticsControl());
69 mod.def("makeStatistics",
70 (Statistics(*)(std::vector<Pixel> const &, std::vector<WeightPixel> const &, int const,
71 StatisticsControl const &))makeStatistics<Pixel>,
72 "v"_a, "vweights"_a, "flags"_a, "sctrl"_a = StatisticsControl());
73 });
74}

◆ declareTransformBoundedField()

void lsst::afw::math::declareTransformBoundedField ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 44 of file _transformBoundedField.cc.

44 {
45 wrappers.wrapType(ClsField(wrappers.module, "TransformBoundedField"), [](auto &mod, auto &cls) {
46 cls.def(py::init<lsst::geom::Box2I const &, TransformBoundedField::Transform const &>(), "bbox"_a,
47 "transform"_a);
48
49 table::io::python::addPersistableMethods<TransformBoundedField>(cls);
50
51 cls.def("__mul__", &TransformBoundedField::operator*, py::is_operator());
52 cls.def("__eq__", &TransformBoundedField::operator==, py::is_operator());
53
54 cls.def("getTransform", &TransformBoundedField::getTransform);
55 cls.def("evaluate", (double (BoundedField::*)(double, double) const) & BoundedField::evaluate);
56 cls.def("evaluate", (ndarray::Array<double, 1, 1>(TransformBoundedField::*)(
57 ndarray::Array<double const, 1> const &,
58 ndarray::Array<double const, 1> const &) const) &
59 TransformBoundedField::evaluate);
60 cls.def("evaluate", (double (TransformBoundedField::*)(lsst::geom::Point2D const &) const) &
61 TransformBoundedField::evaluate);
62 });
63}
py::class_< TransformBoundedField, std::shared_ptr< TransformBoundedField >, BoundedField > ClsField

◆ edgePixel() [1/2]

template<typename ImageT >
ImageT::SinglePixel lsst::afw::math::edgePixel ( lsst::afw::image::detail::Image_tag )

Return an off-the-edge pixel appropriate for a given Image type.

The value is quiet_NaN if that exists for the pixel type, else 0

Definition at line 198 of file ConvolveImage.h.

200 {
201 using SinglePixelT = typename ImageT::SinglePixel;
204 : 0);
205}

◆ edgePixel() [2/2]

template<typename MaskedImageT >
MaskedImageT::SinglePixel lsst::afw::math::edgePixel ( lsst::afw::image::detail::MaskedImage_tag )

Return an off-the-edge pixel appropriate for a given MaskedImage type.

The components are:

  • image = quiet_NaN if that exists for the pixel type, else 0
  • mask = NO_DATA bit set
  • variance = infinity if that exists for the pixel type, else 0
Exceptions
lsst::pex::exceptions::LogicErrorThrown if the global mask plane dictionary does not have a NO_DATA bit.

Definition at line 219 of file ConvolveImage.h.

222 {
223 using ImagePixelT = typename MaskedImageT::Image::Pixel;
224 using VariancePixelT = typename MaskedImageT::Variance::Pixel;
225
228 : 0;
229 auto maskPixel = MaskedImageT::Mask::getPlaneBitMask("NO_DATA");
232 : 0;
233 return typename MaskedImageT::SinglePixel(imagePixel, maskPixel, variancePixel);
234}
T infinity(T... args)
T quiet_NaN(T... args)

◆ flipImage()

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::math::flipImage ( ImageT const & inImage,
bool flipLR,
bool flipTB )

Flip an image left–right and/or top–bottom.

Parameters
inImageThe image to flip
flipLRFlip left <--> right?
flipTBFlip top <--> bottom?

Definition at line 92 of file rotateImage.cc.

92 {
93 std::shared_ptr<ImageT> outImage(new ImageT(inImage, true)); // Output image
94
95 if (flipLR) {
96 if (flipTB) {
97 for (int y = 0; y != inImage.getHeight(); ++y) {
98 typename ImageT::x_iterator optr =
99 outImage->x_at(inImage.getWidth() - 1, inImage.getHeight() - y - 1);
100 for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
101 iptr != end; ++iptr, optr -= 1) {
102 *optr = *iptr;
103 }
104 }
105 } else {
106 for (int y = 0; y != inImage.getHeight(); ++y) {
107 typename ImageT::x_iterator optr = outImage->x_at(inImage.getWidth() - 1, y);
108 for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
109 iptr != end; ++iptr, optr -= 1) {
110 *optr = *iptr;
111 }
112 }
113 }
114 } else {
115 if (flipTB) {
116 for (int y = 0; y != inImage.getHeight(); ++y) {
117 typename ImageT::x_iterator optr = outImage->row_begin(inImage.getHeight() - y - 1);
118 for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
119 iptr != end; ++iptr, ++optr) {
120 *optr = *iptr;
121 }
122 }
123 } else {
124 ; // nothing to do
125 }
126 }
127
128 return outImage;
129}
int y
Definition SpanSet.cc:48

◆ int1d()

template<typename UnaryFunctionT , typename Arg >
Arg lsst::afw::math::int1d ( UnaryFunctionT func,
IntRegion< Arg > & reg,
Arg const & abserr = DEFABSERR,
Arg const & relerr = DEFRELERR )
inline

Front end for the 1d integrator.

Definition at line 704 of file Integrate.h.

706 {
707 using namespace details;
708
709 integ_dbg2 << "start int1d: " << reg.Left() << ".." << reg.Right() << std::endl;
710
711 if ((reg.Left() <= -MOCK_INF && reg.Right() > 0) || (reg.Right() >= MOCK_INF && reg.Left() < 0)) {
712 reg.AddSplit(0);
713 }
714
715 if (reg.NSplit() > 0) {
717 reg.SubDivide(&children);
718 integ_dbg2 << "Subdivided into " << children.size() << " children\n";
719 Arg answer = Arg();
720 Arg err = 0;
721 for (size_t i = 0; i < children.size(); i++) {
722 IntRegion<Arg> &child = children[i];
723 integ_dbg2 << "i = " << i;
724 integ_dbg2 << ": bounds = " << child.Left() << ", " << child.Right() << std::endl;
725 answer += int1d(func, child, abserr, relerr);
726 err += child.Err();
727 integ_dbg2 << "subint = " << child.Area() << " +- " << child.Err() << std::endl;
728 }
729 reg.SetArea(answer, err);
730 return answer;
731
732 } else {
733 if (reg.Left() <= -MOCK_INF) {
734 integ_dbg2 << "left = -infinity, right = " << reg.Right() << std::endl;
735 assert(reg.Right() <= 0.0);
736 IntRegion<Arg> modreg(1.0 / (reg.Right() - 1.0), 0.0, reg.getDbgout());
737 intGKP(Aux2<UnaryFunctionT>(func), modreg, abserr, relerr);
738 reg.SetArea(modreg.Area(), modreg.Err());
739 } else if (reg.Right() >= MOCK_INF) {
740 integ_dbg2 << "left = " << reg.Left() << ", right = infinity\n";
741 assert(reg.Left() >= 0.0);
742 IntRegion<Arg> modreg(0.0, 1.0 / (reg.Left() + 1.0), reg.getDbgout());
743 intGKP(Aux1<UnaryFunctionT>(func), modreg, abserr, relerr);
744 reg.SetArea(modreg.Area(), modreg.Err());
745 } else {
746 integ_dbg2 << "left = " << reg.Left();
747 integ_dbg2 << ", right = " << reg.Right() << std::endl;
748 intGKP(func, reg, abserr, relerr);
749 }
750 integ_dbg2 << "done int1d answer = " << reg.Area();
751 integ_dbg2 << " +- " << reg.Err() << std::endl;
752 return reg.Area();
753 }
754}
#define integ_dbg2
Definition Integrate.h:149
T endl(T... args)
void intGKP(UnaryFunctionT func, IntRegion< Arg > &reg, Arg const epsabs, Arg const epsrel, std::map< Arg, Arg > *fxmap=nullptr)
An adaptive integration algorithm which computes the integral of f over the region reg.
Definition Integrate.h:426
std::ostream * getDbgout()
Definition Integrate.h:230
void SetArea(const T &a, const T &e)
Definition Integrate.h:225
T const & Err() const
Definition Integrate.h:223
T const & Area() const
Definition Integrate.h:224
void AddSplit(const T x)
Definition Integrate.h:218
void SubDivide(std::vector< IntRegion< T > > *children)
Definition Integrate.h:189
T const & Right() const
Definition Integrate.h:222
T const & Left() const
Definition Integrate.h:221

◆ integrate()

template<typename UnaryFunctionT , typename Arg >
auto lsst::afw::math::integrate ( UnaryFunctionT func,
Arg const a,
Arg const b,
double eps = 1.0e-6 )

The 1D integrator.

Note
This simply wraps the int1d function above and handles the instantiation of the intRegion.

Definition at line 765 of file Integrate.h.

768 {
769 IntRegion<Arg> region(a, b);
770 return int1d(func, region, DEFABSERR, eps);
771}
table::Key< int > b
Arg int1d(UnaryFunctionT func, IntRegion< Arg > &reg, Arg const &abserr=DEFABSERR, Arg const &relerr=DEFRELERR)
Front end for the 1d integrator.
Definition Integrate.h:704

◆ integrate2d()

template<typename BinaryFunctionT , typename X , typename Y >
auto lsst::afw::math::integrate2d ( BinaryFunctionT func,
X x1,
X x2,
Y y1,
Y y2,
double eps = 1.0e-6 )

The 2D integrator.

Definition at line 779 of file Integrate.h.

779 {
780 auto outer = [func, x1, x2, eps](auto y) {
781 auto inner = [func, y](auto x) { return func(x, y); };
782 return integrate(inner, x1, x2, eps);
783 };
784 return integrate(outer, y1, y2, eps);
785}

◆ integrateTn()

double lsst::afw::math::integrateTn ( int n)

Definition at line 289 of file ChebyshevBoundedField.cc.

289 {
290 if (n % 2 == 1)
291 return 0;
292 else
293 return 2.0 / (1.0 - double(n * n));
294}

◆ lookupMaxInterpStyle()

Interpolate::Style lsst::afw::math::lookupMaxInterpStyle ( int const n)

Get the highest order Interpolation::Style available for 'n' points.

Parameters
nNumber of points

Definition at line 279 of file Interpolate.cc.

279 {
280 if (n < 1) {
281 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "n must be greater than 0");
282 } else if (n > 4) {
283 return Interpolate::AKIMA_SPLINE;
284 } else {
286 if (styles.empty()) {
287 styles.resize(5);
288
289 styles[0] = Interpolate::UNKNOWN; // impossible to reach as we check for n < 1
290 styles[1] = Interpolate::CONSTANT;
291 styles[2] = Interpolate::LINEAR;
292 styles[3] = Interpolate::CUBIC_SPLINE;
293 styles[4] = Interpolate::CUBIC_SPLINE;
294 }
295 return styles[n];
296 }
297}
T empty(T... args)
T resize(T... args)

◆ lookupMinInterpPoints()

int lsst::afw::math::lookupMinInterpPoints ( Interpolate::Style const style)

Get the minimum number of points needed to use the requested interpolation style.

Parameters
styleThe style in question

Definition at line 318 of file Interpolate.cc.

318 {
319 static std::vector<int> minPoints;
320 if (minPoints.empty()) {
321 minPoints.resize(Interpolate::NUM_STYLES);
322 minPoints[Interpolate::CONSTANT] = 1;
323 minPoints[Interpolate::LINEAR] = 2;
324 minPoints[Interpolate::NATURAL_SPLINE] = 3;
325 minPoints[Interpolate::CUBIC_SPLINE] = 3;
326 minPoints[Interpolate::CUBIC_SPLINE_PERIODIC] = 3;
327 minPoints[Interpolate::AKIMA_SPLINE] = 5;
328 minPoints[Interpolate::AKIMA_SPLINE_PERIODIC] = 5;
329 }
330
331 if (style >= 0 && style < Interpolate::NUM_STYLES) {
332 return minPoints[style];
333 } else {
334 throw LSST_EXCEPT(
336 str(boost::format("Style %d is out of range 0..%d") % style % (Interpolate::NUM_STYLES - 1)));
337 }
338}
Reports attempts to access elements outside a valid range of indices.
Definition Runtime.h:89

◆ makeApproximate()

template<typename PixelT >
std::shared_ptr< Approximate< PixelT > > lsst::afw::math::makeApproximate ( std::vector< double > const & x,
std::vector< double > const & y,
image::MaskedImage< PixelT > const & im,
lsst::geom::Box2I const & bbox,
ApproximateControl const & ctrl )

Construct a new Approximate object, inferring the type from the type of the given MaskedImage.

Parameters
xthe x-values of points
ythe y-values of points
imThe values at (x, y)
bboxRange where approximation should be valid
ctrldesired approximation algorithm

Definition at line 279 of file Approximate.cc.

283 {
284 switch (ctrl.getStyle()) {
285 case ApproximateControl::CHEBYSHEV:
287 new ApproximateChebyshev<PixelT>(x, y, im, bbox, ctrl));
288 default:
290 str(boost::format("Unknown ApproximationStyle: %d") % ctrl.getStyle()));
291 }
292}
AmpInfoBoxKey bbox
Definition Amplifier.cc:117

◆ makeBackground()

template<typename ImageT >
std::shared_ptr< Background > lsst::afw::math::makeBackground ( ImageT const & img,
BackgroundControl const & bgCtrl )

A convenience function that uses function overloading to make the correct type of Background.

cf. std::make_pair()

Definition at line 526 of file Background.h.

526 {
527 return std::shared_ptr<Background>(new BackgroundMI(img, bgCtrl));
528}
A class to evaluate image background levels.
Definition Background.h:434

◆ makeInterpolate() [1/2]

std::shared_ptr< Interpolate > lsst::afw::math::makeInterpolate ( ndarray::Array< double const, 1 > const & x,
ndarray::Array< double const, 1 > const & y,
Interpolate::Style const style = Interpolate::AKIMA_SPLINE )

Definition at line 357 of file Interpolate.cc.

359 {
360 return makeInterpolate(std::vector<double>(x.begin(), x.end()), std::vector<double>(y.begin(), y.end()),
361 style);
362}
std::shared_ptr< Interpolate > makeInterpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
A factory function to make Interpolate objects.

◆ makeInterpolate() [2/2]

std::shared_ptr< Interpolate > lsst::afw::math::makeInterpolate ( std::vector< double > const & x,
std::vector< double > const & y,
Interpolate::Style const style = Interpolate::AKIMA_SPLINE )

A factory function to make Interpolate objects.

Parameters
xthe x-values of points
ythe values at x[]
styledesired interpolator

Definition at line 347 of file Interpolate.cc.

348 {
349 switch (style) {
350 case Interpolate::CONSTANT:
352 default: // use GSL
353 return std::shared_ptr<Interpolate>(new InterpolateGsl(x, y, style));
354 }
355}

◆ makeStatistics() [1/10]

template<typename ImageT , typename MaskT , typename VarianceT >
Statistics makeStatistics ( ImageT const & img,
MaskT const & msk,
VarianceT const & var,
int const flags,
StatisticsControl const & sctrl = StatisticsControl() )

Handle a straight front-end to the constructor.

Definition at line 373 of file Statistics.h.

374 {
375 return Statistics(img, msk, var, flags, sctrl);
376}

◆ makeStatistics() [2/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::Image< Pixel > const & img,
int const flags,
StatisticsControl const & sctrl = StatisticsControl() )

The makeStatistics() overload to handle regular (non-masked) Images.

Parameters
imgImage (or Image) whose properties we want
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 427 of file Statistics.h.

431 {
432 // make a phony mask that will be compiled out
435 return Statistics(img, msk, var, flags, sctrl);
436}
A Mask wrapper to provide an infinite_iterator for Mask::row_begin().
Definition Statistics.h:346

◆ makeStatistics() [3/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::Image< Pixel > const & img,
lsst::afw::image::Mask< image::MaskPixel > const & msk,
int const flags,
StatisticsControl const & sctrl = StatisticsControl() )

Handle a watered-down front-end to the constructor (no variance)

Definition at line 361 of file Statistics.h.

363 {
365 return Statistics(img, msk, var, flags, sctrl);
366}

◆ makeStatistics() [4/10]

Statistics lsst::afw::math::makeStatistics ( lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const & msk,
int const flags,
StatisticsControl const & sctrl = StatisticsControl() )

Specialization to handle Masks.

Parameters
mskImage (or MaskedImage) whose properties we want
flagsDescribe what we want to calculate
sctrlControl how things are calculated

Definition at line 1136 of file Statistics.cc.

1137 {
1138 return Statistics(msk, msk, msk, flags, sctrl);
1139}

◆ makeStatistics() [5/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::MaskedImage< Pixel > const & mimg,
int const flags,
StatisticsControl const & sctrl = StatisticsControl() )

Handle MaskedImages, just pass the getImage() and getMask() values right on through.

Definition at line 383 of file Statistics.h.

384 {
385 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() || sctrl.getCalcErrorMosaicMode()) {
386 return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), flags, sctrl);
387 } else {
388 MaskImposter<WeightPixel> var;
389 return Statistics(*mimg.getImage(), *mimg.getMask(), var, flags, sctrl);
390 }
391}
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.

◆ makeStatistics() [6/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::MaskedImage< Pixel > const & mimg,
lsst::afw::image::Image< WeightPixel > const & weights,
int const flags,
StatisticsControl const & sctrl = StatisticsControl() )

Handle MaskedImages, just pass the getImage() and getMask() values right on through.

Definition at line 398 of file Statistics.h.

400 {
401 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() || sctrl.getCalcErrorMosaicMode() ||
402 (!sctrl.getWeightedIsSet() && (weights.getWidth() != 0 && weights.getHeight() != 0))) {
403 return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), weights, flags, sctrl);
404 } else {
405 MaskImposter<WeightPixel> var;
406 return Statistics(*mimg.getImage(), *mimg.getMask(), var, weights, flags, sctrl);
407 }
408}
int getWidth() const
Return the number of columns in the image.
Definition ImageBase.h:294
int getHeight() const
Return the number of rows in the image.
Definition ImageBase.h:296

◆ makeStatistics() [7/10]

template<typename EntryT >
Statistics makeStatistics ( lsst::afw::math::MaskedVector< EntryT > const & mv,
int const flags,
StatisticsControl const & sctrl = StatisticsControl() )

The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>

Parameters
mvMaskedVector
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 510 of file Statistics.h.

513 {
514 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() || sctrl.getCalcErrorMosaicMode()) {
515 return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), flags, sctrl);
516 } else {
517 MaskImposter<WeightPixel> var;
518 return Statistics(*mv.getImage(), *mv.getMask(), var, flags, sctrl);
519 }
520}
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const

◆ makeStatistics() [8/10]

template<typename EntryT >
Statistics makeStatistics ( lsst::afw::math::MaskedVector< EntryT > const & mv,
std::vector< WeightPixel > const & vweights,
int const flags,
StatisticsControl const & sctrl = StatisticsControl() )

The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>

Parameters
mvMaskedVector
vweightsweights
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 527 of file Statistics.h.

531 {
532 ImageImposter<WeightPixel> weights(vweights);
533
534 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() || sctrl.getCalcErrorMosaicMode()) {
535 return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), weights, flags, sctrl);
536 } else {
537 MaskImposter<WeightPixel> var;
538 return Statistics(*mv.getImage(), *mv.getMask(), var, weights, flags, sctrl);
539 }
540}
A vector wrapper to provide a vector with the necessary methods and typedefs to be processed by Stati...
Definition Statistics.h:443

◆ makeStatistics() [9/10]

template<typename EntryT >
Statistics makeStatistics ( std::vector< EntryT > const & v,
int const flags,
StatisticsControl const & sctrl = StatisticsControl() )

The makeStatistics() overload to handle std::vector<>

Parameters
vImage (or MaskedImage) whose properties we want
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 476 of file Statistics.h.

479 {
480 ImageImposter<EntryT> img(v); // wrap the vector in a fake image
481 MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
483 return Statistics(img, msk, var, flags, sctrl);
484}

◆ makeStatistics() [10/10]

template<typename EntryT >
Statistics makeStatistics ( std::vector< EntryT > const & v,
std::vector< WeightPixel > const & vweights,
int const flags,
StatisticsControl const & sctrl = StatisticsControl() )

The makeStatistics() overload to handle std::vector<>

Parameters
vImage (or MaskedImage) whose properties we want
vweightsWeights
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 491 of file Statistics.h.

495 {
496 ImageImposter<EntryT> img(v); // wrap the vector in a fake image
497 MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
499
500 ImageImposter<WeightPixel> weights(vweights);
501
502 return Statistics(img, msk, var, weights, flags, sctrl);
503}

◆ makeWarpingKernel()

std::shared_ptr< SeparableKernel > lsst::afw::math::makeWarpingKernel ( std::string name)

Return a warping kernel given its name.

Intended for use with warpImage() and warpExposure().

Allowed names are:

A warping kernel is a subclass of SeparableKernel with the following properties (though for the sake of speed few, if any, of these are enforced):

  • Width and height are even. This is unusual for a kernel, but it is more efficient because if the extra pixel was included it would always have value 0.
  • The center pixels should be adjacent to the kernel center. Again, this avoids extra pixels that are sure to have value 0.
  • It has two parameters: fractional x and fractional row position on the source image. The fractional position is the offset of the pixel position on the source from the center of a nearby source pixel:
    • The pixel whose center is just below or to the left of the source position: 0 <= fractional x and y < 0 and the kernel center is the default (size-1)/2.
    • The pixel whose center is just above or to the right of the source position: -1.0 < fractional x and y <= 0 and the kernel center must be set to (size+1)/2.

Definition at line 224 of file warpExposure.cc.

224 {
225 using KernelPtr = std::shared_ptr<SeparableKernel>;
226 std::smatch matches;
227 static const std::regex LanczosRE("lanczos(\\d+)");
228 if (name == "bilinear") {
229 return KernelPtr(new BilinearWarpingKernel());
230 } else if (std::regex_match(name, matches, LanczosRE)) {
231 std::string orderStr(matches[1].first, matches[1].second);
232 int order = std::stoi(orderStr);
233 return KernelPtr(new LanczosWarpingKernel(order));
234 } else if (name == "nearest") {
235 return KernelPtr(new NearestWarpingKernel());
236 } else {
237 throw LSST_EXCEPT(pexExcept::InvalidParameterError, "unknown warping kernel name: \"" + name + "\"");
238 }
239}
Bilinear warping: fast; good for undersampled data.
T regex_match(T... args)
T stoi(T... args)
table::Key< int > order

◆ minimize() [1/2]

template<typename ReturnT >
FitResults lsst::afw::math::minimize ( lsst::afw::math::Function1< ReturnT > const & function,
std::vector< double > const & initialParameterList,
std::vector< double > const & stepSizeList,
std::vector< double > const & measurementList,
std::vector< double > const & varianceList,
std::vector< double > const & xPositionList,
double errorDef )

Find the minimum of a function(x)

Parameters
functionfunction(x) to be minimized
initialParameterListinitial guess for parameters
stepSizeListstep size for each parameter; use 0.0 to fix a parameter
measurementListmeasured values
varianceListvariance for each measurement
xPositionListx position of each measurement
errorDefwhat is this?
Returns
true if minimum is valid, false otherwise

Uses the Minuit fitting package with a standard definition of chiSq (see MinimizerFunctionBase1).

Exceptions
lsst::pex::exceptions::InvalidParameterErrorif any input vector is the wrong length

To do:

  • Document stepSizeList better
  • Document errorDef
  • Compute stepSize automatically? (if so, find a different way to fix parameters)

Definition at line 176 of file minimize.cc.

179 {
180 unsigned int const nParameters = function.getNParameters();
181 if (initialParameterList.size() != nParameters) {
182 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "initialParameterList is the wrong length");
183 }
184 if (stepSizeList.size() != nParameters) {
185 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "stepSizeList is the wrong length");
186 }
187 unsigned int const nMeasurements = measurementList.size();
188 if (varianceList.size() != nMeasurements) {
189 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "varianceList is the wrong length");
190 }
191 if (xPositionList.size() != nMeasurements) {
192 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "xPositionList is the wrong length");
193 }
194
195 MinimizerFunctionBase1<ReturnT> minimizerFunc(function, measurementList, varianceList, xPositionList,
196 errorDef);
197
198 ROOT::Minuit2::MnUserParameters fitPar;
199 std::vector<std::string> paramNames;
200 for (unsigned int i = 0; i < nParameters; ++i) {
201 paramNames.push_back((boost::format("p%d") % i).str());
202 fitPar.Add(paramNames[i].c_str(), initialParameterList[i], stepSizeList[i]);
203 }
204
205 ROOT::Minuit2::MnMigrad migrad(minimizerFunc, fitPar);
206 ROOT::Minuit2::FunctionMinimum min = migrad();
207 ROOT::Minuit2::MnMinos minos(minimizerFunc, min);
208
209 FitResults fitResults;
210 fitResults.chiSq = min.Fval();
211 fitResults.isValid = min.IsValid() && std::isfinite(fitResults.chiSq);
212 if (!fitResults.isValid) {
213 LOGL_WARN("lsst.afw.math.minimize", "Fit failed to converge");
214 }
215
216 for (unsigned int i = 0; i < nParameters; ++i) {
217 fitResults.parameterList.push_back(min.UserState().Value(paramNames[i].c_str()));
218 if (fitResults.isValid) {
219 fitResults.parameterErrorList.push_back(minos(i));
220 } else {
221 double e = min.UserState().Error(paramNames[i].c_str());
222 std::pair<double, double> ep(-1 * e, e);
223 fitResults.parameterErrorList.push_back(ep);
224 }
225 }
226 return fitResults;
227}
int min
#define LOGL_WARN(logger, message...)
Log a warn-level message using a varargs/printf style interface.
Definition Log.h:547
unsigned int getNParameters() const noexcept
Return the number of function parameters.
Definition Function.h:112
T isfinite(T... args)
T push_back(T... args)

◆ minimize() [2/2]

template<typename ReturnT >
FitResults lsst::afw::math::minimize ( lsst::afw::math::Function2< ReturnT > const & function,
std::vector< double > const & initialParameterList,
std::vector< double > const & stepSizeList,
std::vector< double > const & measurementList,
std::vector< double > const & varianceList,
std::vector< double > const & xPositionList,
std::vector< double > const & yPositionList,
double errorDef )

Find the minimum of a function(x, y)

Uses the Minuit fitting package with a standard definition of chiSq. (see MinimizerFunctionBase2).

Parameters
functionfunction(x,y) to be minimized
initialParameterListinitial guess for parameters
stepSizeListstep size for each parameter; use 0.0 to fix a parameter
measurementListmeasured values
varianceListvariance for each measurement
xPositionListx position of each measurement
yPositionListy position of each measurement
errorDefwhat is this?
Returns
true if minimum is valid, false otherwise
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif any input vector is the wrong length

To do:

  • Document stepSizeList better
  • Document errorDef
  • Compute stepSize automatically? (if so, find a different way to fix parameters)

Definition at line 230 of file minimize.cc.

233 {
234 unsigned int const nParameters = function.getNParameters();
235 if (initialParameterList.size() != nParameters) {
236 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "initialParameterList is the wrong length");
237 }
238 if (stepSizeList.size() != nParameters) {
239 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "stepSizeList is the wrong length");
240 }
241 unsigned int const nMeasurements = measurementList.size();
242 if (varianceList.size() != nMeasurements) {
243 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "varianceList is the wrong length");
244 }
245 if (xPositionList.size() != nMeasurements) {
246 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "xPositionList is the wrong length");
247 }
248 if (yPositionList.size() != nMeasurements) {
249 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "yPositionList is the wrong length");
250 }
251
252 MinimizerFunctionBase2<ReturnT> minimizerFunc(function, measurementList, varianceList, xPositionList,
253 yPositionList, errorDef);
254
255 ROOT::Minuit2::MnUserParameters fitPar;
256 std::vector<std::string> paramNames;
257 for (unsigned int i = 0; i < nParameters; ++i) {
258 paramNames.push_back((boost::format("p%d") % i).str());
259 fitPar.Add(paramNames[i].c_str(), initialParameterList[i], stepSizeList[i]);
260 }
261
262 ROOT::Minuit2::MnMigrad migrad(minimizerFunc, fitPar);
263 ROOT::Minuit2::FunctionMinimum min = migrad();
264 ROOT::Minuit2::MnMinos minos(minimizerFunc, min);
265
266 FitResults fitResults;
267 fitResults.chiSq = min.Fval();
268 fitResults.isValid = min.IsValid() && std::isfinite(fitResults.chiSq);
269 if (!fitResults.isValid) {
270 LOGL_WARN("lsst.afw.math.minimize", "Fit failed to converge");
271 }
272
273 for (unsigned int i = 0; i < nParameters; ++i) {
274 fitResults.parameterList.push_back(min.UserState().Value(paramNames[i].c_str()));
275 if (fitResults.isValid) {
276 fitResults.parameterErrorList.push_back(minos(i));
277 } else {
278 double e = min.UserState().Error(paramNames[i].c_str());
279 std::pair<double, double> ep(-1 * e, e);
280 fitResults.parameterErrorList.push_back(ep);
281 }
282 }
283 return fitResults;
284}

◆ offsetImage()

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::math::offsetImage ( ImageT const & image,
float dx,
float dy,
std::string const & algorithmName = "lanczos5",
unsigned int buffer = 0 )

Return an image offset by (dx, dy) using the specified algorithm.

Parameters
imageThe image to offset
dxmove the image this far in the column direction
dymove the image this far in the row direction
algorithmNameType of resampling Kernel to use
bufferWidth of buffer (border) around kernel image to allow for warping edge effects (pixels). Values < 0 are treated as 0. This is only used during computation; the final image has the same dimensions as the kernel.
Note
The image pixels are always offset by a fraction of a pixel and the image origin (XY0) picks is modified to handle the integer portion of the offset. In the special case that the offset in both x and y lies in the range (-1, 1) the origin is not changed. Otherwise the pixels are shifted by (-0.5, 0.5] pixels and the origin shifted accordingly.
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif the algorithm is invalid

Definition at line 41 of file offsetImage.cc.

44 {
45 std::shared_ptr<SeparableKernel> offsetKernel = makeWarpingKernel(algorithmName);
46
48 if (buffer > 0) {
49 // Paste input image into buffered image
50 lsst::geom::Extent2I const& dims = inImage.getDimensions();
51 std::shared_ptr<ImageT> buffered(new ImageT(dims.getX() + 2 * buffer, dims.getY() + 2 * buffer));
52 buffImage = buffered;
53 lsst::geom::Box2I box(lsst::geom::Point2I(buffer, buffer), dims);
54 buffImage->assign(inImage, box);
55 } else {
56 buffImage = std::make_shared<ImageT>(inImage);
57 }
58
59 if (offsetKernel->getWidth() > buffImage->getWidth() ||
60 offsetKernel->getHeight() > buffImage->getHeight()) {
62 (boost::format("Image of size %dx%d is too small to offset using a %s kernel"
63 "(minimum %dx%d)") %
64 buffImage->getWidth() % buffImage->getHeight() % algorithmName %
65 offsetKernel->getWidth() % offsetKernel->getHeight())
66 .str());
67 }
68
69 // std::shared_ptr<ImageT> convImage(new ImageT(buffImage, true)); // output image, a deep copy
70 std::shared_ptr<ImageT> convImage(new ImageT(buffImage->getDimensions())); // Convolved image
71
72 int dOrigX, dOrigY;
73 double fracX, fracY;
74 // If the offset in both axes is in (-1, 1) use it as is, and don't shift the origin
75 if (dx > -1 && dx < 1 && dy > -1 && dy < 1) {
76 dOrigX = 0;
77 dOrigY = 0;
78 fracX = dx;
79 fracY = dy;
80 } else {
81 dOrigX = static_cast<int>(std::floor(dx + 0.5));
82 dOrigY = static_cast<int>(std::floor(dy + 0.5));
83 fracX = dx - dOrigX;
84 fracY = dy - dOrigY;
85 }
86
87 // We seem to have to pass -fracX, -fracY to setKernelParameters, for reasons RHL doesn't understand
88 double dKerX = -fracX;
89 double dKerY = -fracY;
90
91 //
92 // If the shift is -ve, the generated shift kernel (e.g. Lanczos5) is quite asymmetric, with the
93 // largest coefficients to the left of centre. We therefore move the centre of calculated shift kernel
94 // one to the right to center up the largest coefficients
95 //
96 if (dKerX < 0) {
97 offsetKernel->setCtr(offsetKernel->getCtr() + lsst::geom::Extent2I(1, 0));
98 }
99 if (dKerY < 0) {
100 offsetKernel->setCtr(offsetKernel->getCtr() + lsst::geom::Extent2I(0, 1));
101 }
102
103 offsetKernel->setKernelParameters(std::make_pair(dKerX, dKerY));
104
105 ConvolutionControl convolutionControl;
106 convolutionControl.setDoNormalize(true);
107 convolutionControl.setDoCopyEdge(true);
108 convolve(*convImage, *buffImage, *offsetKernel, convolutionControl);
109
111 if (buffer > 0) {
112 lsst::geom::Box2I box(lsst::geom::Point2I(buffer, buffer), inImage.getDimensions());
113 std::shared_ptr<ImageT> out(new ImageT(*convImage, box, afwImage::LOCAL, true));
114 outImage = out;
115 } else {
116 outImage = convImage;
117 }
118
119 // adjust the origin; do this after convolution since convolution also sets XY0
120 outImage->setXY0(lsst::geom::Point2I(inImage.getX0() + dOrigX, inImage.getY0() + dOrigY));
121
122 return outImage;
123}
An integer coordinate rectangle.
Definition Box.h:55
Reports attempts to exceed implementation-defined length limits for some classes.
Definition Runtime.h:76
T floor(T... args)
T make_pair(T... args)
std::shared_ptr< SeparableKernel > makeWarpingKernel(std::string name)
Return a warping kernel given its name.
Extent< int, 2 > Extent2I
Definition Extent.h:397

◆ operator*()

std::shared_ptr< BoundedField > lsst::afw::math::operator* ( double const scale,
std::shared_ptr< BoundedField const > bf )

Definition at line 254 of file BoundedField.cc.

254 {
255 return *bf * scale;
256}

◆ printKernel()

void lsst::afw::math::printKernel ( lsst::afw::math::Kernel const & kernel,
bool doNormalize,
double x = 0,
double y = 0,
std::string pixelFmt = "%7.3f" )

Print the pixel values of a Kernel to std::cout.

Rows increase upward and columns to the right; thus the lower left pixel is (0,0).

Parameters
kernelthe kernel
doNormalizeif true, normalize kernel
xx at which to evaluate kernel
yy at which to evaluate kernel
pixelFmtformat for pixel values

Definition at line 38 of file KernelFunctions.cc.

38 {
39 using Pixel = Kernel::Pixel;
40
41 image::Image<Pixel> kImage(kernel.getDimensions());
42 double kSum = kernel.computeImage(kImage, doNormalize, xPos, yPos);
43
44 for (int y = kImage.getHeight() - 1; y >= 0; --y) {
45 for (image::Image<Pixel>::const_x_iterator ptr = kImage.row_begin(y); ptr != kImage.row_end(y);
46 ++ptr) {
47 std::cout << boost::format(pixelFmt) % *ptr << " ";
48 }
50 }
51
52 if (doNormalize && std::abs(static_cast<double>(kSum) - 1.0) > 1.0e-5) {
53 std::cout << boost::format("Warning! Sum of all pixels = %9.5f != 1.0\n") % kSum;
54 }
56}
typename _const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
Definition ImageBase.h:141

◆ PYBIND11_MODULE()

lsst::afw::math::PYBIND11_MODULE ( _math ,
mod  )

Definition at line 51 of file _math.cc.

51 {
52 lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.math");
53 wrapApproximate(wrappers);
54 wrapBackground(wrappers);
55 wrapBoundedField(wrappers);
57 wrapConvolveImage(wrappers);
58 wrapFunction(wrappers);
59 wrapFunctionLibrary(wrappers);
60 wrapGaussianProcess(wrappers);
61 wrapInterpolate(wrappers);
62 wrapKernel(wrappers);
63 wrapLeastSquares(wrappers);
64 wrapMinimize(wrappers);
65 wrapOffsetImage(wrappers);
68 wrapRandom(wrappers);
69 wrapSpatialCell(wrappers);
70 wrapStack(wrappers);
71 wrapStatistics(wrappers);
73 wrapWarpExposure(wrappers);
74 wrappers.finish();
75}
void wrapBoundedField(lsst::utils::python::WrapperCollection &wrappers)
void wrapKernel(lsst::utils::python::WrapperCollection &wrappers)
Definition _kernel.cc:39
void wrapInterpolate(lsst::utils::python::WrapperCollection &wrappers)
void wrapTransformBoundedField(lsst::utils::python::WrapperCollection &)
void wrapConvolveImage(lsst::utils::python::WrapperCollection &wrappers)
void wrapChebyshevBoundedField(lsst::utils::python::WrapperCollection &wrappers)
void wrapStatistics(lsst::utils::python::WrapperCollection &)
void wrapBackground(lsst::utils::python::WrapperCollection &wrappers)
void wrapGaussianProcess(lsst::utils::python::WrapperCollection &wrappers)
void wrapLeastSquares(lsst::utils::python::WrapperCollection &wrappers)
void wrapApproximate(lsst::utils::python::WrapperCollection &wrappers)
void wrapRandom(lsst::utils::python::WrapperCollection &)
Definition _random.cc:103
void wrapOffsetImage(lsst::utils::python::WrapperCollection &)
void wrapProductBoundedField(lsst::utils::python::WrapperCollection &)
void wrapSpatialCell(lsst::utils::python::WrapperCollection &)
void wrapFunctionLibrary(lsst::utils::python::WrapperCollection &wrappers)
void wrapStack(lsst::utils::python::WrapperCollection &)
Definition _stack.cc:113
void wrapMinimize(lsst::utils::python::WrapperCollection &)
Definition _minimize.cc:60
void wrapWarpExposure(lsst::utils::python::WrapperCollection &)
void wrapPixelAreaBoundedField(lsst::utils::python::WrapperCollection &)
void wrapFunction(lsst::utils::python::WrapperCollection &wrappers)
Definition _function.cc:142

◆ randomChisqImage()

template<typename ImageT >
void lsst::afw::math::randomChisqImage ( ImageT * image,
Random & rand,
double const nu )

Set image to random numbers with a chi^2_{nu} distribution.

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.
[in]nunumber of degrees of freedom

Definition at line 135 of file RandomImage.cc.

135 {
136 lsst::afw::image::for_each_pixel(*image, do_chisq<typename ImageT::Pixel>(rand, nu));
137}
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
Set each pixel in an Image<LhsT> to func()

◆ randomFlatImage()

template<typename ImageT >
void lsst::afw::math::randomFlatImage ( ImageT * image,
Random & rand,
double const a,
double const b )

Set image to random numbers uniformly distributed in the range [a, b)

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.
[in]a(inclusive) lower limit for random variates
[in]b(exclusive) upper limit for random variates

Definition at line 125 of file RandomImage.cc.

125 {
126 lsst::afw::image::for_each_pixel(*image, do_flat<typename ImageT::Pixel>(rand, a, b));
127}

◆ randomGaussianImage()

template<typename ImageT >
void lsst::afw::math::randomGaussianImage ( ImageT * image,
Random & rand )

Set image to random numbers with a gaussian N(0, 1) distribution.

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.

Definition at line 130 of file RandomImage.cc.

130 {
131 lsst::afw::image::for_each_pixel(*image, do_gaussian<typename ImageT::Pixel>(rand));
132}

◆ randomPoissonImage()

template<typename ImageT >
void lsst::afw::math::randomPoissonImage ( ImageT * image,
Random & rand,
double const mu )

Set image to random numbers with a Poisson distribution with mean mu (n.b.

not per-pixel)

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.
[in]mumean of distribution

Definition at line 140 of file RandomImage.cc.

140 {
141 lsst::afw::image::for_each_pixel(*image, do_poisson<typename ImageT::Pixel>(rand, mu));
142}

◆ randomUniformImage()

template<typename ImageT >
void lsst::afw::math::randomUniformImage ( ImageT * image,
Random & rand )

Set image to random numbers uniformly distributed in the range [0, 1)

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.

Definition at line 110 of file RandomImage.cc.

110 {
111 lsst::afw::image::for_each_pixel(*image, do_uniform<typename ImageT::Pixel>(rand));
112}

◆ randomUniformIntImage()

template<typename ImageT >
void lsst::afw::math::randomUniformIntImage ( ImageT * image,
Random & rand,
unsigned long n )

Set image to random integers uniformly distributed in the range 0 ... n - 1.

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.
[in]n(exclusive) upper limit for random variates

Definition at line 120 of file RandomImage.cc.

120 {
121 lsst::afw::image::for_each_pixel(*image, do_uniformInt<typename ImageT::Pixel>(rand, n));
122}

◆ randomUniformPosImage()

template<typename ImageT >
void lsst::afw::math::randomUniformPosImage ( ImageT * image,
Random & rand )

Set image to random numbers uniformly distributed in the range (0, 1)

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.

Definition at line 115 of file RandomImage.cc.

115 {
116 lsst::afw::image::for_each_pixel(*image, do_uniformPos<typename ImageT::Pixel>(rand));
117}

◆ rotateImageBy90()

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::math::rotateImageBy90 ( ImageT const & image,
int nQuarter )

Rotate an image by an integral number of quarter turns.

Parameters
imageThe image to rotate
nQuarterthe desired number of quarter turns

Definition at line 39 of file rotateImage.cc.

39 {
40 std::shared_ptr<ImageT> outImage; // output image
41
42 while (nQuarter < 0) {
43 nQuarter += 4;
44 }
45
46 switch (nQuarter % 4) {
47 case 0:
48 outImage.reset(new ImageT(inImage, true)); // a deep copy of inImage
49 break;
50 case 1:
51 outImage.reset(new ImageT(lsst::geom::Extent2I(inImage.getHeight(), inImage.getWidth())));
52
53 for (int y = 0; y != inImage.getHeight(); ++y) {
54 typename ImageT::y_iterator optr = outImage->col_begin(inImage.getHeight() - y - 1);
55 for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
56 iptr != end; ++iptr, ++optr) {
57 *optr = *iptr;
58 }
59 }
60
61 break;
62 case 2:
63 outImage.reset(new ImageT(inImage.getDimensions()));
64
65 for (int y = 0; y != inImage.getHeight(); ++y) {
66 typename ImageT::x_iterator optr =
67 outImage->x_at(inImage.getWidth() - 1, inImage.getHeight() - y - 1);
68 for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
69 iptr != end; ++iptr, optr -= 1) {
70 *optr = *iptr;
71 }
72 }
73 break;
74 case 3:
75 outImage.reset(new ImageT(lsst::geom::Extent2I(inImage.getHeight(), inImage.getWidth())));
76
77 for (int y = 0; y != inImage.getHeight(); ++y) {
78 typename ImageT::y_iterator optr = outImage->y_at(y, inImage.getWidth() - 1);
79 for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
80 iptr != end; ++iptr, optr -= 1) {
81 *optr = *iptr;
82 }
83 }
84
85 break;
86 }
87
88 return outImage;
89}
T reset(T... args)

◆ scaledPlus()

template<typename OutImageT , typename InImageT >
void lsst::afw::math::scaledPlus ( OutImageT & outImage,
double c1,
InImageT const & inImage1,
double c2,
InImageT const & inImage2 )

Compute the scaled sum of two images.

outImage = c1 inImage1 + c2 inImage2

For example to linearly interpolate between two images set: c1 = 1.0 - fracDist c2 = fracDist where fracDist is the fractional distance of outImage from inImage1: location of outImage - location of inImage1 fracDist = ----------------------------------------— location of inImage2 - location of inImage1

Parameters
[out]outImageoutput image
[in]c1coefficient for image 1
[in]inImage1input image 1
[in]c2coefficient for image 2
[in]inImage2input image 2
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif outImage is not same dimensions as inImage1 and inImage2.

Definition at line 153 of file ConvolveImage.cc.

154 {
155 if (outImage.getDimensions() != inImage1.getDimensions()) {
157 os << "outImage dimensions = ( " << outImage.getWidth() << ", " << outImage.getHeight() << ") != ("
158 << inImage1.getWidth() << ", " << inImage1.getHeight() << ") = inImage1 dimensions";
160 } else if (inImage1.getDimensions() != inImage2.getDimensions()) {
162 os << "inImage1 dimensions = ( " << inImage1.getWidth() << ", " << inImage1.getHeight() << ") != ("
163 << inImage2.getWidth() << ", " << inImage2.getHeight() << ") = inImage2 dimensions";
165 }
166
167 using InConstXIter = typename InImageT::const_x_iterator;
168 using OutXIter = typename OutImageT::x_iterator;
169 for (int y = 0; y != inImage1.getHeight(); ++y) {
170 InConstXIter const end1 = inImage1.row_end(y);
171 InConstXIter inIter1 = inImage1.row_begin(y);
172 InConstXIter inIter2 = inImage2.row_begin(y);
173 OutXIter outIter = outImage.row_begin(y);
174 for (; inIter1 != end1; ++inIter1, ++inIter2, ++outIter) {
175 *outIter = (*inIter1 * c1) + (*inIter2 * c2);
176 }
177 }
178}

◆ statisticsStack() [1/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( image::Image< PixelT > & out,
std::vector< std::shared_ptr< image::Image< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl,
WeightVector const & wvector )

Definition at line 359 of file Stack.cc.

360 {
361 checkObjectsAndWeights(images, wvector);
362 checkOnlyOneFlag(flags);
363 checkImageSizes(out, images);
364
365 if (wvector.empty()) {
366 return computeImageStack<PixelT, false>(out, images, flags, sctrl);
367 } else {
368 return computeImageStack<PixelT, true>(out, images, flags, sctrl, wvector);
369 }
370}

◆ statisticsStack() [2/18]

template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > lsst::afw::math::statisticsStack ( image::Image< PixelT > const & image,
Property flags,
char dimension,
StatisticsControl const & sctrl )

A function to compute statistics on the rows or columns of an image.

Definition at line 444 of file Stack.cc.

445 {
446 int x0 = image.getX0();
447 int y0 = image.getY0();
448 using MImage = image::MaskedImage<PixelT>;
450
451 // do each row or column, one at a time
452 // - create a subimage with a bounding box, and get the stats and assign the value to the output image
453 if (dimension == 'x') {
454 imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(1, image.getHeight())));
455 int y = y0;
456 typename MImage::y_iterator oEnd = imgOut->col_end(0);
457 for (typename MImage::y_iterator oPtr = imgOut->col_begin(0); oPtr != oEnd; ++oPtr, ++y) {
461 Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
462 *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
463 stat.getError() * stat.getError());
464 }
465
466 } else if (dimension == 'y') {
467 imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(image.getWidth(), 1)));
468 int x = x0;
469 typename MImage::x_iterator oEnd = imgOut->row_end(0);
470 for (typename MImage::x_iterator oPtr = imgOut->row_begin(0); oPtr != oEnd; ++oPtr, ++x) {
474 Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
475 *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
476 stat.getError() * stat.getError());
477 }
478 } else {
480 "Can only run statisticsStack in x or y for single image.");
481 }
482
483 return imgOut;
484}
A pixel of a MaskedImage.
Definition Pixel.h:148
double getError(Property const prop=NOTHING) const
Return the error in the desired property (if specified in the constructor)
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)

◆ statisticsStack() [3/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( image::MaskedImage< PixelT > & out,
std::vector< std::shared_ptr< image::MaskedImage< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl,
WeightVector const & wvector,
image::MaskPixel clipped,
image::MaskPixel excuse )

Definition at line 250 of file Stack.cc.

253 {
254 checkObjectsAndWeights(images, wvector);
255 checkOnlyOneFlag(flags);
256 checkImageSizes(out, images);
257
258 if (sctrl.getWeighted()) {
259 if (wvector.empty()) {
260 return computeMaskedImageStack<PixelT, true, true>(out, images, flags, sctrl, clipped,
261 excuse); // use variance
262 } else {
263 return computeMaskedImageStack<PixelT, true, false>(out, images, flags, sctrl, clipped, excuse,
264 wvector); // use wvector
265 }
266 } else {
267 if (!wvector.empty()) {
268 LOGL_WARN(_log,
269 "Weights passed on to statisticsStack are ignored as sctrl.getWeighted() is False."
270 "Set sctrl.setWeighted(True) for them to be used.");
271 }
272 return computeMaskedImageStack<PixelT, false, false>(out, images, flags, sctrl, clipped, excuse);
273 }
274}

◆ statisticsStack() [4/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( image::MaskedImage< PixelT > & out,
std::vector< std::shared_ptr< image::MaskedImage< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl,
WeightVector const & wvector,
image::MaskPixel clipped,
std::vector< std::pair< image::MaskPixel, image::MaskPixel > > const & maskMap )

Definition at line 277 of file Stack.cc.

280 {
281 checkObjectsAndWeights(images, wvector);
282 checkOnlyOneFlag(flags);
283 checkImageSizes(out, images);
284
285 if (sctrl.getWeighted()) {
286 if (wvector.empty()) {
287 return computeMaskedImageStack<PixelT, true, true>(out, images, flags, sctrl, clipped,
288 maskMap); // use variance
289 } else {
290 return computeMaskedImageStack<PixelT, true, false>(out, images, flags, sctrl, clipped, maskMap,
291 wvector); // use wvector
292 }
293 } else {
294 return computeMaskedImageStack<PixelT, false, false>(out, images, flags, sctrl, clipped, maskMap);
295 }
296}

◆ statisticsStack() [5/18]

template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > lsst::afw::math::statisticsStack ( image::MaskedImage< PixelT > const & image,
Property flags,
char dimension,
StatisticsControl const & sctrl )

A function to compute statistics on the rows or columns of an image.

Definition at line 487 of file Stack.cc.

489 {
490 int const x0 = image.getX0();
491 int const y0 = image.getY0();
492 using MImage = image::MaskedImage<PixelT>;
494
495 // do each row or column, one at a time
496 // - create a subimage with a bounding box, and get the stats and assign the value to the output image
497 if (dimension == 'x') {
498 imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(1, image.getHeight())));
499 int y = 0;
500 typename MImage::y_iterator oEnd = imgOut->col_end(0);
501 for (typename MImage::y_iterator oPtr = imgOut->col_begin(0); oPtr != oEnd; ++oPtr, ++y) {
505 Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
506 *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
507 stat.getError() * stat.getError());
508 }
509
510 } else if (dimension == 'y') {
511 imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(image.getWidth(), 1)));
512 int x = 0;
513 typename MImage::x_iterator oEnd = imgOut->row_end(0);
514 for (typename MImage::x_iterator oPtr = imgOut->row_begin(0); oPtr != oEnd; ++oPtr, ++x) {
518 Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
519 *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
520 stat.getError() * stat.getError());
521 }
522 } else {
524 "Can only run statisticsStack in x or y for single image.");
525 }
526
527 return imgOut;
528}

◆ statisticsStack() [6/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( lsst::afw::image::Image< PixelT > & out,
std::vector< std::shared_ptr< lsst::afw::image::Image< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const & wvector = std::vectorlsst::afw::image::VariancePixel >(0) )

@ brief compute statistical stack of Image.

Write to output image in-situ

Parameters
outOutput image
imagesImages to process
flagsstatistics requested
sctrlControl structure
wvectorvector containing weights

◆ statisticsStack() [7/18]

template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > lsst::afw::math::statisticsStack ( lsst::afw::image::Image< PixelT > const & image,
Property flags,
char dimension,
StatisticsControl const & sctrl = StatisticsControl() )

A function to compute statistics on the rows or columns of an image.

Definition at line 444 of file Stack.cc.

445 {
446 int x0 = image.getX0();
447 int y0 = image.getY0();
448 using MImage = image::MaskedImage<PixelT>;
450
451 // do each row or column, one at a time
452 // - create a subimage with a bounding box, and get the stats and assign the value to the output image
453 if (dimension == 'x') {
454 imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(1, image.getHeight())));
455 int y = y0;
456 typename MImage::y_iterator oEnd = imgOut->col_end(0);
457 for (typename MImage::y_iterator oPtr = imgOut->col_begin(0); oPtr != oEnd; ++oPtr, ++y) {
461 Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
462 *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
463 stat.getError() * stat.getError());
464 }
465
466 } else if (dimension == 'y') {
467 imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(image.getWidth(), 1)));
468 int x = x0;
469 typename MImage::x_iterator oEnd = imgOut->row_end(0);
470 for (typename MImage::x_iterator oPtr = imgOut->row_begin(0); oPtr != oEnd; ++oPtr, ++x) {
474 Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
475 *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
476 stat.getError() * stat.getError());
477 }
478 } else {
480 "Can only run statisticsStack in x or y for single image.");
481 }
482
483 return imgOut;
484}

◆ statisticsStack() [8/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( lsst::afw::image::MaskedImage< PixelT > & out,
std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl,
std::vector< lsst::afw::image::VariancePixel > const & wvector,
image::MaskPixel clipped,
std::vector< std::pair< image::MaskPixel, image::MaskPixel > > const & maskMap )

A function to compute some statistics of a stack of Masked Images.

Parameters
[out]outOutput MaskedImage.
[in]imagesMaskedImages to process.
[in]flagsStatistics requested.
[in]sctrlControl structure.
[in]wvectorVector of weights.
[in]clippedMask to set for pixels that were clipped (NOT rejected due to masks).
[in]maskMapVector of pairs of mask pixel values; any pixel on an input with any of the bits in .first will result in all of the bits in .second being set on the corresponding pixel on the output.

If none of the input images are valid for some pixel, the afwMath::StatisticsControl::getNoGoodPixelsMask() bit(s) are set.

All the work is done in the function computeMaskedImageStack.

◆ statisticsStack() [9/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( lsst::afw::image::MaskedImage< PixelT > & out,
std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const & wvector = std::vectorlsst::afw::image::VariancePixel >(0),
image::MaskPixel clipped = 0,
image::MaskPixel excuse = 0 )

@ brief compute statistical stack of MaskedImage.

Write to output image in-situ

Parameters
outOutput image
imagesMaskedImages to process
flagsstatistics requested
sctrlcontrol structure
wvectorvector containing weights
clippedbitmask to set if any input was clipped or masked
excusebitmask to excuse from marking as clipped

◆ statisticsStack() [10/18]

template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > lsst::afw::math::statisticsStack ( lsst::afw::image::MaskedImage< PixelT > const & image,
Property flags,
char dimension,
StatisticsControl const & sctrl = StatisticsControl() )

A function to compute statistics on the rows or columns of an image.

Definition at line 487 of file Stack.cc.

489 {
490 int const x0 = image.getX0();
491 int const y0 = image.getY0();
492 using MImage = image::MaskedImage<PixelT>;
494
495 // do each row or column, one at a time
496 // - create a subimage with a bounding box, and get the stats and assign the value to the output image
497 if (dimension == 'x') {
498 imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(1, image.getHeight())));
499 int y = 0;
500 typename MImage::y_iterator oEnd = imgOut->col_end(0);
501 for (typename MImage::y_iterator oPtr = imgOut->col_begin(0); oPtr != oEnd; ++oPtr, ++y) {
505 Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
506 *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
507 stat.getError() * stat.getError());
508 }
509
510 } else if (dimension == 'y') {
511 imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(image.getWidth(), 1)));
512 int x = 0;
513 typename MImage::x_iterator oEnd = imgOut->row_end(0);
514 for (typename MImage::x_iterator oPtr = imgOut->row_begin(0); oPtr != oEnd; ++oPtr, ++x) {
518 Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
519 *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
520 stat.getError() * stat.getError());
521 }
522 } else {
524 "Can only run statisticsStack in x or y for single image.");
525 }
526
527 return imgOut;
528}

◆ statisticsStack() [11/18]

template<typename PixelT >
std::shared_ptr< image::Image< PixelT > > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< image::Image< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl,
WeightVector const & wvector )

Definition at line 347 of file Stack.cc.

349 {
350 if (images.size() == 0) {
351 throw LSST_EXCEPT(pexExcept::LengthError, "Please specify at least one image to stack");
352 }
353 std::shared_ptr<image::Image<PixelT>> out(new image::Image<PixelT>(images[0]->getDimensions()));
354 statisticsStack(*out, images, flags, sctrl, wvector);
355 return out;
356}

◆ statisticsStack() [12/18]

template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< image::MaskedImage< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl,
WeightVector const & wvector,
image::MaskPixel clipped,
image::MaskPixel excuse )

Definition at line 222 of file Stack.cc.

225 {
226 if (images.size() == 0) {
227 throw LSST_EXCEPT(pexExcept::LengthError, "Please specify at least one image to stack");
228 }
230 new image::MaskedImage<PixelT>(images[0]->getDimensions()));
231 statisticsStack(*out, images, flags, sctrl, wvector, clipped, excuse);
232 return out;
233}

◆ statisticsStack() [13/18]

template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< image::MaskedImage< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl,
WeightVector const & wvector,
image::MaskPixel clipped,
std::vector< std::pair< image::MaskPixel, image::MaskPixel > > const & maskMap )

Definition at line 236 of file Stack.cc.

239 {
240 if (images.size() == 0) {
241 throw LSST_EXCEPT(pexExcept::LengthError, "Please specify at least one image to stack");
242 }
244 new image::MaskedImage<PixelT>(images[0]->getDimensions()));
245 statisticsStack(*out, images, flags, sctrl, wvector, clipped, maskMap);
246 return out;
247}

◆ statisticsStack() [14/18]

template<typename PixelT >
std::shared_ptr< lsst::afw::image::Image< PixelT > > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< lsst::afw::image::Image< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const & wvector = std::vectorlsst::afw::image::VariancePixel >(0) )

A function to compute some statistics of a stack of Images.

Parameters
imagesImages to process
flagsstatistics requested
sctrlControl structure
wvectorvector containing weights

◆ statisticsStack() [15/18]

template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl,
std::vector< lsst::afw::image::VariancePixel > const & wvector,
image::MaskPixel clipped,
std::vector< std::pair< image::MaskPixel, image::MaskPixel > > const & maskMap )

A function to compute some statistics of a stack of Masked Images.

Parameters
[in]imagesMaskedImages to process.
[in]flagsStatistics requested.
[in]sctrlControl structure.
[in]wvectorVector of weights.
[in]clippedMask to set for pixels that were clipped (NOT rejected due to masks).
[in]maskMapVector of pairs of mask pixel values; any pixel on an input with any of the bits in .first will result in all of the bits in .second being set on the corresponding pixel on the output.

If none of the input images are valid for some pixel, the afwMath::StatisticsControl::getNoGoodPixelsMask() bit(s) are set.

All the work is done in the function computeMaskedImageStack.

◆ statisticsStack() [16/18]

template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > > & images,
Property flags,
StatisticsControl const & sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const & wvector = std::vectorlsst::afw::image::VariancePixel >(0),
image::MaskPixel clipped = 0,
image::MaskPixel excuse = 0 )

A function to compute some statistics of a stack of Masked Images.

If none of the input images are valid for some pixel, the afwMath::StatisticsControl::getNoGoodPixelsMask() bit(s) are set.

Delegates to the more general version of statisticsStack taking a maskMap.

Parameters
imagesMaskedImages to process
flagsstatistics requested
sctrlcontrol structure
wvectorvector containing weights
clippedbitmask to set if any input was clipped or masked
excusebitmask to excuse from marking as clipped

◆ statisticsStack() [17/18]

template<typename PixelT >
std::vector< PixelT > lsst::afw::math::statisticsStack ( std::vector< std::vector< PixelT > > & vectors,
Property flags,
StatisticsControl const & sctrl,
WeightVector const & wvector )

Definition at line 424 of file Stack.cc.

426 {
427 checkObjectsAndWeights(vectors, wvector);
428 checkOnlyOneFlag(flags);
429
430 if (wvector.empty()) {
431 return computeVectorStack<PixelT, false>(vectors, flags, sctrl);
432 } else {
433 return computeVectorStack<PixelT, true>(vectors, flags, sctrl, wvector);
434 }
435}

◆ statisticsStack() [18/18]

template<typename PixelT >
std::vector< PixelT > lsst::afw::math::statisticsStack ( std::vector< std::vector< PixelT > > & vectors,
Property flags,
StatisticsControl const & sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const & wvector = std::vectorlsst::afw::image::VariancePixel >(0) )

A function to compute some statistics of a stack of std::vectors.

Parameters
vectorsVectors to process
flagsstatistics requested
sctrlcontrol structure
wvectorvector containing weights

◆ stringToInterpStyle()

Interpolate::Style lsst::afw::math::stringToInterpStyle ( std::string const & style)

Conversion function to switch a string to an Interpolate::Style.

Parameters
styledesired type of interpolation

Definition at line 261 of file Interpolate.cc.

261 {
262 static std::map<std::string, Interpolate::Style> gslInterpTypeStrings;
263 if (gslInterpTypeStrings.empty()) {
264 gslInterpTypeStrings["CONSTANT"] = Interpolate::CONSTANT;
265 gslInterpTypeStrings["LINEAR"] = Interpolate::LINEAR;
266 gslInterpTypeStrings["CUBIC_SPLINE"] = Interpolate::CUBIC_SPLINE;
267 gslInterpTypeStrings["NATURAL_SPLINE"] = Interpolate::NATURAL_SPLINE;
268 gslInterpTypeStrings["CUBIC_SPLINE_PERIODIC"] = Interpolate::CUBIC_SPLINE_PERIODIC;
269 gslInterpTypeStrings["AKIMA_SPLINE"] = Interpolate::AKIMA_SPLINE;
270 gslInterpTypeStrings["AKIMA_SPLINE_PERIODIC"] = Interpolate::AKIMA_SPLINE_PERIODIC;
271 }
272
273 if (gslInterpTypeStrings.find(style) == gslInterpTypeStrings.end()) {
274 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Interp style not found: " + style);
275 }
276 return gslInterpTypeStrings[style];
277}
T find(T... args)

◆ stringToStatisticsProperty()

Property lsst::afw::math::stringToStatisticsProperty ( std::string const property)

Conversion function to switch a string to a Property (see Statistics.h)

Definition at line 762 of file Statistics.cc.

762 {
763 static std::map<std::string, Property> statisticsProperty;
764 if (statisticsProperty.size() == 0) {
765 statisticsProperty["NOTHING"] = NOTHING;
766 statisticsProperty["ERRORS"] = ERRORS;
767 statisticsProperty["NPOINT"] = NPOINT;
768 statisticsProperty["MEAN"] = MEAN;
769 statisticsProperty["STDEV"] = STDEV;
770 statisticsProperty["VARIANCE"] = VARIANCE;
771 statisticsProperty["MEDIAN"] = MEDIAN;
772 statisticsProperty["IQRANGE"] = IQRANGE;
773 statisticsProperty["MEANCLIP"] = MEANCLIP;
774 statisticsProperty["STDEVCLIP"] = STDEVCLIP;
775 statisticsProperty["VARIANCECLIP"] = VARIANCECLIP;
776 statisticsProperty["MIN"] = MIN;
777 statisticsProperty["MAX"] = MAX;
778 statisticsProperty["SUM"] = SUM;
779 statisticsProperty["MEANSQUARE"] = MEANSQUARE;
780 statisticsProperty["ORMASK"] = ORMASK;
781 statisticsProperty["NCLIPPED"] = NCLIPPED;
782 statisticsProperty["NMASKED"] = NMASKED;
783 }
784 return statisticsProperty[property];
785}

◆ stringToUndersampleStyle()

UndersampleStyle lsst::afw::math::stringToUndersampleStyle ( std::string const & style)

Conversion function to switch a string to an UndersampleStyle.

Definition at line 117 of file Background.cc.

117 {
118 static std::map<std::string, UndersampleStyle> undersampleStrings;
119 if (undersampleStrings.size() == 0) {
120 undersampleStrings["THROW_EXCEPTION"] = THROW_EXCEPTION;
121 undersampleStrings["REDUCE_INTERP_ORDER"] = REDUCE_INTERP_ORDER;
122 undersampleStrings["INCREASE_NXNYSAMPLE"] = INCREASE_NXNYSAMPLE;
123 }
124
125 if (undersampleStrings.find(style) == undersampleStrings.end()) {
126 throw LSST_EXCEPT(ex::InvalidParameterError, "Understample style not defined: " + style);
127 }
128 return undersampleStrings[style];
129}

◆ warpCenteredImage()

template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpCenteredImage ( DestImageT & destImage,
SrcImageT const & srcImage,
lsst::geom::LinearTransform const & linearTransform,
lsst::geom::Point2D const & centerPosition,
WarpingControl const & control,
typename DestImageT::SinglePixel padValue = lsst::afw::math::edgePixel<DestImageT>(                typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()) )

Warp an image with a LinearTranform about a specified point.

This enables warping an image of e.g. a PSF without translating the centroid.

Parameters
destImageremapped image
srcImagesource image
linearTransformlinear transformation to apply
centerPositionpixel position for location of linearTransform
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 666 of file warpExposure.cc.

669 {
670 // force src and dest to be the same size and xy0
671 if ((destImage.getWidth() != srcImage.getWidth()) || (destImage.getHeight() != srcImage.getHeight()) ||
672 (destImage.getXY0() != srcImage.getXY0())) {
673 std::ostringstream errStream;
674 errStream << "src and dest images must have same size and xy0.";
676 }
677
678 // set the xy0 coords to 0,0 to make life easier
679 SrcImageT srcImageCopy(srcImage, true);
680 srcImageCopy.setXY0(0, 0);
681 destImage.setXY0(0, 0);
682 lsst::geom::Extent2D cLocal =
683 lsst::geom::Extent2D(centerPosition) - lsst::geom::Extent2D(srcImage.getXY0());
684
685 // for the affine transform, the centerPosition will not only get sheared, but also
686 // moved slightly. So we'll include a translation to move it back by an amount
687 // centerPosition - translatedCenterPosition
688 lsst::geom::AffineTransform affTran(linearTransform, cLocal - linearTransform(cLocal));
689 std::shared_ptr<geom::TransformPoint2ToPoint2> affineTransform22 = geom::makeTransform(affTran);
690
691// now warp
692#if 0
693 static float t = 0.0;
694 float t_before = 1.0*clock()/CLOCKS_PER_SEC;
695 int n = warpImage(destImage, srcImageCopy, affTran, control, padValue);
696 float t_after = 1.0*clock()/CLOCKS_PER_SEC;
697 float dt = t_after - t_before;
698 t += dt;
699 std::cout <<srcImage.getWidth()<<"x"<<srcImage.getHeight()<<": "<< dt <<" "<< t <<std::endl;
700#else
701 int n = warpImage(destImage, srcImageCopy, *affineTransform22, control, padValue);
702#endif
703
704 // fix the origin and we're done.
705 destImage.setXY0(srcImage.getXY0());
706
707 return n;
708}
An affine coordinate transformation consisting of a linear transformation and an offset.
Extent< double, 2 > Extent2D
Definition Extent.h:400
T str(T... args)

◆ warpExposure()

template<typename DestExposureT , typename SrcExposureT >
int lsst::afw::math::warpExposure ( DestExposureT & destExposure,
SrcExposureT const & srcExposure,
WarpingControl const & control,
typename DestExposureT::MaskedImageT::SinglePixel padValue = lsst::afw::math::edgePixel<typename DestExposureT::MaskedImageT>(                        typename lsst::afw::image::detail::image_traits<                                typename DestExposureT::MaskedImageT>::image_category()) )

Warp (remap) one exposure to another.

This is a convenience wrapper around warpImage().

Parameters
destExposureRemapped exposure. Wcs and xy0 are read, MaskedImage is set, and PhotoCalib, FilterLabel and VisitInfo are copied from srcExposure. All other attributes are left alone (including Detector and Psf)
srcExposureSource exposure
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 393 of file warpExposure.cc.

394 {
395 if (!destExposure.hasWcs()) {
396 throw LSST_EXCEPT(pexExcept::InvalidParameterError, "destExposure has no Wcs");
397 }
398 if (!srcExposure.hasWcs()) {
399 throw LSST_EXCEPT(pexExcept::InvalidParameterError, "srcExposure has no Wcs");
400 }
401 typename DestExposureT::MaskedImageT mi = destExposure.getMaskedImage();
402 if (srcExposure.getInfo()->hasId()) {
403 destExposure.getInfo()->setId(srcExposure.getInfo()->getId());
404 }
405 destExposure.setPhotoCalib(srcExposure.getPhotoCalib());
406 destExposure.setFilter(srcExposure.getFilter());
407 destExposure.getInfo()->setVisitInfo(srcExposure.getInfo()->getVisitInfo());
408 return warpImage(mi, *destExposure.getWcs(), srcExposure.getMaskedImage(), *srcExposure.getWcs(), control,
409 padValue);
410}

◆ warpImage() [1/2]

template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpImage ( DestImageT & destImage,
geom::SkyWcs const & destWcs,
SrcImageT const & srcImage,
geom::SkyWcs const & srcWcs,
WarpingControl const & control,
typename DestImageT::SinglePixel padValue = lsst::afw::math::edgePixel<DestImageT>(                      typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()) )

Warp an Image or MaskedImage to a new Wcs.

See also convenience function warpExposure() to warp an Exposure.

Edge pixels are set to padValue; these are pixels that cannot be computed because they are too near the edge of srcImage or miss srcImage entirely.

Returns
the number of valid pixels in destImage (those that are not edge pixels).

Algorithm Without Interpolation:

For each integer pixel position in the remapped Exposure:

  • The associated pixel position on srcImage is determined using the destination and source WCS
  • The warping kernel's parameters are set based on the fractional part of the pixel position on srcImage
  • The warping kernel is applied to srcImage at the integer portion of the pixel position to compute the remapped pixel value
  • A flux-conservation factor is determined from the source and destination WCS and is applied to the remapped pixel

The scaling of intensity for relative area of source and destination uses two minor approximations:

  • The area of the sky marked out by a pixel on the destination image corresponds to a parallellogram on the source image.
  • The area varies slowly enough across the image that we can get away with computing the source area shifted by half a pixel up and to the left of the true area.

Algorithm With Interpolation:

Interpolation simply reduces the number of times WCS is used to map between destination and source pixel position. This computation is only made at a grid of points on the destination image, separated by interpLen pixels along rows and columns. All other source pixel positions are determined by linear interpolation between those grid points. Everything else remains the same.

Exceptions
lsst::pex::exceptions::InvalidParameterErrorif destImage overlaps srcImage
std::bad_allocwhen allocation of CPU memory fails
Todo
Should support an additional color-based position correction in the remapping (differential chromatic refraction). This can be done either object-by-object or pixel-by-pixel.
Todo
Need to deal with oversampling and/or weight maps. If done we can use faster kernels than sinc.
Warning
The code that tests for image overlap is not guranteed to work correctly, based on the C++ standard. It is, in theory, possible for the code to report a "false positive", meaning that it may claim that images overlap when they do not. We don't believe that any of our current compilers have this problem. If, in the future, this becomes a problem then we will probably have to remove the test and rely on users being careful.
Parameters
destImageremapped image
destWcsWCS of remapped image
srcImagesource image
srcWcsWCS of source image
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 441 of file warpExposure.cc.

443 {
444 auto srcToDest = geom::makeWcsPairTransform(srcWcs, destWcs);
445 return warpImage(destImage, srcImage, *srcToDest, control, padValue);
446}

◆ warpImage() [2/2]

template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpImage ( DestImageT & destImage,
SrcImageT const & srcImage,
geom::TransformPoint2ToPoint2 const & srcToDest,
WarpingControl const & control,
typename DestImageT::SinglePixel padValue = lsst::afw::math::edgePixel<DestImageT>(                      typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()) )

A variant of warpImage that uses a Transform<Point2Endpoint, Point2Endpoint> instead of a pair of WCS to describe the transformation.

Parameters
[in,out]destImageDestination image; all pixels are set
[in]srcImageSource image
[in]srcToDestTransformation from source to destination pixels, in parent coordinates; the inverse must be defined (and is the only direction used). makeWcsPairTransform(srcWcs, destWcs) is one way to compute this transform.
[in]controlWarning control parameters
[in]padValueValue used for pixels in the destination image that are outside the region of pixels that can be computed from the source image
Returns
the number of good pixels

Definition at line 449 of file warpExposure.cc.

451 {
452 if (imagesOverlap(destImage, srcImage)) {
453 throw LSST_EXCEPT(pexExcept::InvalidParameterError, "destImage overlaps srcImage; cannot warp");
454 }
455 if (destImage.getBBox(image::LOCAL).isEmpty()) {
456 return 0;
457 }
458 // if src image is too small then don't try to warp
459 std::shared_ptr<SeparableKernel> warpingKernelPtr = control.getWarpingKernel();
460 try {
461 warpingKernelPtr->shrinkBBox(srcImage.getBBox(image::LOCAL));
463 for (int y = 0, height = destImage.getHeight(); y < height; ++y) {
464 for (typename DestImageT::x_iterator destPtr = destImage.row_begin(y), end = destImage.row_end(y);
465 destPtr != end; ++destPtr) {
466 *destPtr = padValue;
467 }
468 }
469 return 0;
470 }
471 int interpLength = control.getInterpLength();
472
473 std::shared_ptr<LanczosWarpingKernel const> const lanczosKernelPtr =
474 std::dynamic_pointer_cast<LanczosWarpingKernel>(warpingKernelPtr);
475
476 int numGoodPixels = 0;
477
478 // compute a transform from local destination pixels to parent source pixels
479 auto const parentDestToParentSrc = srcToDest.inverted();
480 std::vector<double> const localDestToParentDestVec = {static_cast<double>(destImage.getX0()),
481 static_cast<double>(destImage.getY0())};
482 auto const localDestToParentDest = geom::TransformPoint2ToPoint2(ast::ShiftMap(localDestToParentDestVec));
483 auto const localDestToParentSrc = localDestToParentDest.then(*parentDestToParentSrc);
484
485 // Get the source MaskedImage and a pixel accessor to it.
486 int const srcWidth = srcImage.getWidth();
487 int const srcHeight = srcImage.getHeight();
488 LOGL_DEBUG("TRACE2.lsst.afw.math.warp", "source image width=%d; height=%d", srcWidth, srcHeight);
489
490 int const destWidth = destImage.getWidth();
491 int const destHeight = destImage.getHeight();
492 LOGL_DEBUG("TRACE2.lsst.afw.math.warp", "remap image width=%d; height=%d", destWidth, destHeight);
493
494 // Set each pixel of destExposure's MaskedImage
495 LOGL_DEBUG("TRACE3.lsst.afw.math.warp", "Remapping masked image");
496
497 int const maxCol = destWidth - 1;
498 int const maxRow = destHeight - 1;
499
500 detail::WarpAtOnePoint<DestImageT, SrcImageT> warpAtOnePoint(srcImage, control, padValue);
501
502 if (interpLength > 0) {
503 // Use interpolation. Note that 1 produces the same result as no interpolation
504 // but uses this code branch, thus providing an easy way to compare the two branches.
505
506 // Estimate for number of horizontal interpolation band edges, to reserve memory in vectors
507 int const numColEdges = 2 + ((destWidth - 1) / interpLength);
508
509 // A list of edge column indices for interpolation bands;
510 // starts at -1, increments by interpLen (except the final interval), and ends at destWidth-1
511 std::vector<int> edgeColList;
512 edgeColList.reserve(numColEdges);
513
514 // A list of 1/column width for horizontal interpolation bands; the first value is garbage.
515 // The inverse is used for speed because the values are always multiplied.
516 std::vector<double> invWidthList;
517 invWidthList.reserve(numColEdges);
518
519 // Compute edgeColList and invWidthList
520 edgeColList.push_back(-1);
521 invWidthList.push_back(0.0);
522 for (int prevEndCol = -1; prevEndCol < maxCol; prevEndCol += interpLength) {
523 int endCol = prevEndCol + interpLength;
524 if (endCol > maxCol) {
525 endCol = maxCol;
526 }
527 edgeColList.push_back(endCol);
528 assert(endCol - prevEndCol > 0);
529 invWidthList.push_back(1.0 / static_cast<double>(endCol - prevEndCol));
530 }
531 assert(edgeColList.back() == maxCol);
532
533 // A list of delta source positions along the edge columns of the horizontal interpolation bands
534 std::vector<lsst::geom::Extent2D> yDeltaSrcPosList(edgeColList.size());
535
536 // A cache of pixel positions on the source corresponding to the previous or current row
537 // of the destination image.
538 // The first value is for column -1 because the previous source position is used to compute relative
539 // area To simplify the indexing, use an iterator that starts at begin+1, thus: srcPosView =
540 // srcPosList.begin() + 1 srcPosView[col-1] and lower indices are for this row srcPosView[col] and
541 // higher indices are for the previous row
542 std::vector<lsst::geom::Point2D> srcPosList(1 + destWidth);
543 std::vector<lsst::geom::Point2D>::iterator const srcPosView = srcPosList.begin() + 1;
544
546 endColPosList.reserve(numColEdges);
547
548 // Initialize srcPosList for row -1
549 for (int endCol : edgeColList) {
550 endColPosList.emplace_back(lsst::geom::Point2D(endCol, -1));
551 }
552 auto rightSrcPosList = localDestToParentSrc->applyForward(endColPosList);
553 srcPosView[-1] = rightSrcPosList[0];
554 for (int colBand = 1, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
555 int const prevEndCol = edgeColList[colBand - 1];
556 int const endCol = edgeColList[colBand];
557 lsst::geom::Point2D leftSrcPos = srcPosView[prevEndCol];
558
559 lsst::geom::Extent2D xDeltaSrcPos =
560 (rightSrcPosList[colBand] - leftSrcPos) * invWidthList[colBand];
561
562 for (int col = prevEndCol + 1; col <= endCol; ++col) {
563 srcPosView[col] = srcPosView[col - 1] + xDeltaSrcPos;
564 }
565 }
566
567 int endRow = -1;
568 while (endRow < maxRow) {
569 // Next horizontal interpolation band
570
571 int prevEndRow = endRow;
572 endRow = prevEndRow + interpLength;
573 if (endRow > maxRow) {
574 endRow = maxRow;
575 }
576 assert(endRow - prevEndRow > 0);
577 double interpInvHeight = 1.0 / static_cast<double>(endRow - prevEndRow);
578
579 // Set yDeltaSrcPosList for this horizontal interpolation band
581 destRowPosList.reserve(edgeColList.size());
582 for (int endCol : edgeColList) {
583 destRowPosList.emplace_back(lsst::geom::Point2D(endCol, endRow));
584 }
585 auto bottomSrcPosList = localDestToParentSrc->applyForward(destRowPosList);
586 for (int colBand = 0, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
587 int endCol = edgeColList[colBand];
588 yDeltaSrcPosList[colBand] =
589 (bottomSrcPosList[colBand] - srcPosView[endCol]) * interpInvHeight;
590 }
591
592 for (int row = prevEndRow + 1; row <= endRow; ++row) {
593 typename DestImageT::x_iterator destXIter = destImage.row_begin(row);
594 srcPosView[-1] += yDeltaSrcPosList[0];
595 for (int colBand = 1, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
596 // Next vertical interpolation band
597
598 int const prevEndCol = edgeColList[colBand - 1];
599 int const endCol = edgeColList[colBand];
600
601 // Compute xDeltaSrcPos; remember that srcPosView contains
602 // positions for this row in prevEndCol and smaller indices,
603 // and positions for the previous row for larger indices (including endCol)
604 lsst::geom::Point2D leftSrcPos = srcPosView[prevEndCol];
605 lsst::geom::Point2D rightSrcPos = srcPosView[endCol] + yDeltaSrcPosList[colBand];
606 lsst::geom::Extent2D xDeltaSrcPos = (rightSrcPos - leftSrcPos) * invWidthList[colBand];
607
608 for (int col = prevEndCol + 1; col <= endCol; ++col, ++destXIter) {
609 lsst::geom::Point2D leftSrcPos = srcPosView[col - 1];
610 lsst::geom::Point2D srcPos = leftSrcPos + xDeltaSrcPos;
611 double relativeArea = computeRelativeArea(srcPos, leftSrcPos, srcPosView[col]);
612
613 srcPosView[col] = srcPos;
614
615 if (warpAtOnePoint(
616 destXIter, srcPos, relativeArea,
617 typename image::detail::image_traits<DestImageT>::image_category())) {
618 ++numGoodPixels;
619 }
620 } // for col
621 } // for col band
622 } // for row
623 } // while next row band
624
625 } else {
626 // No interpolation
627
628 // prevSrcPosList = source positions from the previous row; these are used to compute pixel area;
629 // to begin, compute sources positions corresponding to destination row = -1
631 destPosList.reserve(1 + destWidth);
632 for (int col = -1; col < destWidth; ++col) {
633 destPosList.emplace_back(lsst::geom::Point2D(col, -1));
634 }
635 auto prevSrcPosList = localDestToParentSrc->applyForward(destPosList);
636
637 for (int row = 0; row < destHeight; ++row) {
638 destPosList.clear();
639 for (int col = -1; col < destWidth; ++col) {
641 }
642 auto srcPosList = localDestToParentSrc->applyForward(destPosList);
643
644 typename DestImageT::x_iterator destXIter = destImage.row_begin(row);
645 for (int col = 0; col < destWidth; ++col, ++destXIter) {
646 // column index = column + 1 because the first entry in srcPosList is for column -1
647 auto srcPos = srcPosList[col + 1];
648 double relativeArea =
649 computeRelativeArea(srcPos, prevSrcPosList[col], prevSrcPosList[col + 1]);
650
651 if (warpAtOnePoint(destXIter, srcPos, relativeArea,
652 typename image::detail::image_traits<DestImageT>::image_category())) {
653 ++numGoodPixels;
654 }
655 } // for col
656 // move points from srcPosList to prevSrcPosList (we don't care about what ends up in srcPosList
657 // because it will be reallocated anyway)
658 swap(srcPosList, prevSrcPosList);
659 } // for row
660 } // if interp
661
662 return numGoodPixels;
663}
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
Definition Log.h:515
T back(T... args)
ShiftMap is a linear Mapping which shifts each axis by a specified constant value.
Definition ShiftMap.h:40
T clear(T... args)
T emplace_back(T... args)
T reserve(T... args)
int row
Definition CR.cc:145
int col
Definition CR.cc:144
table::Key< int > interpLength

◆ wrapApproximate()

void lsst::afw::math::wrapApproximate ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 83 of file _approximate.cc.

83 {
84 wrappers.addSignatureDependency("lsst.afw.image");
85 declareApproximate(wrappers);
86}

◆ wrapBackground()

void lsst::afw::math::wrapBackground ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 162 of file _background.cc.

162 {
163 // FIXME: review when lsst.afw.image is converted to python wrappers
164 wrappers.addInheritanceDependency("lsst.afw.image");
165 declareBackground(wrappers);
166 declareMakeBackground<image::Image<float>>(wrappers);
167 declareMakeBackground<image::MaskedImage<float>>(wrappers);
168 wrappers.wrap(
169 [](auto &mod) { mod.def("stringToUndersampleStyle", stringToUndersampleStyle, "style"_a); });
170}
void declareBackground(lsst::utils::python::WrapperCollection &wrappers)

◆ wrapBoundedField()

void lsst::afw::math::wrapBoundedField ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 97 of file _boundedField.cc.

97 {
98 wrappers.addSignatureDependency("lsst.afw.table.io");
99 declareBoundedField(wrappers);
100}
void declareBoundedField(lsst::utils::python::WrapperCollection &wrappers)

◆ wrapChebyshevBoundedField()

void lsst::afw::math::wrapChebyshevBoundedField ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 86 of file _chebyshevBoundedField.cc.

86 {
87 wrappers.addSignatureDependency("lsst.afw.image");
88 declareChebyshevBoundedField(wrappers);
89}

◆ wrapConvolveImage()

void lsst::afw::math::wrapConvolveImage ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 94 of file _convolveImage.cc.

94 {
95 wrappers.addSignatureDependency("lsst.afw.image");
96 declareConvolveImage(wrappers);
97 declareAll<double, double>(wrappers);
98 declareAll<double, float>(wrappers);
99 declareAll<double, int>(wrappers);
100 declareAll<double, std::uint16_t>(wrappers);
101 declareAll<float, float>(wrappers);
102 declareAll<float, int>(wrappers);
103 declareAll<float, std::uint16_t>(wrappers);
104 declareAll<int, int>(wrappers);
105 declareAll<std::uint16_t, std::uint16_t>(wrappers);
106}

◆ wrapFunction()

void lsst::afw::math::wrapFunction ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 142 of file _function.cc.

142 {
143 wrappers.addSignatureDependency("lsst.afw.table.io");
144 declareAllFunctions<float>(wrappers, "F");
145 declareAllFunctions<double>(wrappers, "D");
146}

◆ wrapFunctionLibrary()

void lsst::afw::math::wrapFunctionLibrary ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 220 of file _functionLibrary.cc.

220 {
221 wrappers.addInheritanceDependency("lsst.geom");
222 declarePolynomialFunctions<float>(wrappers, "F");
223 declareChebyshevFunctions<float>(wrappers, "F");
224 declareGaussianFunctions<float>(wrappers, "F");
225 declareIntegerDeltaFunctions<float>(wrappers, "F");
226 declareLanczosFunctions<float>(wrappers, "F");
227
228 declarePolynomialFunctions<double>(wrappers, "D");
229 declareChebyshevFunctions<double>(wrappers, "D");
230 declareGaussianFunctions<double>(wrappers, "D");
231 declareIntegerDeltaFunctions<double>(wrappers, "D");
232 declareLanczosFunctions<double>(wrappers, "D");
233}

◆ wrapGaussianProcess()

void lsst::afw::math::wrapGaussianProcess ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 153 of file _gaussianProcess.cc.

153 {
154 declareCovariograms<double>(wrappers, "D");
155 declareGaussianProcess<double>(wrappers, "D");
156 declareKdTree<double>(wrappers, "D");
157}

◆ wrapInterpolate()

void lsst::afw::math::wrapInterpolate ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 38 of file _interpolate.cc.

38 {
39 using PyClass = py::class_<Interpolate, std::shared_ptr<Interpolate>>;
40
41 auto clsInterpolate = wrappers.wrapType(PyClass(wrappers.module, "Interpolate"), [](auto &mod,
42 auto &cls) {
43 cls.def("interpolate", [](Interpolate &t, double const x) {
44 /*
45 We use a lambda function here because interpolate (with a double) is a virtual function
46 and therefor cannot be wrapped directly.
47 */
48 return t.interpolate(x);
49 });
50
51 cls.def("interpolate", (std::vector<double>(Interpolate::*)(std::vector<double> const &) const) &
52 Interpolate::interpolate);
53 cls.def("interpolate",
54 (ndarray::Array<double, 1>(Interpolate::*)(ndarray::Array<double const, 1> const &) const) &
55 Interpolate::interpolate);
56
57 mod.def("makeInterpolate",
60 "x"_a, "y"_a, "style"_a = Interpolate::AKIMA_SPLINE);
61 mod.def("makeInterpolate",
62 (std::shared_ptr<Interpolate>(*)(ndarray::Array<double const, 1> const &,
63 ndarray::Array<double const, 1> const &y,
65 "x"_a, "y"_a, "style"_a = Interpolate::AKIMA_SPLINE);
66
67 mod.def("stringToInterpStyle", stringToInterpStyle, "style"_a);
68 mod.def("lookupMaxInterpStyle", lookupMaxInterpStyle, "n"_a);
69 mod.def("lookupMinInterpPoints", lookupMinInterpPoints, "style"_a);
70 });
71 wrappers.wrapType(py::enum_<Interpolate::Style>(clsInterpolate, "Style"), [](auto &mod, auto &enm) {
72 enm.value("UNKNOWN", Interpolate::Style::UNKNOWN);
73 enm.value("CONSTANT", Interpolate::Style::CONSTANT);
74 enm.value("LINEAR", Interpolate::Style::LINEAR);
75 enm.value("NATURAL_SPLINE", Interpolate::Style::NATURAL_SPLINE);
76 enm.value("CUBIC_SPLINE", Interpolate::Style::CUBIC_SPLINE);
77 enm.value("CUBIC_SPLINE_PERIODIC", Interpolate::Style::CUBIC_SPLINE_PERIODIC);
78 enm.value("AKIMA_SPLINE", Interpolate::Style::AKIMA_SPLINE);
79 enm.value("AKIMA_SPLINE_PERIODIC", Interpolate::Style::AKIMA_SPLINE_PERIODIC);
80 enm.value("NUM_STYLES", Interpolate::Style::NUM_STYLES);
81 enm.export_values();
82 });
83}
Interpolate::Style lookupMaxInterpStyle(int const n)
Get the highest order Interpolation::Style available for 'n' points.
int lookupMinInterpPoints(Interpolate::Style const style)
Get the minimum number of points needed to use the requested interpolation style.
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
STL namespace.

◆ wrapKernel()

void lsst::afw::math::wrapKernel ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 39 of file _kernel.cc.

39 {
40 using PyKernel = py::class_<Kernel, std::shared_ptr<Kernel>>;
41
42 wrappers.addSignatureDependency("lsst.afw.table");
43 wrappers.addSignatureDependency("lsst.afw.table.io");
44
45 wrappers.wrapType(PyKernel(wrappers.module, "Kernel"), [](auto &mod, auto &cls) {
46 lsst::afw::table::io::python::addPersistableMethods<Kernel>(cls);
47
48 cls.def("clone", &Kernel::clone);
49 cls.def("resized", &Kernel::resized, "width"_a, "height"_a);
50 cls.def("computeImage", &Kernel::computeImage, "image"_a, "doNormalize"_a, "x"_a = 0.0, "y"_a = 0.0);
51 cls.def("getDimensions", &Kernel::getDimensions);
52 cls.def("setDimensions", &Kernel::setDimensions);
53 cls.def("setWidth", &Kernel::setWidth);
54 cls.def("setHeight", &Kernel::setHeight);
55 cls.def("getWidth", &Kernel::getWidth);
56 cls.def("getHeight", &Kernel::getHeight);
57 cls.def("getCtr", &Kernel::getCtr);
58 cls.def("getBBox", &Kernel::getBBox);
59 cls.def("getNKernelParameters", &Kernel::getNKernelParameters);
60 cls.def("getNSpatialParameters", &Kernel::getNSpatialParameters);
61 cls.def("getSpatialFunction", &Kernel::getSpatialFunction);
62 cls.def("getSpatialFunctionList", &Kernel::getSpatialFunctionList);
63 cls.def("getKernelParameter", &Kernel::getKernelParameter);
64 cls.def("getKernelParameters", &Kernel::getKernelParameters);
65 cls.def("growBBox", &Kernel::growBBox);
66 cls.def("shrinkBBox", &Kernel::shrinkBBox);
67 cls.def("setCtr", &Kernel::setCtr);
68 cls.def("getSpatialParameters", &Kernel::getSpatialParameters);
69 cls.def("isSpatiallyVarying", &Kernel::isSpatiallyVarying);
70 cls.def("setKernelParameters",
71 (void (Kernel::*)(std::vector<double> const &)) & Kernel::setKernelParameters);
72 cls.def("setKernelParameters",
73 (void (Kernel::*)(std::pair<double, double> const &)) & Kernel::setKernelParameters);
74 cls.def("setSpatialParameters", &Kernel::setSpatialParameters);
75 cls.def("computeKernelParametersFromSpatialModel", &Kernel::computeKernelParametersFromSpatialModel);
76 cls.def("toString", &Kernel::toString, "prefix"_a = "");
77 cls.def("computeCache", &Kernel::computeCache);
78 cls.def("getCacheSize", &Kernel::getCacheSize);
79 });
80
81 using PyFixedKernel = py::class_<FixedKernel, std::shared_ptr<FixedKernel>, Kernel>;
82 wrappers.wrapType(PyFixedKernel(wrappers.module, "FixedKernel"), [](auto &mod, auto &cls) {
83 cls.def(py::init<>());
84 cls.def(py::init<lsst::afw::image::Image<Kernel::Pixel> const &>(), "image"_a);
85 cls.def(py::init<lsst::afw::math::Kernel const &, lsst::geom::Point2D const &>(), "kernel"_a,
86 "pos"_a);
87 cls.def("clone", &FixedKernel::clone);
88 cls.def("resized", &FixedKernel::resized, "width"_a, "height"_a);
89 cls.def("toString", &FixedKernel::toString, "prefix"_a = "");
90 cls.def("getSum", &FixedKernel::getSum);
91 cls.def("isPersistable", &FixedKernel::isPersistable);
92 });
93
94 using PyAnalyticKernel = py::class_<AnalyticKernel, std::shared_ptr<AnalyticKernel>, Kernel>;
95 wrappers.wrapType(PyAnalyticKernel(wrappers.module, "AnalyticKernel"), [](auto &mod, auto &cls) {
96 cls.def(py::init<>());
97 // Workaround for NullSpatialFunction and py::arg not playing well with Citizen (TODO: no longer
98 // needed?)
99 cls.def(py::init<int, int, AnalyticKernel::KernelFunction const &>(), "width"_a, "height"_a,
100 "kernelFunction"_a);
101 cls.def(py::init<int, int, AnalyticKernel::KernelFunction const &, Kernel::SpatialFunction const &>(),
102 "width"_a, "height"_a, "kernelFunction"_a, "spatialFunction"_a);
103 cls.def(py::init<int, int, AnalyticKernel::KernelFunction const &,
104 std::vector<Kernel::SpatialFunctionPtr> const &>(),
105 "width"_a, "height"_a, "kernelFunction"_a, "spatialFunctionList"_a);
106 cls.def("clone", &AnalyticKernel::clone);
107 cls.def("resized", &AnalyticKernel::resized, "width"_a, "height"_a);
108 cls.def("computeImage", &AnalyticKernel::computeImage, "image"_a, "doNormalize"_a, "x"_a = 0.0,
109 "y"_a = 0.0);
110 cls.def("getKernelParameters", &AnalyticKernel::getKernelParameters);
111 cls.def("getKernelFunction", &AnalyticKernel::getKernelFunction);
112 cls.def("toString", &AnalyticKernel::toString, "prefix"_a = "");
113 cls.def("isPersistable", &AnalyticKernel::isPersistable);
114 });
115
116 using PyDeltaFunctionKernel =
117 py::class_<DeltaFunctionKernel, std::shared_ptr<DeltaFunctionKernel>, Kernel>;
118 wrappers.wrapType(
119 PyDeltaFunctionKernel(wrappers.module, "DeltaFunctionKernel"), [](auto &mod, auto &cls) {
120 cls.def(py::init<int, int, lsst::geom::Point2I const &>(), "width"_a, "height"_a, "point"_a);
121 cls.def("clone", &DeltaFunctionKernel::clone);
122 cls.def("resized", &DeltaFunctionKernel::resized, "width"_a, "height"_a);
123 cls.def("getPixel", &DeltaFunctionKernel::getPixel);
124 cls.def("toString", &DeltaFunctionKernel::toString, "prefix"_a = "");
125 cls.def("isPersistable", &DeltaFunctionKernel::isPersistable);
126 });
127
128 using PyLinearCombinationKernel =
129 py::class_<LinearCombinationKernel, std::shared_ptr<LinearCombinationKernel>, Kernel>;
130 wrappers.wrapType(
131 PyLinearCombinationKernel(wrappers.module, "LinearCombinationKernel"), [](auto &mod, auto &cls) {
132 cls.def(py::init<>());
133 cls.def(py::init<KernelList const &, std::vector<double> const &>(), "kernelList"_a,
134 "kernelParameters"_a);
135 cls.def(py::init<KernelList const &, Kernel::SpatialFunction const &>(), "kernelList"_a,
136 "spatialFunction"_a);
137 cls.def(py::init<KernelList const &, std::vector<Kernel::SpatialFunctionPtr> const &>(),
138 "kernelList"_a, "spatialFunctionList"_a);
139 cls.def("clone", &LinearCombinationKernel::clone);
140 cls.def("resized", &LinearCombinationKernel::resized, "width"_a, "height"_a);
141 cls.def("getKernelParameters", &LinearCombinationKernel::getKernelParameters);
142 cls.def("getKernelList", &LinearCombinationKernel::getKernelList);
143 cls.def("getKernelSumList", &LinearCombinationKernel::getKernelSumList);
144 cls.def("getNBasisKernels", &LinearCombinationKernel::getNBasisKernels);
145 cls.def("checkKernelList", &LinearCombinationKernel::checkKernelList);
146 cls.def("isDeltaFunctionBasis", &LinearCombinationKernel::isDeltaFunctionBasis);
147 cls.def("refactor", &LinearCombinationKernel::refactor);
148 cls.def("toString", &LinearCombinationKernel::toString, "prefix"_a = "");
149 cls.def("isPersistable", &LinearCombinationKernel::isPersistable);
150 });
151
152 using PySeparableKernel = py::class_<SeparableKernel, std::shared_ptr<SeparableKernel>, Kernel>;
153 wrappers.wrapType(PySeparableKernel(wrappers.module, "SeparableKernel"), [](auto &mod, auto &cls) {
154 cls.def(py::init<>());
155 // Workaround for NullSpatialFunction and py::arg not playing well with Citizen (TODO: no longer
156 // needed?)
157 cls.def(py::init<int, int, SeparableKernel::KernelFunction const &,
158 SeparableKernel::KernelFunction const &>(),
159 "width"_a, "height"_a, "kernelColFunction"_a, "kernelRowFunction"_a);
160 cls.def(py::init<int, int, SeparableKernel::KernelFunction const &,
161 SeparableKernel::KernelFunction const &, Kernel::SpatialFunction const &>(),
162 "width"_a, "height"_a, "kernelColFunction"_a, "kernelRowFunction"_a, "spatialFunction"_a);
163 cls.def(py::init<int, int, SeparableKernel::KernelFunction const &,
164 SeparableKernel::KernelFunction const &,
165 std::vector<Kernel::SpatialFunctionPtr> const &>(),
166 "width"_a, "height"_a, "kernelColFunction"_a, "kernelRowFunction"_a, "spatialFunctionList"_a);
167 cls.def("clone", &SeparableKernel::clone);
168 cls.def("resized", &SeparableKernel::resized, "width"_a, "height"_a);
169 cls.def("computeVectors", &SeparableKernel::computeVectors);
170 cls.def("getKernelParameter", &SeparableKernel::getKernelParameter);
171 cls.def("getKernelParameters", &SeparableKernel::getKernelParameters);
172 cls.def("getKernelColFunction", &SeparableKernel::getKernelColFunction);
173 cls.def("getKernelRowFunction", &SeparableKernel::getKernelRowFunction);
174 cls.def("toString", &SeparableKernel::toString, "prefix"_a = "");
175 cls.def("computeCache", &SeparableKernel::computeCache);
176 cls.def("getCacheSize", &SeparableKernel::getCacheSize);
177 });
178}
Kernels are used for convolution with MaskedImages and (eventually) Images.
Definition Kernel.h:110

◆ wrapLeastSquares()

void lsst::afw::math::wrapLeastSquares ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 80 of file _leastSquares.cc.

80 {
81 declareLeastSquares<double, double, 0, 0>(wrappers);
82}

◆ wrapMinimize()

void lsst::afw::math::wrapMinimize ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 60 of file _minimize.cc.

60 {
61 declareMinimize(wrappers);
62 declareFitResults<double>(wrappers);
63 declareFitResults<float>(wrappers);
64}

◆ wrapOffsetImage()

void lsst::afw::math::wrapOffsetImage ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 74 of file _offsetImage.cc.

74 {
75 using MaskPixel = lsst::afw::image::MaskPixel;
76 wrappers.addSignatureDependency("lsst.afw.image");
77
78 declareOffsetImage<lsst::afw::image::Image<int>>(wrappers);
79 declareOffsetImage<lsst::afw::image::Image<float>>(wrappers);
80 declareOffsetImage<lsst::afw::image::Image<double>>(wrappers);
81 declareOffsetImage<lsst::afw::image::MaskedImage<int>>(wrappers);
82 declareOffsetImage<lsst::afw::image::MaskedImage<float>>(wrappers);
83 declareOffsetImage<lsst::afw::image::MaskedImage<double>>(wrappers);
84
85 declareRotateImageBy90<lsst::afw::image::Image<std::uint16_t>>(wrappers);
86 declareRotateImageBy90<lsst::afw::image::Image<int>>(wrappers);
87 declareRotateImageBy90<lsst::afw::image::Image<float>>(wrappers);
88 declareRotateImageBy90<lsst::afw::image::Image<double>>(wrappers);
89 declareRotateImageBy90<lsst::afw::image::MaskedImage<std::uint16_t>>(wrappers);
90 declareRotateImageBy90<lsst::afw::image::MaskedImage<int>>(wrappers);
91 declareRotateImageBy90<lsst::afw::image::MaskedImage<float>>(wrappers);
92 declareRotateImageBy90<lsst::afw::image::MaskedImage<double>>(wrappers);
93 declareRotateImageBy90<lsst::afw::image::Mask<MaskPixel>>(wrappers);
94
95 declareFlipImage<lsst::afw::image::Image<std::uint16_t>>(wrappers);
96 declareFlipImage<lsst::afw::image::Image<int>>(wrappers);
97 declareFlipImage<lsst::afw::image::Image<float>>(wrappers);
98 declareFlipImage<lsst::afw::image::Image<double>>(wrappers);
99 declareFlipImage<lsst::afw::image::MaskedImage<std::uint16_t>>(wrappers);
100 declareFlipImage<lsst::afw::image::MaskedImage<int>>(wrappers);
101 declareFlipImage<lsst::afw::image::MaskedImage<float>>(wrappers);
102 declareFlipImage<lsst::afw::image::MaskedImage<double>>(wrappers);
103 declareFlipImage<lsst::afw::image::Mask<MaskPixel>>(wrappers);
104
105 declareBinImage<lsst::afw::image::Image<std::uint16_t>>(wrappers);
106 declareBinImage<lsst::afw::image::Image<int>>(wrappers);
107 declareBinImage<lsst::afw::image::Image<float>>(wrappers);
108 declareBinImage<lsst::afw::image::Image<double>>(wrappers);
109 declareBinImage<lsst::afw::image::MaskedImage<std::uint16_t>>(wrappers);
110 declareBinImage<lsst::afw::image::MaskedImage<int>>(wrappers);
111 declareBinImage<lsst::afw::image::MaskedImage<float>>(wrappers);
112 declareBinImage<lsst::afw::image::MaskedImage<double>>(wrappers);
113}
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks

◆ wrapPixelAreaBoundedField()

void lsst::afw::math::wrapPixelAreaBoundedField ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 37 of file _pixelAreaBoundedField.cc.

37 {
38 wrappers.wrapType(PyClass(wrappers.module, "PixelAreaBoundedField"), [](auto &mod, auto &cls) {
39 cls.def(py::init<lsst::geom::Box2I const &, std::shared_ptr<afw::geom::SkyWcs const>,
40 lsst::geom::AngleUnit const &, double>(),
41 "bbox"_a, "skyWcs"_a, "unit"_a = lsst::geom::radians, "scaling"_a = 1.0);
42 // All other operations are wrapped by the BoundedField base class.
43 });
44}

◆ wrapProductBoundedField()

void lsst::afw::math::wrapProductBoundedField ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 37 of file _productBoundedField.cc.

37 {
38 wrappers.wrapType(PyClass(wrappers.module, "ProductBoundedField"), [](auto &mod, auto &cls) {
39 cls.def(py::init<std::vector<std::shared_ptr<BoundedField const>>>());
40 // All other operations are wrapped by the BoundedField base class.
41 });
42}

◆ wrapRandom()

void lsst::afw::math::wrapRandom ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 103 of file _random.cc.

103 {
104 wrappers.addSignatureDependency("lsst.afw.image");
105 declareRandom(wrappers);
106 declareRandomImage<lsst::afw::image::Image<double>>(wrappers);
107 declareRandomImage<lsst::afw::image::Image<float>>(wrappers);
108}
void declareRandom(lsst::utils::python::WrapperCollection &wrappers)
Definition _random.cc:52

◆ wrapSpatialCell()

void lsst::afw::math::wrapSpatialCell ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 262 of file _spatialCell.cc.

262 {
263 declareSpatialCellCandidate(wrappers);
264 declareSpatialCellCandidateIterator(wrappers);
265 declareSpatialCell(wrappers);
266 declareSpatialCellSet(wrappers);
267 declareCandidateVisitor(wrappers);
268 declareSpatialCellImageCandidate(wrappers);
269 /* Test Members */
270 declareTestClasses(wrappers);
271}

◆ wrapStack()

void lsst::afw::math::wrapStack ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 113 of file _stack.cc.

113 {
114 wrappers.addSignatureDependency("lsst.afw.image");
115 declareStatisticsStack<float>(wrappers);
116 declareStatisticsStack<double>(wrappers);
117}

◆ wrapStatistics()

void lsst::afw::math::wrapStatistics ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 146 of file _statistics.cc.

146 {
147 wrappers.addSignatureDependency("lsst.afw.image");
148 declareStatistics(wrappers);
149 declareStatistics<unsigned short>(wrappers);
150 declareStatistics<double>(wrappers);
151 declareStatistics<float>(wrappers);
152 declareStatistics<int>(wrappers);
153 // Declare vector overloads separately to prevent casting errors
154 // that otherwise (mysteriously) occur when overloads are tried
155 // in order.
156 declareStatisticsVectorOverloads<unsigned short>(wrappers);
157 declareStatisticsVectorOverloads<double>(wrappers);
158 declareStatisticsVectorOverloads<float>(wrappers);
159 declareStatisticsVectorOverloads<int>(wrappers);
160}
void declareStatistics(lsst::utils::python::WrapperCollection &wrappers)

◆ wrapTransformBoundedField()

void lsst::afw::math::wrapTransformBoundedField ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 64 of file _transformBoundedField.cc.

64 {
65 wrappers.addSignatureDependency("lsst.afw.table.io");
67}
void declareTransformBoundedField(lsst::utils::python::WrapperCollection &wrappers)

◆ wrapWarpExposure()

void lsst::afw::math::wrapWarpExposure ( lsst::utils::python::WrapperCollection & wrappers)

Definition at line 168 of file _warpExposure.cc.

168 {
169 wrappers.addSignatureDependency("lsst.afw.image");
170 wrappers.addSignatureDependency("lsst.afw.geom.skyWcs");
171
172 declareWarpExposure(wrappers);
173 declareWarpingKernel<LanczosWarpingKernel>(wrappers, "LanczosWarpingKernel");
174 declareSimpleWarpingKernel<BilinearWarpingKernel>(wrappers, "BilinearWarpingKernel");
175 declareSimpleWarpingKernel<NearestWarpingKernel>(wrappers, "NearestWarpingKernel");
176 declareWarpingFunctions<double, double>(wrappers);
177 declareWarpingFunctions<double, float>(wrappers);
178 declareWarpingFunctions<double, int>(wrappers);
179 declareWarpingFunctions<double, std::uint16_t>(wrappers);
180 declareWarpingFunctions<float, float>(wrappers);
181 declareWarpingFunctions<float, int>(wrappers);
182 declareWarpingFunctions<float, std::uint16_t>(wrappers);
183 declareWarpingFunctions<int, int>(wrappers);
184 declareWarpingFunctions<std::uint16_t, std::uint16_t>(wrappers);
185}

Variable Documentation

◆ DEFABSERR

double const lsst::afw::math::DEFABSERR = 1.e-15

Definition at line 238 of file Integrate.h.

◆ DEFRELERR

double const lsst::afw::math::DEFRELERR = 1.e-6

Definition at line 239 of file Integrate.h.

◆ deltafunction_kernel_tag_

deltafunction_kernel_tag lsst::afw::math::deltafunction_kernel_tag_

Used as default value in argument lists.

Definition at line 43 of file Kernel.cc.

◆ generic_kernel_tag_

generic_kernel_tag lsst::afw::math::generic_kernel_tag_

Used as default value in argument lists.

Definition at line 42 of file Kernel.cc.

◆ IS_NOTHROW_INIT

template<typename T >
bool constexpr lsst::afw::math::IS_NOTHROW_INIT = noexcept(static_cast<T>(1.0))
constexpr

Test that a Function's return value is nothrow-castable to T.

std::complex is an example of a numeric type that does not satisfy this requirement.

Definition at line 51 of file Function.h.

◆ MOCK_INF

double const lsst::afw::math::MOCK_INF = 1.e10

Definition at line 137 of file Integrate.h.