LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
lsst::afw::math Namespace Reference

Namespaces

 _background
 
 _backgroundList
 
 _chebyshevBoundedField
 
 _chebyshevBoundedFieldConfig
 
 _spatialCell
 
 _warper
 
 detail
 
 details
 

Classes

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

Typedefs

typedef std::vector< std::shared_ptr< Kernel > > KernelList
 
typedef lsst::afw::image::VariancePixel WeightPixel
 
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. More...
 
UndersampleStyle stringToUndersampleStyle (std::string const &style)
 Conversion function to switch a string to an UndersampleStyle. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename ImageT >
ImageT::SinglePixel edgePixel (lsst::afw::image::detail::Image_tag)
 Return an off-the-edge pixel appropriate for a given Image type. More...
 
template<typename MaskedImageT >
MaskedImageT::SinglePixel edgePixel (lsst::afw::image::detail::MaskedImage_tag)
 Return an off-the-edge pixel appropriate for a given MaskedImage type. More...
 
template<class UF >
UF::result_type int1d (UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const &abserr=DEFABSERR, typename UF::result_type const &relerr=DEFRELERR)
 Front end for the 1d integrator. More...
 
template<class BF , class YREG >
BF::result_type int2d (BF const &func, IntRegion< typename BF::result_type > &reg, YREG const &yreg, typename BF::result_type const &abserr=DEFABSERR, typename BF::result_type const &relerr=DEFRELERR)
 Front end for the 2d integrator. More...
 
template<class TF , class YREG , class ZREG >
TF::result_type int3d (TF const &func, IntRegion< typename TF::result_type > &reg, YREG const &yreg, ZREG const &zreg, typename TF::result_type const &abserr=DEFABSERR, typename TF::result_type const &relerr=DEFRELERR)
 Front end for the 3d integrator. More...
 
template<class BF >
BF::result_type int2d (BF const &func, IntRegion< typename BF::result_type > &reg, IntRegion< typename BF::result_type > &yreg, typename BF::result_type const &abserr=DEFABSERR, typename BF::result_type const &relerr=DEFRELERR)
 Front end for the 2d integrator. More...
 
template<class TF >
TF::result_type int3d (TF const &func, IntRegion< typename TF::result_type > &reg, IntRegion< typename TF::result_type > &yreg, IntRegion< typename TF::result_type > &zreg, typename TF::result_type const &abserr=DEFABSERR, typename TF::result_type const &relerr=DEFRELERR)
 Front end for the 3d integrator. More...
 
template<typename UnaryFunctionT >
UnaryFunctionT::result_type integrate (UnaryFunctionT func, typename UnaryFunctionT::argument_type const a, typename UnaryFunctionT::argument_type const b, double eps=1.0e-6)
 The 1D integrator. More...
 
template<typename BinaryFunctionT >
BinaryFunctionT::result_type integrate2d (BinaryFunctionT func, typename BinaryFunctionT::first_argument_type const x1, typename BinaryFunctionT::first_argument_type const x2, typename BinaryFunctionT::second_argument_type const y1, typename BinaryFunctionT::second_argument_type const y2, double eps=1.0e-6)
 The 2D integrator. More...
 
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. More...
 
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. More...
 
Interpolate::Style lookupMaxInterpStyle (int const n)
 Get the highest order Interpolation::Style available for 'n' points. More...
 
int lookupMinInterpPoints (Interpolate::Style const style)
 Get the minimum number of points needed to use the requested interpolation style. More...
 
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. More...
 
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) More...
 
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) More...
 
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. More...
 
template<typename ImageT >
std::shared_ptr< ImageT > rotateImageBy90 (ImageT const &image, int nQuarter)
 Rotate an image by an integral number of quarter turns. More...
 
template<typename ImageT >
std::shared_ptr< ImageT > flipImage (ImageT const &inImage, bool flipLR, bool flipTB)
 Flip an image left–right and/or top–bottom. More...
 
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) More...
 
template<typename ImageT >
void randomUniformPosImage (ImageT *image, Random &rand)
 Set image to random numbers uniformly distributed in the range (0, 1) More...
 
template<typename ImageT >
void randomUniformIntImage (ImageT *image, Random &rand, unsigned long n)
 Set image to random integers uniformly distributed in the range 0 ... More...
 
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) More...
 
template<typename ImageT >
void randomGaussianImage (ImageT *image, Random &rand)
 Set image to random numbers with a gaussian N(0, 1) distribution. More...
 
template<typename ImageT >
void randomChisqImage (ImageT *image, Random &rand, double const nu)
 Set image to random numbers with a chi^2_{nu} distribution. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
Property stringToStatisticsProperty (std::string const property)
 Conversion function to switch a string to a Property (see Statistics.h) More...
 
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) More...
 
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. More...
 
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. More...
 
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. More...
 
Statistics makeStatistics (lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Specialization to handle Masks. More...
 
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. More...
 
template<typename EntryT >
Statistics makeStatistics (std::vector< EntryT > const &v, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle std::vector<> More...
 
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<> More...
 
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<> More...
 
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<> More...
 
std::shared_ptr< SeparableKernelmakeWarpingKernel (std::string name)
 Return a warping kernel given its name. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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 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. More...
 
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. More...
 

Variables

template<typename T >
constexpr bool IS_NOTHROW_INIT = noexcept(static_cast<T>(1.0))
 Test that a Function's return value is nothrow-castable to T. More...
 
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. More...
 
deltafunction_kernel_tag deltafunction_kernel_tag_
 Used as default value in argument lists. More...
 

Typedef Documentation

◆ ClsField

Definition at line 42 of file _transformBoundedField.cc.

◆ KernelList

Definition at line 463 of file Kernel.h.

◆ PyClass

Definition at line 35 of file _pixelAreaBoundedField.cc.

◆ WeightPixel

Definition at line 58 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 63 of file Statistics.h.

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

◆ 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 38 of file binImage.cc.

38  {
39  return binImage(in, binsize, binsize, flags);
40 }
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:43

◆ 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 43 of file binImage.cc.

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

200  {
201  ConvolutionControl convolutionControl;
202  convolutionControl.setDoNormalize(doNormalize);
203  convolutionControl.setDoCopyEdge(doCopyEdge);
204  convolve(convolvedImage, inImage, kernel, convolutionControl);
205 }
void convolve(OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, bool doNormalize, bool doCopyEdge)

◆ 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:

afw/examples offers programs that time convolution including timeConvolve and timeSpatiallyVaryingConvolve.

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 190 of file ConvolveImage.cc.

191  {
192  detail::basicConvolve(convolvedImage, inImage, kernel, convolutionControl);
193  setEdgePixels(convolvedImage, kernel, inImage, convolutionControl.getDoCopyEdge(),
194  typename image::detail::image_traits<OutImageT>::image_category());
195  convolvedImage.setXY0(inImage.getXY0());
196 }
void basicConvolve(OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl)
Low-level convolution function that does not set edge pixels.

◆ 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 259 of file ConvolveImage.h.

261  {
262  typename OutImageT::SinglePixel outValue = 0;
263  for (int kRow = 0; kRow != kHeight; ++kRow) {
265  kEnd = kernelLocator + image::detail::difference_type(kWidth, 0);
266  kernelLocator != kEnd; ++inImageLocator.x(), ++kernelLocator.x()) {
267  typename Kernel::Pixel const kVal = kernelLocator[0];
268  if (kVal != 0) {
269  outValue += *inImageLocator * kVal;
270  }
271  }
272 
273  inImageLocator += image::detail::difference_type(-kWidth, 1);
274  kernelLocator += image::detail::difference_type(-kWidth, 1);
275  }
276 
277  return outValue;
278 }
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
float Pixel
Typedefs to be used for pixel values.
Definition: common.h:37

◆ 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 295 of file ConvolveImage.h.

297  {
298  typedef typename std::vector<Kernel::Pixel>::const_iterator k_iter;
299 
300  typedef typename OutImageT::SinglePixel OutT;
301  OutT outValue = 0;
302  for (k_iter kernelYIter = kernelYList.begin(), yEnd = kernelYList.end(); kernelYIter != yEnd;
303  ++kernelYIter) {
304  OutT outValueY = 0;
305  for (k_iter kernelXIter = kernelXList.begin(), xEnd = kernelXList.end(); kernelXIter != xEnd;
306  ++kernelXIter, ++inImageLocator.x()) {
307  typename Kernel::Pixel const kValX = *kernelXIter;
308  if (kValX != 0) {
309  outValueY += *inImageLocator * kValX;
310  }
311  }
312 
313  double const kValY = *kernelYIter;
314  if (kValY != 0) {
315  outValue += outValueY * kValY;
316  }
317 
318  inImageLocator += image::detail::difference_type(-kernelXList.size(), 1);
319  }
320 
321  return outValue;
322 }
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 }
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
Definition: python.h:448
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
Definition: python.h:391

◆ 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:746
An abstract base class for 2-d functions defined on an integer bounding boxes.
Definition: BoundedField.h:55
UnaryFunctionT::result_type integrate(UnaryFunctionT func, typename UnaryFunctionT::argument_type const a, typename UnaryFunctionT::argument_type const b, double eps=1.0e-6)
The 1D integrator.
Definition: Integrate.h:886
py::class_< PixelAreaBoundedField, std::shared_ptr< PixelAreaBoundedField >, BoundedField > PyClass
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:87

◆ 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(
83  py::class_<Chebyshev1Function1<ReturnT>, std::shared_ptr<Chebyshev1Function1<ReturnT>>,
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  });
100  wrappers.wrapType(py::class_<Chebyshev1Function2<ReturnT>, std::shared_ptr<Chebyshev1Function2<ReturnT>>,
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 };

◆ 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 */
123  wrappers.wrapType(py::class_<GaussianFunction1<ReturnT>, std::shared_ptr<GaussianFunction1<ReturnT>>,
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 
133  wrappers.wrapType(py::class_<GaussianFunction2<ReturnT>, std::shared_ptr<GaussianFunction2<ReturnT>>,
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(
149  py::class_<DoubleGaussianFunction2<ReturnT>, std::shared_ptr<DoubleGaussianFunction2<ReturnT>>,
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 };

◆ 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(
167  py::class_<IntegerDeltaFunction1<ReturnT>, std::shared_ptr<IntegerDeltaFunction1<ReturnT>>,
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(
179  py::class_<IntegerDeltaFunction2<ReturnT>, std::shared_ptr<IntegerDeltaFunction2<ReturnT>>,
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 };

◆ 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 
194  wrappers.wrapType(py::class_<LanczosFunction1<ReturnT>, std::shared_ptr<LanczosFunction1<ReturnT>>,
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 
206  wrappers.wrapType(py::class_<LanczosFunction2<ReturnT>, std::shared_ptr<LanczosFunction2<ReturnT>>,
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 };

◆ 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(
49  py::class_<PolynomialFunction1<ReturnT>, std::shared_ptr<PolynomialFunction1<ReturnT>>,
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 */
62  wrappers.wrapType(py::class_<PolynomialFunction2<ReturnT>, std::shared_ptr<PolynomialFunction2<ReturnT>>,
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 };

◆ 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 }
table::Key< table::Array< std::uint8_t > > bytes
Definition: python.h:135
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 }
void wrap(WrapperCallback function)
Add a set of wrappers without defining a class.
Definition: python.h:369

◆ declareStatistics()

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",
48  (Statistics(*)(image::MaskedImage<Pixel> const &, image::Image<WeightPixel> const &,
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 }
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:73
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: Statistics.h:354

◆ 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 200 of file ConvolveImage.h.

202  {
203  typedef typename ImageT::SinglePixel SinglePixelT;
206  : 0);
207 }

◆ 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 221 of file ConvolveImage.h.

224  {
225  typedef typename MaskedImageT::Image::Pixel ImagePixelT;
226  typedef typename MaskedImageT::Variance::Pixel VariancePixelT;
227 
230  : 0;
231  auto maskPixel = MaskedImageT::Mask::getPlaneBitMask("NO_DATA");
234  : 0;
235  return typename MaskedImageT::SinglePixel(imagePixel, maskPixel, variancePixel);
236 }
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:49

◆ int1d()

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

Front end for the 1d integrator.

Definition at line 765 of file Integrate.h.

767  {
768  typedef typename UF::result_type UfResult;
769  using namespace details;
770 
771  integ_dbg2 << "start int1d: " << reg.Left() << ".." << reg.Right() << std::endl;
772 
773  if ((reg.Left() <= -MOCK_INF && reg.Right() > 0) || (reg.Right() >= MOCK_INF && reg.Left() < 0)) {
774  reg.AddSplit(0);
775  }
776 
777  if (reg.NSplit() > 0) {
779  reg.SubDivide(&children);
780  integ_dbg2 << "Subdivided into " << children.size() << " children\n";
781  UfResult answer = UfResult();
782  UfResult err = 0;
783  for (size_t i = 0; i < children.size(); i++) {
784  IntRegion<UfResult> &child = children[i];
785  integ_dbg2 << "i = " << i;
786  integ_dbg2 << ": bounds = " << child.Left() << ", " << child.Right() << std::endl;
787  answer += int1d(func, child, abserr, relerr);
788  err += child.Err();
789  integ_dbg2 << "subint = " << child.Area() << " +- " << child.Err() << std::endl;
790  }
791  reg.SetArea(answer, err);
792  return answer;
793 
794  } else {
795  if (reg.Left() <= -MOCK_INF) {
796  integ_dbg2 << "left = -infinity, right = " << reg.Right() << std::endl;
797  assert(reg.Right() <= 0.0);
798  IntRegion<UfResult> modreg(1.0 / (reg.Right() - 1.0), 0.0, reg.getDbgout());
799  intGKP(Aux2<UF>(func), modreg, abserr, relerr);
800  reg.SetArea(modreg.Area(), modreg.Err());
801  } else if (reg.Right() >= MOCK_INF) {
802  integ_dbg2 << "left = " << reg.Left() << ", right = infinity\n";
803  assert(reg.Left() >= 0.0);
804  IntRegion<UfResult> modreg(0.0, 1.0 / (reg.Left() + 1.0), reg.getDbgout());
805  intGKP(Aux1<UF>(func), modreg, abserr, relerr);
806  reg.SetArea(modreg.Area(), modreg.Err());
807  } else {
808  integ_dbg2 << "left = " << reg.Left();
809  integ_dbg2 << ", right = " << reg.Right() << std::endl;
810  intGKP(func, reg, abserr, relerr);
811  }
812  integ_dbg2 << "done int1d answer = " << reg.Area();
813  integ_dbg2 << " +- " << reg.Err() << std::endl;
814  return reg.Area();
815  }
816 }
#define integ_dbg2
Definition: Integrate.h:183
T endl(T... args)
void intGKP(UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const epsabs, typename UF::result_type const epsrel, std::map< typename UF::result_type, typename UF::result_type > *fxmap=0)
An adaptive integration algorithm which computes the integral of f over the region reg.
Definition: Integrate.h:463
double const MOCK_INF
Definition: Integrate.h:171
UF::result_type int1d(UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const &abserr=DEFABSERR, typename UF::result_type const &relerr=DEFRELERR)
Front end for the 1d integrator.
Definition: Integrate.h:765

◆ int2d() [1/2]

template<class BF >
BF::result_type lsst::afw::math::int2d ( BF const &  func,
IntRegion< typename BF::result_type > &  reg,
IntRegion< typename BF::result_type > &  yreg,
typename BF::result_type const &  abserr = DEFABSERR,
typename BF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 2d integrator.

Definition at line 855 of file Integrate.h.

858  {
859  using namespace details;
860  return int2d(func, reg, ConstantReg1<typename BF::result_type>(yreg), abserr, relerr);
861 }
BF::result_type int2d(BF const &func, IntRegion< typename BF::result_type > &reg, IntRegion< typename BF::result_type > &yreg, typename BF::result_type const &abserr=DEFABSERR, typename BF::result_type const &relerr=DEFRELERR)
Front end for the 2d integrator.
Definition: Integrate.h:855

◆ int2d() [2/2]

template<class BF , class YREG >
BF::result_type lsst::afw::math::int2d ( BF const &  func,
IntRegion< typename BF::result_type > &  reg,
YREG const &  yreg,
typename BF::result_type const &  abserr = DEFABSERR,
typename BF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 2d integrator.

Definition at line 822 of file Integrate.h.

824  {
825  using namespace details;
826  integ_dbg2 << "Starting int2d: range = ";
827  integ_dbg2 << reg.Left() << ".." << reg.Right() << std::endl;
828  Int2DAuxType<BF, YREG> faux(func, yreg, abserr * 1.0e-3, relerr * 1.0e-3);
829  typename BF::result_type answer = int1d(faux, reg, abserr, relerr);
830  integ_dbg2 << "done int2d answer = " << answer << " +- " << reg.Err() << std::endl;
831  return answer;
832 }

◆ int3d() [1/2]

template<class TF >
TF::result_type lsst::afw::math::int3d ( TF const &  func,
IntRegion< typename TF::result_type > &  reg,
IntRegion< typename TF::result_type > &  yreg,
IntRegion< typename TF::result_type > &  zreg,
typename TF::result_type const &  abserr = DEFABSERR,
typename TF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 3d integrator.

Definition at line 867 of file Integrate.h.

871  {
872  using namespace details;
873  return int3d(func, reg, ConstantReg1<typename TF::result_type>(yreg),
874  ConstantReg2<typename TF::result_type>(zreg), abserr, relerr);
875 }
TF::result_type int3d(TF const &func, IntRegion< typename TF::result_type > &reg, IntRegion< typename TF::result_type > &yreg, IntRegion< typename TF::result_type > &zreg, typename TF::result_type const &abserr=DEFABSERR, typename TF::result_type const &relerr=DEFRELERR)
Front end for the 3d integrator.
Definition: Integrate.h:867

◆ int3d() [2/2]

template<class TF , class YREG , class ZREG >
TF::result_type lsst::afw::math::int3d ( TF const &  func,
IntRegion< typename TF::result_type > &  reg,
YREG const &  yreg,
ZREG const &  zreg,
typename TF::result_type const &  abserr = DEFABSERR,
typename TF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 3d integrator.

Definition at line 838 of file Integrate.h.

841  {
842  using namespace details;
843  integ_dbg2 << "Starting int3d: range = ";
844  integ_dbg2 << reg.Left() << ".." << reg.Right() << std::endl;
845  Int3DAuxType<TF, YREG, ZREG> faux(func, yreg, zreg, abserr * 1.e-3, relerr * 1.e-3);
846  typename TF::result_type answer = int1d(faux, reg, abserr, relerr);
847  integ_dbg2 << "done int3d answer = " << answer << " +- " << reg.Err() << std::endl;
848  return answer;
849 }

◆ integrate()

template<typename UnaryFunctionT >
UnaryFunctionT::result_type lsst::afw::math::integrate ( UnaryFunctionT  func,
typename UnaryFunctionT::argument_type const  a,
typename UnaryFunctionT::argument_type 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 886 of file Integrate.h.

889  {
890  typedef typename UnaryFunctionT::argument_type Arg;
891  IntRegion<Arg> region(a, b);
892 
893  return int1d(func, region, DEFABSERR, eps);
894 }
table::Key< int > b
table::Key< int > a
double const DEFABSERR
Definition: Integrate.h:272

◆ integrate2d()

template<typename BinaryFunctionT >
BinaryFunctionT::result_type lsst::afw::math::integrate2d ( BinaryFunctionT  func,
typename BinaryFunctionT::first_argument_type const  x1,
typename BinaryFunctionT::first_argument_type const  x2,
typename BinaryFunctionT::second_argument_type const  y1,
typename BinaryFunctionT::second_argument_type const  y2,
double  eps = 1.0e-6 
)

The 2D integrator.

Note
Adapted from RHL's SDSS code

Definition at line 935 of file Integrate.h.

940  {
941  using namespace details;
942  // note the more stringent eps requirement to ensure the requested limit
943  // can be reached.
944  FunctionWrapper<BinaryFunctionT> fwrap(func, x1, x2, eps);
945  return integrate(fwrap, y1, y2, eps);
946 }

◆ integrateTn()

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

Definition at line 290 of file ChebyshevBoundedField.cc.

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

◆ 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 275 of file Interpolate.cc.

275  {
276  if (n < 1) {
277  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "n must be greater than 0");
278  } else if (n > 4) {
279  return Interpolate::AKIMA_SPLINE;
280  } else {
281  static std::vector<Interpolate::Style> styles;
282  if (styles.empty()) {
283  styles.resize(5);
284 
285  styles[0] = Interpolate::UNKNOWN; // impossible to reach as we check for n < 1
286  styles[1] = Interpolate::CONSTANT;
287  styles[2] = Interpolate::LINEAR;
288  styles[3] = Interpolate::CUBIC_SPLINE;
289  styles[4] = Interpolate::CUBIC_SPLINE;
290  }
291  return styles[n];
292  }
293 }
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 314 of file Interpolate.cc.

314  {
315  static std::vector<int> minPoints;
316  if (minPoints.empty()) {
317  minPoints.resize(Interpolate::NUM_STYLES);
318  minPoints[Interpolate::CONSTANT] = 1;
319  minPoints[Interpolate::LINEAR] = 2;
320  minPoints[Interpolate::NATURAL_SPLINE] = 3;
321  minPoints[Interpolate::CUBIC_SPLINE] = 3;
322  minPoints[Interpolate::CUBIC_SPLINE_PERIODIC] = 3;
323  minPoints[Interpolate::AKIMA_SPLINE] = 5;
324  minPoints[Interpolate::AKIMA_SPLINE_PERIODIC] = 5;
325  }
326 
327  if (style >= 0 && style < Interpolate::NUM_STYLES) {
328  return minPoints[style];
329  } else {
330  throw LSST_EXCEPT(
331  pex::exceptions::OutOfRangeError,
332  str(boost::format("Style %d is out of range 0..%d") % style % (Interpolate::NUM_STYLES - 1)));
333  }
334 }

◆ 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
double x

◆ 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 }

◆ 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 353 of file Interpolate.cc.

355  {
356  return makeInterpolate(std::vector<double>(x.begin(), x.end()), std::vector<double>(y.begin(), y.end()),
357  style);
358 }
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.
Definition: Interpolate.cc:343

◆ 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
Examples
splineInterpolate.cc.

Definition at line 343 of file Interpolate.cc.

344  {
345  switch (style) {
346  case Interpolate::CONSTANT:
347  return std::shared_ptr<Interpolate>(new InterpolateConstant(x, y, style));
348  default: // use GSL
349  return std::shared_ptr<Interpolate>(new InterpolateGsl(x, y, style));
350  }
351 }

◆ 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 366 of file Statistics.h.

367  {
368  return Statistics(img, msk, var, flags, sctrl);
369 }

◆ 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 420 of file Statistics.h.

424  {
425  // make a phony mask that will be compiled out
426  MaskImposter<lsst::afw::image::MaskPixel> const msk;
427  MaskImposter<WeightPixel> const var;
428  return Statistics(img, msk, var, flags, sctrl);
429 }

◆ 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)

Examples
imageStatistics.cc.

Definition at line 354 of file Statistics.h.

356  {
357  MaskImposter<WeightPixel> var;
358  return Statistics(img, msk, var, flags, sctrl);
359 }

◆ 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 1113 of file Statistics.cc.

1114  {
1115  return Statistics(msk, msk, msk, flags, sctrl);
1116 }

◆ 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 376 of file Statistics.h.

377  {
378  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
379  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), flags, sctrl);
380  } else {
381  MaskImposter<WeightPixel> var;
382  return Statistics(*mimg.getImage(), *mimg.getMask(), var, flags, sctrl);
383  }
384 }
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
Definition: MaskedImage.h:1079
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
Definition: MaskedImage.h:1058
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Definition: MaskedImage.h:1046

◆ 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 391 of file Statistics.h.

393  {
394  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() ||
395  (!sctrl.getWeightedIsSet() && (weights.getWidth() != 0 && weights.getHeight() != 0))) {
396  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), weights, flags, sctrl);
397  } else {
398  MaskImposter<WeightPixel> var;
399  return Statistics(*mimg.getImage(), *mimg.getMask(), var, weights, flags, sctrl);
400  }
401 }
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 503 of file Statistics.h.

506  {
507  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
508  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), flags, sctrl);
509  } else {
510  MaskImposter<WeightPixel> var;
511  return Statistics(*mv.getImage(), *mv.getMask(), var, flags, sctrl);
512  }
513 }
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
Definition: MaskedVector.h:94
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
Definition: MaskedVector.h:88
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
Definition: MaskedVector.h:91

◆ 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 520 of file Statistics.h.

524  {
525  ImageImposter<WeightPixel> weights(vweights);
526 
527  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
528  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), weights, flags, sctrl);
529  } else {
530  MaskImposter<WeightPixel> var;
531  return Statistics(*mv.getImage(), *mv.getMask(), var, weights, flags, sctrl);
532  }
533 }

◆ 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 469 of file Statistics.h.

472  {
473  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
474  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
475  MaskImposter<WeightPixel> var;
476  return Statistics(img, msk, var, flags, sctrl);
477 }

◆ 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 484 of file Statistics.h.

488  {
489  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
490  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
491  MaskImposter<WeightPixel> var;
492 
493  ImageImposter<WeightPixel> weights(vweights);
494 
495  return Statistics(img, msk, var, weights, flags, sctrl);
496 }

◆ 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 161 of file warpExposure.cc.

161  {
162  typedef std::shared_ptr<SeparableKernel> KernelPtr;
163  boost::cmatch matches;
164  static const boost::regex LanczosRE("lanczos(\\d+)");
165  if (name == "bilinear") {
166  return KernelPtr(new BilinearWarpingKernel());
167  } else if (boost::regex_match(name.c_str(), matches, LanczosRE)) {
168  std::string orderStr(matches[1].first, matches[1].second);
169  int order;
170  std::istringstream(orderStr) >> order;
171  return KernelPtr(new LanczosWarpingKernel(order));
172  } else if (name == "nearest") {
173  return KernelPtr(new NearestWarpingKernel());
174  } else {
175  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "unknown warping kernel name: \"" + name + "\"");
176  }
177 }
table::Key< std::string > name
Definition: Amplifier.cc:116

◆ 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 175 of file minimize.cc.

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

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

◆ 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 
47  std::shared_ptr<ImageT> buffImage;
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 
110  std::shared_ptr<ImageT> outImage;
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)
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.
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 }
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:108

◆ 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  typedef Kernel::Pixel 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 }
Angle abs(Angle const &a)
Definition: Angle.h:106

◆ 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);
56  wrapChebyshevBoundedField(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);
66  wrapPixelAreaBoundedField(wrappers);
67  wrapProductBoundedField(wrappers);
68  wrapRandom(wrappers);
69  wrapSpatialCell(wrappers);
70  wrapStack(wrappers);
71  wrapStatistics(wrappers);
72  wrapTransformBoundedField(wrappers);
73  wrapWarpExposure(wrappers);
74  wrappers.finish();
75 }
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition: python.h:242
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)
Definition: _interpolate.cc:38
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 &)
Definition: _statistics.cc:144
void wrapBackground(lsst::utils::python::WrapperCollection &wrappers)
Definition: _background.cc:162
void wrapGaussianProcess(lsst::utils::python::WrapperCollection &wrappers)
void wrapLeastSquares(lsst::utils::python::WrapperCollection &wrappers)
void wrapApproximate(lsst::utils::python::WrapperCollection &wrappers)
Definition: _approximate.cc:83
void wrapRandom(lsst::utils::python::WrapperCollection &)
Definition: _random.cc:103
void wrapOffsetImage(lsst::utils::python::WrapperCollection &)
Definition: _offsetImage.cc:74
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 }
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
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 162 of file ConvolveImage.cc.

163  {
164  if (outImage.getDimensions() != inImage1.getDimensions()) {
166  os << "outImage dimensions = ( " << outImage.getWidth() << ", " << outImage.getHeight() << ") != ("
167  << inImage1.getWidth() << ", " << inImage1.getHeight() << ") = inImage1 dimensions";
169  } else if (inImage1.getDimensions() != inImage2.getDimensions()) {
171  os << "inImage1 dimensions = ( " << inImage1.getWidth() << ", " << inImage1.getHeight() << ") != ("
172  << inImage2.getWidth() << ", " << inImage2.getHeight() << ") = inImage2 dimensions";
174  }
175 
176  typedef typename InImageT::const_x_iterator InConstXIter;
177  typedef typename OutImageT::x_iterator OutXIter;
178  for (int y = 0; y != inImage1.getHeight(); ++y) {
179  InConstXIter const end1 = inImage1.row_end(y);
180  InConstXIter inIter1 = inImage1.row_begin(y);
181  InConstXIter inIter2 = inImage2.row_begin(y);
182  OutXIter outIter = outImage.row_begin(y);
183  for (; inIter1 != end1; ++inIter1, ++inIter2, ++outIter) {
184  *outIter = (*inIter1 * c1) + (*inIter2 * c2);
185  }
186  }
187 }

◆ 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 360 of file Stack.cc.

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

◆ 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 445 of file Stack.cc.

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

◆ 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 251 of file Stack.cc.

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

◆ 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 278 of file Stack.cc.

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

◆ 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 488 of file Stack.cc.

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

◆ 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 445 of file Stack.cc.

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

◆ 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 488 of file Stack.cc.

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

◆ 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 348 of file Stack.cc.

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

◆ 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 223 of file Stack.cc.

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

◆ 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 237 of file Stack.cc.

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

◆ 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 425 of file Stack.cc.

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

◆ 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 257 of file Interpolate.cc.

257  {
258  static std::map<std::string, Interpolate::Style> gslInterpTypeStrings;
259  if (gslInterpTypeStrings.empty()) {
260  gslInterpTypeStrings["CONSTANT"] = Interpolate::CONSTANT;
261  gslInterpTypeStrings["LINEAR"] = Interpolate::LINEAR;
262  gslInterpTypeStrings["CUBIC_SPLINE"] = Interpolate::CUBIC_SPLINE;
263  gslInterpTypeStrings["NATURAL_SPLINE"] = Interpolate::NATURAL_SPLINE;
264  gslInterpTypeStrings["CUBIC_SPLINE_PERIODIC"] = Interpolate::CUBIC_SPLINE_PERIODIC;
265  gslInterpTypeStrings["AKIMA_SPLINE"] = Interpolate::AKIMA_SPLINE;
266  gslInterpTypeStrings["AKIMA_SPLINE_PERIODIC"] = Interpolate::AKIMA_SPLINE_PERIODIC;
267  }
268 
269  if (gslInterpTypeStrings.find(style) == gslInterpTypeStrings.end()) {
270  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Interp style not found: " + style);
271  }
272  return gslInterpTypeStrings[style];
273 }
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 747 of file Statistics.cc.

747  {
748  static std::map<std::string, Property> statisticsProperty;
749  if (statisticsProperty.size() == 0) {
750  statisticsProperty["NOTHING"] = NOTHING;
751  statisticsProperty["ERRORS"] = ERRORS;
752  statisticsProperty["NPOINT"] = NPOINT;
753  statisticsProperty["MEAN"] = MEAN;
754  statisticsProperty["STDEV"] = STDEV;
755  statisticsProperty["VARIANCE"] = VARIANCE;
756  statisticsProperty["MEDIAN"] = MEDIAN;
757  statisticsProperty["IQRANGE"] = IQRANGE;
758  statisticsProperty["MEANCLIP"] = MEANCLIP;
759  statisticsProperty["STDEVCLIP"] = STDEVCLIP;
760  statisticsProperty["VARIANCECLIP"] = VARIANCECLIP;
761  statisticsProperty["MIN"] = MIN;
762  statisticsProperty["MAX"] = MAX;
763  statisticsProperty["SUM"] = SUM;
764  statisticsProperty["MEANSQUARE"] = MEANSQUARE;
765  statisticsProperty["ORMASK"] = ORMASK;
766  statisticsProperty["NCLIPPED"] = NCLIPPED;
767  statisticsProperty["NMASKED"] = NMASKED;
768  }
769  return statisticsProperty[property];
770 }

◆ 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 510 of file warpExposure.cc.

513  {
514  // force src and dest to be the same size and xy0
515  if ((destImage.getWidth() != srcImage.getWidth()) || (destImage.getHeight() != srcImage.getHeight()) ||
516  (destImage.getXY0() != srcImage.getXY0())) {
517  std::ostringstream errStream;
518  errStream << "src and dest images must have same size and xy0.";
520  }
521 
522  // set the xy0 coords to 0,0 to make life easier
523  SrcImageT srcImageCopy(srcImage, true);
524  srcImageCopy.setXY0(0, 0);
525  destImage.setXY0(0, 0);
526  lsst::geom::Extent2D cLocal =
527  lsst::geom::Extent2D(centerPosition) - lsst::geom::Extent2D(srcImage.getXY0());
528 
529  // for the affine transform, the centerPosition will not only get sheared, but also
530  // moved slightly. So we'll include a translation to move it back by an amount
531  // centerPosition - translatedCenterPosition
532  lsst::geom::AffineTransform affTran(linearTransform, cLocal - linearTransform(cLocal));
534 
535 // now warp
536 #if 0
537  static float t = 0.0;
538  float t_before = 1.0*clock()/CLOCKS_PER_SEC;
539  int n = warpImage(destImage, srcImageCopy, affTran, control, padValue);
540  float t_after = 1.0*clock()/CLOCKS_PER_SEC;
541  float dt = t_after - t_before;
542  t += dt;
543  std::cout <<srcImage.getWidth()<<"x"<<srcImage.getHeight()<<": "<< dt <<" "<< t <<std::endl;
544 #else
545  int n = warpImage(destImage, srcImageCopy, *affineTransform22, control, padValue);
546 #endif
547 
548  // fix the origin and we're done.
549  destImage.setXY0(srcImage.getXY0());
550 
551  return n;
552 }
An affine coordinate transformation consisting of a linear transformation and an offset.
T clock(T... args)
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
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.
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, Filter 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 238 of file warpExposure.cc.

239  {
240  if (!destExposure.hasWcs()) {
241  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "destExposure has no Wcs");
242  }
243  if (!srcExposure.hasWcs()) {
244  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "srcExposure has no Wcs");
245  }
246  typename DestExposureT::MaskedImageT mi = destExposure.getMaskedImage();
247  destExposure.setPhotoCalib(srcExposure.getPhotoCalib());
248  destExposure.setFilterLabel(srcExposure.getFilterLabel());
249  destExposure.getInfo()->setVisitInfo(srcExposure.getInfo()->getVisitInfo());
250  return warpImage(mi, *destExposure.getWcs(), srcExposure.getMaskedImage(), *srcExposure.getWcs(), control,
251  padValue);
252 }

◆ 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 283 of file warpExposure.cc.

285  {
286  auto srcToDest = geom::makeWcsPairTransform(srcWcs, destWcs);
287  return warpImage(destImage, srcImage, *srcToDest, control, padValue);
288 }
std::shared_ptr< TransformPoint2ToPoint2 > makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
A Transform obtained by putting two SkyWcs objects "back to back".
Definition: SkyWcs.cc:151

◆ 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 291 of file warpExposure.cc.

293  {
294  if (imagesOverlap(destImage, srcImage)) {
295  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "destImage overlaps srcImage; cannot warp");
296  }
297  if (destImage.getBBox(image::LOCAL).isEmpty()) {
298  return 0;
299  }
300  // if src image is too small then don't try to warp
301  std::shared_ptr<SeparableKernel> warpingKernelPtr = control.getWarpingKernel();
302  try {
303  warpingKernelPtr->shrinkBBox(srcImage.getBBox(image::LOCAL));
305  for (int y = 0, height = destImage.getHeight(); y < height; ++y) {
306  for (typename DestImageT::x_iterator destPtr = destImage.row_begin(y), end = destImage.row_end(y);
307  destPtr != end; ++destPtr) {
308  *destPtr = padValue;
309  }
310  }
311  return 0;
312  }
313  int interpLength = control.getInterpLength();
314 
315  std::shared_ptr<LanczosWarpingKernel const> const lanczosKernelPtr =
316  std::dynamic_pointer_cast<LanczosWarpingKernel>(warpingKernelPtr);
317 
318  int numGoodPixels = 0;
319 
320  // compute a transform from local destination pixels to parent source pixels
321  auto const parentDestToParentSrc = srcToDest.inverted();
322  std::vector<double> const localDestToParentDestVec = {static_cast<double>(destImage.getX0()),
323  static_cast<double>(destImage.getY0())};
324  auto const localDestToParentDest = geom::TransformPoint2ToPoint2(ast::ShiftMap(localDestToParentDestVec));
325  auto const localDestToParentSrc = localDestToParentDest.then(*parentDestToParentSrc);
326 
327  // Get the source MaskedImage and a pixel accessor to it.
328  int const srcWidth = srcImage.getWidth();
329  int const srcHeight = srcImage.getHeight();
330  LOGL_DEBUG("TRACE2.afw.math.warp", "source image width=%d; height=%d", srcWidth, srcHeight);
331 
332  int const destWidth = destImage.getWidth();
333  int const destHeight = destImage.getHeight();
334  LOGL_DEBUG("TRACE2.afw.math.warp", "remap image width=%d; height=%d", destWidth, destHeight);
335 
336  // Set each pixel of destExposure's MaskedImage
337  LOGL_DEBUG("TRACE3.afw.math.warp", "Remapping masked image");
338 
339  int const maxCol = destWidth - 1;
340  int const maxRow = destHeight - 1;
341 
342  detail::WarpAtOnePoint<DestImageT, SrcImageT> warpAtOnePoint(srcImage, control, padValue);
343 
344  if (interpLength > 0) {
345  // Use interpolation. Note that 1 produces the same result as no interpolation
346  // but uses this code branch, thus providing an easy way to compare the two branches.
347 
348  // Estimate for number of horizontal interpolation band edges, to reserve memory in vectors
349  int const numColEdges = 2 + ((destWidth - 1) / interpLength);
350 
351  // A list of edge column indices for interpolation bands;
352  // starts at -1, increments by interpLen (except the final interval), and ends at destWidth-1
353  std::vector<int> edgeColList;
354  edgeColList.reserve(numColEdges);
355 
356  // A list of 1/column width for horizontal interpolation bands; the first value is garbage.
357  // The inverse is used for speed because the values are always multiplied.
358  std::vector<double> invWidthList;
359  invWidthList.reserve(numColEdges);
360 
361  // Compute edgeColList and invWidthList
362  edgeColList.push_back(-1);
363  invWidthList.push_back(0.0);
364  for (int prevEndCol = -1; prevEndCol < maxCol; prevEndCol += interpLength) {
365  int endCol = prevEndCol + interpLength;
366  if (endCol > maxCol) {
367  endCol = maxCol;
368  }
369  edgeColList.push_back(endCol);
370  assert(endCol - prevEndCol > 0);
371  invWidthList.push_back(1.0 / static_cast<double>(endCol - prevEndCol));
372  }
373  assert(edgeColList.back() == maxCol);
374 
375  // A list of delta source positions along the edge columns of the horizontal interpolation bands
376  std::vector<lsst::geom::Extent2D> yDeltaSrcPosList(edgeColList.size());
377 
378  // A cache of pixel positions on the source corresponding to the previous or current row
379  // of the destination image.
380  // The first value is for column -1 because the previous source position is used to compute relative
381  // area To simplify the indexing, use an iterator that starts at begin+1, thus: srcPosView =
382  // srcPosList.begin() + 1 srcPosView[col-1] and lower indices are for this row srcPosView[col] and
383  // higher indices are for the previous row
384  std::vector<lsst::geom::Point2D> srcPosList(1 + destWidth);
385  std::vector<lsst::geom::Point2D>::iterator const srcPosView = srcPosList.begin() + 1;
386 
387  std::vector<lsst::geom::Point2D> endColPosList;
388  endColPosList.reserve(numColEdges);
389 
390  // Initialize srcPosList for row -1
391  for (int colBand = 0, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
392  int const endCol = edgeColList[colBand];
393  endColPosList.emplace_back(lsst::geom::Point2D(endCol, -1));
394  }
395  auto rightSrcPosList = localDestToParentSrc->applyForward(endColPosList);
396  srcPosView[-1] = rightSrcPosList[0];
397  for (int colBand = 1, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
398  int const prevEndCol = edgeColList[colBand - 1];
399  int const endCol = edgeColList[colBand];
400  lsst::geom::Point2D leftSrcPos = srcPosView[prevEndCol];
401 
402  lsst::geom::Extent2D xDeltaSrcPos =
403  (rightSrcPosList[colBand] - leftSrcPos) * invWidthList[colBand];
404 
405  for (int col = prevEndCol + 1; col <= endCol; ++col) {
406  srcPosView[col] = srcPosView[col - 1] + xDeltaSrcPos;
407  }
408  }
409 
410  int endRow = -1;
411  while (endRow < maxRow) {
412  // Next horizontal interpolation band
413 
414  int prevEndRow = endRow;
415  endRow = prevEndRow + interpLength;
416  if (endRow > maxRow) {
417  endRow = maxRow;
418  }
419  assert(endRow - prevEndRow > 0);
420  double interpInvHeight = 1.0 / static_cast<double>(endRow - prevEndRow);
421 
422  // Set yDeltaSrcPosList for this horizontal interpolation band
423  std::vector<lsst::geom::Point2D> destRowPosList;
424  destRowPosList.reserve(edgeColList.size());
425  for (int colBand = 0, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
426  int endCol = edgeColList[colBand];
427  destRowPosList.emplace_back(lsst::geom::Point2D(endCol, endRow));
428  }
429  auto bottomSrcPosList = localDestToParentSrc->applyForward(destRowPosList);
430  for (int colBand = 0, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
431  int endCol = edgeColList[colBand];
432  yDeltaSrcPosList[colBand] =
433  (bottomSrcPosList[colBand] - srcPosView[endCol]) * interpInvHeight;
434  }
435 
436  for (int row = prevEndRow + 1; row <= endRow; ++row) {
437  typename DestImageT::x_iterator destXIter = destImage.row_begin(row);
438  srcPosView[-1] += yDeltaSrcPosList[0];
439  for (int colBand = 1, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
440  // Next vertical interpolation band
441 
442  int const prevEndCol = edgeColList[colBand - 1];
443  int const endCol = edgeColList[colBand];
444 
445  // Compute xDeltaSrcPos; remember that srcPosView contains
446  // positions for this row in prevEndCol and smaller indices,
447  // and positions for the previous row for larger indices (including endCol)
448  lsst::geom::Point2D leftSrcPos = srcPosView[prevEndCol];
449  lsst::geom::Point2D rightSrcPos = srcPosView[endCol] + yDeltaSrcPosList[colBand];
450  lsst::geom::Extent2D xDeltaSrcPos = (rightSrcPos - leftSrcPos) * invWidthList[colBand];
451 
452  for (int col = prevEndCol + 1; col <= endCol; ++col, ++destXIter) {
453  lsst::geom::Point2D leftSrcPos = srcPosView[col - 1];
454  lsst::geom::Point2D srcPos = leftSrcPos + xDeltaSrcPos;
455  double relativeArea = computeRelativeArea(srcPos, leftSrcPos, srcPosView[col]);
456 
457  srcPosView[col] = srcPos;
458 
459  if (warpAtOnePoint(
460  destXIter, srcPos, relativeArea,
461  typename image::detail::image_traits<DestImageT>::image_category())) {
462  ++numGoodPixels;
463  }
464  } // for col
465  } // for col band
466  } // for row
467  } // while next row band
468 
469  } else {
470  // No interpolation
471 
472  // prevSrcPosList = source positions from the previous row; these are used to compute pixel area;
473  // to begin, compute sources positions corresponding to destination row = -1
475  destPosList.reserve(1 + destWidth);
476  for (int col = -1; col < destWidth; ++col) {
477  destPosList.emplace_back(lsst::geom::Point2D(col, -1));
478  }
479  auto prevSrcPosList = localDestToParentSrc->applyForward(destPosList);
480 
481  for (int row = 0; row < destHeight; ++row) {
482  destPosList.clear();
483  for (int col = -1; col < destWidth; ++col) {
484  destPosList.emplace_back(lsst::geom::Point2D(col, row));
485  }
486  auto srcPosList = localDestToParentSrc->applyForward(destPosList);
487 
488  typename DestImageT::x_iterator destXIter = destImage.row_begin(row);
489  for (int col = 0; col < destWidth; ++col, ++destXIter) {
490  // column index = column + 1 because the first entry in srcPosList is for column -1
491  auto srcPos = srcPosList[col + 1];
492  double relativeArea =
493  computeRelativeArea(srcPos, prevSrcPosList[col], prevSrcPosList[col + 1]);
494 
495  if (warpAtOnePoint(destXIter, srcPos, relativeArea,
496  typename image::detail::image_traits<DestImageT>::image_category())) {
497  ++numGoodPixels;
498  }
499  } // for col
500  // move points from srcPosList to prevSrcPosList (we don't care about what ends up in srcPosList
501  // because it will be reallocated anyway)
502  swap(srcPosList, prevSrcPosList);
503  } // for row
504  } // if interp
505 
506  return numGoodPixels;
507 }
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
Definition: Log.h:504
T back(T... args)
ShiftMap is a linear Mapping which shifts each axis by a specified constant value.
Definition: ShiftMap.h:40
void swap(PolymorphicValue &lhs, PolymorphicValue &rhs) noexcept
Swap specialization for PolymorphicValue.
T clear(T... args)
T emplace_back(T... args)
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition: Transform.h:300
bool imagesOverlap(ImageBase< T1 > const &image1, ImageBase< T2 > const &image2)
Return true if the pixels for two images or masks overlap in memory.
Definition: Image.cc:706
T reserve(T... args)
int row
Definition: CR.cc:145
int col
Definition: CR.cc:144

◆ 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 }
void addSignatureDependency(std::string const &name)
Indicate an external module that provides a type used in function/method signatures.
Definition: python.h:357

◆ 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.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 addInheritanceDependency(std::string const &name)
Indicate an external module that provides a base class for a subsequent addType call.
Definition: python.h:343
void declareBackground(lsst::utils::python::WrapperCollection &wrappers)
Definition: _background.cc:73
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
Definition: Background.cc:117

◆ 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.
Definition: Interpolate.cc:275
int lookupMinInterpPoints(Interpolate::Style const style)
Get the minimum number of points needed to use the requested interpolation style.
Definition: Interpolate.cc:314
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
Definition: Interpolate.cc:257

◆ 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:111

◆ 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  {
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 144 of file _statistics.cc.

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

◆ 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 164 of file _warpExposure.cc.

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

Variable Documentation

◆ DEFABSERR

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

Definition at line 272 of file Integrate.h.

◆ DEFRELERR

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

Definition at line 273 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 52 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 51 of file Kernel.cc.

◆ IS_NOTHROW_INIT

template<typename T >
constexpr bool 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 171 of file Integrate.h.